From 57616accfd55b736e3b402ead96637e23792772a Mon Sep 17 00:00:00 2001 From: Thomas Deutschmann Date: Thu, 19 Nov 2020 19:24:44 +0100 Subject: sys-kernel/linux-firmware: check each command in pipeline manually We cannot use Bash's pipefail option because grep can return exit status 1 to indicate that no line was selected which isn't an error. Fixes: 9bf0896d9 ("sys-kernel/linux-firmware: use copy-firmware.sh to install firmwares") Closes: https://bugs.gentoo.org/754960 Package-Manager: Portage-3.0.9, Repoman-3.0.2 Signed-off-by: Thomas Deutschmann --- sys-kernel/linux-firmware/linux-firmware-20201022-r2.ebuild | 11 +++++++++-- sys-kernel/linux-firmware/linux-firmware-99999999.ebuild | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'sys-kernel') diff --git a/sys-kernel/linux-firmware/linux-firmware-20201022-r2.ebuild b/sys-kernel/linux-firmware/linux-firmware-20201022-r2.ebuild index bc7bc76e3b09..01b85b27a4f0 100644 --- a/sys-kernel/linux-firmware/linux-firmware-20201022-r2.ebuild +++ b/sys-kernel/linux-firmware/linux-firmware-20201022-r2.ebuild @@ -276,12 +276,19 @@ src_install() { [[ -s "${files_to_keep}" ]] || die "grep failed, empty config file?" einfo "Applying USE=savedconfig; Removing all files not listed in config ..." - set -o pipefail find ! -type d -printf "%P\n" \ | grep -Fvx -f "${files_to_keep}" \ | xargs -d '\n' --no-run-if-empty rm -v - [[ ${?} -ne 0 ]] && die "Failed to remove files not listed in config" + if [[ ${PIPESTATUS[0]} -ne 0 ]]; then + die "Find failed to print installed files" + elif [[ ${PIPESTATUS[1]} -eq 2 ]]; then + # grep returns exit status 1 if no lines were selected + # which is the case when we want to keep all files + die "Grep failed to select files to keep" + elif [[ ${PIPESTATUS[2]} -ne 0 ]]; then + die "Failed to remove files not listed in config" + fi fi fi diff --git a/sys-kernel/linux-firmware/linux-firmware-99999999.ebuild b/sys-kernel/linux-firmware/linux-firmware-99999999.ebuild index bc7bc76e3b09..01b85b27a4f0 100644 --- a/sys-kernel/linux-firmware/linux-firmware-99999999.ebuild +++ b/sys-kernel/linux-firmware/linux-firmware-99999999.ebuild @@ -276,12 +276,19 @@ src_install() { [[ -s "${files_to_keep}" ]] || die "grep failed, empty config file?" einfo "Applying USE=savedconfig; Removing all files not listed in config ..." - set -o pipefail find ! -type d -printf "%P\n" \ | grep -Fvx -f "${files_to_keep}" \ | xargs -d '\n' --no-run-if-empty rm -v - [[ ${?} -ne 0 ]] && die "Failed to remove files not listed in config" + if [[ ${PIPESTATUS[0]} -ne 0 ]]; then + die "Find failed to print installed files" + elif [[ ${PIPESTATUS[1]} -eq 2 ]]; then + # grep returns exit status 1 if no lines were selected + # which is the case when we want to keep all files + die "Grep failed to select files to keep" + elif [[ ${PIPESTATUS[2]} -ne 0 ]]; then + die "Failed to remove files not listed in config" + fi fi fi -- cgit v1.2.3-65-gdbad