diff options
author | Neil Williams <codehelp@debian.org> | 2015-11-05 16:38:55 +0000 |
---|---|---|
committer | Neil Williams <codehelp@debian.org> | 2015-11-05 16:38:55 +0000 |
commit | 261af90a7aad0a72c776235b462fa8d1bf312679 (patch) | |
tree | 6de62aa77b254be456528db705bf4eba08f10536 | |
parent | 0100446b4febb76cf96cfd9559d1d22d8dcd83aa (diff) | |
download | vmdebootstrap-261af90a7aad0a72c776235b462fa8d1bf312679.tar.gz |
Exclude dev, proc, sys and run from mksquashfs
-rw-r--r-- | vmdebootstrap/filesystem.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/vmdebootstrap/filesystem.py b/vmdebootstrap/filesystem.py index df3e7b5..a26145c 100644 --- a/vmdebootstrap/filesystem.py +++ b/vmdebootstrap/filesystem.py @@ -24,6 +24,7 @@ import os import cliapp import logging +import tempfile from vmdebootstrap.base import ( Base, runcmd, @@ -181,10 +182,18 @@ class Filesystem(Base): suffixed = os.path.join(self.settings['squash'], "filesystem.squashfs") if os.path.exists(suffixed): os.unlink(suffixed) + _, exclusions = tempfile.mkstemp() + with open(exclusions, 'w') as exclude: + exclude.write("/proc\n") + exclude.write("/dev\n") + exclude.write("/sys\n") + exclude.write("/run\n") self.message("Running mksquashfs on rootfs.") msg = runcmd( ['mksquashfs', self.devices['rootdir'], suffixed, - '-no-progress', '-comp', 'xz'], ignore_fail=False) + '-no-progress', '-comp', 'xz', + '-e', exclusions], ignore_fail=False) + os.unlink(exclusions) logging.debug(msg) check_size = os.path.getsize(suffixed) logging.debug("Created squashfs: %s", suffixed) |