#!/bin/mkpkg
# description: AMD firmware, microcode initramfs and Intel AX210 WiFi/BT
# url: https://gitlab.com/kernel-firmware/linux-firmware

name=amd-firmware
version=20260519
release=1
depends=()
makedeps=(rdfind)
source=(https://www.kernel.org/pub/linux/kernel/firmware/linux-firmware-$version.tar.xz)

sha256sums=(
    "b14e7197a290a7e5569f5ef790cde289bddc47e32126f2eb262a8e677fc39727"
)

build() {
    cd linux-firmware-$version

    # Early microcode initramfs image for limine module_path
    mkdir -p kernel/x86/microcode
    cat amd-ucode/microcode_amd*.bin > kernel/x86/microcode/AuthenticAMD.bin
    find kernel | cpio -o -H newc --owner=0:0 > amd-ucode.img
    install -Dm644 amd-ucode.img $PKG/boot/efi/amd-ucode.img

    # All AMD GPU firmware
    install -Dm644 -t $PKG/lib/firmware/amdgpu amdgpu/*

    # Intel WiFi: real files + symlinks at lib/firmware/ root
    install -Dm644 -t $PKG/lib/firmware/intel/iwlwifi intel/iwlwifi/*
    for f in $PKG/lib/firmware/intel/iwlwifi/*; do
        ln -sr $f $PKG/lib/firmware/$(basename $f)
    done

    # Intel Bluetooth: files and relative symlinks all within intel/
    mkdir -p $PKG/lib/firmware/intel
    cp -a intel/ibt-* $PKG/lib/firmware/intel/

}

signify() {
    untrusted comment: public key
    RWTZ9IduCSQ/mL8337TEUinPwT92xFEUpD92hkS7IxcOnzTt9QdpohT3
}

# vim: filetype=sh
