wok-next view linux/receipt @ rev 20678

Up clisp (2.50)
author Aleksej Bobylev <al.bobylev@gmail.com>
date Tue May 15 02:59:03 2018 +0300 (2018-05-15)
parents efd5fe5db61e
children 99d51a8e04a8
line source
1 # SliTaz package receipt v2.
3 PACKAGE="linux"
4 VERSION="4.14.16"
5 KBASEVER="4.14"
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_arm="xz"
17 BUILD_DEPENDS_x86_64="perl xz patch kmod bc elfutils-dev"
18 BUILD_DEPENDS="perl xz lzma patch kmod bc elfutils-dev" # git
19 # Removed: lguest, linux-firmware, linux-logfs, linux-toshiba
20 SPLIT="\
21 linux-acpi linux-agp linux-aoe \
22 linux-appletalk linux-arcnet linux-autofs \
23 linux-bluetooth linux-bridge linux-btrfs \
24 linux-cifs linux-coda linux-cpufreq \
25 linux-cramfs linux-crypto linux-cryptoloop \
26 linux-dialup linux-dlm linux-drm \
27 linux-ecryptfs linux-efi linux-ethernet \
28 linux-exofs linux-firewire linux-gfs2 \
29 linux-hfs linux-hfsplus linux-hid \
30 linux-hwmon linux-ide linux-input-misc \
31 linux-input-tablet linux-input-touchscreen linux-ipv6 \
32 linux-irda linux-isdn linux-jfs \
33 linux-joystick linux-kvm linux-md \
34 linux-media linux-memstick linux-minix \
35 linux-mmc linux-module-headers linux-mwave \
36 linux-nbd linux-ncpfs linux-netfilter \
37 linux-nfc linux-nfs linux-nfsd \
38 linux-ocfs2 linux-orangefs linux-radio \
39 linux-reiserfs linux-romfs linux-sched \
40 linux-scsi linux-sound linux-source \
41 linux-speakup linux-squashfs linux-staging \
42 linux-usb-gadget linux-usb-misc linux-usbdsl \
43 linux-usbip linux-uwb linux-video \
44 linux-wan linux-watchdog linux-wimax \
45 linux-wireless linux-without-modules linux-zram"
47 if [ "$KBASEVER" != "${VERSION%.0}" ]; then
48 PATCH="$(dirname $WGET_URL)/patch-$VERSION.xz"
49 EXTRA_SOURCE_FILES="$(basename $PATCH)"
50 fi
52 #
53 # The Linux receipt handle cross compilation; for ARM we use a real cross env.
54 # Please discuss any change and try to keep it simple.
55 #
56 # The receipt handle cook option for faster build:
57 # --nonomods : Skip bzImage without modules build
58 #
60 # CONFIG_PAGE_TABLE_ISOLATION
61 # against Meltdown currently available in 4.14 only for x86_64 architecture.
62 # CONFIG_RETPOLINE
63 # against Spectre v.2 available both for i386 and x86_64 architectures.
65 # Handle multiarch installation. ARM use Busybox modutils, so avoid any
66 # deps on kmod. SLITAZ_ARCH can have also custom post_install commands
67 if [ -f $root/etc/slitaz/slitaz.conf ]; then
68 . $root/etc/slitaz/slitaz.conf
69 case "$SLITAZ_ARCH" in
70 arm) DEPENDS="" ;;
71 esac
72 fi
74 # Rules to configure and make the package.
75 compile_rules() {
76 case $ARCH in
77 # Linux don't supported i386 CPU, but ARCH should be 'i386' if we need 32bit CPU support
78 i?86) ConfigFile="$stuff/linux-slitaz.config"; Arch='i386';;
79 x86_64) ConfigFile="$stuff/linux-slitaz64.config"; Arch='x86_64';;
80 arm*) ConfigFile="$stuff/arm/linux-arm.config"; Arch='arm';;
81 esac
83 # Update sources to the $VERSION using base sources ($KBASEVER) and patch
84 if [ "$KBASEVER" != "${VERSION%.0}" ]; then
85 [ -s $SRC/$(basename $PATCH) ] || wget $PATCH -O $SRC/$(basename $PATCH)
86 # don't patch twice for `cook $PACKAGE --continue`
87 if [ ! -f "done.patch-$VERSION" ]; then
88 xzcat $SRC/$(basename $PATCH) | patch -Np1
89 touch done.patch-$VERSION
90 fi
91 fi
93 #
94 if [ -f "/usr/share/boot/initrd" ]; then
95 cp /usr/share/boot/initrd initrd.cpio
96 fi
98 # Handle cross compilation
99 case "$ARCH" in
100 arm)
101 echo "Compiling: $Arch Kernel"
102 make mrproper
103 patch -Np1 < $stuff/arm/linux-arm.patch || exit 1
104 cp -f $ConfigFile .config
105 yes '' | make ARCH=$Arch oldconfig
106 make ARCH=$Arch CROSS_COMPILE=${HOST_SYSTEM}- bzImage &&
107 make ARCH=$Arch CROSS_COMPILE=${HOST_SYSTEM}- modules &&
108 make ARCH=$Arch CROSS_COMPILE=${HOST_SYSTEM}- \
109 INSTALL_MOD_PATH=$DESTDIR modules_install &&
110 mkdir -p $DESTDIR/boot &&
111 cp -a arch/arm/boot/zImage \
112 $DESTDIR/boot/linux-$VERSION-slitaz-$ARCH
113 #$stuff/tools/gztazmod.sh $DESTDIR/lib/modules/$VERSION-slitaz
114 return 0 ;;
115 esac
117 # Get and apply Aufs patches
118 . $stuff/tools/aufs-patches
120 echo "cook:linux" > $command
122 # Apply misc patches
123 echo "Applying patches..."
124 while read patch_file; do
125 if [ -f done.$patch_file ]; then
126 echo "Skipping $patch_file"; continue
127 fi
128 echo -e "\nApply $patch_file"
129 patch -p1 -i $stuff/patches/$patch_file || return 1
130 touch done.$patch_file
131 done < $stuff/patches/patch.order
133 echo "Making kernel proper..."
134 make mrproper
138 echo "Making $Arch Kernel..."
140 # Build bzImage without modules first
141 if [ -z "$nonomods" ]; then
142 cp -f $ConfigFile .config
143 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
144 # We can't keep every driver in staging???
145 sed -i \
146 -e 's/^CONFIG_RTL8192/#&/' \
147 -e 's/^CONFIG_R8187SE/#&/' \
148 -e 's/^CONFIG_RT2870/#&/' .config
150 title 'Configure bzImage without modules...'
151 yes '' | make ARCH=$Arch oldconfig
153 title 'Building bzImage without modules...'
154 make ARCH=$Arch -j4 bzImage || exit 1
156 mkdir -p $DESTDIR
157 mv arch/x86/boot/bzImage $DESTDIR
158 mv System.map System.map-without-modules
159 fi
161 # Build bzImage with modules
162 cp -f $ConfigFile .config
164 title 'Configure bzImage with modules...'
165 yes '' | make ARCH=$Arch oldconfig
168 title 'Building bzImage with modules...'
169 make ARCH=$Arch -j4 bzImage &&
170 make ARCH=$Arch -j4 modules &&
171 make ARCH=$Arch INSTALL_MOD_PATH=$DESTDIR modules_install &&
172 make ARCH=$Arch INSTALL_HDR_PATH=$DESTDIR/usr headers_install &&
174 [ -s arch/x86/boot/bzImage ] || return 1
175 mkdir -p $DESTDIR/boot
176 mv arch/x86/boot/bzImage $DESTDIR/boot/vmlinuz-$VERSION-slitaz
178 $stuff/tools/install_module_headers.sh $DESTDIR $src $VERSION-slitaz
180 ln System.map System.map-modules
181 ln Module.symvers Module.symvers-modules
183 # for linux-zram package
184 mkdir -p $install/etc/init.d
185 install -o root -m755 $stuff/compcache $install/etc/init.d/
186 install -o root -m644 $stuff/compcache.conf $install/etc/
187 }
190 # Rules to gen a SliTaz package suitable for Tazpkg.
191 genpkg_rules() {
192 DEPENDS="linux" # default, may be subject to change later
194 case $PACKAGE in
195 *-acpi) c="ACPI modules";;
196 *-agp) c="AGP modules";;
197 *-aoe) c="AoE (ATA over Ethernet) modules";;
198 *-appletalk) c="Appletalk modules";;
199 *-arcnet) c="ARCnet modules";;
200 *-autofs) c="Automounter module";;
201 *-bluetooth) c="Bluetooth modules";;
202 *-bridge) c="Bridge modules";;
203 *-btrfs) c="Btrfs module"; DEPENDS="linux-crypto";;
204 *-cifs) c="CIFS module";;
205 *-coda) c="Coda module";;
206 *-cpufreq) c="Cpufreq modules";;
207 *-cramfs) c="CramFs module";;
208 *-crypto) c="Crypto modules";;
209 *-cryptoloop) c="Cryptoloop modules"; DEPENDS="linux-crypto";;
210 *-dialup) c="Dial-up modules";;
211 *-dlm) c="DLMFS module";;
212 *-drm) c="DRM module"; DEPENDS="linux-agp";;
213 *-ecryptfs) c="eCrypt FS module";;
214 *-efi) c="EFI modules";;
215 *-ethernet) c="Ethernet drivers"; DEPENDS="linux-crypto";;
216 *-exofs) c="OSD based FS module"; DEPENDS="linux-crypto";;
217 *-firewire) c="Firewire modules";;
218 *-gfs2) c="GFS2 module";;
219 *-hfs) c="HFS module";;
220 *-hfsplus) c="HFSplus module";;
221 *-hid) c="HID (human interface device) modules";;
222 *-hwmon) c="Hwmon modules";;
223 *-ide) c="IDE modules";;
224 *-input-misc) c="misc. input drivers";;
225 *-input-tablet) c="tablet input drivers";;
226 *-input-touchscreen) c="touchscreen input drivers";;
227 *-ipv6) c="IPv6 modules"; DEPENDS="linux-netfilter";;
228 *-irda) c="IRDA modules";;
229 *-isdn) c="ISDN modules";;
230 *-jfs) c="JFS module";;
231 *-joystick) c="joystick modules";;
232 *-kvm) c="KVM and Virtio modules";;
233 *-logfs) c="Logfs module";;
234 *-md) c="MD modules"; DEPENDS="linux-crypto";;
235 *-media) c="media modules"; DEPENDS="linux-radio";;
236 *-memstick) c="Sony memory stick modules";;
237 *-minix) c="Minix module";;
238 *-mmc) c="MMC modules - card reader";;
239 *-mwave) c="ACP Modem driver module - for IBM Thinkpad";;
240 *-nbd) c="NBD (network block device) modules";;
241 *-ncpfs) c="NCPFS module";;
242 *-netfilter) c="Netfilter modules";;
243 *-nfc) c="NFC modules";;
244 *-nfs) c="NFS modules"; DEPENDS="linux-crypto";;
245 *-nfsd) c="NFS server module"; DEPENDS="linux-nfs";;
246 *-ocfs2) c="OCFS2 modules"; DEPENDS="linux-dlm";;
247 *-orangefs) c="OrangeFS module";;
248 *-radio) c="radio modules"; DEPENDS="linux-sound";;
249 *-reiserfs) c="ReiserFS module";;
250 *-romfs) c="ROMFS module";;
251 *-sched) c="Sched modules";;
252 *-scsi) c="SCSI modules";;
253 *-sound) c="sound modules"
254 copy firmware/ess/ firmware/korg/ firmware/sun/ firmware/yamaha/
255 ;;
256 *-speakup) c="Speakup modules";;
257 *-squashfs) c="Squashfs module"; PROVIDE="squashfs-module";;
258 *-staging) c="staging kernel modules";;
259 *-toshiba) c="Toshiba module";;
260 *-usb-gadget) c="USB gadget modules";;
261 *-usb-misc) c="misc. USB drivers";;
262 *-usbdsl) c="USB DSL modem modules";;
263 *-usbip) c="Usbip module"; PROVIDE="usbip-module";;
264 *-uwb) c="UWB modules";;
265 *-video) c="video modules";;
266 *-wan) c="Wide Area Networks (WANs) modules"; DEPENDS="linux-wireless";;
267 *-watchdog) c="watchdog drivers";;
268 *-wimax) c="Wimax modules";;
269 *-wireless) c="wireless modules"; DEPENDS="linux-crypto wireless_tools";;
270 *-zram) c="compressed caching support"; PROVIDE="compcache"
271 copy compcache compcache.conf
272 ;;
273 esac
275 case $PACKAGE in
276 linux)
277 DEPENDS="kmod"
278 case "$ARCH" in
279 arm)
280 echo "Packing: ARM Kernel"
281 cp -a $install/* $fs
282 rm -f $fs/lib/modules/*/build $fs/lib/modules/*/source
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 modules.{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/aufs/$AUFSDIR ]; then
364 mkdir $fs/usr/src/kernel-patches/slitaz/aufs4
365 cp -a $WOK/aufs/$AUFSDIR/Documentation \
366 $WOK/aufs/$AUFSDIR/fs \
367 $WOK/aufs/$AUFSDIR/include \
368 $fs/usr/src/kernel-patches/slitaz/aufs4
369 fi
371 ln -s ../../../usr/src/linux-$VERSION $fs/lib/modules/$VERSION-slitaz/source
373 chown -R root:root $fs
374 ;;
375 *-without-modules)
376 CAT="base-system|without module support"
377 PROVIDE="linux"
378 mkdir -p $fs/boot
379 cp -a $install/bzImage $fs/boot/vmlinuz-$VERSION-slitaz-without-modules
380 ;;
381 *)
382 . $stuff/tools/copy_modules.sh
383 CAT="base-system|$c"
384 ;;
385 esac
387 case $PACKAGE in
388 *fs|*fs2|*-coda|*-dlm|*-hfsplus|*-minix|*-nfsd)
389 CONFIG_FILES="/etc/filesystems";;
390 *-zram)
391 CONFIG_FILES="/etc/compcache.conf";;
392 esac
393 }
396 post_install_linux() {
397 # Handle multiarch installation
398 case "$SLITAZ_ARCH" in
399 arm)
400 echo "Kernel : /boot/linux-$VERSION-slitaz-$ARCH"
401 echo "Modules: /lib/modules/$VERSION-slitaz"
402 return 0 ;;
403 esac
405 # GRUB stuff.
406 if [ -f "$1/boot/grub/menu.lst" ]; then
407 # Current root device
408 root_dev="/dev/$(lsblk | grep '/$'| grep -o '[a-z]d[a-z][0-9]*')"
409 grub_part="$(( $(echo $root_dev | grep -o '[0-9]*$')-1 ))"
410 # Use device.map to find grub device number
411 grub_dev="$(grep $(echo $root_dev | grep -o '^/dev/.d.' ) \
412 "$1/boot/grub/device.map" | cut -f1 | sed "s/)$/.$grub_part)/g")"
414 # Add and clean Kernel entries in case of upgrade for installed system.
415 if ! grep -q vmlinuz-$VERSION-slitaz "$1/boot/grub/menu.lst"; then
417 # Clean the old entry
418 # TODO: old vmlinuz file is removed but the entry is still there.
419 # So grub error:15 when selected: http://bugs.slitaz.org/?id=74
421 # Add the new entry
422 cat >> "$1/boot/grub/menu.lst" <<EOT
424 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
425 $grub_dev
426 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev quiet
427 EOT
428 # Make it the default entry
429 last_entry=$(( $(grep -c '^title' "$1/boot/grub/menu.lst")-1 ))
430 sed -e "s/^default.*/default $last_entry/g" -i "$1/boot/grub/menu.lst"
431 fi
433 # Display information message.
434 [ -z "$quiet" ] && cat <<EOT
436 ----
437 GRUB is installed, these three lines must be in your /boot/grub/menu.lst:
439 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
440 $grub_dev
441 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
442 ----
443 EOT
444 fi
445 :
446 }
448 pre_remove_linux_module_headers() {
449 if [ -e "$1/usr/src/linux" ]; then
450 rm -rf "$1/usr/src/linux"
451 fi
452 }
454 # Added soft link to make it easier to point to kernel folder
455 post_install_linux_module_headers() {
456 KVERSION="$VERSION-slitaz"
457 [ -L "$1/usr/src/linux" ] && rm -f "$1/usr/src/linux"
458 ln -sf /usr/src/linux-$KVERSION "$1/usr/src/linux"
459 ln -sf /usr/src/linux-$KVERSION "$1/lib/modules/$KVERSION/build"
460 }
462 post_install_linux_zram() {
463 chroot "$1/" depmod -a $VERSION-slitaz &&
464 RAM=$(grep MemTotal /proc/meminfo | tr -dc 0-9) &&
465 echo "SIZE_KB="$(($RAM/2)) > "$1/etc/compcache.conf"
466 [ -n "$quiet" ] || cat <<EOT
468 You can add compressed swap according /etc/compcache.conf configuration with:
469 # /etc/init.d/compcache start
470 Or add compcache to the RUN_DAEMONS list of /etc/rcS.conf.
471 EOT
472 }