|
| 1 | +# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org> |
| 2 | + |
| 3 | +pkgbase=linux-drm-misc-next-git |
| 4 | +pkgver=6.1.0 |
| 5 | +pkgrel=1 |
| 6 | +pkgdesc='Linux with patches requied to use steamvr proxy driver' |
| 7 | +_product="${pkgbase%-git}" |
| 8 | +_branch="${_product#linux-}" |
| 9 | +arch=(x86_64) |
| 10 | +license=(GPL2) |
| 11 | +makedepends=( |
| 12 | + bc libelf pahole cpio perl tar xz git |
| 13 | +) |
| 14 | +options=('!strip') |
| 15 | +_srcname=archlinux-linux |
| 16 | +source=( |
| 17 | + "$_srcname::git+https://anongit.freedesktop.org/git/drm/drm-misc.git#branch=$_branch" |
| 18 | + config # the main kernel config file |
| 19 | + 0001-drm-edid-non-desktop.patch |
| 20 | + 0003-drm-edid-dsc-bpp-parse.patch |
| 21 | + 0004-drm-amd-dsc-bpp-apply.patch |
| 22 | +) |
| 23 | +sha256sums=('SKIP' |
| 24 | + 'SKIP' |
| 25 | + 'SKIP' |
| 26 | + 'SKIP' |
| 27 | + 'SKIP') |
| 28 | + |
| 29 | +pkgver() { |
| 30 | + cd $_srcname |
| 31 | + local version="$(grep \^VERSION Makefile|cut -d"=" -f2|cut -d" " -f2)" |
| 32 | + local patch="$(grep \^PATCHLEVEL Makefile|cut -d"=" -f2|cut -d" " -f2)" |
| 33 | + |
| 34 | + printf "%s.%s.r%s.%s" "${version}" "${patch}" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" |
| 35 | +} |
| 36 | + |
| 37 | +export KBUILD_BUILD_HOST=archlinux |
| 38 | +export KBUILD_BUILD_USER=$pkgbase |
| 39 | +export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})" |
| 40 | + |
| 41 | +prepare() { |
| 42 | + cd $_srcname |
| 43 | + |
| 44 | + echo "Setting version..." |
| 45 | + scripts/setlocalversion --save-scmversion |
| 46 | + echo "-$pkgrel" > localversion.10-pkgrel |
| 47 | + echo "${pkgbase#linux}" > localversion.20-pkgname |
| 48 | + |
| 49 | + local src |
| 50 | + for src in "${source[@]}"; do |
| 51 | + src="${src%%::*}" |
| 52 | + src="${src##*/}" |
| 53 | + [[ $src = *.patch ]] || continue |
| 54 | + echo "Applying patch $src..." |
| 55 | + patch -Np1 < "../$src" |
| 56 | + done |
| 57 | + |
| 58 | + echo "Setting config..." |
| 59 | + cp ../config .config |
| 60 | + make olddefconfig |
| 61 | + diff -u ../config .config || : |
| 62 | + |
| 63 | + make -s kernelrelease > version |
| 64 | + echo "Prepared $pkgbase version $(<version)" |
| 65 | +} |
| 66 | + |
| 67 | +build() { |
| 68 | + cd $_srcname |
| 69 | + make -j`nproc` all |
| 70 | +} |
| 71 | + |
| 72 | +_package() { |
| 73 | + pkgdesc="The $pkgdesc kernel and modules" |
| 74 | + depends=(coreutils kmod initramfs) |
| 75 | + optdepends=('wireless-regdb: to set the correct wireless channels of your country' |
| 76 | + 'linux-firmware: firmware images needed for some devices') |
| 77 | + provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE KSMBD-MODULE) |
| 78 | + replaces=(virtualbox-guest-modules-arch wireguard-arch) |
| 79 | + |
| 80 | + cd $_srcname |
| 81 | + local kernver="$(<version)" |
| 82 | + local modulesdir="$pkgdir/usr/lib/modules/$kernver" |
| 83 | + |
| 84 | + echo "Installing boot image..." |
| 85 | + # systemd expects to find the kernel here to allow hibernation |
| 86 | + # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344 |
| 87 | + install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz" |
| 88 | + |
| 89 | + # Used by mkinitcpio to name the kernel |
| 90 | + echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase" |
| 91 | + |
| 92 | + echo "Installing modules..." |
| 93 | + make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \ |
| 94 | + DEPMOD=/doesnt/exist modules_install # Suppress depmod |
| 95 | + |
| 96 | + # remove build and source links |
| 97 | + rm "$modulesdir"/{source,build} |
| 98 | +} |
| 99 | + |
| 100 | +_package-headers() { |
| 101 | + pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel" |
| 102 | + depends=(pahole) |
| 103 | + |
| 104 | + cd $_srcname |
| 105 | + local builddir="$pkgdir/usr/lib/modules/$(<version)/build" |
| 106 | + |
| 107 | + echo "Installing build files..." |
| 108 | + install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \ |
| 109 | + localversion.* version vmlinux |
| 110 | + install -Dt "$builddir/kernel" -m644 kernel/Makefile |
| 111 | + install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile |
| 112 | + cp -t "$builddir" -a scripts |
| 113 | + |
| 114 | + # required when STACK_VALIDATION is enabled |
| 115 | + install -Dt "$builddir/tools/objtool" tools/objtool/objtool |
| 116 | + |
| 117 | + # required when DEBUG_INFO_BTF_MODULES is enabled |
| 118 | + install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids |
| 119 | + |
| 120 | + echo "Installing headers..." |
| 121 | + cp -t "$builddir" -a include |
| 122 | + cp -t "$builddir/arch/x86" -a arch/x86/include |
| 123 | + install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s |
| 124 | + |
| 125 | + install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h |
| 126 | + install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h |
| 127 | + |
| 128 | + # https://bugs.archlinux.org/task/13146 |
| 129 | + install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h |
| 130 | + |
| 131 | + # https://bugs.archlinux.org/task/20402 |
| 132 | + install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h |
| 133 | + install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h |
| 134 | + install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h |
| 135 | + |
| 136 | + # https://bugs.archlinux.org/task/71392 |
| 137 | + install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h |
| 138 | + |
| 139 | + echo "Installing KConfig files..." |
| 140 | + find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \; |
| 141 | + |
| 142 | + echo "Removing unneeded architectures..." |
| 143 | + local arch |
| 144 | + for arch in "$builddir"/arch/*/; do |
| 145 | + [[ $arch = */x86/ ]] && continue |
| 146 | + echo "Removing $(basename "$arch")" |
| 147 | + rm -r "$arch" |
| 148 | + done |
| 149 | + |
| 150 | + echo "Removing documentation..." |
| 151 | + rm -r "$builddir/Documentation" |
| 152 | + |
| 153 | + echo "Removing broken symlinks..." |
| 154 | + find -L "$builddir" -type l -printf 'Removing %P\n' -delete |
| 155 | + |
| 156 | + echo "Removing loose objects..." |
| 157 | + find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete |
| 158 | + |
| 159 | + echo "Stripping build tools..." |
| 160 | + local file |
| 161 | + while read -rd '' file; do |
| 162 | + case "$(file -bi "$file")" in |
| 163 | + application/x-sharedlib\;*) # Libraries (.so) |
| 164 | + strip -v $STRIP_SHARED "$file" ;; |
| 165 | + application/x-archive\;*) # Libraries (.a) |
| 166 | + strip -v $STRIP_STATIC "$file" ;; |
| 167 | + application/x-executable\;*) # Binaries |
| 168 | + strip -v $STRIP_BINARIES "$file" ;; |
| 169 | + application/x-pie-executable\;*) # Relocatable binaries |
| 170 | + strip -v $STRIP_SHARED "$file" ;; |
| 171 | + esac |
| 172 | + done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0) |
| 173 | + |
| 174 | + echo "Stripping vmlinux..." |
| 175 | + strip -v $STRIP_STATIC "$builddir/vmlinux" |
| 176 | + |
| 177 | + echo "Adding symlink..." |
| 178 | + mkdir -p "$pkgdir/usr/src" |
| 179 | + ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase" |
| 180 | +} |
| 181 | + |
| 182 | +pkgname=("$pkgbase" "$pkgbase-headers") |
| 183 | +for _p in "${pkgname[@]}"; do |
| 184 | + eval "package_$_p() { |
| 185 | + $(declare -f "_package${_p#$pkgbase}") |
| 186 | + _package${_p#$pkgbase} |
| 187 | + }" |
| 188 | +done |
| 189 | + |
| 190 | +# vim:set ts=8 sts=2 sw=2 et: |
0 commit comments