wok-next view linux/receipt @ rev 15733

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