summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-05-07 16:11:28 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-05-08 09:28:39 +0000
commit15c82afd22557d8ecc48d5048c70012c4eef2044 (patch)
tree5ac07d01da5822d3472195afe6ffeec055c7ea11
parent4cef8436cf3f38e2927950c495fc860175bb724a (diff)
downloadmorph-15c82afd22557d8ecc48d5048c70012c4eef2044.tar.gz
Rework previous patch
-rw-r--r--morphlib/bins.py12
-rw-r--r--morphlib/builder2.py12
2 files changed, 11 insertions, 13 deletions
diff --git a/morphlib/bins.py b/morphlib/bins.py
index d1a90657..2373ae0f 100644
--- a/morphlib/bins.py
+++ b/morphlib/bins.py
@@ -91,13 +91,21 @@ def create_chunk(rootdir, f, include, dump_memory_profile=None):
dump_memory_profile('after removing in create_chunks')
-def create_system(rootdir, f, name=None, filter=None):
+def create_system(rootdir, f, name):
'''Create a system artifact from the contents of a directory.
'''
+ unslashy_root = rootdir[1:]
+ def uproot_info(info):
+ '''Strip rootdir from a file's path before adding to a tarfile.'''
+ info.name = os.path.relpath(info.name, unslashy_root)
+ if info.islnk():
+ info.linkname = os.path.relpath(info.linkname, unslashy_root)
+ return info
+
tar = tarfile.open(fileobj=f, mode="w", name=name)
- tar.add(rootdir, recursive=True, filter=filter)
+ tar.add(rootdir, recursive=True, filter=uproot_info)
tar.close()
diff --git a/morphlib/builder2.py b/morphlib/builder2.py
index 02e8b485..e3b7df07 100644
--- a/morphlib/builder2.py
+++ b/morphlib/builder2.py
@@ -20,7 +20,6 @@ import errno
import json
import logging
import os
-from os.path import relpath
import shutil
import stat
import tarfile
@@ -590,19 +589,10 @@ class SystemBuilder(BuilderBase): # pragma: no cover
self.write_metadata(fs_root, rootfs_name)
self.run_system_integration_commands(fs_root)
self.copy_kernel_into_artifact_cache(fs_root)
- unslashy_root = fs_root[1:]
- def uproot_info(info):
- info.name = relpath(info.name, unslashy_root)
- if info.islnk():
- info.linkname = relpath(info.linkname,
- unslashy_root)
- return info
artiname = self.artifact.source.morphology['name']
- tar = tarfile.open(fileobj=handle, mode="w", name=artiname)
self.app.status(msg='Constructing tarball of root filesystem',
chatty=True)
- tar.add(fs_root, recursive=True, filter=uproot_info)
- tar.close()
+ morphlib.bins.create_system(fs_root, handle, artiname)
except BaseException, e:
logging.error(traceback.format_exc())
self.app.status(msg='Error while building system',