1 # Maintainer: David Runge <dvzrv@archlinux.org>
2 # Contributor: Joakim Hernberg <jbh@alchemy.lu>
5 pkgver=6.2.0.3.realtime1
9 url="https://gitlab.archlinux.org/archlinux/packaging/upstream/linux-rt/-/commits/v$pkgver"
28 git+https://gitlab.archlinux.org/archlinux/packaging/upstream/linux-rt#tag=v$pkgver?signed
32 'e079399cdd0b4916e931fda264eaef691e893f0aef085eb4af033f6766f373fbd4d13d1ae421664955c0febb4cb7b8a65a463156dab5c7256f537bd747cc94d7')
34 '99f4ce5e8ebde99652614730d9e7c65e275f8c1d2a01b97edf62b44852140fed7b8a53cc4e0b7d6d2783aaab6d10c7c6b0fe91d5456fd31baef2e284df659cbf')
36 '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman <gregkh@kernel.org>
37 '64254695FFF0AA4466CC19E67B96E8162A8CF5D1' # Sebastian Andrzej Siewior
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})"
49 echo "Setting version..."
50 scripts/setlocalversion --save-scmversion
51 echo "-$pkgrel" > localversion.10-pkgrel
52 echo "${pkgbase#linux}" > localversion.20-pkgname
55 for src in "${source[@]}"; do
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"
65 echo "Setting config..."
70 make -s kernelrelease > version
71 echo "Prepared $pkgbase version $(<version)"
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)
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}
107 pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
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..."
150 for arch in "$builddir"/arch/*/; do
151 [[ $arch = */x86/ ]] && continue
152 echo "Removing $(basename "$arch")"
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..."
167 while read -rd '' file; do
168 case "$(file -Sbi "$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" ;;
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"
189 pkgdesc="Documentation for the $pkgdesc kernel"
192 local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
194 echo "Installing documentation..."
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}
215 # vim:set ts=8 sts=2 sw=2 et: