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