summaryrefslogtreecommitdiff
path: root/src/system-update-generator
diff options
context:
space:
mode:
authorEric Curtin <ecurtin@redhat.com>2023-04-17 22:09:24 +0100
committerLennart Poettering <lennart@poettering.net>2023-04-25 17:40:41 +0200
commitb9dac418372401742609bd600f05267ae3a724de (patch)
tree6de7b81b4c4deff66a693aab495d32ddd5209df2 /src/system-update-generator
parentd30d5a0374687e4bd5e0a0cceb38ed3a57d42d79 (diff)
downloadsystemd-b9dac418372401742609bd600f05267ae3a724de.tar.gz
Support /etc/system-update for OSTree systems
This is required when / is immutable and cannot be written at runtime. Co-authored-by: Richard Hughes <richard@hughsie.com>
Diffstat (limited to 'src/system-update-generator')
-rw-r--r--src/system-update-generator/system-update-generator.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/system-update-generator/system-update-generator.c b/src/system-update-generator/system-update-generator.c
index 54cd943af7..ee5f8ec12e 100644
--- a/src/system-update-generator/system-update-generator.c
+++ b/src/system-update-generator/system-update-generator.c
@@ -6,6 +6,7 @@
#include "fs-util.h"
#include "generator.h"
#include "log.h"
+#include "path-util.h"
#include "proc-cmdline.h"
#include "special.h"
#include "string-util.h"
@@ -18,19 +19,25 @@
static const char *arg_dest = NULL;
static int generate_symlink(void) {
- const char *p = NULL;
+ _cleanup_free_ char *j = NULL;
- if (laccess("/system-update", F_OK) < 0) {
- if (errno == ENOENT)
- return 0;
+ FOREACH_STRING(p, "/system-update", "/etc/system-update") {
+ if (laccess(p, F_OK) >= 0)
+ goto link_found;
- log_error_errno(errno, "Failed to check for system update: %m");
- return -EINVAL;
+ if (errno != ENOENT)
+ log_warning_errno(errno, "Failed to check if %s symlink exists, ignoring: %m", p);
}
- p = strjoina(arg_dest, "/" SPECIAL_DEFAULT_TARGET);
- if (symlink(SYSTEM_DATA_UNIT_DIR "/system-update.target", p) < 0)
- return log_error_errno(errno, "Failed to create symlink %s: %m", p);
+ return 0;
+
+link_found:
+ j = path_join(arg_dest, SPECIAL_DEFAULT_TARGET);
+ if (!j)
+ return log_oom();
+
+ if (symlink(SYSTEM_DATA_UNIT_DIR "/system-update.target", j) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", j);
return 1;
}