diff options
-rw-r--r-- | morphlib/stagingarea.py | 20 | ||||
-rw-r--r-- | morphlib/stagingarea_tests.py | 19 |
2 files changed, 29 insertions, 10 deletions
diff --git a/morphlib/stagingarea.py b/morphlib/stagingarea.py index 31fb8410..c8b53bd3 100644 --- a/morphlib/stagingarea.py +++ b/morphlib/stagingarea.py @@ -93,16 +93,20 @@ class StagingArea(object): logging.debug('Installing artifact %s' % getattr(handle, 'name', 'unknown name')) - decompressed_artifact = os.path.join(self._app.settings['cachedir'],'artifacts',os.path.basename(handle.name) + '.d') - if not os.path.exists(decompressed_artifact): - self._mkdir(decompressed_artifact) - morphlib.bins.unpack_binary_from_file(handle, decompressed_artifact + "/") + unpacked_artifact = os.path.join( + self._app.settings['cachedir'], + 'artifacts', + os.path.basename(handle.name) + '.d') + if not os.path.exists(unpacked_artifact): + self._mkdir(unpacked_artifact) + morphlib.bins.unpack_binary_from_file( + handle, unpacked_artifact + '/') if not os.path.exists(self.dirname): self._mkdir(self.dirname) - self._app.runcmd(["cp -al " + decompressed_artifact+"/* " + self.dirname+"/"],shell=True) - + self._app.runcmd( + ['cp', '-al', unpacked_artifact + '/.', self.dirname + '/.']) def remove(self): '''Remove the entire staging area. @@ -115,7 +119,7 @@ class StagingArea(object): shutil.rmtree(self.dirname) - def chroot_open(self, source): + def chroot_open(self, source): # pragma: no cover # After setup, and before it's use as a chroot assert self.builddirname == None and self.destdirname == None @@ -132,7 +136,7 @@ class StagingArea(object): return builddir, destdir - def chroot_close(self): + def chroot_close(self): # pragma: no cover # After it's use as a chroot is complete. pass diff --git a/morphlib/stagingarea_tests.py b/morphlib/stagingarea_tests.py index 3230b9e3..15131272 100644 --- a/morphlib/stagingarea_tests.py +++ b/morphlib/stagingarea_tests.py @@ -14,6 +14,7 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +import cliapp import os import shutil import tarfile @@ -31,14 +32,28 @@ class FakeSource(object): } +class FakeApplication(object): + + def __init__(self, cachedir): + self.settings = { + 'cachedir': cachedir, + } + + def runcmd(self, *args, **kwargs): + cliapp.runcmd(*args, **kwargs) + + class StagingAreaTests(unittest.TestCase): def setUp(self): self.tempdir = tempfile.mkdtemp() + self.cachedir = os.path.join(self.tempdir, 'cachedir') + os.mkdir(self.cachedir) + os.mkdir(os.path.join(self.cachedir, 'artifacts')) self.staging = os.path.join(self.tempdir, 'staging') self.created_dirs = [] - self.sa = morphlib.stagingarea.StagingArea(object(), self.staging, - self.staging) + self.sa = morphlib.stagingarea.StagingArea( + FakeApplication(self.cachedir), self.staging, self.staging) def tearDown(self): shutil.rmtree(self.tempdir) |