summaryrefslogtreecommitdiff
path: root/vmdebootstrap/filesystem.py
diff options
context:
space:
mode:
authorNeil Williams <codehelp@debian.org>2015-08-16 12:21:26 +0200
committerNeil Williams <codehelp@debian.org>2015-08-16 17:02:12 +0200
commit34252150c3ca24e1dc88712406f73f0a78d9ea55 (patch)
treead9168d67c4593d73e2758df793bb1b653a3bcf2 /vmdebootstrap/filesystem.py
parent9d776bb74654b80815fe08d87b5237e577ef1099 (diff)
downloadvmdebootstrap-34252150c3ca24e1dc88712406f73f0a78d9ea55.tar.gz
use a constants handler
Add support for using squashfs as an alternative to creating a tarball of a directory tree.
Diffstat (limited to 'vmdebootstrap/filesystem.py')
-rw-r--r--vmdebootstrap/filesystem.py32
1 files changed, 31 insertions, 1 deletions
diff --git a/vmdebootstrap/filesystem.py b/vmdebootstrap/filesystem.py
index 07ec9ca..ccc95a4 100644
--- a/vmdebootstrap/filesystem.py
+++ b/vmdebootstrap/filesystem.py
@@ -160,7 +160,37 @@ class Filesystem(Base):
elif self.settings['swap'] > 0:
fstab.write("/dev/sda2 swap swap defaults 0 0\n")
- def squash(self):
+ def squash_filesystem(self):
+ """
+ Run squashfs on the temporary directory
+ """
+ if not self.settings['squash']:
+ return
+ if self.settings['image']:
+ return
+ if not os.path.exists('/usr/bin/mksquashfs'):
+ logging.warning("Squash selected but mksquashfs not found!")
+ return
+ logging.debug(
+ "%s usage: %s", self.settings['image'],
+ runcmd(['du', self.settings['image']]))
+ self.message("Running mksquashfs")
+ output = self.settings['squash-file']
+ if os.path.exists(output):
+ os.unlink(output)
+ msg = runcmd(
+ ['mksquashfs', self.devices['rootdir'],
+ output, '-no-progress', '-comp', 'xz'], ignore_fail=False)
+ logging.debug(msg)
+ check_size = os.path.getsize(output)
+ if check_size < (1024 * 1024):
+ logging.warning(
+ "%s appears to be too small! %s bytes",
+ output, check_size)
+ else:
+ logging.debug("squashed size: %s", check_size)
+
+ def squash_image(self):
"""
Run squashfs on the image.
"""