name       : sof-firmware
homepage   : https://github.com/thesofproject/sof-bin
version    : '2.9'
release    : 21
source     :
    - https://github.com/thesofproject/sof-bin/releases/download/v2024.03/sof-bin-2024.03.tar.gz : 4fd932f7bbc1517b06fa7911e6d566814d5dc4fec5608bdb44e7c4fe4929fbf6
license    :
    - BSD-3-Clause
    - ISC
component  : kernel
summary    : Sound Open Firmware
description: |
    Sound Open Firmware
install    : |
    install -dm00755 $installdir/usr/lib64/firmware/intel
    cp -at $installdir/usr/lib64/firmware/intel sof*

    # Exit if there are any absolute symlinks anywhere since those will mess things up
    pushd $installdir/
    ! find . -type l -lname '/*' -print | grep .
    popd

    # Usr-merge
    install -dm00755 $installdir/lib64
    pushd $installdir/usr
    file_list=()
    while IFS=  read -r -d $'\0'; do
        file_list+=("$REPLY")
    done < <(find lib64 -type f -print0)
    for file in "${file_list[@]}"; do
        parent=$(dirname $file)
        install -dm00755 $installdir/$parent
        ln -srv $installdir/usr/$file $installdir/$file
    done

    link_list=()
    while IFS=  read -r -d $'\0'; do
        link_list+=("$REPLY")
    done < <(find lib64 -type l -print0)
    for file in "${link_list[@]}"; do
        parent=$(dirname $file)
        install -dm00755 $installdir/$parent
        link=$(readlink $file)
        ln -sv $link $installdir/$file
    done
    popd

    # Fix permissions and respect SOURCE_DATE_EPOCH
    chown root:root -R $installdir
    find $installdir -exec touch --date="@$SOURCE_DATE_EPOCH" --no-dereference {} \;

    install -Dm00644 $pkgfiles/sof-firmware.metainfo.xml $installdir/usr/share/metainfo/sof-firmware.metainfo.xml
