← Back to team overview

curtin-dev team mailing list archive

[Merge] ~dbungert/curtin:no-wipe-ebr into curtin:master

 

Dan Bungert has proposed merging ~dbungert/curtin:no-wipe-ebr into curtin:master.

Commit message:
block/v2: fix wipe check for extended

As the comment in _wipe_for_action notes, we never want to wipe the
extended, so do that check first, in case someone specifies a wipe on an
extended.



Requested reviews:
  curtin developers (curtin-dev)

For more details, see:
https://code.launchpad.net/~dbungert/curtin/+git/curtin/+merge/430914
-- 
Your team curtin developers is requested to review the proposed merge of ~dbungert/curtin:no-wipe-ebr into curtin:master.
diff --git a/curtin/commands/block_meta_v2.py b/curtin/commands/block_meta_v2.py
index 2cb5bc4..d985f70 100644
--- a/curtin/commands/block_meta_v2.py
+++ b/curtin/commands/block_meta_v2.py
@@ -314,16 +314,16 @@ def _find_part_info(sfdisk_info, offset):
 
 
 def _wipe_for_action(action):
+    # New partitions are wiped by default apart from extended partitions, where
+    # it would destroy the EBR.
+    if action.get('flag') == 'extended':
+        return None
     # If a wipe action is specified, do that.
     if 'wipe' in action:
         return action['wipe']
     # Existing partitions are left alone by default.
     if action.get('preserve', False):
         return None
-    # New partitions are wiped by default apart from extended partitions, where
-    # it would destroy the EBR.
-    if action.get('flag') == 'extended':
-        return None
     return 'superblock'
 
 
diff --git a/tests/integration/test_block_meta.py b/tests/integration/test_block_meta.py
index f753a39..5f7434f 100644
--- a/tests/integration/test_block_meta.py
+++ b/tests/integration/test_block_meta.py
@@ -385,7 +385,8 @@ class TestBlockMeta(IntegrationTestCase):
         # curtin adds 1MiB to the size of the extend partition per contained
         # logical partition, but only in v1 mode
         size = '97M' if version == 1 else '99M'
-        config.add_part(size=size, number=1, flag='extended')
+        config.add_part(size=size, number=1, flag='extended',
+                        wipe='superblock')
         config.add_part(size='10M', number=5, flag='logical')
         config.add_part(size='10M', number=6, flag='logical')
         self.run_bm(config.render())

Follow ups