]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Drop list reset on empty value
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 24 Aug 2023 14:19:41 +0000 (16:19 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 24 Aug 2023 14:42:13 +0000 (16:42 +0200)
This does not work properly with python's configparser, which will
insert empty lines when doing something like the following:

```
Packages=
       abc
```

Instead, we restore the "!" operator for lists to remove values from
the list as it did originally instead of preventing values from being
added.

NEWS.md
mkosi/config.py
mkosi/resources/mkosi.md

diff --git a/NEWS.md b/NEWS.md
index f72d4d4cb6b88aa3b078fd7063b1587b8f2ceee8..20d75e7dcc432e39c6a0db27cbdaa6556f9a323f 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -6,8 +6,8 @@
   well following the usual config precedence logic
 - The "first assignment wins" logic was dropped from configuration
   parsing. Settings parsed later will now override earlier values and
-  the `!` exclusion logic for lists was removed. Assigning the empty
-  string to a list can be used to clear previously assigned values.
+  the `!` operator for lists will now remove values already in the list
+  instead of preventing specific values from being added.
 
 ## v15.1
 
index 5ee5492f677ec551ef7e709c745a744f9daf5422..99040dfcce9d0b2c82c87bc1ed0c2431921dbf05 100644 (file)
@@ -358,9 +358,12 @@ def config_make_list_parser(delimiter: str,
 
         for v in values:
             if not v:
-                new = []
                 continue
 
+            if v.startswith("!"):
+                v = v[1:]
+                new = [n for n in new if not fnmatch.fnmatchcase(v, n)]
+
             new.append(parse(v))
 
         return new
index 9d2710ebce9261a2c69c0686c1089e51b58dce02..2f86070085843a6c16ba4cf812bf45e1acfd706c 100644 (file)
@@ -272,8 +272,10 @@ setting. Also note that before v16, we used to do the opposite, where
 the earlier assignment would be used instead of later assignments.
 
 Settings that take a list of values are merged by appending the new
-values to the previously configured values. If a list setting is set to
-the empty list, all previously assigned values are cleared.
+values to the previously configured values. If a value of a list setting
+is prefixed with `!`, all existing instances of that value in the list
+are removed. Values prefixed with `!` can be globs to remove more than
+one value.
 
 To conditionally include configuration files, the `[Match]` section can
 be used. Matches can use a pipe symbol ("|") after the equals sign