wok view linux/receipt @ rev 15781

linux: remove kmod dep
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Jan 13 00:02:35 2014 +0100 (2014-01-13)
parents a1084fda7f23
children db5b03f42dd9
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=""
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 # Rules to configure and make the package.
41 compile_rules()
42 {
43 cd $src
44 cp /usr/share/boot/initrd initrd.cpio
46 if [ "$KBASEVER" != "$VERSION" ]; then
47 [ -s $SRC/$(basename $PATCH) ] ||
48 wget $PATCH -O $SRC/$(basename $PATCH)
49 xzcat $SRC/$(basename $PATCH) | patch -Np1
50 touch done.patch-$VERSION
51 fi
53 case "$ARCH" in
54 arm)
55 echo "Compiling: ARM Kernel"
56 if [ ! -s $SRC/$(basename $PATCH) ]; then
57 wget $PATCH -O $SRC/$(basename $PATCH)
58 fi
59 make mrproper
60 # Buggy: we got kernel panic about module not tinted 3.2.14
61 #echo "Applying patch: $(basename $PATCH)"
62 #xzcat $SRC/$(basename $PATCH) | patch -Np1 >/dev/null
63 patch -Np1 < $stuff/$ARCH/linux-arm.patch || exit 1
64 cp -f $stuff/$ARCH/linux-arm.config .config
65 echo "Configure $ARCH kernel..."
66 yes '' | make ARCH=$ARCH oldconfig
67 echo "Build $ARCH kernel..."
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 $PACKAGE-subroot.u
136 $PACKAGE-CVE-2013-2929.u
137 aufs3-base.patch
138 aufs3-standalone.patch
139 aufs3-loopback.patch
140 aufs3-mmap.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 echo "Configure bzImage64 without modules..."
176 yes '' | make ARCH=x86_64 oldconfig
177 echo "Build bzImage64 without modules..."
178 if [ -x /usr/bin/cook ]; then
179 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || exit 1
180 elif [ -x /usr/bin/tazwok ]; then
181 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || { report close-bloc; return 1; }
182 fi
183 [ -d $DESTDIR ] || mkdir -p $DESTDIR/linux64
184 mv arch/x86/boot/bzImage $DESTDIR/linux64
185 mv System.map System.map-without-modules64
187 [ ! -x /usr/bin/cook ] && report step "Now build bzImage64 with modules"
189 # Build bzImage64 with modules
190 cp -f $stuff/$PACKAGE-slitaz.config64 .config
191 echo "Configure bzImage64 with modules..."
192 yes '' | make ARCH=x86_64 oldconfig
193 echo "Build bzImage64 with modules..."
194 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage &&
195 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- modules &&
196 make ARCH=x86_64 INSTALL_MOD_PATH=$DESTDIR/linux64 modules_install &&
197 make ARCH=x86_64 INSTALL_HDR_PATH=$DESTDIR/linux64/usr headers_install &&
198 ln .config $WOK/$PACKAGE/source/slitaz/config64
199 if [ -x /usr/bin/cook ]; then
200 [ -s arch/x86/boot/bzImage ] || return 1
201 elif [ -x /usr/bin/tazwok ]; then
202 [ -s arch/x86/boot/bzImage ] || { report close-bloc; return 1; }
203 fi
204 mkdir -p $DESTDIR/linux64/boot 2> /dev/null
205 mv arch/x86/boot/bzImage $DESTDIR/linux64/boot/vmlinuz-$VERSION-slitaz
206 ln System.map System.map-modules64
207 ln Module.symvers Module.symvers-modules64
208 esac
210 #
211 # Standard kernel
212 #
213 [ ! -x /usr/bin/cook ] && report step "Make bzImage without modules first"
214 [ -x /usr/bin/cook ] && echo "Building standard kernel..."
216 # Build bzImage without modules first
217 cp -f $stuff/$PACKAGE-slitaz.config .config
218 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
220 # We can't keep every driver in staging
221 sed -i -e 's/^CONFIG_RTL8192/#&/' \
222 -e 's/^CONFIG_R8187SE/#&/' \
223 -e 's/^CONFIG_RT2870/#&/' .config
224 echo "Configure bzImage without modules..."
225 yes '' | make ARCH=i386 oldconfig
226 echo "Build bzImage without modules..."
227 if [ -x /usr/bin/cook ]; then
228 make ARCH=i386 -j 4 bzImage || exit 1
229 elif [ -x /usr/bin/tazwok ]; then
230 make ARCH=i386 -j 4 bzImage || { report close-bloc; return 1; }
231 fi
232 [ -d $DESTDIR ] || mkdir -p $DESTDIR
233 mv arch/x86/boot/bzImage $DESTDIR
234 mv System.map System.map-without-modules
236 [ ! -x /usr/bin/cook ] && report step "Now build bzImage with modules"
238 # Build bzImage with modules
239 cp -f $stuff/$PACKAGE-slitaz.config .config
240 echo "Configure bzImage with modules..."
241 yes '' | make ARCH=i386 oldconfig
242 ln .config $WOK/$PACKAGE/source/slitaz/config
243 echo "Build bzImage with modules..."
244 make ARCH=i386 -j 4 bzImage &&
245 make ARCH=i386 -j 4 modules &&
246 make ARCH=i386 INSTALL_MOD_PATH=$DESTDIR modules_install &&
247 make ARCH=i386 INSTALL_HDR_PATH=$DESTDIR/usr headers_install &&
248 if [ -x /usr/bin/cook ]; then
249 [ -s arch/x86/boot/bzImage ] || return 1
250 elif [ -x /usr/bin/tazwok ]; then
251 [ -s arch/x86/boot/bzImage ] || { report close-bloc; return 1; }
252 fi
253 mkdir -p $DESTDIR/boot 2> /dev/null
254 mv arch/x86/boot/bzImage $DESTDIR/boot/vmlinuz-$VERSION-slitaz
256 [ ! -x /usr/bin/cook ] && report step "Compressing all modules"
258 # Compress all modules.
259 $stuff/gztazmod.sh $DESTDIR/lib/modules/$KBASEVER-slitaz
260 $stuff/gztazmod.sh $DESTDIR/linux64/lib/modules/$KBASEVER-slitaz
261 ln System.map System.map-modules
262 ln Module.symvers Module.symvers-modules
264 if [ ! -x /usr/bin/cook ]; then
265 report close-bloc
266 fi
267 }
269 # Rules to gen a SliTaz package suitable for Tazpkg.
270 genpkg_rules()
271 {
272 case "$ARCH" in
273 arm)
274 echo "Packing: ARM Kernel"
275 cp -a $install/* $fs
276 rm -f $fs/lib/modules/*/build $fs/lib/modules/*/source
277 return 0 ;;
278 x86_64)
279 echo "TODO: use default or custom x86_64 packing"
280 return 0 ;;
281 esac
283 export PACKAGE VERSION
284 local path
285 cp -a $install/boot $fs
286 # Compress all modules.
287 path=$fs/lib/modules/$KBASEVER-slitaz/kernel
288 mkdir -p $path
289 cp -a $install/lib/modules/$KBASEVER-slitaz/mo* \
290 $fs/lib/modules/$KBASEVER-slitaz
291 [ "$KBASEVER" != "$VERSION" ] &&
292 ln -s $KBASEVER-slitaz $fs/lib/modules/$VERSION-slitaz
293 # Get the base modules
294 export src
295 export _pkg
296 mkdir -p $WOK/$PACKAGE/source/tmp
297 # Warning stuff/list_modules.sh must find the generated modules.list
298 $stuff/list_modules.sh \
299 $(cat $stuff/modules.list) > $WOK/$PACKAGE/source/tmp/modules.list
300 while read module; do
301 dir=$(dirname $module)
302 [ -d $path/$dir ] || mkdir -p $path/$dir
303 cp -a $install/lib/modules/$KBASEVER-slitaz/kernel/$module $path/$dir
304 done < $WOK/$PACKAGE/source/tmp/modules.list
305 # Remove unresolved links
306 rm -f $fs/lib/modules/$KBASEVER-slitaz/build
307 rm -f $fs/lib/modules/$KBASEVER-slitaz/source
308 # Cook all packages with a kernel module
309 for i in $(cd $WOK; grep -l 'cook linux$' */receipt)
310 do
311 echo cook ${i%/receipt}
312 done
313 # Fixed modules.dep to use right path
314 # saves 100kb of space too
315 sed -i "s|$_pkg||g" $fs/lib/modules/$KBASEVER-slitaz/modules.dep
316 sed -i "s|99.98.$KBASEVER-slitaz|$KBASEVER-slitaz|g" $fs/lib/modules/$KBASEVER-slitaz/modules.dep
317 # Check and echo any module in kernel .config that's not added to
318 # one of linux-* pkgs
319 $stuff/check_modules.sh
320 }
322 # Pre and post install commands for Tazpkg.
323 post_install()
324 {
325 echo "Processing post-install commands..."
326 case "$ARCH" in
327 arm)
328 echo "Kernel : /boot/linux-$VERSION-slitaz-$ARCH"
329 echo "Modules: /lib/modules/$VERSION-slitaz"
330 return 0 ;;
331 esac
332 chroot "$1/" depmod -a $KBASEVER-slitaz
333 # GRUB stuff.
334 if [ -f "$1/boot/grub/menu.lst" ]; then
335 root_dev="/dev/`lsblk | grep '/$'| grep -o '[a-z]d[a-z][0-9]*'`" # current root device
336 grub_part="$(( `echo $root_dev | grep -o '[0-9]*$'`-1 ))"
337 grub_dev="`grep $(echo $root_dev | grep -o '^/dev/.d.' ) $1/boot/grub/device.map |\
338 cut -f1 | sed "s/)$/.$grub_part)/g"`" # use device.map to find grub device number
340 # Add and clean kernel entrys in case of upgrade for installed system.
341 if ! grep -q vmlinuz-$VERSION-slitaz $1/boot/grub/menu.lst; then
343 #clean the old entry
344 # TODO somewhere, the old vmlinuz file is removed.
345 # but the entry is still there. this cause a grub error:15 when selected
346 # see http://bugs.slitaz.org/?id=74
348 #add the new
349 cat >> $1/boot/grub/menu.lst << EOT
351 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
352 $grub_dev
353 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev quiet
354 EOT
355 # Make it the default entry
356 last_entry=$(( $(grep -c '^title' $1/boot/grub/menu.lst)-1 ))
357 sed -e "s/^default.*/default $last_entry/g" -i $1/boot/grub/menu.lst
358 fi
359 # Display information message.
360 cat <<EOT
361 ----
362 GRUB is installed, these tree lines must be in your /boot/grub/menu.lst:
364 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
365 $grub_dev
366 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
367 ----
368 EOT
369 fi
370 }