]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Skip directories when generating checksums
authorMichael Ferrari <nekkodroid404@gmail.com>
Sat, 22 Jun 2024 09:38:23 +0000 (11:38 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 24 Jun 2024 10:02:58 +0000 (12:02 +0200)
It is possible that some directory is created by the user in
`mkosi.postoutput`, so just make sure to skip those as they can't be
hashed.

Also remove the check for directory output type as auxiliary files may
be created that should be hashed.

mkosi/__init__.py

index aa0b4b60bbcb320e4ce35a389ab8515661acb936..8545ed095109c7983405b015c6ad6ed95d89aa5a 100644 (file)
@@ -2653,12 +2653,13 @@ def calculate_sha256sum(context: Context) -> None:
     if not context.config.checksum:
         return
 
-    if context.config.output_format == OutputFormat.directory:
-        return
-
     with complete_step("Calculating SHA256SUMS…"):
         with open(context.workspace / context.config.output_checksum, "w") as f:
             for p in context.staging.iterdir():
+                if p.is_dir():
+                    logging.warning(f"Cannot checksum directory '{p}', skipping")
+                    continue
+
                 print(hash_file(p) + " *" + p.name, file=f)
 
         (context.workspace / context.config.output_checksum).rename(context.staging / context.config.output_checksum)
@@ -2668,9 +2669,6 @@ def calculate_signature(context: Context) -> None:
     if not context.config.sign or not context.config.checksum:
         return
 
-    if context.config.output_format == OutputFormat.directory:
-        return
-
     cmdline: list[PathString] = ["gpg", "--detach-sign"]
 
     # Need to specify key before file to sign