1 # Maintainer: Andreas Radke <andyrtr@archlinux.org>
7 url="https://www.kernel.org/"
11 bc libelf pahole cpio perl tar xz
12 xmlto python-sphinx python-sphinx_rtd_theme graphviz imagemagick texlive-latexextra
15 _srcname=linux-$pkgver
17 https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/${_srcname}.tar.{xz,sign}
18 config # the main kernel config file
19 0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-C.patch
20 0002-PCI_Add_more_NVIDIA_controllers_to_the_MSI_masking_quirk.patch
21 0003-iommu_intel_do_deep_dma-unmapping_to_avoid_kernel-flooding.patch
22 0004-Bluetooth_btintel_Fix_bdaddress_comparison_with_garbage_value.patch
23 0005-lg-laptop_Recognize_more_models.patch
24 0006_fix_NFSv4_mount_regression.diff
27 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
28 '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman
30 # https://www.kernel.org/pub/linux/kernel/v5.x/sha256sums.asc
31 sha256sums=('19f0075d1b94d6874a2af7127a59b6b6c423fc7d4a883a51415543e7ec1be2a6'
33 'af05290a1719130cef27e15e9f2d483eee86c9d77fd0ec0aef8d4933a8c948f6'
34 '99df282c594cc269d9a5d19bb86ea887892d3654cfc53c4ce94a644cf3278423'
35 'c35018601f04ae81e0a2018a8597595db6ae053158c206845399cdebb2d2b706'
36 '7c7707c738983f3683d76295b496f578996b7341fa39ad334ec2833bfe4b966e'
37 '3fa8a4af66d5a3b99b48ca979a247c61e81c9b2d3bcdffa9d3895a5532a420b4'
38 '79266c6cc970733fd35881d9a8f0a74c25c00b4d81741b8d4bba6827c48f7c78'
39 'e9527ad81d5b1821a7b17c56cb3abaec85785563f51e448cb3c06f1c68e2966f')
41 export KBUILD_BUILD_HOST=archlinux
42 export KBUILD_BUILD_USER=$pkgbase
43 export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
48 # fix NFSv4 mounting issue regression - FS#73838 / FS#73860
49 # https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/patch/?id=6f2836341d8a39e1e000572b10959347d7e61fd9
50 patch -Rp1 -i ../0006_fix_NFSv4_mount_regression.diff
52 echo "Setting version..."
53 scripts/setlocalversion --save-scmversion
54 echo "-$pkgrel" > localversion.10-pkgrel
55 echo "${pkgbase#linux}" > localversion.20-pkgname
58 for src in "${source[@]}"; do
61 [[ $src = *.patch ]] || continue
62 echo "Applying patch $src..."
63 patch -Np1 < "../$src"
66 echo "Setting config..."
69 # diff -u ../config .config || :
71 make -s kernelrelease > version
72 echo "Prepared $pkgbase version $(<version)"
82 pkgdesc="The $pkgdesc kernel and modules"
83 depends=(coreutils kmod initramfs)
84 optdepends=('wireless-regdb: to set the correct wireless channels of your country'
85 'linux-firmware: firmware images needed for some devices')
86 provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE)
87 replaces=(wireguard-lts)
90 local kernver="$(<version)"
91 local modulesdir="$pkgdir/usr/lib/modules/$kernver"
93 echo "Installing boot image..."
94 # systemd expects to find the kernel here to allow hibernation
95 # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
96 install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
98 # Used by mkinitcpio to name the kernel
99 echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
101 echo "Installing modules..."
102 make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \
103 DEPMOD=/doesnt/exist modules_install # Suppress depmod
105 # remove build and source links
106 rm "$modulesdir"/{source,build}
110 pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
114 local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
116 echo "Installing build files..."
117 install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
118 localversion.* version vmlinux
119 install -Dt "$builddir/kernel" -m644 kernel/Makefile
120 install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
121 cp -t "$builddir" -a scripts
123 # add objtool for external module building and enabled VALIDATION_STACK option
124 install -Dt "$builddir/tools/objtool" tools/objtool/objtool
126 # add xfs and shmem for aufs building
127 mkdir -p "$builddir"/{fs/xfs,mm}
129 echo "Installing headers..."
130 cp -t "$builddir" -a include
131 cp -t "$builddir/arch/x86" -a arch/x86/include
132 install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
134 install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
135 install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
137 # https://bugs.archlinux.org/task/13146
138 install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
140 # https://bugs.archlinux.org/task/20402
141 install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
142 install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
143 install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
145 # https://bugs.archlinux.org/task/71392
146 install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
148 echo "Installing KConfig files..."
149 find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
151 echo "Removing unneeded architectures..."
153 for arch in "$builddir"/arch/*/; do
154 [[ $arch = */x86/ ]] && continue
155 echo "Removing $(basename "$arch")"
159 echo "Removing documentation..."
160 rm -r "$builddir/Documentation"
162 echo "Removing broken symlinks..."
163 find -L "$builddir" -type l -printf 'Removing %P\n' -delete
165 echo "Removing loose objects..."
166 find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
168 echo "Stripping build tools..."
170 while read -rd '' file; do
171 case "$(file -bi "$file")" in
172 application/x-sharedlib\;*) # Libraries (.so)
173 strip -v $STRIP_SHARED "$file" ;;
174 application/x-archive\;*) # Libraries (.a)
175 strip -v $STRIP_STATIC "$file" ;;
176 application/x-executable\;*) # Binaries
177 strip -v $STRIP_BINARIES "$file" ;;
178 application/x-pie-executable\;*) # Relocatable binaries
179 strip -v $STRIP_SHARED "$file" ;;
181 done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
183 echo "Stripping vmlinux..."
184 strip -v $STRIP_STATIC "$builddir/vmlinux"
186 echo "Adding symlink..."
187 mkdir -p "$pkgdir/usr/src"
188 ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
192 pkgdesc="Documentation for the $pkgdesc kernel"
195 local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
197 echo "Installing documentation..."
199 while read -rd '' src; do
200 dst="${src#Documentation/}"
201 dst="$builddir/Documentation/${dst#output/}"
202 install -Dm644 "$src" "$dst"
203 done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
205 echo "Adding symlink..."
206 mkdir -p "$pkgdir/usr/share/doc"
207 ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
210 pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs")
211 for _p in "${pkgname[@]}"; do
212 eval "package_$_p() {
213 $(declare -f "_package${_p#$pkgbase}")
214 _package${_p#$pkgbase}
218 # vim:set ts=8 sts=2 sw=2 et: