debugging, in order to test generators and other code against specific kernel
command lines.
+* `$SYSTEMD_OS_RELEASE` — if set, use this path instead of `/etc/os-release` or
+ `/usr/lib/os-release`. When operating under some root (e.g. `systemctl
+ --root=…`), the path is taken relative to the outside root. Only useful for
+ debugging.
+
* `$SYSTEMD_FSTAB` — if set, use this path instead of `/etc/fstab`. Only useful
for debugging.
}
}
} else {
- FOREACH_STRING(p, "/etc/os-release", "/usr/lib/os-release") {
- r = chase_symlinks(p, root, CHASE_PREFIX_ROOT,
+ const char *var = secure_getenv("SYSTEMD_OS_RELEASE");
+ if (var)
+ r = chase_symlinks(var, root, 0,
ret_path ? &q : NULL,
ret_fd ? &fd : NULL);
- if (r != -ENOENT)
- break;
- }
+ else
+ FOREACH_STRING(path, "/etc/os-release", "/usr/lib/os-release") {
+ r = chase_symlinks(path, root, CHASE_PREFIX_ROOT,
+ ret_path ? &q : NULL,
+ ret_fd ? &fd : NULL);
+ if (r != -ENOENT)
+ break;
+ }
}
if (r < 0)
return r;
# FIXME: if there's an invalid Alias=, we shouldn't preach about empty [Install]
-exit 0 # yes, this is needed because the last test above fails
-
# TODO: repeat the tests above for presets
+
+: -------SYSTEMD_OS_RELEASE relative to root------------------
+# check that os-release overwriting works as expected with root
+test -e "$root/etc/os-release"
+
+cat >"$root/etc/os-release2" <<EOF
+ID='the-id2'
+EOF
+
+SYSTEMD_OS_RELEASE="$root/etc/os-release2" check_alias o 'the-id2'