wok-current view linux/receipt @ rev 14419
new: python-edbus-dev
author | Dominique Corbex <domcox@slitaz.org> |
---|---|
date | Tue Apr 23 19:21:30 2013 +0200 (2013-04-23) |
parents | 70d569bf17ed |
children | d26fdfd458ef |
line source
1 # SliTaz package receipt.
3 PACKAGE="linux"
4 VERSION="3.2.40"
5 KBASEVER="${VERSION:0:3}"
6 CATEGORY="base-system"
7 SHORT_DESC="The Linux kernel and modules."
8 MAINTAINER="devel@slitaz.org"
9 TARBALL="$PACKAGE-$KBASEVER.tar.xz"
10 WEB_SITE="http://www.kernel.org/"
11 WGET_URL="ftp://ftp.kernel.org/pub/linux/kernel/v3.0/$TARBALL"
12 HOST_ARCH="i486 arm x86_64"
14 DEPENDS="kmod"
15 BUILD_DEPENDS="slitaz-toolchain perl git xz lzma patch uclibc-cross-compiler-x86_64"
17 # Use version patch so we dont dl full kernel source on each minor update
18 [ "$KBASEVER" != "$VERSION" ] &&
19 PATCH="$(dirname $WGET_URL)/patch-$VERSION.xz" &&
20 EXTRA_SOURCE_FILES="$(basename $PATCH)"
22 # Aufs enable chroot
23 AUFS_NOT_RAMFS="uclibc-cross-compiler-x86_64 is not compatible with aufs+tmpfs 8("
25 # This will save/restore modules.dep but we want to regenerate it on
26 # install or upgrade.
27 #CONFIG_FILES="/lib/modules/$KBASEVER-slitaz/modules.dep"
29 # Handle multiarch compilation. Less bdeps when cross-compiling for ARM
30 case "$ARCH" in
31 arm) BUILD_DEPENDS="xz" TARBALL="$PACKAGE-$VERSION.tar.bz2" ;;
32 x86_64) BUILD_DEPENDS="xz" ;;
33 esac
35 # TODO: slitaz.conf provide SLITAZ_ARCH and must be handled by tazpkg/spk
36 [ -f "$root/etc/slitaz/slitaz.conf" ] && . $root/etc/slitaz/slitaz.conf
38 # Handle multiarch installation. ARM use Busybox modutils, so avoid any
39 # deps on kmod
40 case "$SLITAZ_ARCH" in
41 arm) DEPENDS="" ;;
42 esac
44 # Rules to configure and make the package.
45 compile_rules()
46 {
47 cd $src
49 if [ "$KBASEVER" != "$VERSION" ]; then
50 [ -s $SRC/$(basename $PATCH) ] ||
51 wget $PATCH -O $SRC/$(basename $PATCH)
52 xzcat $SRC/$(basename $PATCH) | patch -Np1
53 touch done.patch-$VERSION
54 fi
56 case "$ARCH" in
57 arm)
58 echo "Compiling: ARM Kernel"
59 if [ ! -s $SRC/$(basename $PATCH) ]; then
60 wget $PATCH -O $SRC/$(basename $PATCH)
61 fi
62 make mrproper
63 # Buggy: we got kernel panic about module not tinted 3.2.14
64 #echo "Applying patch: $(basename $PATCH)"
65 #xzcat $SRC/$(basename $PATCH) | patch -Np1 >/dev/null
66 patch -Np1 < $stuff/$ARCH/linux-arm.patch || exit 1
67 cp -f $stuff/$ARCH/linux-arm.config .config
68 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- bzImage &&
69 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- modules &&
70 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- \
71 INSTALL_MOD_PATH=$DESTDIR modules_install &&
72 mkdir -p $DESTDIR/boot &&
73 cp -a arch/arm/boot/zImage \
74 $DESTDIR/boot/linux-$VERSION-slitaz-$ARCH
75 return 0 ;;
76 x86_64)
77 echo "TODO: Maybe use default ? But cross compile in x86_64 chroot"
78 echo "so we can remove the 64 build by uclibc-cross-compiler-x86_64"
79 return 0 ;;
80 esac
82 [ ! -x /usr/bin/cook ] && report open-bloc
84 # Check for Aufs and cook it if unbuilt.
85 echo "Checking for Aufs packages..."
86 _AUFSVER=`grep ^VERSION= $WOK/aufs/receipt | cut -d "=" -f2 | sed -e 's/"//g'`
87 if [ -x /usr/bin/cook ]; then
88 # Give info an redirect to /dev/null since aufs got it own log.
89 AUFSDIR=$WOK/aufs/source/aufs-${_AUFSVER}
90 [ -d "$AUFSDIR" ] && rm -rf $AUFSDIR
91 #echo "Cook: aufs $_AUFSVER"
92 cook aufs --getsrc
93 mkdir -p $WOK/aufs/source/
94 tar xjf $SRC/aufs-${_AUFSVER}.tar.bz2 -C $WOK/aufs/source/
95 elif [ -x /usr/bin/tazwok ]; then
96 # we just need aufs source. Also cooking now is a bad idea since it
97 # needs linux-module-headers. The one your cooking not the one from the web.
98 AUFSDIR=$WOK/aufs/aufs-${_AUFSVER}
99 [ -d "$AUFSDIR" ] && rm -rf $AUFSDIR
100 tazwok get-src aufs --target=$AUFSDIR || { report close-bloc; return 1; }
101 fi
102 echo "cook:linux" > $command
104 echo "Copying Aufs files and patches..."
105 cp -a $AUFSDIR/Documentation $AUFSDIR/fs $AUFSDIR/include $src
106 cp -a $AUFSDIR/aufs3-*.patch $stuff
108 # SliTaz db
109 [ -d $WOK/$PACKAGE/source/slitaz ] && rm -rf $WOK/$PACKAGE/source/slitaz 2> /dev/null
110 mkdir -p $WOK/$PACKAGE/source/slitaz
111 echo "$WGET_URL" > $WOK/$PACKAGE/source/slitaz/url
112 cp $stuff/gztazmod.sh $stuff/list_modules.sh $WOK/$PACKAGE/source/slitaz
113 cp $stuff/bootloader.sh $WOK/$PACKAGE/source/slitaz
115 # Apply patches
116 echo "Applying patches..."
117 while read patch_file; do
118 echo "$patch_file" >> $WOK/$PACKAGE/source/slitaz/patches
119 cp $stuff/$patch_file $WOK/$PACKAGE/source/slitaz
120 if [ -f done.$patch_file ]; then
121 echo "Skipping $patch_file"
122 continue
123 fi
124 echo "Apply $patch_file"
125 if [ -x /usr/bin/cook ]; then
126 patch -p1 < $WOK/$PACKAGE/source/slitaz/$patch_file || return 1
127 elif [ -x /usr/bin/tazwok ]; then
128 patch -p1 < $WOK/$PACKAGE/source/slitaz/$patch_file || { report close-bloc; return 1; }
129 fi
130 touch done.$patch_file
131 done <<EOT
132 $PACKAGE-diff.u
133 $PACKAGE-header.u
134 $PACKAGE-freeinitrd.u
135 aufs3-base.patch
136 aufs3-standalone.patch
137 aufs3-loopback.patch
138 aufs3-proc_map.patch
139 channel-negative-one-maxim.patch
140 mac80211.compat08082009.wl_frag+ack_v1.patch
141 EOT
143 sed -i 's|SUBLEVEL =.*|SUBLEVEL =|g' Makefile
145 [ ! -x /usr/bin/cook ] && report step "Make kernel proper and then build lguest"
146 [ -x /usr/bin/cook ] && echo "Make kernel proper and then build lguest"
147 make mrproper
148 cd Documentation/virtual/lguest
149 if [ -x /usr/bin/cook ]; then
150 make lguest || return 1
151 elif [ -x /usr/bin/tazwok ]; then
152 make lguest || { report close-bloc; return 1; }
153 fi
154 cd $src
156 case "$opt" in
157 *--no64*);;
158 *)
159 #
160 # Arch x86_64
161 #
162 [ ! -x /usr/bin/cook ] && report step "Make bzImage64 without modules first"
163 [ -x /usr/bin/cook ] && echo "Building x86_64 Kernel"
165 # Build bzImage64 without modules first
166 cp -f $stuff/$PACKAGE-slitaz.config64 .config
167 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
169 # We can't keep every driver in staging
170 sed -i -e 's/^CONFIG_RTL8192/#&/' \
171 -e 's/^CONFIG_R8187SE/#&/' \
172 -e 's/^CONFIG_RT2870/#&/' .config
173 yes '' | make ARCH=x86_64 oldconfig
174 if [ -x /usr/bin/cook ]; then
175 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || exit 1
176 elif [ -x /usr/bin/tazwok ]; then
177 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || { report close-bloc; return 1; }
178 fi
179 [ -d $PWD/_pkg ] || mkdir -p $DESTDIR/linux64
180 mv arch/x86/boot/bzImage $DESTDIR/linux64
181 mv System.map System.map-without-modules64
183 [ ! -x /usr/bin/cook ] && report step "Now build bzImage64 with modules"
185 # Build bzImage64 with modules
186 cp -f $stuff/$PACKAGE-slitaz.config64 .config
187 #make ARCH=x86_64 oldconfig
188 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage &&
189 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- modules &&
190 make ARCH=x86_64 INSTALL_MOD_PATH=$DESTDIR/linux64 modules_install &&
191 make ARCH=x86_64 INSTALL_HDR_PATH=$DESTDIR/linux64/usr headers_install &&
192 ln .config $WOK/$PACKAGE/source/slitaz/config64
193 if [ -x /usr/bin/cook ]; then
194 [ -s arch/x86/boot/bzImage ] || return 1
195 elif [ -x /usr/bin/tazwok ]; then
196 [ -s arch/x86/boot/bzImage ] || { report close-bloc; return 1; }
197 fi
198 mkdir -p $DESTDIR/linux64/boot 2> /dev/null
199 mv arch/x86/boot/bzImage $DESTDIR/linux64/boot/vmlinuz-$VERSION-slitaz
200 ln System.map System.map-modules64
201 ln Module.symvers Module.symvers-modules64
202 esac
204 #
205 # Standard kernel
206 #
207 [ ! -x /usr/bin/cook ] && report step "Make bzImage without modules first"
208 [ -x /usr/bin/cook ] && echo "Building standard kernel..."
210 # Build bzImage without modules first
211 cp -f $stuff/$PACKAGE-slitaz.config .config
212 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
214 # We can't keep every driver in staging
215 sed -i -e 's/^CONFIG_RTL8192/#&/' \
216 -e 's/^CONFIG_R8187SE/#&/' \
217 -e 's/^CONFIG_RT2870/#&/' .config
218 yes '' | make oldconfig
219 if [ -x /usr/bin/cook ]; then
220 make -j 4 bzImage || exit 1
221 elif [ -x /usr/bin/tazwok ]; then
222 make -j 4 bzImage || { report close-bloc; return 1; }
223 fi
224 [ -d $DESTDIR ] || mkdir -p $DESTDIR
225 mv arch/x86/boot/bzImage $DESTDIR
226 mv System.map System.map-without-modules
228 [ ! -x /usr/bin/cook ] && report step "Now build bzImage with modules"
230 # Build bzImage with modules
231 cp -f $stuff/$PACKAGE-slitaz.config .config
232 #make oldconfig
233 ln .config $WOK/$PACKAGE/source/slitaz/config
234 make -j 4 bzImage &&
235 make -j 4 modules &&
236 make INSTALL_MOD_PATH=$DESTDIR modules_install &&
237 make INSTALL_HDR_PATH=$DESTDIR/usr headers_install &&
238 if [ -x /usr/bin/cook ]; then
239 [ -s arch/x86/boot/bzImage ] || return 1
240 elif [ -x /usr/bin/tazwok ]; then
241 [ -s arch/x86/boot/bzImage ] || { report close-bloc; return 1; }
242 fi
243 mkdir -p $DESTDIR/boot 2> /dev/null
244 mv arch/x86/boot/bzImage $DESTDIR/boot/vmlinuz-$VERSION-slitaz
246 [ ! -x /usr/bin/cook ] && report step "Compressing all modules"
248 # Compress all modules.
249 $stuff/gztazmod.sh $DESTDIR/lib/modules/$KBASEVER-slitaz
250 $stuff/gztazmod.sh $DESTDIR/linux64/lib/modules/$KBASEVER-slitaz
251 ln System.map System.map-modules
252 ln Module.symvers Module.symvers-modules
254 if [ ! -x /usr/bin/cook ]; then
255 report close-bloc
256 fi
257 }
259 # Rules to gen a SliTaz package suitable for Tazpkg.
260 genpkg_rules()
261 {
262 case "$ARCH" in
263 arm)
264 echo "Packing: ARM Kernel"
265 cp -a $install/* $fs
266 rm -f $fs/lib/modules/*/build $fs/lib/modules/*/source
267 return 0 ;;
268 x86_64)
269 echo "TODO: use default or custom x86_64 packing"
270 return 0 ;;
271 esac
273 export PACKAGE VERSION
274 local path
275 cp -a $_pkg/boot $fs
276 # Compress all modules.
277 path=$fs/lib/modules/$KBASEVER-slitaz/kernel
278 mkdir -p $path
279 cp -a $_pkg/lib/modules/$KBASEVER-slitaz/mo* \
280 $fs/lib/modules/$KBASEVER-slitaz
281 [ "$KBASEVER" != "$VERSION" ] &&
282 ln -s $KBASEVER-slitaz $fs/lib/modules/$VERSION-slitaz
283 # Get the base modules
284 export src
285 export _pkg
286 mkdir -p $WOK/$PACKAGE/source/tmp
287 # Warning stuff/list_modules.sh must find the generated modules.list
288 $stuff/list_modules.sh \
289 $(cat $stuff/modules.list) > $WOK/$PACKAGE/source/tmp/modules.list
290 while read module; do
291 dir=$(dirname $module)
292 [ -d $path/$dir ] || mkdir -p $path/$dir
293 cp -a $_pkg/lib/modules/$KBASEVER-slitaz/kernel/$module $path/$dir
294 done < $WOK/$PACKAGE/source/tmp/modules.list
295 # Remove unresolved links
296 rm -f $fs/lib/modules/$KBASEVER-slitaz/build
297 rm -f $fs/lib/modules/$KBASEVER-slitaz/source
298 # Cook all packages with a kernel module
299 for i in $(cd $WOK; grep -l 'cook linux$' */receipt)
300 do
301 echo cook ${i%/receipt}
302 done
303 # Fixed modules.dep to use right path
304 # saves 100kb of space too
305 sed -i "s|$_pkg||g" $fs/lib/modules/$KBASEVER-slitaz/modules.dep
306 sed -i "s|99.98.$KBASEVER-slitaz|$KBASEVER-slitaz|g" $fs/lib/modules/$KBASEVER-slitaz/modules.dep
307 # Check and echo any module in kernel .config that's not added to
308 # one of linux-* pkgs
309 $stuff/check_modules.sh
310 }
312 # Pre and post install commands for Tazpkg.
313 post_install()
314 {
315 echo "Processing post-install commands..."
316 case "$ARCH" in
317 arm)
318 echo "Kernel : /boot/linux-$VERSION-slitaz-$ARCH"
319 echo "Modules: /lib/modules/$VERSION-slitaz"
320 return 0 ;;
321 esac
322 chroot "$1/" depmod -a $KBASEVER-slitaz
323 # GRUB stuff.
324 if [ -f "$1/boot/grub/menu.lst" ]; then
325 root_dev="/dev/`lsblk | grep '/$'| grep -o '[a-z]d[a-z][0-9]*'`" # current root device
326 grub_part="$(( `echo $root_dev | grep -o '[0-9]*$'`-1 ))"
327 grub_dev="`grep $(echo $root_dev | grep -o '^/dev/.d.' ) $1/boot/grub/device.map |\
328 cut -f1 | sed "s/)$/.$grub_part)/g"`" # use device.map to find grub device number
330 # Add and clean kernel entrys in case of upgrade for installed system.
331 if ! grep -q vmlinuz-$VERSION-slitaz $1/boot/grub/menu.lst; then
333 #clean the old entry
334 # TODO somewhere, the old vmlinuz file is removed.
335 # but the entry is still there. this cause a grub error:15 when selected
336 # see http://bugs.slitaz.org/?id=74
338 #add the new
339 cat >> $1/boot/grub/menu.lst << EOT
341 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
342 $grub_dev
343 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev quiet
344 EOT
345 # Make it the default entry
346 last_entry=$(( $(grep -c '^title' $1/boot/grub/menu.lst)-1 ))
347 sed -e "s/^default.*/default $last_entry/g" -i $1/boot/grub/menu.lst
348 fi
349 # Display information message.
350 cat <<EOT
351 ----
352 GRUB is installed, these tree lines must be in your /boot/grub/menu.lst:
354 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
355 $grub_dev
356 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
357 ----
358 EOT
359 fi
360 }