Skip to content

Commit 4f6e00d

Browse files
committed
sys-kernel/coreos-firmware: Fix deletion of unneeded firmware files
The code was tripping up over whitespace, resulting in scary error messages, and was more cumbersome than it needed to be. Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
1 parent 303f2a6 commit 4f6e00d

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

sdk_container/src/third_party/coreos-overlay/sys-kernel/coreos-firmware/coreos-firmware-99999999.ebuild

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -156,18 +156,17 @@ src_prepare() {
156156

157157
# Fail if any firmware is missing.
158158
einfo "Scanning for files required by ${KV_FULL}"
159-
echo -n > "${T}/firmware-scan"
159+
echo "# Remove files that shall not be installed from this list." > ${PN}.conf
160160
local kofile fwfile failed
161161
for kofile in $(find "${kernel_mods}" -name '*.ko' -o -name '*.ko.xz'); do
162162
for fwfile in $(modinfo --field firmware "${kofile}"); do
163163
if [[ ! -e "${fwfile}" ]]; then
164164
eerror "Missing firmware: ${fwfile} (${kofile##*/})"
165165
failed=1
166166
elif [[ -L "${fwfile}" ]]; then
167-
echo "${fwfile}" >> "${T}/firmware-scan"
168-
realpath --relative-to=. "${fwfile}" >> "${T}/firmware-scan"
167+
printf "%s\n" "${fwfile}" "$(realpath --relative-to=. "${fwfile}")" >> ${PN}.conf
169168
else
170-
echo "${fwfile}" >> "${T}/firmware-scan"
169+
printf "%s\n" "${fwfile}" >> ${PN}.conf
171170
fi
172171
done
173172
done
@@ -177,20 +176,13 @@ src_prepare() {
177176

178177
# AMD's microcode is shipped as part of coreos-firmware, but not a dependency to
179178
# any module, so add it manually
180-
use amd64 && find amd-ucode/ -type f -not -name "*.asc" >> "${T}/firmware-scan"
179+
use amd64 && find amd-ucode/ -type f -not -name "*.asc" >> ${PN}.conf
181180

182181
einfo "Pruning all unneeded firmware files..."
183-
sort -u "${T}/firmware-scan" > "${T}/firmware"
184-
find * -not -type d \
185-
| sort "${T}/firmware" "${T}/firmware" - \
186-
| uniq -u | xargs -r rm
187-
find * -type f -name "* *" -exec rm -f {} \;
182+
find * -not -type d -not -name ${PN}.conf -print0 | grep -Fzxvf ${PN}.conf | xargs -r0 rm -v
188183

189184
default
190185

191-
echo "# Remove files that shall not be installed from this list." > ${PN}.conf
192-
find * \( \! -type d -and \! -name ${PN}.conf \) >> ${PN}.conf
193-
194186
# whitelist of misc files
195187
local misc_files=(
196188
build_packages.py
@@ -318,7 +310,7 @@ src_prepare() {
318310
if use !unknown-license; then
319311
einfo "Removing files with unknown license ..."
320312
# Flatcar: do not die even if no such license file is there.
321-
rm -v "${unknown_license[@]}"
313+
rm -vf "${unknown_license[@]}"
322314
fi
323315

324316
if use !redistributable; then

0 commit comments

Comments
 (0)