wok-current view linux/receipt @ rev 20221

Up advancecomp (2.1), lzip (1.20), lzo (2.10), lzop (1.04)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Feb 26 17:40:15 2018 +0100 (2018-02-26)
parents 6ebbd98ea342
children 708b5293dd29
line source
1 # SliTaz package receipt.
3 PACKAGE="linux"
4 VERSION="3.2.98"
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="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 kmod \
16 uclibc-cross-compiler-x86_64"
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 if [ -f $root/etc/slitaz/slitaz.conf ]; then
41 . $root/etc/slitaz/slitaz.conf
42 case "$SLITAZ_ARCH" in
43 arm) DEPENDS="" ;;
44 esac
45 fi
47 install_module_headers()
48 {
49 local path
50 path=usr/src/linux-$KVERSION
51 mkdir -p $1/lib/modules/$KVERSION
52 ln -sf /$path $1/lib/modules/$KVERSION/build
53 install -D -m644 $src/Makefile \
54 $1/$path/Makefile
55 install -D -m644 $src/kernel/Makefile \
56 $1/$path/kernel/Makefile
57 install -D -m644 $src/.config \
58 $1/$path/.config
59 mkdir -p $1/$path/include
61 for i in acpi asm-generic config crypto drm generated linux math-emu \
62 media net pcmcia scsi sound trace video xen; do
63 cp -a $src/include/$i $1/$path/include/
64 done
66 # copy arch includes for external modules
67 mkdir -p $1/$path/arch/x86
68 cp -a $src/arch/x86/include $1/$path/arch/x86/
70 # copy files necessary for later builds, like nvidia and vmware
71 cp -a $src/Module.symvers $1/$path/Module.symvers
72 cp -a $src/scripts $1/$path
73 # fix permissions on scripts dir
74 chmod og-w -R $1/$path/scripts
75 mkdir -p $1/$path/.tmp_versions
77 mkdir -p $1/$path/arch/x86/kernel
78 cp -a $src/arch/x86/Makefile $1/$path/arch/x86/
79 cp -a $src/arch/x86/Makefile_32.cpu $1/$path/arch/x86/
80 cp -a $src/arch/x86/kernel/asm-offsets.s $1/$path/arch/x86/kernel/
82 # add headers for lirc package
83 mkdir -p $1/$path/drivers/media/video
84 cp -a $src/drivers/media/video/*.h $1/$path/drivers/media/video/
86 for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102 ; do
87 mkdir -p $1/$path/drivers/media/video/$i
88 cp -a $src/drivers/media/video/$i/*.h $1/$path/drivers/media/video/$i
89 done
91 # add docbook makefile
92 install -D -m644 $src/Documentation/DocBook/Makefile \
93 $1/$path/Documentation/DocBook/Makefile
95 # add dm headers
96 mkdir -p $1/$path/drivers/md
97 cp -a $src/drivers/md/*.h $1/$path/drivers/md
99 # add inotify.h
100 mkdir -p $1/$path/include/linux
101 cp -a $src/include/linux/inotify.h $1/$path/include/linux/
103 # add wireless headers
104 mkdir -p $1/$path/net/mac80211/
105 cp -a $src/net/mac80211/*.h $1/$path/net/mac80211/
107 # add dvb headers for external modules
108 # in reference to:
109 # http://bugs.archlinux.org/task/9912
110 mkdir -p $1/$path/drivers/media/dvb/dvb-core
111 cp -a $src/drivers/media/dvb/dvb-core/*.h $1/$path/drivers/media/dvb/dvb-core/
113 # add dvb headers for external modules
114 # in reference to:
115 # http://bugs.archlinux.org/task/11194
116 if [ -d $src/include/config/dvb/ ]; then
117 mkdir -p $1/$path/include/config/dvb/
118 cp $src/include/config/dvb/*.h $1/$path/include/config/dvb/
119 fi
121 # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
122 # in reference to:
123 # http://bugs.archlinux.org/task/13146
124 mkdir -p $1/$path/drivers/media/dvb/frontends/
125 cp -a $src/drivers/media/dvb/frontends/lgdt330x.h $1/$path/drivers/media/dvb/frontends/
126 cp -a $src/drivers/media/video/msp3400-driver.h $1/$path/drivers/media/dvb/frontends/
128 # add dvb headers
129 # in reference to:
130 # http://bugs.archlinux.org/task/20402
131 mkdir -p $1/$path/drivers/media/dvb/dvb-usb
132 cp -a $src/drivers/media/dvb/dvb-usb/*.h $1/$path/drivers/media/dvb/dvb-usb/
133 mkdir -p $1/$path/drivers/media/dvb/frontends
134 cp -a $src/drivers/media/dvb/frontends/*.h $1/$path/drivers/media/dvb/frontends/
135 mkdir -p $1/$path/drivers/media/common/tuners
136 cp -a $src/drivers/media/common/tuners/*.h $1/$path/drivers/media/common/tuners/
138 # add xfs and shmem for aufs building
139 mkdir -p $1/$path/fs/xfs
140 mkdir -p $1/$path/mm
141 cp -a $src/fs/xfs/xfs_sb.h $1/$path/fs/xfs/xfs_sb.h
143 # copy in Kconfig files
144 for i in $(find . -name "Kconfig*"); do
145 mkdir -p $1/$path/$(echo $i | sed 's|/Kconfig.*||')
146 cp -a $src/$i $1/$path/$i
147 done
149 chown -R root.root $1/$path
150 find $1/$path -type d -exec chmod 755 {} \;
151 # remove unneeded architectures
152 rm -rf $1/$path/arch/{alpha,arm,arm26,avr32,blackfin,cris,frv,h8300,ia64,m32r,m68k,m68knommu,mips,microblaze,mn10300,parisc,powerpc,ppc,s390,sh,sh64,sparc,sparc64,um,v850,xtensa}
153 }
155 # Rules to configure and make the package.
156 compile_rules()
157 {
158 if [ -f "/usr/share/boot/initrd" ]; then
159 cp /usr/share/boot/initrd initrd.cpio
160 fi
162 # Handle cross compilation
163 case "$ARCH" in
164 arm)
165 echo "Compiling: $ARCH Kernel"
166 make mrproper
167 patch -Np1 < $stuff/$ARCH/linux-arm.patch || exit 1
168 cp -f $stuff/$ARCH/linux-arm.config .config
169 yes '' | make ARCH=$ARCH oldconfig
170 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- bzImage &&
171 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- modules &&
172 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- \
173 INSTALL_MOD_PATH=$DESTDIR modules_install &&
174 mkdir -p $DESTDIR/boot &&
175 cp -a arch/arm/boot/zImage \
176 $DESTDIR/boot/linux-$VERSION-slitaz-$ARCH
177 #$stuff/gztazmod.sh $DESTDIR/lib/modules/$VERSION-slitaz
178 return 0 ;;
179 x86_64)
180 echo "TODO: Maybe use default ? But cross compile in x86_64 chroot"
181 echo "so we can remove the 64 build by uclibc-cross-compiler-x86_64"
182 return 0 ;;
183 esac
185 # Check for Aufs and get source/patches if needed
186 echo "Checking for Aufs packages..."
187 AUFSVER=$(grep ^VERSION= $WOK/aufs/receipt | cut -d "=" -f2 | sed -e 's/"//g')
188 AUFSDIR="$WOK/aufs/source/aufs-${AUFSVER}"
189 if [ ! -d "$AUFSDIR" ]; then
190 [ ! -f "$SRC/aufs-${AUFSVER}.tar.bz2" ] && cook aufs --getsrc
191 mkdir -p $WOK/aufs/source/
192 echo "Extracting: aufs-${AUFSVER}.tar.bz2"
193 tar xjf $SRC/aufs-${AUFSVER}.tar.bz2 -C $WOK/aufs/source/
194 fi
196 echo "cook:linux" > $command
198 echo "Copying Aufs files and patches..."
199 cp -a $AUFSDIR/Documentation $AUFSDIR/fs $AUFSDIR/include $src
200 cp -a $AUFSDIR/aufs3-*.patch $stuff
202 # SliTaz db stuff
203 [ -d $WOK/$PACKAGE/source/slitaz ] && rm -rf $WOK/$PACKAGE/source/slitaz
204 mkdir -p $WOK/$PACKAGE/source/slitaz
205 echo "$WGET_URL" > $WOK/$PACKAGE/source/slitaz/url
206 cp $stuff/gztazmod.sh $stuff/list_modules.sh $WOK/$PACKAGE/source/slitaz
207 cp $stuff/bootloader.sh $WOK/$PACKAGE/source/slitaz
209 # Apply patches
210 echo "Applying patches..."
211 while read patch_file; do
212 echo "$patch_file" >> $WOK/$PACKAGE/source/slitaz/patches
213 cp $stuff/$patch_file $WOK/$PACKAGE/source/slitaz
214 if [ -f done.$patch_file ]; then
215 echo "Skipping $patch_file" && continue
216 fi
217 echo "Apply $patch_file"
218 patch -p1 < $WOK/$PACKAGE/source/slitaz/$patch_file || return 1
219 touch done.$patch_file
220 done <<EOT
221 $PACKAGE-diff.u
222 $PACKAGE-header.u
223 $PACKAGE-freeinitrd.u
224 $PACKAGE-subroot.u
225 $PACKAGE-romfs.u
226 aufs3-base.patch
227 aufs3-standalone.patch
228 aufs3-loopback.patch
229 aufs3-mmap.patch
230 channel-negative-one-maxim.patch
231 mac80211.compat08082009.wl_frag+ack_v1.patch
232 EOT
234 # Mrproper and lguest
235 echo "Make kernel proper and then build lguest..."
236 make mrproper
237 cd Documentation/virtual/lguest
238 make lguest || return 1
239 cd $src
241 #
242 # Arch x86_64: TODO have a real cross environment
243 #
244 if [ ! "$nox64" ]; then
245 echo "Compiling: x86_64 Kernel"
247 # Build bzImage64 without modules first
248 if [ ! "$nonomods" ]; then
249 cp -f $stuff/$PACKAGE-slitaz.config64 .config
250 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
251 # We can't keep every driver in staging ???
252 sed -i -e 's/^CONFIG_RTL8192/#&/' \
253 -e 's/^CONFIG_R8187SE/#&/' \
254 -e 's/^CONFIG_RT2870/#&/' .config
255 echo -e "\n* Configure bzImage64 without modules...\n"
256 yes '' | make ARCH=x86_64 oldconfig
257 echo -e "\n* Building bzImage64 without modules...\n"
258 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || exit 1
259 [ -d $DESTDIR ] || mkdir -p $DESTDIR/linux64
260 mv arch/x86/boot/bzImage $DESTDIR/linux64
261 mv System.map System.map-without-modules64
262 mv vmlinux vmlinux-without-modules64
263 mv .config config-without-modules64
264 fi
266 # Build bzImage64 with modules
267 cp -f $stuff/$PACKAGE-slitaz.config64 .config
268 echo -e "\n* Configure bzImage64 with modules...\n"
269 yes '' | make ARCH=x86_64 oldconfig
270 echo -e "\n* Building bzImage64 with modules...\n"
271 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage &&
272 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- modules &&
273 make ARCH=x86_64 INSTALL_MOD_PATH=$DESTDIR/linux64 modules_install &&
274 make ARCH=x86_64 INSTALL_HDR_PATH=$DESTDIR/linux64/usr headers_install &&
275 ln .config $WOK/$PACKAGE/source/slitaz/config64
276 [ -s arch/x86/boot/bzImage ] || return 1
277 mkdir -p $DESTDIR/linux64/boot 2> /dev/null
278 mv arch/x86/boot/bzImage $DESTDIR/linux64/boot/vmlinuz-$VERSION-slitaz64
279 KVERSION=$VERSION-slitaz64
280 install_module_headers $DESTDIR/linux64
281 ln System.map System.map-modules64
282 ln vmlinux vmlinux-modules64
283 ln Module.symvers Module.symvers-modules64
284 cp .config config-modules64
285 else
286 echo "* Skipping: x86_64 Kernel..."
287 fi
289 #
290 # Linux Arch i386 - GCC arch i486
291 #
292 echo "Compiling: i386 Kernel..."
294 # Build bzImage without modules first
295 if [ ! "$nonomods" ]; then
296 cp -f $stuff/$PACKAGE-slitaz.config .config
297 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
298 # We can't keep every driver in staging ???
299 sed -i -e 's/^CONFIG_RTL8192/#&/' \
300 -e 's/^CONFIG_R8187SE/#&/' \
301 -e 's/^CONFIG_RT2870/#&/' .config
302 echo -e "\n* Configure bzImage without modules...\n"
303 yes '' | make ARCH=i386 oldconfig
304 echo -e "\n* Building bzImage without modules...\n"
305 make ARCH=i386 -j 4 bzImage || exit 1
306 [ -d $DESTDIR ] || mkdir -p $DESTDIR
307 mv arch/x86/boot/bzImage $DESTDIR
308 mv System.map System.map-without-modules
309 mv vmlinux vmlinux-without-modules
310 mv .config config-without-modules
311 fi
313 # Build bzImage with modules
314 cp -f $stuff/$PACKAGE-slitaz.config .config
315 echo -e "\n* Configure bzImage with modules...\n"
316 yes '' | make ARCH=i386 oldconfig
317 ln .config $WOK/$PACKAGE/source/slitaz/config
318 echo -e "\n* Building bzImage with modules...\n"
319 make ARCH=i386 -j 4 bzImage &&
320 make ARCH=i386 -j 4 modules &&
321 make ARCH=i386 INSTALL_MOD_PATH=$DESTDIR modules_install &&
322 make ARCH=i386 INSTALL_HDR_PATH=$DESTDIR/usr headers_install &&
323 [ -s arch/x86/boot/bzImage ] || return 1
324 mkdir -p $DESTDIR/boot 2> /dev/null
325 mv arch/x86/boot/bzImage $DESTDIR/boot/vmlinuz-$VERSION-slitaz
326 KVERSION=$VERSION-slitaz
327 install_module_headers $DESTDIR
329 # Compress all modules.
330 if [ -d "$DESTDIR/lib/modules/$VERSION-slitaz" ]; then
331 $stuff/gztazmod.sh $DESTDIR/lib/modules/$VERSION-slitaz
332 else
333 return 1
334 fi
335 if [ -d "$DESTDIR/linux64/lib/modules/$VERSION-slitaz64" ]; then
336 $stuff/gztazmod.sh $DESTDIR/linux64/lib/modules/$VERSION-slitaz64
337 fi
338 ln System.map System.map-modules
339 ln vmlinux vmlinux-modules
340 ln Module.symvers Module.symvers-modules
341 cp .config config-modules
342 }
344 # Rules to gen a SliTaz package suitable for Tazpkg.
345 genpkg_rules()
346 {
347 case "$ARCH" in
348 arm)
349 echo "Packing: ARM Kernel"
350 cp -a $install/* $fs
351 rm -f $fs/lib/modules/*/build $fs/lib/modules/*/source
352 return 0 ;;
353 x86_64)
354 echo "TODO: use default or custom x86_64 packing"
355 return 0 ;;
356 esac
358 export PACKAGE VERSION
359 local path
360 cp -a $install/boot $fs
362 # Compress all modules.
363 path=$fs/lib/modules/$VERSION-slitaz/kernel
364 mkdir -p $path
366 # Get the base modules
367 export src install
368 mkdir -p $WOK/$PACKAGE/source/tmp
369 # Warning stuff/list_modules.sh must find the generated modules.list
370 $stuff/list_modules.sh \
371 $(cat $stuff/modules.list) > $WOK/$PACKAGE/source/tmp/modules.list
372 while read module; do
373 dir=$(dirname $module)
374 [ -d $path/$dir ] || mkdir -p $path/$dir
375 cp -a $install/lib/modules/$VERSION-slitaz/kernel/$module $path/$dir
376 done < $WOK/$PACKAGE/source/tmp/modules.list
378 # Remove unresolved links
379 rm -f $fs/lib/modules/$VERSION-slitaz/build
380 rm -f $fs/lib/modules/$VERSION-slitaz/source
382 # We only need module.{order,builtin} because other map files are
383 # generated by depmod in post_install
384 cp -a $install/lib/modules/$VERSION-slitaz/modules.order \
385 $install/lib/modules/$VERSION-slitaz/modules.builtin \
386 $fs/lib/modules/$VERSION-slitaz
388 # Pack all packages with a kernel module
389 for i in $(cd $WOK; grep -l '^WANTED="linux"' */receipt); do
390 [ ! -d "$install/lib/modules/$VERSION-slitaz" ] && return 1
391 cook ${i%/receipt}
392 done
394 # Check any module in kernel .config that's not added to a linux-* pkgs
395 # and remove aufs patches: we dont need them in HG wok.
396 $stuff/check_modules.sh
397 rm -f $stuff/aufs3-*
398 }
400 # Pre and post install commands for Tazpkg.
401 post_install()
402 {
403 chroot "$root/" depmod -a $VERSION-slitaz
405 # Handle multiarch installation
406 case "$SLITAZ_ARCH" in
407 arm)
408 echo "Kernel : /boot/linux-$VERSION-slitaz-$ARCH"
409 echo "Modules: /lib/modules/$VERSION-slitaz"
410 return 0 ;;
411 esac
413 # GRUB stuff.
414 if [ -f "$1/boot/grub/menu.lst" ]; then
415 # Current root device
416 root_dev="/dev/$(lsblk | grep '/$'| grep -o '[a-z]d[a-z][0-9]*')"
417 grub_part="$(( $(echo $root_dev | grep -o '[0-9]*$')-1 ))"
418 # Use device.map to find grub device number
419 grub_dev="$(grep $(echo $root_dev | grep -o '^/dev/.d.' ) \
420 "$1/boot/grub/device.map" | cut -f1 | sed "s/)$/.$grub_part)/g")"
422 # Add and clean kernel entries in case of upgrade for installed system.
423 if ! grep -q vmlinuz-$VERSION-slitaz "$1/boot/grub/menu.lst"; then
425 # Clean the old entry
426 # TODO: old vmlinuz file is removed but the entry is still there.
427 # So grub error:15 when selected: http://bugs.slitaz.org/?id=74
429 # Add the new entry
430 cat >> "$1/boot/grub/menu.lst" << EOT
432 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
433 $grub_dev
434 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev quiet
435 EOT
436 # Make it the default entry
437 last_entry=$(( $(grep -c '^title' "$1/boot/grub/menu.lst")-1 ))
438 sed -e "s/^default.*/default $last_entry/g" -i "$1/boot/grub/menu.lst"
439 fi
441 # Display information message.
442 cat <<EOT
444 ----
445 GRUB is installed, these tree lines must be in your /boot/grub/menu.lst:
447 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
448 $grub_dev
449 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
450 ----
451 EOT
452 fi
453 true
454 }