wok view linux/receipt @ rev 12803

linux: dep on kmod for i486 and handle arm ARCH
author Christophe Lincoln <pankso@slitaz.org>
date Sat May 19 00:04:09 2012 +0200 (2012-05-19)
parents 8106b97b965e
children 4c9801543b7c
line source
1 # SliTaz package receipt.
3 PACKAGE="linux"
4 CATEGORY="base-system"
5 SHORT_DESC="The Linux kernel and modules."
6 MAINTAINER="devel@slitaz.org"
7 WEB_SITE="http://www.kernel.org/"
8 WGET_URL="http://www.kernel.org/pub/linux/kernel/v3.0/$TARBALL"
9 HOST_ARCH="i486 arm x86_64"
11 # Aufs enable chroot
12 AUFS_NOT_SUPPORTED="uclibc-cross-compiler-x86_64 is not compatible with aufs 8("
14 # This will save/restore the modules.dep but we want to regenerate it
15 # on install/upgrade.
16 #CONFIG_FILES="/lib/modules/$KBASEVER-slitaz/modules.dep"
18 case "$ARCH" in
19 i?86)
20 VERSION="3.2.14"
21 KBASEVER="${VERSION:0:3}"
22 TARBALL="$PACKAGE-$KBASEVER.tar.xz"
23 DEPENDS="kmod"
24 BUILD_DEPENDS="slitaz-toolchain perl git xz lzma patch uclibc-cross-compiler-x86_64"
25 [ "$KBASEVER" != "$VERSION" ] && PATCH="http://www.kernel.org/pub/linux/kernel/v3.0/patch-$VERSION.xz" ;;
26 arm)
27 # Old school way :-) Until ARM was tested on real hardware and
28 # we know wich modules/features we realy need for ARM machines.
29 # No deps on kmod since we use Busybox modutils for ARM.
30 VERSION="2.6.35.13"
31 TARBALL="$PACKAGE-$VERSION.tar.bz2" ;;
32 esac
34 # Rules to configure and make the package.
35 compile_rules()
36 {
37 cd $src
39 case "$ARCH" in
40 arm)
41 echo "Compiling: ARM Kernel"
42 make mrproper &&
43 cp -f $stuff/$ARCH/linux-slitaz.config .config &&
44 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- bzImage &&
45 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- modules &&
46 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- \
47 INSTALL_MOD_PATH=$DESTDIR modules_install &&
48 mkdir -p $DESTDIR/boot &&
49 mv arch/arm/boot/compressed/vmlinux \
50 $DESTDIR/boot/linux-$VERSION-slitaz-$ARCH
51 return 0 ;;
52 x86_64)
53 echo "TODO: Maybe use default ? But cross compile in x86_64 chroot"
54 echo "so we can remove the 64 build by uclibc-cross-compiler-x86_64"
55 return 0 ;;
56 esac
58 # this is code to help update the kernel version faster
59 #for i in $(grep -l 'WANTED="linux"' $WOK/*/receipt)
60 #do
61 # sed -i 's|VERSION="OLDVERSION"|VERSION="NEWVERSION"|g' $i
62 #done
64 [ ! -x /usr/bin/cook ] && report open-bloc
66 # Check for Aufs and cook it if unbuilt.
67 echo "Checking for Aufs packages..."
68 _AUFSVER=`grep ^VERSION= $WOK/aufs/receipt | cut -d "=" -f2 | sed -e 's/"//g'`
69 if [ -x /usr/bin/cook ]; then
70 # Give info an redirect to /dev/null since aufs got it own log.
71 AUFSDIR=$WOK/aufs/source/aufs-${_AUFSVER}
72 [ -d "$AUFSDIR" ] && rm -rf $AUFSDIR
73 #echo "Cook: aufs $_AUFSVER"
74 cook aufs --getsrc
75 mkdir -p $WOK/aufs/source/
76 tar xjf $SRC/aufs-${_AUFSVER}.tar.bz2 -C $WOK/aufs/source/
77 elif [ -x /usr/bin/tazwok ]; then
78 # we just need aufs source. Also cooking now is a bad idea since it
79 # needs linux-module-headers. The one your cooking not the one from the web.
80 AUFSDIR=$WOK/aufs/aufs-${_AUFSVER}
81 [ -d "$AUFSDIR" ] && rm -rf $AUFSDIR
82 tazwok get-src aufs --target=$AUFSDIR || { report close-bloc; return 1; }
83 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
91 [ -d $WOK/$PACKAGE/source/slitaz ] && rm -rf $WOK/$PACKAGE/source/slitaz 2> /dev/null
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"
104 continue
105 fi
106 echo "Apply $patch_file"
107 if [ -x /usr/bin/cook ]; then
108 patch -p1 < $WOK/$PACKAGE/source/slitaz/$patch_file || return 1
109 elif [ -x /usr/bin/tazwok ]; then
110 patch -p1 < $WOK/$PACKAGE/source/slitaz/$patch_file || { report close-bloc; return 1; }
111 fi
112 touch done.$patch_file
113 done <<EOT
114 $PACKAGE-diff.u
115 $PACKAGE-header.u
116 $PACKAGE-freeinitrd.u
117 aufs3-base.patch
118 aufs3-standalone.patch
119 aufs3-loopback.patch
120 aufs3-proc_map.patch
121 channel-negative-one-maxim.patch
122 mac80211.compat08082009.wl_frag+ack_v1.patch
123 EOT
125 if [ "$KBASEVER" != "$VERSION" ]; then
126 if [ -f $SOURCES_REPOSITORY/$(basename $PATCH) ]; then
127 xzcat $SOURCES_REPOSITORY/$(basename $PATCH) | patch -Np1
128 touch done.patch-$VERSION
129 else
130 wget $PATCH -O $SRC/$(basename $PATCH)
131 xzcat $SRC/$(basename $PATCH) | patch -Np1
132 touch done.patch-$VERSION
133 fi
134 fi
136 sed -i 's|SUBLEVEL =.*|SUBLEVEL =|g' Makefile
138 [ ! -x /usr/bin/cook ] && report step "Make kernel proper and then build lguest"
139 [ -x /usr/bin/cook ] && echo "Make kernel proper and then build lguest"
140 make mrproper
141 cd Documentation/virtual/lguest
142 if [ -x /usr/bin/cook ]; then
143 make lguest || return 1
144 elif [ -x /usr/bin/tazwok ]; then
145 make lguest || { report close-bloc; return 1; }
146 fi
147 cd $src
149 case "$opt" in
150 *--no64*);;
151 *)
152 #
153 # Arch x86_64
154 #
155 [ ! -x /usr/bin/cook ] && report step "Make bzImage64 without modules first"
156 [ -x /usr/bin/cook ] && echo "Building x86_64 Kernel"
158 # Build bzImage64 without modules first
159 cp -f $stuff/$PACKAGE-slitaz.config64 .config
160 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
162 # We can't keep every driver in staging
163 sed -i -e 's/^CONFIG_RTL8192/#&/' \
164 -e 's/^CONFIG_R8187SE/#&/' \
165 -e 's/^CONFIG_RT2870/#&/' .config
166 yes '' | make ARCH=x86_64 oldconfig
167 if [ -x /usr/bin/cook ]; then
168 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || exit 1
169 elif [ -x /usr/bin/tazwok ]; then
170 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || { report close-bloc; return 1; }
171 fi
172 [ -d $PWD/_pkg ] || mkdir -p $DESTDIR/linux64
173 mv arch/x86/boot/bzImage $DESTDIR/linux64
174 mv System.map System.map-without-modules64
176 [ ! -x /usr/bin/cook ] && report step "Now build bzImage64 with modules"
178 # Build bzImage64 with modules
179 cp -f $stuff/$PACKAGE-slitaz.config64 .config
180 #make ARCH=x86_64 oldconfig
181 ln .config $WOK/$PACKAGE/slitaz/config64
182 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage &&
183 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- modules &&
184 make ARCH=x86_64 INSTALL_MOD_PATH=$DESTDIR/linux64 modules_install &&
185 make ARCH=x86_64 INSTALL_HDR_PATH=$DESTDIR/linux64/usr headers_install &&
186 if [ -x /usr/bin/cook ]; then
187 [ -s arch/x86/boot/bzImage ] || return 1
188 elif [ -x /usr/bin/tazwok ]; then
189 [ -s arch/x86/boot/bzImage ] || { report close-bloc; return 1; }
190 fi
191 mkdir -p $DESTDIR/linux64/boot 2> /dev/null
192 mv arch/x86/boot/bzImage $DESTDIR/linux64/boot/vmlinuz-$VERSION-slitaz
193 ln System.map System.map-modules64
194 ln Module.symvers Module.symvers-modules64
195 esac
197 #
198 # Standard kernel
199 #
200 [ ! -x /usr/bin/cook ] && report step "Make bzImage without modules first"
201 [ -x /usr/bin/cook ] && echo "Building standard kernel..."
203 # Build bzImage without modules first
204 cp -f $stuff/$PACKAGE-slitaz.config .config
205 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
207 # We can't keep every driver in staging
208 sed -i -e 's/^CONFIG_RTL8192/#&/' \
209 -e 's/^CONFIG_R8187SE/#&/' \
210 -e 's/^CONFIG_RT2870/#&/' .config
211 yes '' | make oldconfig
212 if [ -x /usr/bin/cook ]; then
213 make -j 4 bzImage || exit 1
214 elif [ -x /usr/bin/tazwok ]; then
215 make -j 4 bzImage || { report close-bloc; return 1; }
216 fi
217 [ -d $DESTDIR ] || mkdir -p $DESTDIR
218 mv arch/x86/boot/bzImage $DESTDIR
219 mv System.map System.map-without-modules
221 [ ! -x /usr/bin/cook ] && report step "Now build bzImage with modules"
223 # Build bzImage with modules
224 cp -f $stuff/$PACKAGE-slitaz.config .config
225 #make oldconfig
226 ln .config $WOK/$PACKAGE/source/slitaz/config
227 make -j 4 bzImage &&
228 make -j 4 modules &&
229 make INSTALL_MOD_PATH=$DESTDIR modules_install &&
230 make INSTALL_HDR_PATH=$DESTDIR/usr headers_install &&
231 if [ -x /usr/bin/cook ]; then
232 [ -s arch/x86/boot/bzImage ] || return 1
233 elif [ -x /usr/bin/tazwok ]; then
234 [ -s arch/x86/boot/bzImage ] || { report close-bloc; return 1; }
235 fi
236 mkdir -p $DESTDIR/boot 2> /dev/null
237 mv arch/x86/boot/bzImage $DESTDIR/boot/vmlinuz-$VERSION-slitaz
239 [ ! -x /usr/bin/cook ] && report step "Compressing all modules"
241 # Compress all modules.
242 $stuff/gztazmod.sh $DESTDIR/lib/modules/$KBASEVER-slitaz
243 $stuff/gztazmod.sh $DESTDIR/linux64/lib/modules/$KBASEVER-slitaz
244 ln System.map System.map-modules
245 ln Module.symvers Module.symvers-modules
247 if [ ! -x /usr/bin/cook ]; then
248 report close-bloc
249 fi
250 }
252 # Rules to gen a SliTaz package suitable for Tazpkg.
253 genpkg_rules()
254 {
255 case "$ARCH" in
256 arm)
257 echo "Packing: ARM Kernel"
258 cp -a $install/* $fs
259 rm -f $fs/lib/modules/*/build $fs/lib/modules/*/source
260 return 0 ;;
261 x86_64)
262 echo "TODO: use default or custom x86_64 packing"
263 return 0 ;;
264 esac
266 export PACKAGE VERSION
267 local path
268 cp -a $_pkg/boot $fs
269 # Compress all modules.
270 $stuff/gztazmod.sh $_pkg/lib/modules/$KBASEVER-slitaz
271 path=$fs/lib/modules/$KBASEVER-slitaz/kernel
272 mkdir -p $path
273 cp -a $_pkg/lib/modules/$KBASEVER-slitaz/mo* \
274 $fs/lib/modules/$KBASEVER-slitaz
275 # Get the base modules
276 export src
277 export _pkg
278 mkdir -p $WOK/$PACKAGE/source/tmp
279 $stuff/list_modules.sh \
280 $(cat $stuff/modules.list) > $WOK/$PACKAGE/source/tmp/modules.list
281 while read module; do
282 dir=$(dirname $module)
283 [ -d $path/$dir ] || mkdir -p $path/$dir
284 cp -a $_pkg/lib/modules/$KBASEVER-slitaz/kernel/$module $path/$dir
285 done < $WOK/$PACKAGE/source/tmp/modules.list
286 # Remove unresolved links
287 rm -f $fs/lib/modules/$KBASEVER-slitaz/build
288 rm -f $fs/lib/modules/$KBASEVER-slitaz/source
289 # Cook all packages with a kernel module
290 for i in $(cd $WOK; grep -l 'tazwok cook linux$' */receipt)
291 do
292 echo tazwok cook ${i%/receipt}
293 done
294 # Fixed modules.dep to use right path
295 # saves 100kb of space too
296 sed -i "s|$_pkg||g" $fs/lib/modules/$KBASEVER-slitaz/modules.dep
297 sed -i "s|99.98.$KBASEVER-slitaz|$KBASEVER-slitaz|g" $fs/lib/modules/$KBASEVER-slitaz/modules.dep
298 # Check and echo any module in kernel .config that's not added to
299 # one of linux-* pkgs
300 $stuff/check_modules.sh
301 }
303 # Pre and post install commands for Tazpkg.
304 post_install()
305 {
306 echo "Processing post-install commands..."
307 case "$ARCH" in
308 arm)
309 echo "Kernel : /boot/linux-$VERSION-slitaz-$ARCH"
310 echo "Modules: /lib/modules/$VERSION-slitaz"
311 return 0 ;;
312 esac
313 chroot "$1/" depmod -a $KBASEVER-slitaz
314 # GRUB stuff.
315 if [ -f "$1/boot/grub/menu.lst" ]; then
316 root_dev=`cat $1/boot/grub/menu.lst | grep root= | sed 's/.*root=\([^ ]*\).*/\1/' | head -n 1`
317 grub_dev=`cat $1/boot/grub/menu.lst | grep "root (" | head -n 1`
318 # Add new kernel entry in case of upgrade for installed system.
319 if ! grep -q vmlinuz-$VERSION-slitaz $1/boot/grub/menu.lst; then
320 cat >> $1/boot/grub/menu.lst << EOT
322 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
323 $grub_dev
324 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
325 EOT
326 fi
327 # Display information message.
328 cat <<EOT
329 ----
330 GRUB is installed, these tree lines must be in your /boot/grub/menu.lst:
332 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
333 $grub_dev
334 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
335 ----
336 EOT
337 fi
338 }