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"
32 "$_srcname::git+https://github.com/zen-kernel/zen-kernel?signed#tag=$_srctag"
33 config # the main kernel config file
36 ABAF11C65A2970B130ABE3C479BE3E4300411886 # Linus Torvalds
37 647F28654894E3BD457199BE38DBBDC86092693E # Greg Kroah-Hartman
38 A2FF3A36AAA56654109064AB19802F8B0D70FC30 # Jan Alexander Steffens (heftig)
39 C5ADB4F3FEBBCE27A3E54D7D9AE4078033F8024D # Steven Barrett <steven@liquorix.net>
42 '4c4d14668bc08902dfd5f070cb6a43f03ed66961377cece1ce1703bb8a28ddd14928c235d838eb96d0d9734f8187a009df543b9ab76943bc92daeba89ecd40e5')
44 export KBUILD_BUILD_HOST=archlinux
45 export KBUILD_BUILD_USER=$pkgbase
46 export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
50 make KERNELRELEASE="$(<version)" "$@"
56 echo "Setting version..."
57 echo "-$pkgrel" > localversion.10-pkgrel
58 echo "${pkgbase#linux}" > localversion.20-pkgname
60 make -s kernelrelease > version
64 for src in "${source[@]}"; do
67 [[ $src = *.patch ]] || continue
68 echo "Applying patch $src..."
69 patch -Np1 < "../$src"
72 echo "Setting config..."
75 diff -u ../config .config || :
77 echo "Prepared $pkgbase version $(<version)"
86 pkgdesc="The $pkgdesc kernel and modules"
93 'wireless-regdb: to set the correct wireless channels of your country'
94 'linux-firmware: firmware images needed for some devices'
100 VIRTUALBOX-GUEST-MODULES
107 local modulesdir="$pkgdir/usr/lib/modules/$(<version)"
109 echo "Installing boot image..."
110 # systemd expects to find the kernel here to allow hibernation
111 # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
112 install -Dm644 "$(_make -s image_name)" "$modulesdir/vmlinuz"
114 # Used by mkinitcpio to name the kernel
115 echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
117 echo "Installing modules..."
118 _make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \
119 DEPMOD=/doesnt/exist modules_install # Suppress depmod
121 # remove build and source links
122 rm "$modulesdir"/{source,build}
126 pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
130 local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
132 echo "Installing build files..."
133 install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
134 localversion.* version vmlinux
135 install -Dt "$builddir/kernel" -m644 kernel/Makefile
136 install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
137 cp -t "$builddir" -a scripts
139 # required when STACK_VALIDATION is enabled
140 install -Dt "$builddir/tools/objtool" tools/objtool/objtool
142 # required when DEBUG_INFO_BTF_MODULES is enabled
143 install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids
145 echo "Installing headers..."
146 cp -t "$builddir" -a include
147 cp -t "$builddir/arch/x86" -a arch/x86/include
148 install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
150 install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
151 install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
153 # https://bugs.archlinux.org/task/13146
154 install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
156 # https://bugs.archlinux.org/task/20402
157 install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
158 install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
159 install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
161 # https://bugs.archlinux.org/task/71392
162 install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
164 echo "Installing KConfig files..."
165 find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
167 echo "Removing unneeded architectures..."
169 for arch in "$builddir"/arch/*/; do
170 [[ $arch = */x86/ ]] && continue
171 echo "Removing $(basename "$arch")"
175 echo "Removing documentation..."
176 rm -r "$builddir/Documentation"
178 echo "Removing broken symlinks..."
179 find -L "$builddir" -type l -printf 'Removing %P\n' -delete
181 echo "Removing loose objects..."
182 find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
184 echo "Stripping build tools..."
186 while read -rd '' file; do
187 case "$(file -Sib "$file")" in
188 application/x-sharedlib\;*) # Libraries (.so)
189 strip -v $STRIP_SHARED "$file" ;;
190 application/x-archive\;*) # Libraries (.a)
191 strip -v $STRIP_STATIC "$file" ;;
192 application/x-executable\;*) # Binaries
193 strip -v $STRIP_BINARIES "$file" ;;
194 application/x-pie-executable\;*) # Relocatable binaries
195 strip -v $STRIP_SHARED "$file" ;;
197 done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
199 echo "Stripping vmlinux..."
200 strip -v $STRIP_STATIC "$builddir/vmlinux"
202 echo "Adding symlink..."
203 mkdir -p "$pkgdir/usr/src"
204 ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
208 pkgdesc="Documentation for the $pkgdesc kernel"
211 local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
213 echo "Installing documentation..."
215 while read -rd '' src; do
216 dst="${src#Documentation/}"
217 dst="$builddir/Documentation/${dst#output/}"
218 install -Dm644 "$src" "$dst"
219 done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
221 echo "Adding symlink..."
222 mkdir -p "$pkgdir/usr/share/doc"
223 ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
231 for _p in "${pkgname[@]}"; do
232 eval "package_$_p() {
233 $(declare -f "_package${_p#$pkgbase}")
234 _package${_p#$pkgbase}
238 # vim:set ts=8 sts=2 sw=2 et: