]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
postmarketos: Coding style fixes
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 24 Sep 2025 08:44:08 +0000 (10:44 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 24 Sep 2025 08:48:58 +0000 (10:48 +0200)
Use similar variable names as we use elsewhere instead of the verbose
variable names that stick out like a sore thumb.

mkosi/distributions/postmarketos.py
mkosi/installer/apk.py

index 2404be30e82eea970b92af1eb3ef35552186147a..a5fa17ddd2a58adc85ce3e098f017f6fc3a626a7 100644 (file)
@@ -39,11 +39,9 @@ class Installer(DistributionInstaller):
     @classmethod
     def setup(cls, context: Context) -> None:
         with complete_step("Setting up postmarketOS keyring"):
-            # Create keys directory in sandbox
-            keys_dir = context.sandbox_tree / "etc/apk/keys"
-            keys_dir.mkdir(parents=True, exist_ok=True)
+            keys = context.sandbox_tree / "etc/apk/keys"
+            keys.mkdir(parents=True, exist_ok=True)
 
-            # Copy keys from various sources (if they exist)
             for d in [
                 context.config.tools() / "usr/lib/apk/keys",
                 context.config.tools() / "usr/share/distribution-gpg-keys/alpine-linux",
@@ -51,13 +49,17 @@ class Installer(DistributionInstaller):
             ]:
                 if not d.exists():
                     continue
-                # Preserve/do not overwrite keys in keys_dir that already exist
+
+                # Do not overwrite keys in /etc/apk/keys to make sure that user provided keys take priority.
                 for key in d.iterdir():
-                    if key.is_file():
-                        dest = keys_dir / key.name
-                        if dest.exists():
-                            continue
-                        shutil.copy2(key, dest)
+                    if key.is_dir():
+                        continue
+
+                    dest = keys / key.name
+                    if dest.exists():
+                        continue
+
+                    shutil.copy2(key, dest)
 
         Apk.setup(context, list(cls.repositories(context)))
 
@@ -92,13 +94,8 @@ class Installer(DistributionInstaller):
         mirror = context.config.mirror or "https://mirror.postmarketos.org/postmarketos"
         subdir = "master" if context.config.release == "edge" else f"v{context.config.release}"
 
-        # systemd repo
-        url = f"{mirror}/extra-repos/systemd/{subdir}"
-        yield ApkRepository(url=url)
-
-        # main repo
-        url = f"{mirror}/{subdir}"
-        yield ApkRepository(url=url)
+        yield ApkRepository(url=f"{mirror}/extra-repos/systemd/{subdir}")
+        yield ApkRepository(url=f"{mirror}/{subdir}")
 
     @classmethod
     def architecture(cls, arch: Architecture) -> str:
index 5f31ec140f9a14e2d457dfc05ae5a6391c24e107..541380715063f24e46537965d63a94c3f0553e8b 100644 (file)
@@ -44,7 +44,6 @@ class Apk(PackageManager):
             return
 
         config.parent.mkdir(exist_ok=True, parents=True)
-
         config.write_text("\n".join(repo.url for repo in repositories) + "\n")
 
     @classmethod
@@ -98,14 +97,18 @@ class Apk(PackageManager):
         apivfs: bool = True,
         allow_downgrade: bool = False,
     ) -> None:
-        arguments = [
-            "--initdb",
-            "--upgrade",
-            # effectively disable refreshing the cache in this situation
-            "--cache-max-age", "999999999",
-            *packages,
-        ]  # fmt: skip
-        cls.invoke(context, "add", arguments, apivfs=apivfs)
+        cls.invoke(
+            context,
+            "add",
+            [
+                "--initdb",
+                "--upgrade",
+                # effectively disable refreshing the cache in this situation
+                "--cache-max-age", "999999999",
+                *packages,
+            ],
+            apivfs=apivfs,
+        )  # fmt: skip
 
     @classmethod
     def remove(cls, context: Context, packages: Sequence[str]) -> None: