From 2baded9ecc3434abadec43bbcc0aca95a12deddd Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Tue, 22 Feb 2022 18:04:34 +0000 Subject: [PATCH] base-files: make sure tools are present in sysupgrade ramdisk Not all targets create /var/lock or touch /var/lock/fw_printenv.lock in their platform.sh. This is problematic as fw_printenv then fails in case /var/lock/fw_printenv.lock has not been created by previous calls to fw_printenv/fw_setenv before sysupgrade is run. Targets using fw_printenv/fw_setenv during sysupgrade: * ath79/* * ipq40xx/* * ipq806x/* * kirkwood/* * layerscape/* * mediatek/mt7622 * mvebu/* * ramips/* * realtek/* Targets currently using additional steps in /lib/upgrade/platform.sh to make sure /var/lock/fw_printenv.lock (or at least /var/lock) actually exists: * ath79/* (openmesh devices) * ipq40xx/* (linksys devices) * ipq806x/* (linksys devices) * kirkwood/* (linksys devices) * layerscape/* * mvebu/cortexa9 (linksys devices) Given that accessing the U-Boot environment during sysupgrade is not uncommon and the situation across targets is currently quite diverse, just make sure both tools as well fw_env.config are always copied to the ramdisk used for sysupgrade. Also make sure /var/lock always exists. This now allows to remove copying of fw_printenv/fw_setenv as well as fw_env.config, creation of /var/lock or even /var/lock/fw_printenv.lock from lib/upgrade/platform.sh or files included there. As the same applies also to 'fwtool' which is used by generic eMMC sysupgrade, also always copy that to ramdisk. Signed-off-by: Daniel Golle --- package/base-files/files/lib/upgrade/stage2 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/package/base-files/files/lib/upgrade/stage2 b/package/base-files/files/lib/upgrade/stage2 index 74edd61104..5e0d73631b 100755 --- a/package/base-files/files/lib/upgrade/stage2 +++ b/package/base-files/files/lib/upgrade/stage2 @@ -46,13 +46,19 @@ switch_to_ramfs() { ubiupdatevol ubiattach ubiblock ubiformat \ ubidetach ubirsvol ubirmvol ubimkvol \ snapshot snapshot_tool date logger \ + /usr/sbin/fw_printenv /usr/bin/fwtool \ $RAMFS_COPY_LOSETUP $RAMFS_COPY_LVM \ $RAMFS_COPY_BIN do local file="$(command -v "$binary" 2>/dev/null)" [ -n "$file" ] && install_bin "$file" done - install_file /etc/resolv.conf /lib/*.sh /lib/functions/*.sh /lib/upgrade/*.sh /lib/upgrade/do_stage2 /usr/share/libubox/jshn.sh $RAMFS_COPY_DATA + install_file /etc/resolv.conf /lib/*.sh /lib/functions/*.sh \ + /lib/upgrade/*.sh /lib/upgrade/do_stage2 \ + /usr/share/libubox/jshn.sh /usr/sbin/fw_setenv \ + /etc/fw_env.config $RAMFS_COPY_DATA + + mkdir -p $RAM_ROOT/var/lock [ -L "/lib64" ] && ln -s /lib $RAM_ROOT/lib64 -- 2.30.2