wok-next view linux/receipt @ rev 20395

e4rat: update patch (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Dec 02 12:33:04 2017 +0100 (2017-12-02)
parents b53ebb2699ba
children e65b8db12080
line source
1 # SliTaz package receipt v2.
3 PACKAGE="linux"
4 VERSION="4.9.30"
5 KBASEVER="4.9"
6 CATEGORY="base-system"
7 SHORT_DESC="The Linux Kernel"
8 MAINTAINER="devel@slitaz.org"
9 LICENSE="GPL2"
10 WEB_SITE="https://www.kernel.org/"
11 HOST_ARCH="i486 arm x86_64"
13 TARBALL="$PACKAGE-$KBASEVER.tar.xz"
14 WGET_URL="https://www.kernel.org/pub/linux/kernel/v4.x/$TARBALL"
16 BUILD_DEPENDS="slitaz-toolchain perl xz lzma patch kmod bc" # git
17 SPLIT="lguest linux-acpi linux-agp linux-aoe linux-appletalk linux-arcnet \
18 linux-autofs linux-bluetooth linux-bridge linux-btrfs linux-cifs linux-coda \
19 linux-cpufreq linux-cramfs linux-crypto linux-cryptoloop linux-dialup \
20 linux-dlm linux-drm linux-ecryptfs linux-efi linux-ethernet linux-exofs \
21 linux-firewire linux-firmware linux-gfs2 linux-hfs linux-hfsplus linux-hid \
22 linux-hwmon linux-ide linux-input-misc linux-input-tablet \
23 linux-input-touchscreen linux-ipv6 linux-irda linux-isdn linux-jfs \
24 linux-joystick linux-kvm linux-logfs linux-md linux-media linux-memstick \
25 linux-minix linux-mmc linux-module-headers linux-mwave linux-nbd linux-ncpfs \
26 linux-netfilter linux-nfc linux-nfs linux-nfsd linux-ocfs2 linux-orangefs \
27 linux-radio linux-reiserfs linux-romfs linux-sched linux-scsi linux-sound \
28 linux-source linux-speakup linux-squashfs linux-staging linux-toshiba \
29 linux-usb-gadget linux-usb-misc linux-usbdsl linux-usbip linux-uwb linux-video \
30 linux-wan linux-watchdog linux-wimax linux-wireless linux-without-modules \
31 linux-zram"
32 SIBLINGS="linux-api-headers linux-dev linux-man"
34 if [ "$KBASEVER" != "${VERSION%.0}" ]; then
35 PATCH="$(dirname $WGET_URL)/patch-$VERSION.xz"
36 EXTRA_SOURCE_FILES="$(basename $PATCH)"
37 fi
39 #
40 # The Linux receipt handle cross compilation. For x86_64 we actually use
41 # the uclibc-cross-compiler-x86_64 and for ARM we use a real cross env.
42 # Please discuss any change and keep it simple, don't play with VERSION
43 # string or Kernel SUBLEVEL because depmod and Pankso don't like that!
44 #
45 # The receipt also handle some cook options for faster build:
46 # --nonomods : Skip bzImage without modules build
47 #
49 # Handle multiarch compilation. Less bdeps when cross-compiling for ARM
50 case "$ARCH" in
51 arm) BUILD_DEPENDS="xz" ;;
52 x86_64) BUILD_DEPENDS="xz" ;;
53 esac
55 # Handle multiarch installation. ARM use Busybox modutils, so avoid any
56 # deps on kmod. SLITAZ_ARCH can have also custom post_install commands
57 if [ -f $root/etc/slitaz/slitaz.conf ]; then
58 . $root/etc/slitaz/slitaz.conf
59 case "$SLITAZ_ARCH" in
60 arm) DEPENDS="" ;;
61 esac
62 fi
64 # Rules to configure and make the package.
65 compile_rules()
66 {
67 # Update sources to the $VERSION using base sources ($KBASEVER) and patch
68 if [ "$KBASEVER" != "${VERSION%.0}" ]; then
69 [ -s $SRC/$(basename $PATCH) ] || wget $PATCH -O $SRC/$(basename $PATCH)
70 # don't patch twice for `cook $PACKAGE --continue`
71 if [ ! -f "done.patch-$VERSION" ]; then
72 xzcat $SRC/$(basename $PATCH) | patch -Np1
73 touch done.patch-$VERSION
74 fi
75 fi
77 #
78 if [ -f "/usr/share/boot/initrd" ]; then
79 cp /usr/share/boot/initrd initrd.cpio
80 fi
82 # Handle cross compilation
83 case "$ARCH" in
84 arm)
85 echo "Compiling: $ARCH Kernel"
86 make mrproper
87 patch -Np1 < $stuff/$ARCH/linux-arm.patch || exit 1
88 cp -f $stuff/$ARCH/linux-arm.config .config
89 yes '' | make ARCH=$ARCH oldconfig
90 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- bzImage &&
91 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- modules &&
92 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- \
93 INSTALL_MOD_PATH=$DESTDIR modules_install &&
94 mkdir -p $DESTDIR/boot &&
95 cp -a arch/arm/boot/zImage \
96 $DESTDIR/boot/linux-$VERSION-slitaz-$ARCH
97 #$stuff/tools/gztazmod.sh $DESTDIR/lib/modules/$VERSION-slitaz
98 return 0 ;;
99 x86_64)
100 echo "TODO: Maybe use default? But cross compile in x86_64 chroot"
101 echo "so we can remove the 64 build by uclibc-cross-compiler-x86_64"
102 return 0 ;;
103 esac
105 # Get and apply Aufs patches
106 . $stuff/tools/aufs-patches
108 echo "cook:linux" > $command
110 # Apply misc patches
111 echo "Applying patches..."
112 while read patch_file; do
113 if [ -f done.$patch_file ]; then
114 echo "Skipping $patch_file"; continue
115 fi
116 echo -e "\nApply $patch_file"
117 patch -p1 -i $stuff/patches/$patch_file || return 1
118 touch done.$patch_file
119 done < $stuff/patches/patch.order
121 # Mrproper and lguest
122 echo "Making kernel proper and then build lguest..."
123 make mrproper
124 cd tools/lguest
125 make lguest || return 1
126 cd $src
128 #
129 # Linux Arch i386 - GCC arch i486
130 #
131 echo "Making x86 Kernel..."
133 # Build bzImage without modules first
134 if [ -z "$nonomods" ]; then
135 cp -f $stuff/$PACKAGE-slitaz.config .config
136 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
137 # We can't keep every driver in staging???
138 sed -i \
139 -e 's/^CONFIG_RTL8192/#&/' \
140 -e 's/^CONFIG_R8187SE/#&/' \
141 -e 's/^CONFIG_RT2870/#&/' .config
143 title 'Configure bzImage without modules...'
144 yes '' | make ARCH=i386 oldconfig
146 title 'Building bzImage without modules...'
147 make ARCH=i386 -j 4 bzImage || exit 1
149 mkdir -p $DESTDIR
150 mv arch/x86/boot/bzImage $DESTDIR
151 mv System.map System.map-without-modules
152 fi
154 # Build bzImage with modules
155 cp -f $stuff/$PACKAGE-slitaz.config .config
157 title 'Configure bzImage with modules...'
158 yes '' | make ARCH=i386 oldconfig
161 title 'Building bzImage with modules...'
162 make ARCH=i386 -j 4 bzImage &&
163 make ARCH=i386 -j 4 modules &&
164 make ARCH=i386 INSTALL_MOD_PATH=$DESTDIR modules_install &&
165 make ARCH=i386 INSTALL_HDR_PATH=$DESTDIR/usr headers_install &&
167 [ -s arch/x86/boot/bzImage ] || return 1
168 mkdir -p $DESTDIR/boot
169 mv arch/x86/boot/bzImage $DESTDIR/boot/vmlinuz-$VERSION-slitaz
171 $stuff/tools/install_module_headers.sh $DESTDIR $src $VERSION-slitaz
173 ln System.map System.map-modules
174 ln Module.symvers Module.symvers-modules
176 # for linux-zram package
177 mkdir -p $install/etc/init.d
178 install -o root -m 755 $stuff/compcache $install/etc/init.d/
179 install -o root -m 644 $stuff/compcache.conf $install/etc/
181 # for lguest package
182 mkdir -p $install/usr/sbin
183 cp -a $src/tools/lguest/lguest $install/usr/sbin
184 }
186 # Rules to gen a SliTaz package suitable for Tazpkg.
187 genpkg_rules()
188 {
189 DEPENDS="linux" # default, may be subject to change later
191 case $PACKAGE in
192 *-acpi) c="ACPI modules";;
193 *-agp) c="AGP modules";;
194 *-aoe) c="AoE (ATA over Ethernet) modules";;
195 *-appletalk) c="Appletalk modules";;
196 *-arcnet) c="ARCnet modules";;
197 *-autofs) c="Automounter module";;
198 *-bluetooth) c="Bluetooth modules";;
199 *-bridge) c="Bridge modules";;
200 *-btrfs) c="Btrfs module"; DEPENDS="linux-crypto";;
201 *-cifs) c="CIFS module";;
202 *-coda) c="Coda module";;
203 *-cpufreq) c="Cpufreq modules";;
204 *-cramfs) c="CramFs module";;
205 *-crypto) c="Crypto modules";;
206 *-cryptoloop) c="Cryptoloop modules"; DEPENDS="linux-crypto";;
207 *-dialup) c="Dial-up modules";;
208 *-dlm) c="DLMFS module";;
209 *-drm) c="DRM module"; DEPENDS="linux-agp";;
210 *-ecryptfs) c="eCrypt FS module";;
211 *-efi) c="EFI modules";;
212 *-ethernet) c="Ethernet drivers"; DEPENDS="linux-crypto";;
213 *-exofs) c="OSD based FS module"; DEPENDS="linux-crypto";;
214 *-firewire) c="Firewire modules";;
215 *-gfs2) c="GFS2 module";;
216 *-hfs) c="HFS module";;
217 *-hfsplus) c="HFSplus module";;
218 *-hid) c="HID (human interface device) modules";;
219 *-hwmon) c="Hwmon modules";;
220 *-ide) c="IDE modules";;
221 *-input-misc) c="misc. input drivers";;
222 *-input-tablet) c="tablet input drivers";;
223 *-input-touchscreen) c="touchscreen input drivers";;
224 *-ipv6) c="IPv6 modules"; DEPENDS="linux-netfilter";;
225 *-irda) c="IRDA modules";;
226 *-isdn) c="ISDN modules";;
227 *-jfs) c="JFS module";;
228 *-joystick) c="joystick modules";;
229 *-kvm) c="KVM and Virtio modules";;
230 *-logfs) c="Logfs module";;
231 *-md) c="MD modules"; DEPENDS="linux-crypto";;
232 *-media) c="media modules"; DEPENDS="linux-radio";;
233 *-memstick) c="Sony memory stick modules";;
234 *-minix) c="Minix module";;
235 *-mmc) c="MMC modules - card reader";;
236 *-mwave) c="ACP Modem driver module - for IBM Thinkpad";;
237 *-nbd) c="NBD (network block device) modules";;
238 *-ncpfs) c="NCPFS module";;
239 *-netfilter) c="Netfilter modules";;
240 *-nfc) c="NFC modules";;
241 *-nfs) c="NFS modules"; DEPENDS="linux-crypto";;
242 *-nfsd) c="NFS server module"; DEPENDS="linux-nfs";;
243 *-ocfs2) c="OCFS2 modules"; DEPENDS="linux-dlm";;
244 *-orangefs) c="OrangeFS module";;
245 *-radio) c="radio modules"; DEPENDS="linux-sound";;
246 *-reiserfs) c="ReiserFS module";;
247 *-romfs) c="ROMFS module";;
248 *-sched) c="Sched modules";;
249 *-scsi) c="SCSI modules";;
250 *-sound) c="sound modules"
251 copy firmware/ess/ firmware/korg/ firmware/sun/ firmware/yamaha/
252 ;;
253 *-speakup) c="Speakup modules";;
254 *-squashfs) c="Squashfs module"; PROVIDE="squashfs-module";;
255 *-staging) c="staging kernel modules";;
256 *-toshiba) c="Toshiba module";;
257 *-usb-gadget) c="USB gadget modules";;
258 *-usb-misc) c="misc. USB drivers";;
259 *-usbdsl) c="USB DSL modem modules";;
260 *-usbip) c="Usbip module"; PROVIDE="usbip-module";;
261 *-uwb) c="UWB modules";;
262 *-video) c="video modules";;
263 *-wan) c="Wide Area Networks (WANs) modules"; DEPENDS="linux-wireless";;
264 *-watchdog) c="watchdog drivers";;
265 *-wimax) c="Wimax modules";;
266 *-wireless) c="wireless modules"; DEPENDS="linux-crypto wireless_tools";;
267 *-zram) c="compressed caching support"; PROVIDE="compcache"
268 copy compcache compcache.conf
269 ;;
270 esac
272 case $PACKAGE in
273 linux)
274 DEPENDS="kmod"
275 case "$ARCH" in
276 arm)
277 echo "Packing: ARM Kernel"
278 cp -a $install/* $fs
279 rm -f $fs/lib/modules/*/build $fs/lib/modules/*/source
280 return 0 ;;
281 x86_64)
282 echo "TODO: use default or custom x86_64 packing"
283 return 0 ;;
284 esac
286 # Copy the Kernel
287 cp -a $install/boot $fs
289 # Copy base modules
290 . $stuff/tools/copy_modules.sh
292 # We only need module.{order,builtin} because other map files are
293 # generated by depmod in post_install
294 copy modules.order modules.builtin
295 rm -rf $fs/usr
297 # Pack all packages with a Kernel modules
298 [ ! -d "$install/lib/modules/$VERSION-slitaz" ] && return 1
300 # Checking for Linux Kernel modules that don't belong to any of the packages
301 # $stuff/tools/check_modules.sh
302 # please, see web interface instead
303 ;;
304 *-firmware)
305 mkdir -p $fs/lib
306 cp -a $install/lib/firmware $fs/lib
307 # remove linux-sound firmware files
308 for i in ess korg sun yamaha; do
309 rm -rf $fs/lib/firmware/$i
310 done
311 CAT="non-free|firmware thats compiled from Linux source code"
312 PROVIDE="linux64-firmware"
313 ;;
314 *-module-headers)
315 CAT="development|header files and scripts for building modules for Linux Kernel"
316 KVERSION="$VERSION-slitaz"
317 DEPENDS="slitaz-toolchain"
318 mkdir -p $fs/lib/modules/$KVERSION $fs/usr
319 cp -a $install/usr/src $fs/usr
320 ;;
321 *-source)
322 CAT="development|source files"
323 DEPENDS="linux slitaz-toolchain ncurses-dev perl xz lzma patch busybox-boot"
325 local _AUFSVER=$(. $WOK/aufs/receipt; echo $VERSION)
326 local AUFSDIR="aufs-${_AUFSVER}"
327 kps=$fs/usr/src/kernel-patches/slitaz
328 mkdir -p $kps \
329 $fs/lib/modules/$VERSION-slitaz \
330 $fs/usr/bin $fs/usr/sbin
332 # URL
333 echo $(. $WOK/linux/receipt; echo $WGET_URL) > $kps/url
334 # stuff
335 cp $stuff/tools/* $stuff/bootloader.sh $kps
336 # Kernel patch
337 xzcat $SRC/patch-$VERSION.xz > $kps/linux-$VERSION.patch
338 echo "linux-$VERSION.patch" > $kps/patches
339 # Aufs patches
340 sed '/^aufs4.*patch$/!d' $stuff/tools/aufs-patches | \
341 tee -a $kps/patches | \
342 while read i; do
343 cp $WOK/aufs/source/*/$i $kps
344 done
345 # misc. patches
346 cat $stuff/patches/patch.order >> $kps/patches
347 cp $stuff/patches/* $kps
348 rm $kps/patch.order
349 # config
350 cp $WOK/linux/source/linux-$VERSION/.config $kps/config
352 cp -a $stuff/linux-source/buildtaz $kps
353 cp -a $stuff/linux-source/make-tazpkg.u $kps
354 cp -a $stuff/linux-source/get-linux-source $fs/usr/bin
355 cp -a $stuff/linux-source/list_modules.sh $kps
356 cp -a $stuff/linux-source/rdev $fs/usr/sbin
357 ln -s rdev $fs/usr/sbin/rootflags
358 ln -s rdev $fs/usr/sbin/ramsize
359 ln -s rdev $fs/usr/sbin/vidmode
360 sed -i "s|=XXX|=$VERSION|g" $fs/usr/bin/get-linux-source
362 # Copy Aufs4 source files
363 if [ -d $WOK/$WANTED/$AUFSDIR ]; then
364 mkdir $fs/usr/src/kernel-patches/slitaz/aufs4
365 cp -a $WOK/$WANTED/$AUFSDIR/Documentation \
366 $WOK/$WANTED/$AUFSDIR/fs $WOK/$WANTED/$AUFSDIR/include \
367 $fs/usr/src/kernel-patches/slitaz/aufs4
368 fi
370 ln -s ../../../usr/src/linux-$VERSION $fs/lib/modules/$VERSION-slitaz/source
372 chown -R root:root $fs
373 ;;
374 *-without-modules)
375 CAT="base-system|without module support"
376 PROVIDE="linux"
377 mkdir -p $fs/boot
378 cp -a $install/bzImage $fs/boot/vmlinuz-$VERSION-slitaz-without-modules
379 ;;
380 lguest)
381 CAT="base-system|paravirtualization tool"
382 DEPENDS=" "
383 copy lguest
384 ;;
385 *)
386 . $stuff/tools/copy_modules.sh
387 CAT="base-system|$c"
388 ;;
389 esac
391 case $PACKAGE in
392 *fs|*fs2|*-coda|*-dlm|*-hfsplus|*-minix|*-nfsd)
393 CONFIG_FILES="/etc/filesystems";;
394 *-zram)
395 CONFIG_FILES="/etc/compcache.conf";;
396 esac
397 }
400 post_install_linux() {
401 # Handle multiarch installation
402 case "$SLITAZ_ARCH" in
403 arm)
404 echo "Kernel : /boot/linux-$VERSION-slitaz-$ARCH"
405 echo "Modules: /lib/modules/$VERSION-slitaz"
406 return 0 ;;
407 esac
409 # GRUB stuff.
410 if [ -f "$1/boot/grub/menu.lst" ]; then
411 # Current root device
412 root_dev="/dev/$(lsblk | grep '/$'| grep -o '[a-z]d[a-z][0-9]*')"
413 grub_part="$(( $(echo $root_dev | grep -o '[0-9]*$')-1 ))"
414 # Use device.map to find grub device number
415 grub_dev="$(grep $(echo $root_dev | grep -o '^/dev/.d.' ) \
416 "$1/boot/grub/device.map" | cut -f1 | sed "s/)$/.$grub_part)/g")"
418 # Add and clean Kernel entries in case of upgrade for installed system.
419 if ! grep -q vmlinuz-$VERSION-slitaz "$1/boot/grub/menu.lst"; then
421 # Clean the old entry
422 # TODO: old vmlinuz file is removed but the entry is still there.
423 # So grub error:15 when selected: http://bugs.slitaz.org/?id=74
425 # Add the new entry
426 cat >> "$1/boot/grub/menu.lst" <<EOT
428 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
429 $grub_dev
430 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev quiet
431 EOT
432 # Make it the default entry
433 last_entry=$(( $(grep -c '^title' "$1/boot/grub/menu.lst")-1 ))
434 sed -e "s/^default.*/default $last_entry/g" -i "$1/boot/grub/menu.lst"
435 fi
437 # Display information message.
438 [ -z "$quiet" ] && cat <<EOT
440 ----
441 GRUB is installed, these three lines must be in your /boot/grub/menu.lst:
443 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
444 $grub_dev
445 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
446 ----
447 EOT
448 fi
449 :
450 }
452 pre_remove_linux_module_headers() {
453 if [ -e "$1/usr/src/linux" ]; then
454 rm -rf "$1/usr/src/linux"
455 fi
456 }
458 # Added soft link to make it easier to point to kernel folder
459 post_install_linux_module_headers() {
460 KVERSION="$VERSION-slitaz"
461 [ -L "$1/usr/src/linux" ] && rm -f "$1/usr/src/linux"
462 ln -sf /usr/src/linux-$KVERSION "$1/usr/src/linux"
463 ln -sf /usr/src/linux-$KVERSION "$1/lib/modules/$KVERSION/build"
464 }
466 post_install_linux_zram() {
467 chroot "$1/" depmod -a $VERSION-slitaz &&
468 RAM=$(grep MemTotal /proc/meminfo | tr -dc 0-9) &&
469 echo "SIZE_KB="$(($RAM/2)) > "$1/etc/compcache.conf"
470 [ -n "$quiet" ] || cat <<EOT
472 You can add compressed swap according /etc/compcache.conf configuration with:
473 # /etc/init.d/compcache start
474 Or add compcache to the RUN_DAEMONS list of /etc/rcS.conf.
475 EOT
476 }