← Back to team overview

curtin-dev team mailing list archive

[Merge] ~laiderlai/curtin:oem into curtin:master

 

Laider Lai has proposed merging ~laiderlai/curtin:oem into curtin:master.

Commit message:
For Ubuntu OEM images, it's a preinstallation format.
The image already includes
 - Partition layout
 - Cloud-init configurations
 - Some necessary configurations
    
Therefore, we should make curtin can identify it and
handle it as a special case to skip hook operations.

Requested reviews:
  curtin developers (curtin-dev)

For more details, see:
https://code.launchpad.net/~laiderlai/curtin/+git/curtin/+merge/475096

[A document to introduce why we trigger this PR]
https://docs.google.com/document/d/1AKRlGRu28XqhRrjP2hJd-l-SOQ9M1UWB3od1Kdj_fTk/edit?tab=t.0

[tox test result]
  py3-flake8: commands succeeded
  py3: commands succeeded
  py3-pyflakes: commands succeeded
  py3-pylint: commands succeeded
  block-schema: commands succeeded
  congratulations :)

[Sucessfully operate log]
---- [[ subiquity step extract ]] ----
curtin: Installation started. (24.0.0-55-g6c9cae2d3)
start: cmd-install/stage-extract/builtin/cmd-extract: curtin command extract
Installing sources: [{'type': 'dd-xz', 'uri': 'file:///cdrom/casper/xxx.img.xz'}] to target at /target
start: cmd-install/stage-extract/builtin/cmd-extract: acquiring and extracting image from file:///cdrom/casper/xxx.img.xz
finish: cmd-install/stage-extract/builtin/cmd-extract: SUCCESS: acquiring and extracting image from file:///cdrom/casper/xxx.img.xz
Applying write_files from config.
finish: cmd-install/stage-extract/builtin/cmd-extract: SUCCESS: curtin command extract
curtin: Installation finished.

---- [[ subiquity step curthooks ]] ----
curtin: Installation started. (24.0.0-55-g6c9cae2d3)
start: cmd-install/stage-curthooks/builtin/cmd-curthooks: curtin command curthooks
Detected Ubuntu OEM image, skip hooks
finish: cmd-install/stage-curthooks/builtin/cmd-curthooks: SUCCESS: curtin command curthooks
curtin: Installation finished.
-- 
Your team curtin developers is requested to review the proposed merge of ~laiderlai/curtin:oem into curtin:master.
diff --git a/curtin/commands/block_meta.py b/curtin/commands/block_meta.py
index 7506c4a..ea5472b 100644
--- a/curtin/commands/block_meta.py
+++ b/curtin/commands/block_meta.py
@@ -188,7 +188,8 @@ def write_image_to_disk(source, dev):
     # /curtin -> Most Ubuntu Images
     # /system-data/var/lib/snapd -> UbuntuCore 16 or 18
     # /snaps -> UbuntuCore20
-    paths = ["curtin", "system-data/var/lib/snapd", "snaps"]
+    # /.disk -> UbuntuOEM
+    paths = ["curtin", "system-data/var/lib/snapd", "snaps", ".disk"]
     return block.get_root_device([devname], paths=paths)
 
 
diff --git a/curtin/commands/curthooks.py b/curtin/commands/curthooks.py
index 4bc3614..46298bd 100644
--- a/curtin/commands/curthooks.py
+++ b/curtin/commands/curthooks.py
@@ -2091,6 +2091,10 @@ def curthooks(args):
                 description="Configuring Ubuntu-Core for first boot"):
             ubuntu_core_curthooks(cfg, target)
         sys.exit(0)
+    # OEM is special too, handle it.
+    elif distro.is_ubuntu_oem(target):
+        LOG.info('Detected Ubuntu OEM image, skip hooks')
+        sys.exit(0)
 
     # user asked for target, or auto mode
     if curthooks_mode in ['auto', 'target']:
diff --git a/curtin/distro.py b/curtin/distro.py
index e6e13d5..c7639ad 100644
--- a/curtin/distro.py
+++ b/curtin/distro.py
@@ -163,6 +163,11 @@ def is_ubuntu_core_20(target=None):
     return os.path.exists(target_path(target, 'snaps'))
 
 
+def is_ubuntu_oem(target=None):
+    """Check if Ubuntu OEM specific file is present at target"""
+    return os.path.exists(target_path(target, '.disk/info'))
+
+
 def is_centos(target=None):
     """Check if CentOS specific file is present at target"""
     return os.path.exists(target_path(target, 'etc/centos-release'))
diff --git a/tests/unittests/test_commands_block_meta.py b/tests/unittests/test_commands_block_meta.py
index a5ccac1..09c3c7f 100644
--- a/tests/unittests/test_commands_block_meta.py
+++ b/tests/unittests/test_commands_block_meta.py
@@ -456,7 +456,7 @@ class TestBlockMetaSimple(CiTestCase):
                                          call(['udevadm', 'trigger', devnode]),
                                          call(['udevadm', 'settle']),
                                          call(['udevadm', 'settle'])])
-        paths = ["curtin", "system-data/var/lib/snapd", "snaps"]
+        paths = ["curtin", "system-data/var/lib/snapd", "snaps", ".disk"]
         self.mock_block_get_root_device.assert_called_with([devname],
                                                            paths=paths)
 
@@ -483,7 +483,7 @@ class TestBlockMetaSimple(CiTestCase):
                                          call(['udevadm', 'trigger', devnode]),
                                          call(['udevadm', 'settle']),
                                          call(['udevadm', 'settle'])])
-        paths = ["curtin", "system-data/var/lib/snapd", "snaps"]
+        paths = ["curtin", "system-data/var/lib/snapd", "snaps", ".disk"]
         self.mock_block_get_root_device.assert_called_with([devname],
                                                            paths=paths)
 
@@ -509,7 +509,7 @@ class TestBlockMetaSimple(CiTestCase):
                                          call(['udevadm', 'trigger', devnode]),
                                          call(['udevadm', 'settle']),
                                          call(['udevadm', 'settle'])])
-        paths = ["curtin", "system-data/var/lib/snapd", "snaps"]
+        paths = ["curtin", "system-data/var/lib/snapd", "snaps", ".disk"]
         self.mock_block_get_root_device.assert_called_with([devname],
                                                            paths=paths)
 

Follow ups