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