archrelease: copy trunk to extra-x86_64
[arch-packages.git] / linux-lts / repos / core-x86_64 / PKGBUILD
blob03d782027f16b6e47a72ba77db4d6e5db9a5aa4d
1 # Maintainer: Andreas Radke <andyrtr@archlinux.org>
3 pkgbase=linux-lts
4 pkgver=6.1.29
5 pkgrel=1
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 gettext
12   xmlto python-sphinx 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
21 validpgpkeys=(
22   'ABAF11C65A2970B130ABE3C479BE3E4300411886'  # Linus Torvalds
23   '647F28654894E3BD457199BE38DBBDC86092693E'  # Greg Kroah-Hartman
25 # https://www.kernel.org/pub/linux/kernel/v6.x/sha256sums.asc
26 sha256sums=('1e736cc9bd6036379a1d915e518abd4c2c94ad0fd1ea0da961c3489308b8fcfb'
27             'SKIP'
28             'ec7a2cb3af65594ff97c967172a783f1f4d23b7b46cb76d35d3aa279c6035e1c'
29             '1bd8388fcb6ed4eec46450c65eb7a0889a8c541f164a39e3064633981a7a4a3d')
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})"
35 prepare() {
36   cd $_srcname
38   echo "Setting version..."
39   scripts/setlocalversion --save-scmversion
40   echo "-$pkgrel" > localversion.10-pkgrel
41   echo "${pkgbase#linux}" > localversion.20-pkgname
43   local src
44   for src in "${source[@]}"; do
45     src="${src%%::*}"
46     src="${src##*/}"
47     [[ $src = *.patch ]] || continue
48     echo "Applying patch $src..."
49     patch -Np1 < "../$src"
50   done
52   echo "Setting config..."
53   cp ../config .config
54   make olddefconfig
55   diff -u ../config .config || :
57   make -s kernelrelease > version
58   echo "Prepared $pkgbase version $(<version)"
61 build() {
62   cd $_srcname
63   make htmldocs all
66 _package() {
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 KSMBD-MODULE)
72   replaces=(wireguard-lts)
74   cd $_srcname
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}
94 _package-headers() {
95   pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
96   depends=(pahole)
98   cd $_srcname
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..."
137   local arch
138   for arch in "$builddir"/arch/*/; do
139     [[ $arch = */x86/ ]] && continue
140     echo "Removing $(basename "$arch")"
141     rm -r "$arch"
142   done
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..."
154   local file
155   while read -rd '' file; do
156     case "$(file -Sib "$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" ;;
165     esac
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"
176 _package-docs() {
177   pkgdesc="Documentation for the $pkgdesc kernel"
179   cd $_srcname
180   local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
182   echo "Installing documentation..."
183   local src dst
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}
200   }"
201 done
203 # vim:set ts=8 sts=2 sw=2 et: