wok-next view linux/receipt @ rev 13460
Up: mtps (1.0)
author | Eric Joseph-Alexandre <erjo@slitaz.org> |
---|---|
date | Sun Oct 07 23:53:29 2012 +0200 (2012-10-07) |
parents | 4c9801543b7c |
children | 2771a5b12f2f |
line source
1 # SliTaz package receipt.
3 PACKAGE="linux"
4 VERSION="3.2.14"
5 KBASEVER="${VERSION:0:3}"
6 CATEGORY="base-system"
7 SHORT_DESC="The Linux kernel and modules."
8 MAINTAINER="devel@slitaz.org"
9 TARBALL="$PACKAGE-$KBASEVER.tar.xz"
10 WEB_SITE="http://www.kernel.org/"
11 WGET_URL="http://www.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 uclibc-cross-compiler-x86_64"
17 # Use version patch so we dont dl full kernel source on each minor update
18 [ "$KBASEVER" != "$VERSION" ] && \
19 PATCH="http://www.kernel.org/pub/linux/kernel/v3.0/patch-$VERSION.xz"
21 # Aufs enable chroot
22 AUFS_NOT_SUPPORTED="uclibc-cross-compiler-x86_64 is not compatible with aufs 8("
24 # This will save/restore modules.dep but we want to regenerate it on
25 # install or upgrade.
26 #CONFIG_FILES="/lib/modules/$KBASEVER-slitaz/modules.dep"
28 # Handle multiarch compilation. Less bdeps when cross-compiling for ARM
29 case "$ARCH" in
30 arm) BUILD_DEPENDS="xz" TARBALL="$PACKAGE-$VERSION.tar.bz2" ;;
31 x86_64) BUILD_DEPENDS="xz" ;;
32 esac
34 # TODO: slitaz.conf provide SLITAZ_ARCH and must be handled by tazpkg/spk
35 [ -f "$root/etc/slitaz/slitaz.conf" ] && . $root/etc/slitaz/slitaz.conf
37 # Handle multiarch installation. ARM use Busybox modutils, so avoid any
38 # deps on kmod
39 case "$SLITAZ_ARCH" in
40 arm) DEPENDS="" ;;
41 esac
43 # Rules to configure and make the package.
44 compile_rules()
45 {
46 cd $src
48 case "$ARCH" in
49 arm)
50 echo "Compiling: ARM Kernel"
51 if [ ! -f $SRC/$(basename $PATCH) ]; then
52 wget $PATCH -O $SRC/$(basename $PATCH)
53 fi
54 make mrproper
55 # Buggy: we got kernel panic about module not tinted 3.2.14
56 #echo "Applying patch: $(basename $PATCH)"
57 #xzcat $SRC/$(basename $PATCH) | patch -Np1 >/dev/null
58 patch -Np1 < $stuff/$ARCH/linux-arm.patch || exit 1
59 cp -f $stuff/$ARCH/linux-arm.config .config
60 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- bzImage &&
61 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- modules &&
62 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- \
63 INSTALL_MOD_PATH=$DESTDIR modules_install &&
64 mkdir -p $DESTDIR/boot &&
65 cp -a arch/arm/boot/zImage \
66 $DESTDIR/boot/linux-$VERSION-slitaz-$ARCH
67 return 0 ;;
68 x86_64)
69 echo "TODO: Maybe use default ? But cross compile in x86_64 chroot"
70 echo "so we can remove the 64 build by uclibc-cross-compiler-x86_64"
71 return 0 ;;
72 esac
74 [ ! -x /usr/bin/cook ] && report open-bloc
76 # Check for Aufs and cook it if unbuilt.
77 echo "Checking for Aufs packages..."
78 _AUFSVER=`grep ^VERSION= $WOK/aufs/receipt | cut -d "=" -f2 | sed -e 's/"//g'`
79 if [ -x /usr/bin/cook ]; then
80 # Give info an redirect to /dev/null since aufs got it own log.
81 AUFSDIR=$WOK/aufs/source/aufs-${_AUFSVER}
82 [ -d "$AUFSDIR" ] && rm -rf $AUFSDIR
83 #echo "Cook: aufs $_AUFSVER"
84 cook aufs --getsrc
85 mkdir -p $WOK/aufs/source/
86 tar xjf $SRC/aufs-${_AUFSVER}.tar.bz2 -C $WOK/aufs/source/
87 elif [ -x /usr/bin/tazwok ]; then
88 # we just need aufs source. Also cooking now is a bad idea since it
89 # needs linux-module-headers. The one your cooking not the one from the web.
90 AUFSDIR=$WOK/aufs/aufs-${_AUFSVER}
91 [ -d "$AUFSDIR" ] && rm -rf $AUFSDIR
92 tazwok get-src aufs --target=$AUFSDIR || { report close-bloc; return 1; }
93 fi
94 echo "cook:linux" > $command
96 echo "Copying Aufs files and patches..."
97 cp -a $AUFSDIR/Documentation $AUFSDIR/fs $AUFSDIR/include $src
98 cp -a $AUFSDIR/aufs3-*.patch $stuff
100 # SliTaz db
101 [ -d $WOK/$PACKAGE/source/slitaz ] && rm -rf $WOK/$PACKAGE/source/slitaz 2> /dev/null
102 mkdir -p $WOK/$PACKAGE/source/slitaz
103 echo "$WGET_URL" > $WOK/$PACKAGE/source/slitaz/url
104 cp $stuff/gztazmod.sh $stuff/list_modules.sh $WOK/$PACKAGE/source/slitaz
105 cp $stuff/bootloader.sh $WOK/$PACKAGE/source/slitaz
107 # Apply patches
108 echo "Applying patches..."
109 while read patch_file; do
110 echo "$patch_file" >> $WOK/$PACKAGE/source/slitaz/patches
111 cp $stuff/$patch_file $WOK/$PACKAGE/source/slitaz
112 if [ -f done.$patch_file ]; then
113 echo "Skipping $patch_file"
114 continue
115 fi
116 echo "Apply $patch_file"
117 if [ -x /usr/bin/cook ]; then
118 patch -p1 < $WOK/$PACKAGE/source/slitaz/$patch_file || return 1
119 elif [ -x /usr/bin/tazwok ]; then
120 patch -p1 < $WOK/$PACKAGE/source/slitaz/$patch_file || { report close-bloc; return 1; }
121 fi
122 touch done.$patch_file
123 done <<EOT
124 $PACKAGE-diff.u
125 $PACKAGE-header.u
126 $PACKAGE-freeinitrd.u
127 aufs3-base.patch
128 aufs3-standalone.patch
129 aufs3-loopback.patch
130 aufs3-proc_map.patch
131 channel-negative-one-maxim.patch
132 mac80211.compat08082009.wl_frag+ack_v1.patch
133 EOT
135 if [ "$KBASEVER" != "$VERSION" ]; then
136 if [ -f $SOURCES_REPOSITORY/$(basename $PATCH) ]; then
137 xzcat $SOURCES_REPOSITORY/$(basename $PATCH) | patch -Np1
138 touch done.patch-$VERSION
139 else
140 wget $PATCH -O $SRC/$(basename $PATCH)
141 xzcat $SRC/$(basename $PATCH) | patch -Np1
142 touch done.patch-$VERSION
143 fi
144 fi
146 sed -i 's|SUBLEVEL =.*|SUBLEVEL =|g' Makefile
148 [ ! -x /usr/bin/cook ] && report step "Make kernel proper and then build lguest"
149 [ -x /usr/bin/cook ] && echo "Make kernel proper and then build lguest"
150 make mrproper
151 cd Documentation/virtual/lguest
152 if [ -x /usr/bin/cook ]; then
153 make lguest || return 1
154 elif [ -x /usr/bin/tazwok ]; then
155 make lguest || { report close-bloc; return 1; }
156 fi
157 cd $src
159 case "$opt" in
160 *--no64*);;
161 *)
162 #
163 # Arch x86_64
164 #
165 [ ! -x /usr/bin/cook ] && report step "Make bzImage64 without modules first"
166 [ -x /usr/bin/cook ] && echo "Building x86_64 Kernel"
168 # Build bzImage64 without modules first
169 cp -f $stuff/$PACKAGE-slitaz.config64 .config
170 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
172 # We can't keep every driver in staging
173 sed -i -e 's/^CONFIG_RTL8192/#&/' \
174 -e 's/^CONFIG_R8187SE/#&/' \
175 -e 's/^CONFIG_RT2870/#&/' .config
176 yes '' | make ARCH=x86_64 oldconfig
177 if [ -x /usr/bin/cook ]; then
178 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || exit 1
179 elif [ -x /usr/bin/tazwok ]; then
180 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || { report close-bloc; return 1; }
181 fi
182 [ -d $PWD/_pkg ] || mkdir -p $DESTDIR/linux64
183 mv arch/x86/boot/bzImage $DESTDIR/linux64
184 mv System.map System.map-without-modules64
186 [ ! -x /usr/bin/cook ] && report step "Now build bzImage64 with modules"
188 # Build bzImage64 with modules
189 cp -f $stuff/$PACKAGE-slitaz.config64 .config
190 #make ARCH=x86_64 oldconfig
191 ln .config $WOK/$PACKAGE/slitaz/config64
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 if [ -x /usr/bin/cook ]; then
197 [ -s arch/x86/boot/bzImage ] || return 1
198 elif [ -x /usr/bin/tazwok ]; then
199 [ -s arch/x86/boot/bzImage ] || { report close-bloc; return 1; }
200 fi
201 mkdir -p $DESTDIR/linux64/boot 2> /dev/null
202 mv arch/x86/boot/bzImage $DESTDIR/linux64/boot/vmlinuz-$VERSION-slitaz
203 ln System.map System.map-modules64
204 ln Module.symvers Module.symvers-modules64
205 esac
207 #
208 # Standard kernel
209 #
210 [ ! -x /usr/bin/cook ] && report step "Make bzImage without modules first"
211 [ -x /usr/bin/cook ] && echo "Building standard kernel..."
213 # Build bzImage without modules first
214 cp -f $stuff/$PACKAGE-slitaz.config .config
215 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
217 # We can't keep every driver in staging
218 sed -i -e 's/^CONFIG_RTL8192/#&/' \
219 -e 's/^CONFIG_R8187SE/#&/' \
220 -e 's/^CONFIG_RT2870/#&/' .config
221 yes '' | make oldconfig
222 if [ -x /usr/bin/cook ]; then
223 make -j 4 bzImage || exit 1
224 elif [ -x /usr/bin/tazwok ]; then
225 make -j 4 bzImage || { report close-bloc; return 1; }
226 fi
227 [ -d $DESTDIR ] || mkdir -p $DESTDIR
228 mv arch/x86/boot/bzImage $DESTDIR
229 mv System.map System.map-without-modules
231 [ ! -x /usr/bin/cook ] && report step "Now build bzImage with modules"
233 # Build bzImage with modules
234 cp -f $stuff/$PACKAGE-slitaz.config .config
235 #make oldconfig
236 ln .config $WOK/$PACKAGE/source/slitaz/config
237 make -j 4 bzImage &&
238 make -j 4 modules &&
239 make INSTALL_MOD_PATH=$DESTDIR modules_install &&
240 make INSTALL_HDR_PATH=$DESTDIR/usr headers_install &&
241 if [ -x /usr/bin/cook ]; then
242 [ -s arch/x86/boot/bzImage ] || return 1
243 elif [ -x /usr/bin/tazwok ]; then
244 [ -s arch/x86/boot/bzImage ] || { report close-bloc; return 1; }
245 fi
246 mkdir -p $DESTDIR/boot 2> /dev/null
247 mv arch/x86/boot/bzImage $DESTDIR/boot/vmlinuz-$VERSION-slitaz
249 [ ! -x /usr/bin/cook ] && report step "Compressing all modules"
251 # Compress all modules.
252 $stuff/gztazmod.sh $DESTDIR/lib/modules/$KBASEVER-slitaz
253 $stuff/gztazmod.sh $DESTDIR/linux64/lib/modules/$KBASEVER-slitaz
254 ln System.map System.map-modules
255 ln Module.symvers Module.symvers-modules
257 if [ ! -x /usr/bin/cook ]; then
258 report close-bloc
259 fi
260 }
262 # Rules to gen a SliTaz package suitable for Tazpkg.
263 genpkg_rules()
264 {
265 case "$ARCH" in
266 arm)
267 echo "Packing: ARM Kernel"
268 cp -a $install/* $fs
269 rm -f $fs/lib/modules/*/build $fs/lib/modules/*/source
270 return 0 ;;
271 x86_64)
272 echo "TODO: use default or custom x86_64 packing"
273 return 0 ;;
274 esac
276 export PACKAGE VERSION
277 local path
278 cp -a $_pkg/boot $fs
279 # Compress all modules.
280 $stuff/gztazmod.sh $_pkg/lib/modules/$KBASEVER-slitaz
281 path=$fs/lib/modules/$KBASEVER-slitaz/kernel
282 mkdir -p $path
283 cp -a $_pkg/lib/modules/$KBASEVER-slitaz/mo* \
284 $fs/lib/modules/$KBASEVER-slitaz
285 # Get the base modules
286 export src
287 export _pkg
288 mkdir -p $WOK/$PACKAGE/source/tmp
289 $stuff/list_modules.sh \
290 $(cat $stuff/modules.list) > $WOK/$PACKAGE/source/tmp/modules.list
291 while read module; do
292 dir=$(dirname $module)
293 [ -d $path/$dir ] || mkdir -p $path/$dir
294 cp -a $_pkg/lib/modules/$KBASEVER-slitaz/kernel/$module $path/$dir
295 done < $WOK/$PACKAGE/source/tmp/modules.list
296 # Remove unresolved links
297 rm -f $fs/lib/modules/$KBASEVER-slitaz/build
298 rm -f $fs/lib/modules/$KBASEVER-slitaz/source
299 # Cook all packages with a kernel module
300 for i in $(cd $WOK; grep -l 'tazwok cook linux$' */receipt)
301 do
302 echo tazwok cook ${i%/receipt}
303 done
304 # Fixed modules.dep to use right path
305 # saves 100kb of space too
306 sed -i "s|$_pkg||g" $fs/lib/modules/$KBASEVER-slitaz/modules.dep
307 sed -i "s|99.98.$KBASEVER-slitaz|$KBASEVER-slitaz|g" $fs/lib/modules/$KBASEVER-slitaz/modules.dep
308 # Check and echo any module in kernel .config that's not added to
309 # one of linux-* pkgs
310 $stuff/check_modules.sh
311 }
313 # Pre and post install commands for Tazpkg.
314 post_install()
315 {
316 echo "Processing post-install commands..."
317 case "$ARCH" in
318 arm)
319 echo "Kernel : /boot/linux-$VERSION-slitaz-$ARCH"
320 echo "Modules: /lib/modules/$VERSION-slitaz"
321 return 0 ;;
322 esac
323 chroot "$1/" depmod -a $KBASEVER-slitaz
324 # GRUB stuff.
325 if [ -f "$1/boot/grub/menu.lst" ]; then
326 root_dev=`cat $1/boot/grub/menu.lst | grep root= | sed 's/.*root=\([^ ]*\).*/\1/' | head -n 1`
327 grub_dev=`cat $1/boot/grub/menu.lst | grep "root (" | head -n 1`
328 # Add new kernel entry in case of upgrade for installed system.
329 if ! grep -q vmlinuz-$VERSION-slitaz $1/boot/grub/menu.lst; then
330 cat >> $1/boot/grub/menu.lst << EOT
332 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
333 $grub_dev
334 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
335 EOT
336 fi
337 # Display information message.
338 cat <<EOT
339 ----
340 GRUB is installed, these tree lines must be in your /boot/grub/menu.lst:
342 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
343 $grub_dev
344 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
345 ----
346 EOT
347 fi
348 }