From 39debca9fc2676688d922b3f08d72adbeaf7c637 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 17 Nov 2020 15:15:50 +0100 Subject: [PATCH] Fix U-Boot environment handling (#1001) * Use /run as default location for lock files for U-Boot tools While there is a command line parameter to set the lock file explicitly, there are other tools invoking fw_setenv (in particular rauc) which do not set the lock file. Using /run by default makes fw_setenv use the correct lock file in all situations. * Don't explicitly set lock file location Since we patch U-Boot tools to use /run by default setting it explicitly is unnecessary. --- ...run-as-default-location-for-lock-fil.patch | 49 +++++++++++++++++++ .../usr/libexec/hassos-persists | 4 +- 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 buildroot-external/patches/uboot-tools/0001-fw_printenv-use-run-as-default-location-for-lock-fil.patch diff --git a/buildroot-external/patches/uboot-tools/0001-fw_printenv-use-run-as-default-location-for-lock-fil.patch b/buildroot-external/patches/uboot-tools/0001-fw_printenv-use-run-as-default-location-for-lock-fil.patch new file mode 100644 index 000000000..eac957065 --- /dev/null +++ b/buildroot-external/patches/uboot-tools/0001-fw_printenv-use-run-as-default-location-for-lock-fil.patch @@ -0,0 +1,49 @@ +From 63d929a7c6523ca5fcaed4a4d2a2e6643aa4ae44 Mon Sep 17 00:00:00 2001 +Message-Id: <63d929a7c6523ca5fcaed4a4d2a2e6643aa4ae44.1605605643.git.stefan@agner.ch> +From: Stefan Agner +Date: Tue, 17 Nov 2020 10:33:05 +0100 +Subject: [PATCH] fw_printenv: use /run as default location for lock files + +Use /run as location for lock files. This is the recommended location +for lock files. The current location /var/lock is considered legacy by +systemd. + +Signed-off-by: Stefan Agner +--- + tools/env/fw_env_main.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/tools/env/fw_env_main.c b/tools/env/fw_env_main.c +index 1d193bd437..0b201b9e62 100644 +--- a/tools/env/fw_env_main.c ++++ b/tools/env/fw_env_main.c +@@ -73,7 +73,7 @@ void usage_printenv(void) + " -c, --config configuration file, default:" CONFIG_FILE "\n" + #endif + " -n, --noheader do not repeat variable name in output\n" +- " -l, --lock lock node, default:/var/lock\n" ++ " -l, --lock lock node, default:/run\n" + "\n"); + } + +@@ -88,7 +88,7 @@ void usage_env_set(void) + #ifdef CONFIG_FILE + " -c, --config configuration file, default:" CONFIG_FILE "\n" + #endif +- " -l, --lock lock node, default:/var/lock\n" ++ " -l, --lock lock node, default:/run\n" + " -s, --script batch mode to minimize writes\n" + "\n" + "Examples:\n" +@@ -206,7 +206,7 @@ int parse_setenv_args(int argc, char *argv[]) + + int main(int argc, char *argv[]) + { +- char *lockname = "/var/lock/" CMD_PRINTENV ".lock"; ++ char *lockname = "/run/" CMD_PRINTENV ".lock"; + int lockfd = -1; + int retval = EXIT_SUCCESS; + char *_cmdname; +-- +2.29.2 + diff --git a/buildroot-external/rootfs-overlay/usr/libexec/hassos-persists b/buildroot-external/rootfs-overlay/usr/libexec/hassos-persists index bac0d89fe..305cdc95e 100755 --- a/buildroot-external/rootfs-overlay/usr/libexec/hassos-persists +++ b/buildroot-external/rootfs-overlay/usr/libexec/hassos-persists @@ -8,9 +8,9 @@ MACHINE_ID=$(cat /etc/machine-id) if [ -e /usr/sbin/fw_setenv ]; then # machine-id - if [ "$(fw_printenv -l /run -n MACHINE_ID)" != "${MACHINE_ID}" ]; then + if [ "$(fw_printenv -n MACHINE_ID)" != "${MACHINE_ID}" ]; then echo "[INFO] set machine-id to ${MACHINE_ID}" - fw_setenv -l /run MACHINE_ID "${MACHINE_ID}" + fw_setenv MACHINE_ID "${MACHINE_ID}" else echo "[INFO] machine-id is okay" fi