1 # Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
7 _srctag=v${pkgver%.*}-${pkgver##*.}
8 url="https://github.com/zen-kernel/zen-kernel/commits/$_srctag"
12 bc libelf pahole cpio perl tar xz
13 xmlto python-sphinx graphviz imagemagick texlive-latexextra
19 "$_srcname::git+https://github.com/zen-kernel/zen-kernel?signed#tag=$_srctag"
20 config # the main kernel config file
23 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
24 '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman
25 'A2FF3A36AAA56654109064AB19802F8B0D70FC30' # Jan Alexander Steffens (heftig)
26 'C5ADB4F3FEBBCE27A3E54D7D9AE4078033F8024D' # Steven Barrett <steven@liquorix.net>
29 '1849351b506a1110c5325eaac7e9c0c697baf6c885cf4bbadb6117b6f09186c7')
31 export KBUILD_BUILD_HOST=archlinux
32 export KBUILD_BUILD_USER=$pkgbase
33 export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
38 echo "Setting version..."
39 scripts/setlocalversion --save-scmversion
40 echo "-$pkgrel" > localversion.10-pkgrel
41 echo "${pkgbase#linux}" > localversion.20-pkgname
44 for src in "${source[@]}"; do
47 [[ $src = *.patch ]] || continue
48 echo "Applying patch $src..."
49 patch -Np1 < "../$src"
52 echo "Setting config..."
55 diff -u ../config .config || :
57 make -s kernelrelease > version
58 echo "Prepared $pkgbase version $(<version)"
67 pkgdesc="The $pkgdesc kernel and modules"
68 depends=(coreutils kmod initramfs)
69 optdepends=('wireless-regdb: to set the correct wireless channels of your country'
70 'linux-firmware: firmware images needed for some devices')
71 provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE KSMBD-MODULE VHBA-MODULE
76 local kernver="$(<version)"
77 local modulesdir="$pkgdir/usr/lib/modules/$kernver"
79 echo "Installing boot image..."
80 # systemd expects to find the kernel here to allow hibernation
81 # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
82 install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
84 # Used by mkinitcpio to name the kernel
85 echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
87 echo "Installing modules..."
88 make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \
89 DEPMOD=/doesnt/exist modules_install # Suppress depmod
91 # remove build and source links
92 rm "$modulesdir"/{source,build}
96 pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
100 local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
102 echo "Installing build files..."
103 install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
104 localversion.* version vmlinux
105 install -Dt "$builddir/kernel" -m644 kernel/Makefile
106 install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
107 cp -t "$builddir" -a scripts
109 # required when STACK_VALIDATION is enabled
110 install -Dt "$builddir/tools/objtool" tools/objtool/objtool
112 # required when DEBUG_INFO_BTF_MODULES is enabled
113 install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids
115 echo "Installing headers..."
116 cp -t "$builddir" -a include
117 cp -t "$builddir/arch/x86" -a arch/x86/include
118 install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
120 install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
121 install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
123 # https://bugs.archlinux.org/task/13146
124 install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
126 # https://bugs.archlinux.org/task/20402
127 install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
128 install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
129 install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
131 # https://bugs.archlinux.org/task/71392
132 install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
134 echo "Installing KConfig files..."
135 find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
137 echo "Removing unneeded architectures..."
139 for arch in "$builddir"/arch/*/; do
140 [[ $arch = */x86/ ]] && continue
141 echo "Removing $(basename "$arch")"
145 echo "Removing documentation..."
146 rm -r "$builddir/Documentation"
148 echo "Removing broken symlinks..."
149 find -L "$builddir" -type l -printf 'Removing %P\n' -delete
151 echo "Removing loose objects..."
152 find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
154 echo "Stripping build tools..."
156 while read -rd '' file; do
157 case "$(file -Sib "$file")" in
158 application/x-sharedlib\;*) # Libraries (.so)
159 strip -v $STRIP_SHARED "$file" ;;
160 application/x-archive\;*) # Libraries (.a)
161 strip -v $STRIP_STATIC "$file" ;;
162 application/x-executable\;*) # Binaries
163 strip -v $STRIP_BINARIES "$file" ;;
164 application/x-pie-executable\;*) # Relocatable binaries
165 strip -v $STRIP_SHARED "$file" ;;
167 done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
169 echo "Stripping vmlinux..."
170 strip -v $STRIP_STATIC "$builddir/vmlinux"
172 echo "Adding symlink..."
173 mkdir -p "$pkgdir/usr/src"
174 ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
178 pkgdesc="Documentation for the $pkgdesc kernel"
181 local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
183 echo "Installing documentation..."
185 while read -rd '' src; do
186 dst="${src#Documentation/}"
187 dst="$builddir/Documentation/${dst#output/}"
188 install -Dm644 "$src" "$dst"
189 done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
191 echo "Adding symlink..."
192 mkdir -p "$pkgdir/usr/share/doc"
193 ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
196 pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs")
197 for _p in "${pkgname[@]}"; do
198 eval "package_$_p() {
199 $(declare -f "_package${_p#$pkgbase}")
200 _package${_p#$pkgbase}
204 # vim:set ts=8 sts=2 sw=2 et: