OCaml 4.14.0 rebuild
[arch-packages.git] / linux-lts / repos / core-x86_64 / PKGBUILD
blob41d36f39993f97e863c8e73f347c88cf5a3a4286
1 # Maintainer: Andreas Radke <andyrtr@archlinux.org>
3 pkgbase=linux-lts
4 pkgver=5.15.59
5 pkgrel=2
6 pkgdesc='LTS Linux'
7 url="https://www.kernel.org/"
8 arch=(x86_64)
9 license=(GPL2)
10 makedepends=(
11   bc libelf pahole cpio perl tar xz
12   xmlto python-sphinx python-sphinx_rtd_theme graphviz imagemagick texlive-latexextra
14 options=('!strip')
15 _srcname=linux-$pkgver
16 source=(
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-q.patch
21   0003-iommu-intel-do-deep-dma-unmapping-to-avoid-kernel-fl.patch
22   0004-Bluetooth-btintel-Fix-bdaddress-comparison-with-garb.patch
23   0005-lg-laptop-Recognize-more-models.patch
24   0006-Fix-NFSv4-mount-regression.patch
26 validpgpkeys=(
27   'ABAF11C65A2970B130ABE3C479BE3E4300411886'  # Linus Torvalds
28   '647F28654894E3BD457199BE38DBBDC86092693E'  # Greg Kroah-Hartman
30 # https://www.kernel.org/pub/linux/kernel/v5.x/sha256sums.asc
31 sha256sums=('e6ddc642057340db06b3b921c2b31bfed2c611359e8f144c3e5cf9c3ac33bccb'
32             'SKIP'
33             'd54ffc9e42ceed0a6b53b9ce0c707743c60986fd0919e282aedcca9a7746160c'
34             '7bd64ff894475b3415d792ba8466ba7e8f872af56dbf1aeed0d261fe4008b8b5'
35             '39649dc1dfcb06b411ad124e123769e955a78961b4ea17538c0919a930925549'
36             '56c12551e859cc67520909e64feecbf1b190cee8addef150c5b9d1bb1d40981e'
37             '5c1ee81fdd5818442af6081de987f9c1a9ce3c8d183566b3dfc19a8433aa3dde'
38             '067e8995fcd6f6ed25e0253e9374c0e179a000c154da3e59ce62634945ac5be9'
39             '95dad02b01937681af0a207e22a6bf64c33e067bf7a14cb98262dd8f69194eb8')
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})"
45 prepare() {
46   cd $_srcname
48   echo "Setting version..."
49   scripts/setlocalversion --save-scmversion
50   echo "-$pkgrel" > localversion.10-pkgrel
51   echo "${pkgbase#linux}" > localversion.20-pkgname
53   local src
54   for src in "${source[@]}"; do
55     src="${src%%::*}"
56     src="${src##*/}"
57     [[ $src = *.patch ]] || continue
58     echo "Applying patch $src..."
59     patch -Np1 < "../$src"
60   done
62   echo "Setting config..."
63   cp ../config .config
64   make olddefconfig
65   diff -u ../config .config || :
67   make -s kernelrelease > version
68   echo "Prepared $pkgbase version $(<version)"
71 build() {
72   cd $_srcname
73   make htmldocs all
76 _package() {
77   pkgdesc="The $pkgdesc kernel and modules"
78   depends=(coreutils kmod initramfs)
79   optdepends=('wireless-regdb: to set the correct wireless channels of your country'
80               'linux-firmware: firmware images needed for some devices')
81   provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE KSMBD-MODULE)
82   replaces=(wireguard-lts)
84   cd $_srcname
85   local kernver="$(<version)"
86   local modulesdir="$pkgdir/usr/lib/modules/$kernver"
88   echo "Installing boot image..."
89   # systemd expects to find the kernel here to allow hibernation
90   # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
91   install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
93   # Used by mkinitcpio to name the kernel
94   echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
96   echo "Installing modules..."
97   make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \
98     DEPMOD=/doesnt/exist modules_install  # Suppress depmod
100   # remove build and source links
101   rm "$modulesdir"/{source,build}
104 _package-headers() {
105   pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
106   depends=(pahole)
108   cd $_srcname
109   local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
111   echo "Installing build files..."
112   install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
113     localversion.* version vmlinux
114   install -Dt "$builddir/kernel" -m644 kernel/Makefile
115   install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
116   cp -t "$builddir" -a scripts
118   # required when STACK_VALIDATION is enabled
119   install -Dt "$builddir/tools/objtool" tools/objtool/objtool
121   # required when DEBUG_INFO_BTF_MODULES is enabled
122   install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids
124   echo "Installing headers..."
125   cp -t "$builddir" -a include
126   cp -t "$builddir/arch/x86" -a arch/x86/include
127   install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
129   install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
130   install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
132   # https://bugs.archlinux.org/task/13146
133   install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
135   # https://bugs.archlinux.org/task/20402
136   install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
137   install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
138   install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
140   # https://bugs.archlinux.org/task/71392
141   install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
143   echo "Installing KConfig files..."
144   find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
146   echo "Removing unneeded architectures..."
147   local arch
148   for arch in "$builddir"/arch/*/; do
149     [[ $arch = */x86/ ]] && continue
150     echo "Removing $(basename "$arch")"
151     rm -r "$arch"
152   done
154   echo "Removing documentation..."
155   rm -r "$builddir/Documentation"
157   echo "Removing broken symlinks..."
158   find -L "$builddir" -type l -printf 'Removing %P\n' -delete
160   echo "Removing loose objects..."
161   find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
163   echo "Stripping build tools..."
164   local file
165   while read -rd '' file; do
166     case "$(file -bi "$file")" in
167       application/x-sharedlib\;*)      # Libraries (.so)
168         strip -v $STRIP_SHARED "$file" ;;
169       application/x-archive\;*)        # Libraries (.a)
170         strip -v $STRIP_STATIC "$file" ;;
171       application/x-executable\;*)     # Binaries
172         strip -v $STRIP_BINARIES "$file" ;;
173       application/x-pie-executable\;*) # Relocatable binaries
174         strip -v $STRIP_SHARED "$file" ;;
175     esac
176   done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
178   echo "Stripping vmlinux..."
179   strip -v $STRIP_STATIC "$builddir/vmlinux"
181   echo "Adding symlink..."
182   mkdir -p "$pkgdir/usr/src"
183   ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
186 _package-docs() {
187   pkgdesc="Documentation for the $pkgdesc kernel"
189   cd $_srcname
190   local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
192   echo "Installing documentation..."
193   local src dst
194   while read -rd '' src; do
195     dst="${src#Documentation/}"
196     dst="$builddir/Documentation/${dst#output/}"
197     install -Dm644 "$src" "$dst"
198   done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
200   echo "Adding symlink..."
201   mkdir -p "$pkgdir/usr/share/doc"
202   ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
205 pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs")
206 for _p in "${pkgname[@]}"; do
207   eval "package_$_p() {
208     $(declare -f "_package${_p#$pkgbase}")
209     _package${_p#$pkgbase}
210   }"
211 done
213 # vim:set ts=8 sts=2 sw=2 et: