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 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
20 0002-HID-holtek-fix-mouse-probing.patch
23 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
24 '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman
26 # https://www.kernel.org/pub/linux/kernel/v5.x/sha256sums.asc
27 sha256sums=('6f8631b6c382a2b0cfeff1e5f8805c8e1cfbe8d714b6e65f5bb79733c99068eb'
29 '259196906a6e3c3c4fcbacd083094b3e3d4e2b75cfb7a18382381a88a07399be'
30 '96a72e1652314215da7140956c3abcf495cafd00811eda3cf4ce03ec5f791f1e'
31 '4753850a30c6a64e2bb27b1c07ea72f3c40b8c7ee73e890bbc4745860ce1798d')
33 export KBUILD_BUILD_HOST=archlinux
34 export KBUILD_BUILD_USER=$pkgbase
35 export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
40 echo "Setting version..."
41 scripts/setlocalversion --save-scmversion
42 echo "-$pkgrel" > localversion.10-pkgrel
43 echo "${pkgbase#linux}" > localversion.20-pkgname
46 for src in "${source[@]}"; do
49 [[ $src = *.patch ]] || continue
50 echo "Applying patch $src..."
51 patch -Np1 < "../$src"
54 echo "Setting config..."
58 make -s kernelrelease > version
59 echo "Prepared $pkgbase version $(<version)"
69 pkgdesc="The $pkgdesc kernel and modules"
70 depends=(coreutils kmod initramfs)
71 optdepends=('crda: to set the correct wireless channels of your country'
72 'linux-firmware: firmware images needed for some devices')
73 provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE)
74 replaces=(wireguard-lts)
77 local kernver="$(<version)"
78 local modulesdir="$pkgdir/usr/lib/modules/$kernver"
80 echo "Installing boot image..."
81 # systemd expects to find the kernel here to allow hibernation
82 # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
83 install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
85 # Used by mkinitcpio to name the kernel
86 echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
88 echo "Installing modules..."
89 make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 modules_install
91 # remove build and source links
92 rm "$modulesdir"/{source,build}
96 pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
99 local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
101 echo "Installing build files..."
102 install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
103 localversion.* version vmlinux
104 install -Dt "$builddir/kernel" -m644 kernel/Makefile
105 install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
106 cp -t "$builddir" -a scripts
108 # add objtool for external module building and enabled VALIDATION_STACK option
109 install -Dt "$builddir/tools/objtool" tools/objtool/objtool
111 # add xfs and shmem for aufs building
112 mkdir -p "$builddir"/{fs/xfs,mm}
114 echo "Installing headers..."
115 cp -t "$builddir" -a include
116 cp -t "$builddir/arch/x86" -a arch/x86/include
117 install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
119 install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
120 install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
122 # http://bugs.archlinux.org/task/13146
123 install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
125 # http://bugs.archlinux.org/task/20402
126 install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
127 install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
128 install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
130 echo "Installing KConfig files..."
131 find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
133 echo "Removing unneeded architectures..."
135 for arch in "$builddir"/arch/*/; do
136 [[ $arch = */x86/ ]] && continue
137 echo "Removing $(basename "$arch")"
141 echo "Removing documentation..."
142 rm -r "$builddir/Documentation"
144 echo "Removing broken symlinks..."
145 find -L "$builddir" -type l -printf 'Removing %P\n' -delete
147 echo "Removing loose objects..."
148 find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
150 echo "Stripping build tools..."
152 while read -rd '' file; do
153 case "$(file -bi "$file")" in
154 application/x-sharedlib\;*) # Libraries (.so)
155 strip -v $STRIP_SHARED "$file" ;;
156 application/x-archive\;*) # Libraries (.a)
157 strip -v $STRIP_STATIC "$file" ;;
158 application/x-executable\;*) # Binaries
159 strip -v $STRIP_BINARIES "$file" ;;
160 application/x-pie-executable\;*) # Relocatable binaries
161 strip -v $STRIP_SHARED "$file" ;;
163 done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
165 echo "Stripping vmlinux..."
166 strip -v $STRIP_STATIC "$builddir/vmlinux"
168 echo "Adding symlink..."
169 mkdir -p "$pkgdir/usr/src"
170 ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
174 pkgdesc="Documentation for the $pkgdesc kernel"
177 local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
179 echo "Installing documentation..."
181 while read -rd '' src; do
182 dst="${src#Documentation/}"
183 dst="$builddir/Documentation/${dst#output/}"
184 install -Dm644 "$src" "$dst"
185 done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
187 echo "Adding symlink..."
188 mkdir -p "$pkgdir/usr/share/doc"
189 ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
192 pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs")
193 for _p in "${pkgname[@]}"; do
194 eval "package_$_p() {
195 $(declare -f "_package${_p#$pkgbase}")
196 _package${_p#$pkgbase}
200 # vim:set ts=8 sts=2 sw=2 et: