File: install.sh

package info (click to toggle)
firmware-sof 2025.05-1
  • links: PTS, VCS
  • area: non-free-firmware
  • in suites: forky, sid
  • size: 39,800 kB
  • sloc: sh: 56; python: 27; makefile: 11
file content (76 lines) | stat: -rwxr-xr-x 2,198 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh
# shellcheck disable=SC3043

# Keep this script as short as possible _and_ optional - some
# distributions don't use it at all.
#
# The "real" installation process belongs to sof/installer/ in the
# main repo where any developer can use it and fix it.

set -e

# Default values, override on the command line
: "${FW_DEST:=/lib/firmware/intel}"
: "${TOOLS_DEST:=/usr/local/bin}"

usage()
{
    cat <<EOF
Usage example:
        sudo $0 [[v1.8.x/]v1.8]
EOF
    exit 1
}

main()
{
    test "$#" -le 1 || usage

    # Never empty, dirname returns "." instead (opengroup.org)
    local path; path=$(dirname "$1")
    local ver; ver=$(basename "$1")
    local sdir optversuffix

    [ -z "$ver" ] || optversuffix="-$ver"

    # Do this first so we can fail immediately and not leave a
    # half-install behind
    if [ -n "$optversuffix" ]; then
        if test -e "$path/sof${optversuffix}" -a -e "$path/sof-tplg${optversuffix}" ; then
            : # SOF IPC3 SOF layout
        elif test -e "$path/sof-ipc4${optversuffix}" -a -e "$path/sof-ace-tplg${optversuffix}" ; then
            : # SOF IPC4 layout for Intel Meteor Lake (and newer)
        else
            die "Files not found or unknown FW file layout $1 \n"
        fi

        for sdir in sof sof-ipc4 sof-ipc4-tplg sof-ace-tplg sof-tplg; do
            if test -e "$path/$sdir${optversuffix}" ; then
                # Test workaround. Currently enough to run the whole test suite on Darwin
                case "$(uname)" in
                    Darwin) safer_ln=;;
                    *) safer_ln='--no-target-directory';;
                esac
                ( set -x; ln -s $safer_ln "$sdir-$ver" "${FW_DEST}/$sdir" ) || {
                    set +x
                    die '%s already installed? (Re)move it first.\n' "${FW_DEST}/$sdir"
                }
            fi
        done
    fi

    # Trailing slash in srcdir/ ~= srcdir/*
    rsync -a "${path}"/sof*"$optversuffix" "${FW_DEST}"/
    rsync -a "${path}"/tools"$optversuffix"/ "${TOOLS_DEST}"/
}

die()
{
    >&2 printf '%s ERROR: ' "$0"
    # We want die() to be usable exactly like printf
    # shellcheck disable=SC2059
    >&2 printf "$@"
    exit 1
}

main "$@"