wok view linux/receipt @ rev 14332

emotion: no /usr/bin
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Apr 12 21:02:26 2013 +0200 (2013-04-12)
parents f51d35fb6a4a
children a62a3bf42fb0
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="ftp://ftp.kernel.org/pub/linux/kernel/v3.0/patch-$VERSION.xz"
21 # Aufs enable chroot
22 AUFS_NOT_RAMFS="uclibc-cross-compiler-x86_64 is not compatible with aufs+tmpfs 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 if [ "$KBASEVER" != "$VERSION" ]; then
49 [ -s $SRC/$(basename $PATCH) ] ||
50 wget $PATCH -O $SRC/$(basename $PATCH)
51 xzcat $SRC/$(basename $PATCH) | patch -Np1
52 touch done.patch-$VERSION
53 fi
55 case "$ARCH" in
56 arm)
57 echo "Compiling: ARM Kernel"
58 if [ ! -s $SRC/$(basename $PATCH) ]; then
59 wget $PATCH -O $SRC/$(basename $PATCH)
60 fi
61 make mrproper
62 # Buggy: we got kernel panic about module not tinted 3.2.14
63 #echo "Applying patch: $(basename $PATCH)"
64 #xzcat $SRC/$(basename $PATCH) | patch -Np1 >/dev/null
65 patch -Np1 < $stuff/$ARCH/linux-arm.patch || exit 1
66 cp -f $stuff/$ARCH/linux-arm.config .config
67 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- bzImage &&
68 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- modules &&
69 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- \
70 INSTALL_MOD_PATH=$DESTDIR modules_install &&
71 mkdir -p $DESTDIR/boot &&
72 cp -a arch/arm/boot/zImage \
73 $DESTDIR/boot/linux-$VERSION-slitaz-$ARCH
74 return 0 ;;
75 x86_64)
76 echo "TODO: Maybe use default ? But cross compile in x86_64 chroot"
77 echo "so we can remove the 64 build by uclibc-cross-compiler-x86_64"
78 return 0 ;;
79 esac
81 [ ! -x /usr/bin/cook ] && report open-bloc
83 # Check for Aufs and cook it if unbuilt.
84 echo "Checking for Aufs packages..."
85 _AUFSVER=`grep ^VERSION= $WOK/aufs/receipt | cut -d "=" -f2 | sed -e 's/"//g'`
86 if [ -x /usr/bin/cook ]; then
87 # Give info an redirect to /dev/null since aufs got it own log.
88 AUFSDIR=$WOK/aufs/source/aufs-${_AUFSVER}
89 [ -d "$AUFSDIR" ] && rm -rf $AUFSDIR
90 #echo "Cook: aufs $_AUFSVER"
91 cook aufs --getsrc
92 mkdir -p $WOK/aufs/source/
93 tar xjf $SRC/aufs-${_AUFSVER}.tar.bz2 -C $WOK/aufs/source/
94 elif [ -x /usr/bin/tazwok ]; then
95 # we just need aufs source. Also cooking now is a bad idea since it
96 # needs linux-module-headers. The one your cooking not the one from the web.
97 AUFSDIR=$WOK/aufs/aufs-${_AUFSVER}
98 [ -d "$AUFSDIR" ] && rm -rf $AUFSDIR
99 tazwok get-src aufs --target=$AUFSDIR || { report close-bloc; return 1; }
100 fi
101 echo "cook:linux" > $command
103 echo "Copying Aufs files and patches..."
104 cp -a $AUFSDIR/Documentation $AUFSDIR/fs $AUFSDIR/include $src
105 cp -a $AUFSDIR/aufs3-*.patch $stuff
107 # SliTaz db
108 [ -d $WOK/$PACKAGE/source/slitaz ] && rm -rf $WOK/$PACKAGE/source/slitaz 2> /dev/null
109 mkdir -p $WOK/$PACKAGE/source/slitaz
110 echo "$WGET_URL" > $WOK/$PACKAGE/source/slitaz/url
111 cp $stuff/gztazmod.sh $stuff/list_modules.sh $WOK/$PACKAGE/source/slitaz
112 cp $stuff/bootloader.sh $WOK/$PACKAGE/source/slitaz
114 # Apply patches
115 echo "Applying patches..."
116 while read patch_file; do
117 echo "$patch_file" >> $WOK/$PACKAGE/source/slitaz/patches
118 cp $stuff/$patch_file $WOK/$PACKAGE/source/slitaz
119 if [ -f done.$patch_file ]; then
120 echo "Skipping $patch_file"
121 continue
122 fi
123 echo "Apply $patch_file"
124 if [ -x /usr/bin/cook ]; then
125 patch -p1 < $WOK/$PACKAGE/source/slitaz/$patch_file || return 1
126 elif [ -x /usr/bin/tazwok ]; then
127 patch -p1 < $WOK/$PACKAGE/source/slitaz/$patch_file || { report close-bloc; return 1; }
128 fi
129 touch done.$patch_file
130 done <<EOT
131 $PACKAGE-diff.u
132 $PACKAGE-header.u
133 $PACKAGE-freeinitrd.u
134 aufs3-base.patch
135 aufs3-standalone.patch
136 aufs3-loopback.patch
137 aufs3-proc_map.patch
138 channel-negative-one-maxim.patch
139 mac80211.compat08082009.wl_frag+ack_v1.patch
140 EOT
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 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage &&
188 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- modules &&
189 make ARCH=x86_64 INSTALL_MOD_PATH=$DESTDIR/linux64 modules_install &&
190 make ARCH=x86_64 INSTALL_HDR_PATH=$DESTDIR/linux64/usr headers_install &&
191 ln .config $WOK/$PACKAGE/source/slitaz/config64
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 }