wok view linux/receipt @ rev 15855

New kernel config and huge receipt clean up
author Christophe Lincoln <pankso@slitaz.org>
date Wed Jan 29 09:56:07 2014 +0100 (2014-01-29)
parents de8cd706512c
children 673b107f2fd7
line source
1 # SliTaz package receipt.
3 PACKAGE="linux"
4 VERSION="3.2.53"
5 CATEGORY="base-system"
6 SHORT_DESC="The Linux kernel and modules."
7 MAINTAINER="devel@slitaz.org"
8 LICENSE="GPL2"
9 TARBALL="$PACKAGE-$VERSION.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 kmod \
16 uclibc-cross-compiler-x86_64 busybox-boot"
18 #
19 # The Linux receipt handle cross compilation. For x86_64 we actually use
20 # the uclibc-cross-compiler-x86_64 and for ARM we use a real cross env.
21 # Please discuss any change and keep it simple, dont play with VERSION
22 # string or Kernel SUBLEVEL because depmod and Pankso dont like that!
23 #
24 # The receipt also handle some cook options for faster build:
25 # --nox64 : Skip the x86_64 cross compilation
26 # --nonomods : Skip bzImage without modules build
27 #
29 # Aufs enable chroot
30 AUFS_NOT_RAMFS="uclibc-cross-compiler-x86_64 is not compatible with aufs+tmpfs 8("
32 # Handle multiarch compilation. Less bdeps when cross-compiling for ARM
33 case "$ARCH" in
34 arm) BUILD_DEPENDS="xz" ;;
35 x86_64) BUILD_DEPENDS="xz" ;;
36 esac
38 # Handle multiarch installation. ARM use Busybox modutils, so avoid any
39 # deps on kmod. SLITAZ_ARCH can have also custom post_install commands
40 . $root/etc/slitaz/slitaz.conf || exit 1
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
49 cp /usr/share/boot/initrd initrd.cpio
51 # Handle cross compilation
52 case "$ARCH" in
53 arm)
54 echo "Compiling: $ARCH Kernel"
55 make mrproper
56 patch -Np1 < $stuff/$ARCH/linux-arm.patch || exit 1
57 cp -f $stuff/$ARCH/linux-arm.config .config
58 yes '' | make ARCH=$ARCH oldconfig
59 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- bzImage &&
60 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- modules &&
61 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- \
62 INSTALL_MOD_PATH=$DESTDIR modules_install &&
63 mkdir -p $DESTDIR/boot &&
64 cp -a arch/arm/boot/zImage \
65 $DESTDIR/boot/linux-$VERSION-slitaz-$ARCH
66 return 0 ;;
67 x86_64)
68 echo "TODO: Maybe use default ? But cross compile in x86_64 chroot"
69 echo "so we can remove the 64 build by uclibc-cross-compiler-x86_64"
70 return 0 ;;
71 esac
73 # Check for Aufs and get source/patches if needed
74 echo "Checking for Aufs packages..."
75 AUFSVER=$(grep ^VERSION= $WOK/aufs/receipt | cut -d "=" -f2 | sed -e 's/"//g')
76 AUFSDIR="$WOK/aufs/source/aufs-${AUFSVER}"
77 if [ ! -d "$AUFSDIR" ]; then
78 [ ! -f "$SRC/aufs-${AUFSVER}.tar.bz2" ] && cook aufs --getsrc
79 mkdir -p $WOK/aufs/source/
80 echo "Extracting: aufs-${AUFSVER}.tar.bz2"
81 tar xjf $SRC/aufs-${AUFSVER}.tar.bz2 -C $WOK/aufs/source/
82 fi
84 echo "cook:linux" > $command
86 echo "Copying Aufs files and patches..."
87 cp -a $AUFSDIR/Documentation $AUFSDIR/fs $AUFSDIR/include $src
88 cp -a $AUFSDIR/aufs3-*.patch $stuff
90 # SliTaz db stuff
91 [ -d $WOK/$PACKAGE/source/slitaz ] && rm -rf $WOK/$PACKAGE/source/slitaz
92 mkdir -p $WOK/$PACKAGE/source/slitaz
93 echo "$WGET_URL" > $WOK/$PACKAGE/source/slitaz/url
94 cp $stuff/gztazmod.sh $stuff/list_modules.sh $WOK/$PACKAGE/source/slitaz
95 cp $stuff/bootloader.sh $WOK/$PACKAGE/source/slitaz
97 # Apply patches
98 echo "Applying patches..."
99 while read patch_file; do
100 echo "$patch_file" >> $WOK/$PACKAGE/source/slitaz/patches
101 cp $stuff/$patch_file $WOK/$PACKAGE/source/slitaz
102 if [ -f done.$patch_file ]; then
103 echo "Skipping $patch_file" && continue
104 fi
105 echo "Apply $patch_file"
106 patch -p1 < $WOK/$PACKAGE/source/slitaz/$patch_file || return 1
107 touch done.$patch_file
108 done <<EOT
109 $PACKAGE-diff.u
110 $PACKAGE-header.u
111 $PACKAGE-freeinitrd.u
112 $PACKAGE-subroot.u
113 $PACKAGE-CVE-2013-2929.u
114 aufs3-base.patch
115 aufs3-standalone.patch
116 aufs3-loopback.patch
117 aufs3-mmap.patch
118 channel-negative-one-maxim.patch
119 mac80211.compat08082009.wl_frag+ack_v1.patch
120 EOT
122 # Mrproper and lguest
123 echo "Make kernel proper and then build lguest..."
124 make mrproper
125 cd Documentation/virtual/lguest
126 make lguest || return 1
127 cd $src
129 #
130 # Arch x86_64: TODO have a real cross environment
131 #
132 if [ ! "nox64" ]; then
133 echo "Compiling: x86_64 Kernel"
135 # Build bzImage64 without modules first
136 if [ ! "nonomods" ]; then
137 cp -f $stuff/$PACKAGE-slitaz.config64 .config
138 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
139 # We can't keep every driver in staging ???
140 sed -i -e 's/^CONFIG_RTL8192/#&/' \
141 -e 's/^CONFIG_R8187SE/#&/' \
142 -e 's/^CONFIG_RT2870/#&/' .config
143 echo -e "\n* Configure bzImage64 without modules...\n"
144 yes '' | make ARCH=x86_64 oldconfig
145 echo -e "\n* Building bzImage64 without modules...\n"
146 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || exit 1
147 [ -d $DESTDIR ] || mkdir -p $DESTDIR/linux64
148 mv arch/x86/boot/bzImage $DESTDIR/linux64
149 mv System.map System.map-without-modules64
150 fi
152 # Build bzImage64 with modules
153 cp -f $stuff/$PACKAGE-slitaz.config64 .config
154 echo -e "\n* Configure bzImage64 with modules...\n"
155 yes '' | make ARCH=x86_64 oldconfig
156 echo -e "\n* Building bzImage64 with modules...\n"
157 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage &&
158 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- modules &&
159 make ARCH=x86_64 INSTALL_MOD_PATH=$DESTDIR/linux64 modules_install &&
160 make ARCH=x86_64 INSTALL_HDR_PATH=$DESTDIR/linux64/usr headers_install &&
161 ln .config $WOK/$PACKAGE/source/slitaz/config64
162 [ -s arch/x86/boot/bzImage ] || return 1
163 mkdir -p $DESTDIR/linux64/boot 2> /dev/null
164 mv arch/x86/boot/bzImage $DESTDIR/linux64/boot/vmlinuz-$VERSION-slitaz
165 ln System.map System.map-modules64
166 ln Module.symvers Module.symvers-modules64
167 else
168 echo "* Skipping: x86_64 Kernel..."
169 fi
171 #
172 # Linux Arch i386 - GCC arch i486
173 #
174 echo "Compiling: i386 Kernel..."
176 # Build bzImage without modules first
177 if [ ! "nonomods" ]; then
178 cp -f $stuff/$PACKAGE-slitaz.config .config
179 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
180 # We can't keep every driver in staging ???
181 sed -i -e 's/^CONFIG_RTL8192/#&/' \
182 -e 's/^CONFIG_R8187SE/#&/' \
183 -e 's/^CONFIG_RT2870/#&/' .config
184 echo -e "\n* Configure bzImage without modules...\n"
185 yes '' | make ARCH=i386 oldconfig
186 echo -e "\n* Building bzImage without modules...\n"
187 make ARCH=i386 -j 4 bzImage || exit 1
188 [ -d $DESTDIR ] || mkdir -p $DESTDIR
189 mv arch/x86/boot/bzImage $DESTDIR
190 mv System.map System.map-without-modules
191 fi
193 # Build bzImage with modules
194 cp -f $stuff/$PACKAGE-slitaz.config .config
195 echo -e "\n* Configure bzImage with modules...\n"
196 yes '' | make ARCH=i386 oldconfig
197 ln .config $WOK/$PACKAGE/source/slitaz/config
198 echo -e "\n* Building bzImage with modules...\n"
199 make ARCH=i386 -j 4 bzImage &&
200 make ARCH=i386 -j 4 modules &&
201 make ARCH=i386 INSTALL_MOD_PATH=$DESTDIR modules_install &&
202 make ARCH=i386 INSTALL_HDR_PATH=$DESTDIR/usr headers_install &&
203 [ -s arch/x86/boot/bzImage ] || return 1
204 mkdir -p $DESTDIR/boot 2> /dev/null
205 mv arch/x86/boot/bzImage $DESTDIR/boot/vmlinuz-$VERSION-slitaz
207 # Compress all modules.
208 if [ -d "$DESTDIR/lib/modules/$VERSION-slitaz" ]; then
209 $stuff/gztazmod.sh $DESTDIR/lib/modules/$VERSION-slitaz
210 else
211 return 1
212 fi
213 if [ -d "$DESTDIR/linux64/lib/modules/$VERSION-slitaz" ]; then
214 $stuff/gztazmod.sh $DESTDIR/linux64/lib/modules/$VERSION-slitaz
215 fi
216 ln System.map System.map-modules
217 ln Module.symvers Module.symvers-modules
218 }
220 # Rules to gen a SliTaz package suitable for Tazpkg.
221 genpkg_rules()
222 {
223 case "$ARCH" in
224 arm)
225 echo "Packing: ARM Kernel"
226 cp -a $install/* $fs
227 rm -f $fs/lib/modules/*/build $fs/lib/modules/*/source
228 return 0 ;;
229 x86_64)
230 echo "TODO: use default or custom x86_64 packing"
231 return 0 ;;
232 esac
234 export PACKAGE VERSION
235 local path
236 cp -a $install/boot $fs
238 # Compress all modules.
239 path=$fs/lib/modules/$VERSION-slitaz/kernel
240 mkdir -p $path
242 # Get the base modules
243 export src install
244 mkdir -p $WOK/$PACKAGE/source/tmp
245 # Warning stuff/list_modules.sh must find the generated modules.list
246 $stuff/list_modules.sh \
247 $(cat $stuff/modules.list) > $WOK/$PACKAGE/source/tmp/modules.list
248 while read module; do
249 dir=$(dirname $module)
250 [ -d $path/$dir ] || mkdir -p $path/$dir
251 cp -a $install/lib/modules/$VERSION-slitaz/kernel/$module $path/$dir
252 done < $WOK/$PACKAGE/source/tmp/modules.list
254 # Remove unresolved links
255 rm -f $fs/lib/modules/$VERSION-slitaz/build
256 rm -f $fs/lib/modules/$VERSION-slitaz/source
258 # We only need module.{order,builtin} because other map files are
259 # generated by depmod in post_install
260 cp -a $install/lib/modules/$VERSION-slitaz/modules.order \
261 $install/lib/modules/$VERSION-slitaz/modules.builtin \
262 $fs/lib/modules/$VERSION-slitaz
264 # Pack all packages with a kernel module
265 for i in $(cd $WOK; grep -l '^WANTED="linux"' */receipt)
266 do
267 [ ! -d "$install/lib/modules/$VERSION-slitaz" ] && return 1
268 cook ${i%/receipt}
269 done
271 # Check any module in kernel .config that's not added to a linux-* pkgs
272 # and remove aufs patches: we dont need them in HG wok.
273 $stuff/check_modules.sh
274 rm -f $stuff/aufs3-*
275 }
277 # Pre and post install commands for Tazpkg.
278 post_install()
279 {
280 echo "Processing post-install commands..."
281 chroot "$root/" depmod -a $VERSION-slitaz
283 # Handle multiarch installation
284 case "$SLITAZ_ARCH" in
285 arm)
286 echo "Kernel : /boot/linux-$VERSION-slitaz-$ARCH"
287 echo "Modules: /lib/modules/$VERSION-slitaz"
288 return 0 ;;
289 esac
291 # GRUB stuff.
292 if [ -f "$1/boot/grub/menu.lst" ]; then
293 # Current root device
294 root_dev="/dev/$(lsblk | grep '/$'| grep -o '[a-z]d[a-z][0-9]*')"
295 grub_part="$(( $(echo $root_dev | grep -o '[0-9]*$')-1 ))"
296 # Use device.map to find grub device number
297 grub_dev="$(grep $(echo $root_dev | grep -o '^/dev/.d.' ) \
298 $1/boot/grub/device.map | cut -f1 | sed "s/)$/.$grub_part)/g")"
300 # Add and clean kernel entries in case of upgrade for installed system.
301 if ! grep -q vmlinuz-$VERSION-slitaz $1/boot/grub/menu.lst; then
303 # Clean the old entry
304 # TODO: old vmlinuz file is removed but the entry is still there.
305 # So grub error:15 when selected: http://bugs.slitaz.org/?id=74
307 # Add the new entry
308 cat >> $1/boot/grub/menu.lst << EOT
310 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
311 $grub_dev
312 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev quiet
313 EOT
314 # Make it the default entry
315 last_entry=$(( $(grep -c '^title' $1/boot/grub/menu.lst)-1 ))
316 sed -e "s/^default.*/default $last_entry/g" -i $1/boot/grub/menu.lst
317 fi
319 # Display information message.
320 cat <<EOT
321 ----
322 GRUB is installed, these tree lines must be in your /boot/grub/menu.lst:
324 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
325 $grub_dev
326 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
327 ----
328 EOT
329 fi
330 }