Skip to contentSkip to conversation

wic: remove partition images

PATCH Superseded Ed Bartosh 1 participant 2 messages Sep 22, 2016 – Sep 23, 2016

lore
Share & tools
lore

Ed Bartosh

author
#0 lore raw

PATCH 1/1 wic: remove partition images

Preserving images for every partition doubles disk space consumed by a build. As those images are not used it's better to remove them after assembling final image.

---
 scripts/lib/wic/utils/partitionedfs.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/lib/wic/utils/partitionedfs.py +1 -1
index 46b5d34..3dbf9a6 100644
@@ -351,7 +351,7 @@ class Image():
                             (source, part['num'], part['start'],
                              part['start'] + part['size'] - 1, part['size']))
 
-                os.rename(source, image_file + '.p%d' % part['num'])
+                os.unlink(source)
 
     def create(self):
         for dev in self.disks:
Signature · 1 line
2.1.4
author
#1 lore raw

PATCH v2 1/1 wic: remove partition images

Preserving images for every partition doubles disk space consumed by an image build. As those images are not used, so it's better to remove them after assembling final image.

---
 scripts/lib/wic/utils/partitionedfs.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
scripts/lib/wic/utils/partitionedfs.py +8 -1
index 46b5d34..cafb933 100644
@@ -43,6 +43,7 @@ class Image():
     def __init__(self, native_sysroot=None):
         self.disks = {}
         self.partitions = []
+        self.partimages = []
         # Size of a sector used in calculations
         self.sector_size = SECTOR_SIZE
         self._partitions_layed_out = False
@@ -336,6 +337,10 @@ class Image():
                     disk['disk'].cleanup()
                 except:
                     pass
+        # remove partition images
+        for image in self.partimages:
+            if os.path.isfile(image):
+                os.remove(image)
 
     def assemble(self, image_file):
         msger.debug("Installing partitions")
@@ -351,7 +356,9 @@ class Image():
                             (source, part['num'], part['start'],
                              part['start'] + part['size'] - 1, part['size']))
 
-                os.rename(source, image_file + '.p%d' % part['num'])
+                partimage = image_file + '.p%d' % part['num']
+                os.rename(source, partimage)
+                self.partimages.append(partimage)
 
     def create(self):
         for dev in self.disks:
Signature · 1 line
2.1.4