linux-beacon-artix

Patched Artix/Arch kernel that fixes iwlwifi driver
git clone git://mattcarlson.org/repos/linux-beacon-artix.git
Log | Files | Refs | README

PKGBUILD (6747B)


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