summaryrefslogtreecommitdiff
path: root/vmdebootstrap
diff options
context:
space:
mode:
authorNeil Williams <codehelp@debian.org>2015-11-05 14:39:41 +0000
committerNeil Williams <codehelp@debian.org>2015-11-05 14:39:41 +0000
commit0df079707118df72ba1131f53ace18d1561e0d17 (patch)
tree08a037cafc1ca3dd3d65b693e8d54fb91736dddb /vmdebootstrap
parente5987ce7b617b36935aeea406145078981fc1dca (diff)
downloadvmdebootstrap-0df079707118df72ba1131f53ace18d1561e0d17.tar.gz
Move copy_file functionality into base.
Diffstat (limited to 'vmdebootstrap')
-rw-r--r--vmdebootstrap/base.py10
-rw-r--r--vmdebootstrap/filesystem.py16
2 files changed, 17 insertions, 9 deletions
diff --git a/vmdebootstrap/base.py b/vmdebootstrap/base.py
index 279e5bc..0a302a4 100644
--- a/vmdebootstrap/base.py
+++ b/vmdebootstrap/base.py
@@ -22,6 +22,7 @@
import os
import crypt
+import shutil
import cliapp
import logging
import subprocess
@@ -74,6 +75,15 @@ def delete_password(rootdir, user):
runcmd(['chroot', rootdir, 'passwd', '-d', user])
+def copy_files(src, dest):
+ for filename in os.listdir(src):
+ if os.path.isdir(filename) or os.path.islink(filename):
+ continue
+ shutil.copyfile(
+ os.path.join(src, filename),
+ os.path.join(dest, filename))
+
+
class Base(object):
name = 'base'
diff --git a/vmdebootstrap/filesystem.py b/vmdebootstrap/filesystem.py
index 23c7fef..df3e7b5 100644
--- a/vmdebootstrap/filesystem.py
+++ b/vmdebootstrap/filesystem.py
@@ -22,10 +22,13 @@
import os
-import shutil
import cliapp
import logging
-from vmdebootstrap.base import Base, runcmd
+from vmdebootstrap.base import (
+ Base,
+ runcmd,
+ copy_files
+)
# pylint: disable=missing-docstring
@@ -184,7 +187,7 @@ class Filesystem(Base):
'-no-progress', '-comp', 'xz'], ignore_fail=False)
logging.debug(msg)
check_size = os.path.getsize(suffixed)
- logging.debug("Created squashfs: %s" % suffixed)
+ logging.debug("Created squashfs: %s", suffixed)
if check_size < (1024 * 1024):
logging.warning(
"%s appears to be too small! %s bytes",
@@ -194,12 +197,7 @@ class Filesystem(Base):
bootdir = os.path.join(self.devices['rootdir'], 'boot')
# copying the boot/* files
self.message("Copying boot files out of squashfs")
- for filename in os.listdir(bootdir):
- if os.path.isdir(filename) or os.path.islink(filename):
- continue
- shutil.copyfile(
- os.path.join(bootdir, filename),
- os.path.join(self.settings['squash'], filename))
+ copy_files(bootdir, self.settings['squash'])
def configure_apt(self):
rootdir = self.devices['rootdir']