archrelease: copy trunk to extra-x86_64
[arch-packages.git] / linux-rt-lts / trunk / PKGBUILD
bloba3c334420286232fb36e847ce6e8ed36753d38e4
1 # Maintainer: David Runge <dvzrv@archlinux.org>
2 # Contributor:  Joakim Hernberg <jbh@alchemy.lu>
4 pkgbase=linux-rt-lts
5 pkgver=5.15.107.62.realtime1
6 pkgrel=2
7 pkgdesc='Linux RT LTS'
8 arch=(x86_64)
9 url="https://gitlab.archlinux.org/archlinux/packaging/upstream/linux-rt-lts/-/commits/v$pkgver"
10 license=(GPL2)
11 makedepends=(
12   bc
13   git
14   graphviz
15   imagemagick
16   kmod
17   libelf
18   pahole
19   python-sphinx
20   texlive-latexextra
21   xmlto
23 options=(!strip)
24 source=(
25   git+https://gitlab.archlinux.org/archlinux/packaging/upstream/linux-rt-lts.git/#tag=v$pkgver?signed
26   gcc13-compat.patch
27   config
29 sha512sums=('SKIP'
30             'ce514cb2949c991ffc9258c6d6c879b3c80d7a9661875ae4530375c14c71753f8257795fbbeef9ce39301336bab32c199ca05659e805a12f6249e875b51fbf30'
31             '463c256a8d36a0eeddf583b00e0ebc3585e00c2a4c3ad4f07ccd7318aee243b6a571df531c7e75d8af81f4f258e6c2791b02cdad2a57bf435219ca54cd96b4dc')
32 b2sums=('SKIP'
33         'c1355786897ba36f5dbb01e0c2b434a901d9df88e1305a4be607bb41bbf59769d5ec351166dcfb6035d94a922aad6bac4bf1b8783ea91b7ceb17d59b4613be01'
34         '443e2997459673250b7dca3ffd24bffeda8a905c507c535814516e676bf359853c05d65eff71aac9c6c91c39bc1508e68ced64336edaab049954c2adc995c4bd')
35 validpgpkeys=(
36   '647F28654894E3BD457199BE38DBBDC86092693E'  # Greg Kroah-Hartman <gregkh@linuxfoundation.org>
37   '5ED9A48FC54C0A22D1D0804CEBC26CDB5A56DE73'  # Steven Rostedt (Der Hacker) <rostedt@goodmis.org>
38   'C7E7849466FE2358343588377258734B41C31549'  # David Runge <dvzrv@archlinux.org>
39   '991F6E3F0765CF6295888586139B09DA5BF0D338'  # David Runge <dvzrv@archlinux.org>
42 export KBUILD_BUILD_HOST=archlinux
43 export KBUILD_BUILD_USER=$pkgbase
44 export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
46 prepare() {
47   cd $pkgbase
49   echo "Setting version..."
50   scripts/setlocalversion --save-scmversion
51   echo "-$pkgrel" > localversion.10-pkgrel
52   echo "${pkgbase#linux}" > localversion.20-pkgname
54   local src
55   for src in "${source[@]}"; do
56     src="${src%%::*}"
57     src="${src##*/}"
58     # picking up the RT patch
59     src="${src//patch.xz/patch}"
60     [[ $src = *.patch ]] || continue
61     echo "Applying patch $src..."
62     patch -Np1 < "../$src"
63   done
65   echo "Setting config..."
66   cp ../config .config
67   make olddefconfig
68   # make nconfig
70   make -s kernelrelease > version
71   echo "Prepared $pkgbase version $(<version)"
74 build() {
75   cd $pkgbase
76   make htmldocs all
79 _package() {
80   pkgdesc="The $pkgdesc kernel and modules"
81   depends=(coreutils initramfs kmod)
82   optdepends=('wireless-regdb: to set the correct wireless channels of your country'
83               'linux-firmware: firmware images needed for some devices')
84   provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE KSMBD-MODULE)
86   cd $pkgbase
87   local kernver="$(<version)"
88   local modulesdir="$pkgdir/usr/lib/modules/$kernver"
90   echo "Installing boot image..."
91   # systemd expects to find the kernel here to allow hibernation
92   # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
93   install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
95   # Used by mkinitcpio to name the kernel
96   echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
98   echo "Installing modules..."
99   make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \
100     DEPMOD=/doesnt/exist modules_install  # Suppress depmod
102   # remove build and source links
103   rm "$modulesdir"/{source,build}
106 _package-headers() {
107   pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
108   depends=(pahole)
110   cd $pkgbase
111   local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
113   echo "Installing build files..."
114   install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
115     localversion.* version vmlinux
116   install -Dt "$builddir/kernel" -m644 kernel/Makefile
117   install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
118   cp -t "$builddir" -a scripts
120   # required when STACK_VALIDATION is enabled
121   install -Dt "$builddir/tools/objtool" tools/objtool/objtool
123   # required when DEBUG_INFO_BTF_MODULES is enabled
124   install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids
126   echo "Installing headers..."
127   cp -t "$builddir" -a include
128   cp -t "$builddir/arch/x86" -a arch/x86/include
129   install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
131   install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
132   install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
134   # https://bugs.archlinux.org/task/13146
135   install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
137   # https://bugs.archlinux.org/task/20402
138   install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
139   install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
140   install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
142   # https://bugs.archlinux.org/task/71392
143   install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
145   echo "Installing KConfig files..."
146   find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
148   echo "Removing unneeded architectures..."
149   local arch
150   for arch in "$builddir"/arch/*/; do
151     [[ $arch = */x86/ ]] && continue
152     echo "Removing $(basename "$arch")"
153     rm -r "$arch"
154   done
156   echo "Removing documentation..."
157   rm -r "$builddir/Documentation"
159   echo "Removing broken symlinks..."
160   find -L "$builddir" -type l -printf 'Removing %P\n' -delete
162   echo "Removing loose objects..."
163   find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
165   echo "Stripping build tools..."
166   local file
167   while read -rd '' file; do
168     case "$(file -bi "$file")" in
169       application/x-sharedlib\;*)      # Libraries (.so)
170         strip -v $STRIP_SHARED "$file" ;;
171       application/x-archive\;*)        # Libraries (.a)
172         strip -v $STRIP_STATIC "$file" ;;
173       application/x-executable\;*)     # Binaries
174         strip -v $STRIP_BINARIES "$file" ;;
175       application/x-pie-executable\;*) # Relocatable binaries
176         strip -v $STRIP_SHARED "$file" ;;
177     esac
178   done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
180   echo "Stripping vmlinux..."
181   strip -v $STRIP_STATIC "$builddir/vmlinux"
183   echo "Adding symlink..."
184   mkdir -p "$pkgdir/usr/src"
185   ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
188 _package-docs() {
189   pkgdesc="Documentation for the $pkgdesc kernel"
191   cd $pkgbase
192   local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
194   echo "Installing documentation..."
195   local src dst
196   while read -rd '' src; do
197     dst="${src#Documentation/}"
198     dst="$builddir/Documentation/${dst#output/}"
199     install -Dm644 "$src" "$dst"
200   done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
202   echo "Adding symlink..."
203   mkdir -p "$pkgdir/usr/share/doc"
204   ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
207 pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs")
208 for _p in "${pkgname[@]}"; do
209   eval "package_$_p() {
210     $(declare -f "_package${_p#$pkgbase}")
211     _package${_p#$pkgbase}
212   }"
213 done
215 # vim:set ts=8 sts=2 sw=2 et: