wok-backports view linux/receipt @ rev 5

linux-kvm: fix module list
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Dec 19 15:27:00 2013 +0000 (2013-12-19)
parents 87efcf9eac62
children beaf13a43b46
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"
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
51 if [ "$KBASEVER" != "$VERSION" ]; then
52 [ -s $SRC/$(basename $PATCH) ] ||
53 wget $PATCH -O $SRC/$(basename $PATCH)
54 xzcat $SRC/$(basename $PATCH) | patch -Np1
55 touch done.patch-$VERSION
56 fi
58 case "$ARCH" in
59 arm)
60 echo "Compiling: ARM Kernel"
61 if [ ! -s $SRC/$(basename $PATCH) ]; then
62 wget $PATCH -O $SRC/$(basename $PATCH)
63 fi
64 make mrproper
65 # Buggy: we got kernel panic about module not tinted 3.2.14
66 #echo "Applying patch: $(basename $PATCH)"
67 #xzcat $SRC/$(basename $PATCH) | patch -Np1 >/dev/null
68 patch -Np1 < $stuff/$ARCH/linux-arm.patch || exit 1
69 cp -f $stuff/$ARCH/linux-arm.config .config
70 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- bzImage &&
71 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- modules &&
72 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- \
73 INSTALL_MOD_PATH=$DESTDIR modules_install &&
74 mkdir -p $DESTDIR/boot &&
75 cp -a arch/arm/boot/zImage \
76 $DESTDIR/boot/linux-$VERSION-slitaz-$ARCH
77 return 0 ;;
78 x86_64)
79 echo "TODO: Maybe use default ? But cross compile in x86_64 chroot"
80 echo "so we can remove the 64 build by uclibc-cross-compiler-x86_64"
81 return 0 ;;
82 esac
84 [ ! -x /usr/bin/cook ] && report open-bloc
86 # Check for Aufs and cook it if unbuilt.
87 echo "Checking for Aufs packages..."
88 _AUFSVER=`grep ^VERSION= $WOK/aufs/receipt | cut -d "=" -f2 | sed -e 's/"//g'`
89 if [ -x /usr/bin/cook ]; then
90 # Give info an redirect to /dev/null since aufs got it own log.
91 AUFSDIR=$WOK/aufs/source/aufs-${_AUFSVER}
92 [ -d "$AUFSDIR" ] && rm -rf $AUFSDIR
93 #echo "Cook: aufs $_AUFSVER"
94 cook aufs --getsrc
95 mkdir -p $WOK/aufs/source/
96 tar xjf $SRC/aufs-${_AUFSVER}.tar.bz2 -C $WOK/aufs/source/
97 elif [ -x /usr/bin/tazwok ]; then
98 # we just need aufs source. Also cooking now is a bad idea since it
99 # needs linux-module-headers. The one your cooking not the one from the web.
100 AUFSDIR=$WOK/aufs/aufs-${_AUFSVER}
101 [ -d "$AUFSDIR" ] && rm -rf $AUFSDIR
102 tazwok get-src aufs --target=$AUFSDIR || { report close-bloc; return 1; }
103 fi
104 echo "cook:linux" > $command
106 echo "Copying Aufs files and patches..."
107 cp -a $AUFSDIR/Documentation $AUFSDIR/fs $AUFSDIR/include $src
108 cp -a $AUFSDIR/aufs3-*.patch $stuff
110 # SliTaz db
111 [ -d $WOK/$PACKAGE/source/slitaz ] && rm -rf $WOK/$PACKAGE/source/slitaz 2> /dev/null
112 mkdir -p $WOK/$PACKAGE/source/slitaz
113 echo "$WGET_URL" > $WOK/$PACKAGE/source/slitaz/url
114 cp $stuff/gztazmod.sh $stuff/list_modules.sh $WOK/$PACKAGE/source/slitaz
115 cp $stuff/bootloader.sh $WOK/$PACKAGE/source/slitaz
117 # Apply patches
118 echo "Applying patches..."
119 while read patch_file; do
120 echo "$patch_file" >> $WOK/$PACKAGE/source/slitaz/patches
121 cp $stuff/$patch_file $WOK/$PACKAGE/source/slitaz
122 if [ -f done.$patch_file ]; then
123 echo "Skipping $patch_file"
124 continue
125 fi
126 echo "Apply $patch_file"
127 if [ -x /usr/bin/cook ]; then
128 patch -p1 < $WOK/$PACKAGE/source/slitaz/$patch_file || return 1
129 elif [ -x /usr/bin/tazwok ]; then
130 patch -p1 < $WOK/$PACKAGE/source/slitaz/$patch_file || { report close-bloc; return 1; }
131 fi
132 touch done.$patch_file
133 done <<EOT
134 $PACKAGE-diff.u
135 $PACKAGE-header.u
136 $PACKAGE-freeinitrd.u
137 $PACKAGE-subroot.u
138 $PACKAGE-CVE-2013-2929.u
139 aufs3-base.patch
140 aufs3-standalone.patch
141 aufs3-loopback.patch
142 aufs3-proc_map.patch
143 channel-negative-one-maxim.patch
144 mac80211.compat08082009.wl_frag+ack_v1.patch
145 EOT
147 sed -i 's|SUBLEVEL =.*|SUBLEVEL =|g' Makefile
149 [ ! -x /usr/bin/cook ] && report step "Make kernel proper and then build lguest"
150 [ -x /usr/bin/cook ] && echo "Make kernel proper and then build lguest"
151 make mrproper
152 cd Documentation/virtual/lguest
153 if [ -x /usr/bin/cook ]; then
154 make lguest || return 1
155 elif [ -x /usr/bin/tazwok ]; then
156 make lguest || { report close-bloc; return 1; }
157 fi
158 cd $src
160 case "$opt" in
161 *--no64*);;
162 *)
163 #
164 # Arch x86_64
165 #
166 [ ! -x /usr/bin/cook ] && report step "Make bzImage64 without modules first"
167 [ -x /usr/bin/cook ] && echo "Building x86_64 Kernel"
169 # Build bzImage64 without modules first
170 cp -f $stuff/$PACKAGE-slitaz.config64 .config
171 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
173 # We can't keep every driver in staging
174 sed -i -e 's/^CONFIG_RTL8192/#&/' \
175 -e 's/^CONFIG_R8187SE/#&/' \
176 -e 's/^CONFIG_RT2870/#&/' .config
177 yes '' | make ARCH=x86_64 oldconfig
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 #make ARCH=x86_64 oldconfig
192 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage &&
193 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- modules &&
194 make ARCH=x86_64 INSTALL_MOD_PATH=$DESTDIR/linux64 modules_install &&
195 make ARCH=x86_64 INSTALL_HDR_PATH=$DESTDIR/linux64/usr headers_install &&
196 ln .config $WOK/$PACKAGE/source/slitaz/config64
197 if [ -x /usr/bin/cook ]; then
198 [ -s arch/x86/boot/bzImage ] || return 1
199 elif [ -x /usr/bin/tazwok ]; then
200 [ -s arch/x86/boot/bzImage ] || { report close-bloc; return 1; }
201 fi
202 mkdir -p $DESTDIR/linux64/boot 2> /dev/null
203 mv arch/x86/boot/bzImage $DESTDIR/linux64/boot/vmlinuz-$VERSION-slitaz
204 ln System.map System.map-modules64
205 ln Module.symvers Module.symvers-modules64
206 esac
208 #
209 # Standard kernel
210 #
211 [ ! -x /usr/bin/cook ] && report step "Make bzImage without modules first"
212 [ -x /usr/bin/cook ] && echo "Building standard kernel..."
214 # Build bzImage without modules first
215 cp -f $stuff/$PACKAGE-slitaz.config .config
216 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
218 # We can't keep every driver in staging
219 sed -i -e 's/^CONFIG_RTL8192/#&/' \
220 -e 's/^CONFIG_R8187SE/#&/' \
221 -e 's/^CONFIG_RT2870/#&/' .config
222 yes '' | make ARCH=i386 oldconfig
223 if [ -x /usr/bin/cook ]; then
224 make ARCH=i386 -j 4 bzImage || exit 1
225 elif [ -x /usr/bin/tazwok ]; then
226 make ARCH=i386 -j 4 bzImage || { report close-bloc; return 1; }
227 fi
228 [ -d $DESTDIR ] || mkdir -p $DESTDIR
229 mv arch/x86/boot/bzImage $DESTDIR
230 mv System.map System.map-without-modules
232 [ ! -x /usr/bin/cook ] && report step "Now build bzImage with modules"
234 # Build bzImage with modules
235 cp -f $stuff/$PACKAGE-slitaz.config .config
236 #make ARCH=i386 oldconfig
237 ln .config $WOK/$PACKAGE/source/slitaz/config
238 make ARCH=i386 -j 4 bzImage &&
239 make ARCH=i386 -j 4 modules &&
240 make ARCH=i386 INSTALL_MOD_PATH=$DESTDIR modules_install &&
241 make ARCH=i386 INSTALL_HDR_PATH=$DESTDIR/usr headers_install &&
242 if [ -x /usr/bin/cook ]; then
243 [ -s arch/x86/boot/bzImage ] || return 1
244 elif [ -x /usr/bin/tazwok ]; then
245 [ -s arch/x86/boot/bzImage ] || { report close-bloc; return 1; }
246 fi
247 mkdir -p $DESTDIR/boot 2> /dev/null
248 mv arch/x86/boot/bzImage $DESTDIR/boot/vmlinuz-$VERSION-slitaz
250 [ ! -x /usr/bin/cook ] && report step "Compressing all modules"
252 # Compress all modules.
253 $stuff/gztazmod.sh $DESTDIR/lib/modules/$KBASEVER-slitaz
254 $stuff/gztazmod.sh $DESTDIR/linux64/lib/modules/$KBASEVER-slitaz
255 ln System.map System.map-modules
256 ln Module.symvers Module.symvers-modules
258 if [ ! -x /usr/bin/cook ]; then
259 report close-bloc
260 fi
261 }
263 # Rules to gen a SliTaz package suitable for Tazpkg.
264 genpkg_rules()
265 {
266 case "$ARCH" in
267 arm)
268 echo "Packing: ARM Kernel"
269 cp -a $install/* $fs
270 rm -f $fs/lib/modules/*/build $fs/lib/modules/*/source
271 return 0 ;;
272 x86_64)
273 echo "TODO: use default or custom x86_64 packing"
274 return 0 ;;
275 esac
277 export PACKAGE VERSION
278 local path
279 cp -a $install/boot $fs
280 # Compress all modules.
281 path=$fs/lib/modules/$KBASEVER-slitaz/kernel
282 mkdir -p $path
283 cp -a $install/lib/modules/$KBASEVER-slitaz/mo* \
284 $fs/lib/modules/$KBASEVER-slitaz
285 [ "$KBASEVER" != "$VERSION" ] &&
286 ln -s $KBASEVER-slitaz $fs/lib/modules/$VERSION-slitaz
287 # Get the base modules
288 export src
289 export _pkg
290 mkdir -p $WOK/$PACKAGE/source/tmp
291 # Warning stuff/list_modules.sh must find the generated modules.list
292 $stuff/list_modules.sh \
293 $(cat $stuff/modules.list) > $WOK/$PACKAGE/source/tmp/modules.list
294 while read module; do
295 dir=$(dirname $module)
296 [ -d $path/$dir ] || mkdir -p $path/$dir
297 cp -a $install/lib/modules/$KBASEVER-slitaz/kernel/$module $path/$dir
298 done < $WOK/$PACKAGE/source/tmp/modules.list
299 # Remove unresolved links
300 rm -f $fs/lib/modules/$KBASEVER-slitaz/build
301 rm -f $fs/lib/modules/$KBASEVER-slitaz/source
302 # Cook all packages with a kernel module
303 for i in $(cd $WOK; grep -l 'cook linux$' */receipt)
304 do
305 echo cook ${i%/receipt}
306 done
307 # Fixed modules.dep to use right path
308 # saves 100kb of space too
309 sed -i "s|$_pkg||g" $fs/lib/modules/$KBASEVER-slitaz/modules.dep
310 sed -i "s|99.98.$KBASEVER-slitaz|$KBASEVER-slitaz|g" $fs/lib/modules/$KBASEVER-slitaz/modules.dep
311 # Check and echo any module in kernel .config that's not added to
312 # one of linux-* pkgs
313 $stuff/check_modules.sh
314 }
316 # Pre and post install commands for Tazpkg.
317 post_install()
318 {
319 echo "Processing post-install commands..."
320 case "$ARCH" in
321 arm)
322 echo "Kernel : /boot/linux-$VERSION-slitaz-$ARCH"
323 echo "Modules: /lib/modules/$VERSION-slitaz"
324 return 0 ;;
325 esac
326 chroot "$1/" depmod -a $KBASEVER-slitaz
327 # GRUB stuff.
328 if [ -f "$1/boot/grub/menu.lst" ]; then
329 root_dev="/dev/`lsblk | grep '/$'| grep -o '[a-z]d[a-z][0-9]*'`" # current root device
330 grub_part="$(( `echo $root_dev | grep -o '[0-9]*$'`-1 ))"
331 grub_dev="`grep $(echo $root_dev | grep -o '^/dev/.d.' ) $1/boot/grub/device.map |\
332 cut -f1 | sed "s/)$/.$grub_part)/g"`" # use device.map to find grub device number
334 # Add and clean kernel entrys in case of upgrade for installed system.
335 if ! grep -q vmlinuz-$VERSION-slitaz $1/boot/grub/menu.lst; then
337 #clean the old entry
338 # TODO somewhere, the old vmlinuz file is removed.
339 # but the entry is still there. this cause a grub error:15 when selected
340 # see http://bugs.slitaz.org/?id=74
342 #add the new
343 cat >> $1/boot/grub/menu.lst << EOT
345 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
346 $grub_dev
347 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev quiet
348 EOT
349 # Make it the default entry
350 last_entry=$(( $(grep -c '^title' $1/boot/grub/menu.lst)-1 ))
351 sed -e "s/^default.*/default $last_entry/g" -i $1/boot/grub/menu.lst
352 fi
353 # Display information message.
354 cat <<EOT
355 ----
356 GRUB is installed, these tree lines must be in your /boot/grub/menu.lst:
358 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
359 $grub_dev
360 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
361 ----
362 EOT
363 fi
364 }