]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: add simple mechanism to override fstype choices
authorLennart Poettering <lennart@poettering.net>
Thu, 5 Oct 2023 16:54:43 +0000 (18:54 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 5 Oct 2023 17:18:36 +0000 (19:18 +0200)
This is very useful for quickly testing things when building DDIs, in
particular in the CI, and trivial to add.

docs/ENVIRONMENT.md
src/partition/repart.c

index 6396789e4a2da0af5ab77e358d50dd8c0c8a7039..65d28e6bfa6edef5093da76bc254c0fc4375579e 100644 (file)
@@ -552,3 +552,6 @@ SYSTEMD_HOME_DEBUG_SUFFIX=foo \
 * `$SYSTEMD_REPART_MKFS_OPTIONS_<FSTYPE>` – configure additional arguments to use for
   `mkfs` when formatting partition file systems. There's one variable for each
   of the supported file systems.
+
+* `$SYSTEMD_REPART_OVERRIDE_FSTYPE` – if set the value will override the file
+  system type specified in Format= lines in partition definition files.
index 51706c839a3415166b017063cf6cc9ac2273fabd..3d4baac295046684d21d81dac3c3bd9611b10c4d 100644 (file)
@@ -1378,9 +1378,18 @@ static int config_parse_fstype(
                 void *userdata) {
 
         char **fstype = ASSERT_PTR(data);
+        const char *e;
 
         assert(rvalue);
 
+        /* Let's provide an easy way to override the chosen fstype for file system partitions */
+        e = secure_getenv("SYSTEMD_REPART_OVERRIDE_FSTYPE");
+        if (e && !streq(rvalue, e)) {
+                log_syntax(unit, LOG_NOTICE, filename, line, 0,
+                           "Overriding defined file system type '%s' with '%s'.", rvalue, e);
+                rvalue = e;
+        }
+
         if (!filename_is_valid(rvalue))
                 return log_syntax(unit, LOG_ERR, filename, line, 0,
                                   "File system type is not valid, refusing: %s", rvalue);