1 # Maintainer: Andreas Radke <andyrtr@archlinux.org>
7 url="https://www.kernel.org/"
11 bc kmod libelf pahole cpio perl tar xz
12 xmlto python-sphinx python-sphinx_rtd_theme python-six graphviz imagemagick
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
22 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
23 '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman
25 # https://www.kernel.org/pub/linux/kernel/v5.x/sha256sums.asc
26 sha256sums=('945e4264c014a3d9dfc0a4639309dd1ec2fb545416556421f931b95da78c2725'
28 '80de9382be09f765b5cb1c11e21a09c99f75a0000bcc10def0542228644ea828'
29 '96a72e1652314215da7140956c3abcf495cafd00811eda3cf4ce03ec5f791f1e')
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..."
56 make -s kernelrelease > version
57 echo "Prepared $pkgbase version $(<version)"
67 pkgdesc="The $pkgdesc kernel and modules"
68 depends=(coreutils kmod initramfs)
69 optdepends=('crda: 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)
72 replaces=(wireguard-lts)
75 local kernver="$(<version)"
76 local modulesdir="$pkgdir/usr/lib/modules/$kernver"
78 echo "Installing boot image..."
79 # systemd expects to find the kernel here to allow hibernation
80 # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
81 install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
83 # Used by mkinitcpio to name the kernel
84 echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
86 echo "Installing modules..."
87 make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 modules_install
89 # remove build and source links
90 rm "$modulesdir"/{source,build}
94 pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
97 local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
99 echo "Installing build files..."
100 install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
101 localversion.* version vmlinux
102 install -Dt "$builddir/kernel" -m644 kernel/Makefile
103 install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
104 cp -t "$builddir" -a scripts
106 # add objtool for external module building and enabled VALIDATION_STACK option
107 install -Dt "$builddir/tools/objtool" tools/objtool/objtool
109 # add xfs and shmem for aufs building
110 mkdir -p "$builddir"/{fs/xfs,mm}
112 echo "Installing headers..."
113 cp -t "$builddir" -a include
114 cp -t "$builddir/arch/x86" -a arch/x86/include
115 install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
117 install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
118 install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
120 # http://bugs.archlinux.org/task/13146
121 install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
123 # http://bugs.archlinux.org/task/20402
124 install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
125 install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
126 install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
128 echo "Installing KConfig files..."
129 find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
131 echo "Removing unneeded architectures..."
133 for arch in "$builddir"/arch/*/; do
134 [[ $arch = */x86/ ]] && continue
135 echo "Removing $(basename "$arch")"
139 echo "Removing documentation..."
140 rm -r "$builddir/Documentation"
142 echo "Removing broken symlinks..."
143 find -L "$builddir" -type l -printf 'Removing %P\n' -delete
145 echo "Removing loose objects..."
146 find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
148 echo "Stripping build tools..."
150 while read -rd '' file; do
151 case "$(file -bi "$file")" in
152 application/x-sharedlib\;*) # Libraries (.so)
153 strip -v $STRIP_SHARED "$file" ;;
154 application/x-archive\;*) # Libraries (.a)
155 strip -v $STRIP_STATIC "$file" ;;
156 application/x-executable\;*) # Binaries
157 strip -v $STRIP_BINARIES "$file" ;;
158 application/x-pie-executable\;*) # Relocatable binaries
159 strip -v $STRIP_SHARED "$file" ;;
161 done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
163 echo "Stripping vmlinux..."
164 strip -v $STRIP_STATIC "$builddir/vmlinux"
166 echo "Adding symlink..."
167 mkdir -p "$pkgdir/usr/src"
168 ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
172 pkgdesc="Documentation for the $pkgdesc kernel"
175 local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
177 echo "Installing documentation..."
179 while read -rd '' src; do
180 dst="${src#Documentation/}"
181 dst="$builddir/Documentation/${dst#output/}"
182 install -Dm644 "$src" "$dst"
183 done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
185 echo "Adding symlink..."
186 mkdir -p "$pkgdir/usr/share/doc"
187 ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
190 pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs")
191 for _p in "${pkgname[@]}"; do
192 eval "package_$_p() {
193 $(declare -f "_package${_p#$pkgbase}")
194 _package${_p#$pkgbase}
198 # vim:set ts=8 sts=2 sw=2 et: