From d34f62ee3de98caaf7c973e802f9ab99a77fc8ed Mon Sep 17 00:00:00 2001 From: Tim Gover Date: Thu, 1 Oct 2020 20:07:53 +0100 Subject: [PATCH] rpi-eeprom-update: Move .bin filter for checksums into subshell Move all package checksum related operations to the subshell and check the old rpi-eeprom-images packages if rpi-eeprom contains no .bin files. The rpi-eeprom-config --edit and --apply option passes the -i flag so checksums should have been skipped anyway. --- rpi-eeprom-update | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/rpi-eeprom-update b/rpi-eeprom-update index f693e8d..b48f287 100755 --- a/rpi-eeprom-update +++ b/rpi-eeprom-update @@ -192,20 +192,26 @@ applyRecoveryUpdate() } applyUpdate() { - package_checksums_file="/var/lib/dpkg/info/rpi-eeprom.md5sums" - CHECKSUMS=$(mktemp) - cat "${package_checksums_file}" | grep -E '\.bin$' > "${CHECKSUMS}" - [ "$(id -u)" = "0" ] || die "* Must be run as root - try 'sudo rpi-eeprom-update'" - if [ "${IGNORE_DPKG_CHECKSUMS}" = 0 ] && [ -f "${CHECKSUMS}" ]; then + if [ "${IGNORE_DPKG_CHECKSUMS}" = 0 ]; then ( + package_info_dir="/var/lib/dpkg/info/" + package_checksums_file="${package_info_dir}/rpi-eeprom.md5sums" + + if ! grep -qE '\.bin$' "${package_info_dir}/rpi-eeprom.md5sums"; then + # Try the old rpi-eeprom-images package + package_checksums_file="${package_info_dir}/rpi-eeprom-images.md5sums" + fi + + CHECKSUMS=$(mktemp) + cat "${package_checksums_file}" | grep -E '\.bin$' > "${CHECKSUMS}" cd / if ! md5sum -c "${CHECKSUMS}" > /dev/null 2>&1; then md5sum -c "${CHECKSUMS}" die "rpi-eeprom checksums failed - try reinstalling this package" fi - ) + ) || die "Unable to validate EEPROM image package checksums" fi if [ "${USE_FLASHROM}" = 0 ]; then