]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Force initializing the partition table every time create_image is called
authorMichael A Cassaniti <michael@cassaniti.id.au>
Thu, 21 Jul 2022 08:11:28 +0000 (18:11 +1000)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 27 Jul 2022 11:19:28 +0000 (13:19 +0200)
When creating the build and final images `args.partition_table` is not
re-initialized which results in a mismatch between the on disk partition
layout and the records in memory.

Also added is some testing for UsrOnly.

.github/workflows/ci.yml
mkosi/__init__.py
mkosi/gentoo.py

index dd841778724037663c66ce894b905a8b72db3951..3863afa7722fb67942acfe002de0f182d70ac169 100644 (file)
@@ -184,6 +184,15 @@ jobs:
 
         sudo MKOSI_TEST_DEFAULT_VERB=boot python3 -m pytest -m integration -sv tests
 
+    - name: Build ${{ matrix.distro }}/${{ matrix.format }} UsrOnly
+      run: |
+        tee mkosi.default <<- EOF
+        [Output]
+        UsrOnly=True
+        EOF
+
+        sudo mkosi --force build
+
     - name: Build/Boot ${{ matrix.distro }}/${{ matrix.format }} UEFI UKI
       run: |
         tee mkosi.default <<- EOF
index fcece22e1d65a6e3d53c6e7f464e8091f9c2f1c0..04991b17dabdc085210c15ec990c64de0754cbf0 100644 (file)
@@ -769,8 +769,8 @@ def root_partition_description(
     return prefix + ' ' + (suffix if suffix is not None else 'Partition')
 
 
-def initialize_partition_table(args: MkosiArgs) -> None:
-    if args.partition_table is not None:
+def initialize_partition_table(args: MkosiArgs, force: bool = False) -> None:
+    if args.partition_table is not None and not force:
         return
 
     if not args.output_format.is_disk():
@@ -809,7 +809,7 @@ def initialize_partition_table(args: MkosiArgs) -> None:
 
 
 def create_image(args: MkosiArgs, for_cache: bool) -> Optional[BinaryIO]:
-    initialize_partition_table(args)
+    initialize_partition_table(args, force=True)
     if args.partition_table is None:
         return None
 
index 6e48e07123a14b8eb50092345c1eb463a4415f22..435fb5d0b7e29b208aca5f3abdc56bf6f0a1fff9 100644 (file)
@@ -20,6 +20,7 @@ from .backend import (
     OutputFormat,
     PartitionIdentifier,
     die,
+    root_home,
     run_workspace_command,
 )
 
@@ -501,6 +502,8 @@ class Gentoo:
                                     f"actions={actions} outside stage3")
             emerge_main([*pkgs, *opts, *actions] + PREFIX_OPTS + self.emerge_default_opts)
         else:
+            if args.usr_only:
+                root_home(args, root).mkdir(mode=0o750, exist_ok=True)
 
             cmd = ["/usr/bin/emerge", *pkgs, *self.emerge_default_opts, *opts, *actions]