Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 927022 | Differences between
and this patch

Collapse All | Expand All

(-)a/copy-firmware.sh (-7 / +34 lines)
Lines 1-4 Link Here
1
#!/bin/sh
1
#!/bin/bash
2
# SPDX-License-Identifier: GPL-2.0
2
# SPDX-License-Identifier: GPL-2.0
3
#
3
#
4
# Copy firmware files based on WHENCE list
4
# Copy firmware files based on WHENCE list
Lines 19-24 Link Here
19
    printf "WARNING: %s\n" "$*"
19
    printf "WARNING: %s\n" "$*"
20
}
20
}
21
21
22
unset FIRMWARE_LIST
23
24
load_firmware_list() {
25
    local firmware_list_path="$1" ; shift
26
    local LINE
27
    declare -Ag FIRMWARE_LIST
28
    while read LINE ; do
29
        FIRMWARE_LIST[$LINE]="Y"
30
    done <"$firmware_list_path"
31
    # Let the above loop set the return value.
32
}
33
34
is_firmware_list_loaded() {
35
    # ${FIRMWARE_LIST@A} expands to a declare -A statement if FIRMWARE_LIST
36
    # is an associative array.
37
    [ -n "${FIRMWARE_LIST@A}" ]
38
    # Let the above be the return value.
39
}
40
41
is_not_in_firmware_list() {
42
    local firmware_name="$1" ; shift
43
    # Only return true if the firmware list is loaded and the given name is
44
    # not in it.  If no list is loaded, treat that as though everything is
45
    # in the list.
46
    is_firmware_list_loaded && [ -z "${FIRMWARE_LIST[$firmware_name]}" ]
47
    # Let the above be the return value.
48
}
49
22
while test $# -gt 0; do
50
while test $# -gt 0; do
23
    case $1 in
51
    case $1 in
24
        -v | --verbose)
52
        -v | --verbose)
Lines 48-58 Link Here
48
76
49
        --firmware-list)
77
        --firmware-list)
50
            if [ -n "$2" ]; then
78
            if [ -n "$2" ]; then
51
                FIRMWARE_LIST=`cat $2`
79
                load_firmware_list "$2" || err "ERROR:  Unable to load firmware list"
52
                shift 2
80
                shift 2
53
            else
81
            else
54
                echo "ERROR: '--firmware-list' requires a non-empty option argument of firmware files to install"
82
                err "ERROR: '--firmware-list' requires a non-empty option argument of firmware files to install"
55
                exit 1
56
            fi
83
            fi
57
            ;;
84
            ;;
58
85
Lines 81-87 Link Here
81
108
82
# shellcheck disable=SC2162 # file/folder name can include escaped symbols
109
# shellcheck disable=SC2162 # file/folder name can include escaped symbols
83
grep -E '^(RawFile|File):' WHENCE | sed -E -e 's/^(RawFile|File): */\1 /;s/"//g' | while read k f; do
110
grep -E '^(RawFile|File):' WHENCE | sed -E -e 's/^(RawFile|File): */\1 /;s/"//g' | while read k f; do
84
    [ -n "${FIRMWARE_LIST}" ]  && if ! echo "${FIRMWARE_LIST}" | grep -q "${f}"; then continue; fi
111
    is_not_in_firmware_list "$f" && continue
85
    install -d "$destdir/$(dirname "$f")"
112
    install -d "$destdir/$(dirname "$f")"
86
    $verbose "copying/compressing file $f$compext"
113
    $verbose "copying/compressing file $f$compext"
87
    if test "$compress" != "cat" && test "$k" = "RawFile"; then
114
    if test "$compress" != "cat" && test "$k" = "RawFile"; then
Lines 94-100 Link Here
94
121
95
# shellcheck disable=SC2162 # file/folder name can include escaped symbols
122
# shellcheck disable=SC2162 # file/folder name can include escaped symbols
96
grep -E '^Link:' WHENCE | sed -e 's/^Link: *//g;s/-> //g' | while read l t; do
123
grep -E '^Link:' WHENCE | sed -e 's/^Link: *//g;s/-> //g' | while read l t; do
97
    [ -n "${FIRMWARE_LIST}" ]  && if ! echo "${FIRMWARE_LIST}" | grep -q "${t}"; then continue; fi
124
    is_not_in_firmware_list "$l" && continue
98
    directory="$destdir/$(dirname "$l")"
125
    directory="$destdir/$(dirname "$l")"
99
    install -d "$directory"
126
    install -d "$directory"
100
    target="$(cd "$directory" && realpath -m -s "$t")"
127
    target="$(cd "$directory" && realpath -m -s "$t")"
Lines 109-115 Link Here
109
136
110
# Verify no broken symlinks
137
# Verify no broken symlinks
111
if test "$(find "$destdir" -xtype l | wc -l)" -ne 0 ; then
138
if test "$(find "$destdir" -xtype l | wc -l)" -ne 0 ; then
112
    if  [ -z "${FIRMWARE_LIST}" ]; then
139
    if ! is_firmware_list_loaded ; then
113
        err "Broken symlinks found:\\n$(find "$destdir" -xtype l)"
140
        err "Broken symlinks found:\\n$(find "$destdir" -xtype l)"
114
    fi
141
    fi
115
fi
142
fi

Return to bug 927022