1 # Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
7 _srctag=v${pkgver%.*}-${pkgver##*.}
8 url="https://github.com/archlinux/linux/commits/$_srctag"
12 bc libelf pahole cpio perl tar xz
13 xmlto python-sphinx python-sphinx_rtd_theme graphviz imagemagick texlive-latexextra
17 _srcname=archlinux-linux
19 "$_srcname::git+https://github.com/archlinux/linux?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 'C7E7849466FE2358343588377258734B41C31549' # David Runge <dvzrv@archlinux.org>
29 '77fdfe47d8ab448787ac9cc4b73ad6d44ded735a4a001005e39301f6ddb553b4')
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)
72 replaces=(virtualbox-guest-modules-arch wireguard-arch)
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 \
88 DEPMOD=/doesnt/exist modules_install # Suppress depmod
90 # remove build and source links
91 rm "$modulesdir"/{source,build}
95 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 # required when STACK_VALIDATION is enabled
109 install -Dt "$builddir/tools/objtool" tools/objtool/objtool
111 # required when DEBUG_INFO_BTF_MODULES is enabled
112 install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids
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 # https://bugs.archlinux.org/task/13146
123 install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
125 # https://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 # https://bugs.archlinux.org/task/71392
131 install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
133 echo "Installing KConfig files..."
134 find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
136 echo "Removing unneeded architectures..."
138 for arch in "$builddir"/arch/*/; do
139 [[ $arch = */x86/ ]] && continue
140 echo "Removing $(basename "$arch")"
144 echo "Removing documentation..."
145 rm -r "$builddir/Documentation"
147 echo "Removing broken symlinks..."
148 find -L "$builddir" -type l -printf 'Removing %P\n' -delete
150 echo "Removing loose objects..."
151 find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
153 echo "Stripping build tools..."
155 while read -rd '' file; do
156 case "$(file -bi "$file")" in
157 application/x-sharedlib\;*) # Libraries (.so)
158 strip -v $STRIP_SHARED "$file" ;;
159 application/x-archive\;*) # Libraries (.a)
160 strip -v $STRIP_STATIC "$file" ;;
161 application/x-executable\;*) # Binaries
162 strip -v $STRIP_BINARIES "$file" ;;
163 application/x-pie-executable\;*) # Relocatable binaries
164 strip -v $STRIP_SHARED "$file" ;;
166 done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
168 echo "Stripping vmlinux..."
169 strip -v $STRIP_STATIC "$builddir/vmlinux"
171 echo "Adding symlink..."
172 mkdir -p "$pkgdir/usr/src"
173 ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
177 pkgdesc="Documentation for the $pkgdesc kernel"
180 local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
182 echo "Installing documentation..."
184 while read -rd '' src; do
185 dst="${src#Documentation/}"
186 dst="$builddir/Documentation/${dst#output/}"
187 install -Dm644 "$src" "$dst"
188 done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
190 echo "Adding symlink..."
191 mkdir -p "$pkgdir/usr/share/doc"
192 ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
195 pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs")
196 for _p in "${pkgname[@]}"; do
197 eval "package_$_p() {
198 $(declare -f "_package${_p#$pkgbase}")
199 _package${_p#$pkgbase}
203 # vim:set ts=8 sts=2 sw=2 et: