wok view linux/receipt @ rev 14178

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