diff --git a/imagegw/shifter_imagegw/dockerv2.py b/imagegw/shifter_imagegw/dockerv2.py index f3678a4b..87ef3b98 100755 --- a/imagegw/shifter_imagegw/dockerv2.py +++ b/imagegw/shifter_imagegw/dockerv2.py @@ -622,6 +622,10 @@ def filter_layer(layer_members, to_remove): # get directory of tar contents members = tfp.getmembers() + # Normalize paths + for x in members: + if x.name[0:2] == './': + x.name = x.name[2:] # remove all illegal files members = filter_layer(members, 'dev/') members = filter_layer(members, '/') diff --git a/imagegw/test/dockerv2_test.py b/imagegw/test/dockerv2_test.py index 0c6c7ca5..19ada049 100644 --- a/imagegw/test/dockerv2_test.py +++ b/imagegw/test/dockerv2_test.py @@ -105,6 +105,18 @@ def test_chgtype(self): bfile = os.path.join(resp['expandedpath'], 'build/test2') assert os.path.exists(bfile) + def test_import(self): + cache = tempfile.mkdtemp() + expand = tempfile.mkdtemp() + self.cleanpaths.append(cache) + self.cleanpaths.append(expand) + + resp = dockerv2.pull_image(self.options, 'scanon/importtest', 'latest', + cachedir=cache, expanddir=expand) + assert os.path.exists(resp['expandedpath']) + bfile = os.path.join(resp['expandedpath'], 'home') + self.assertTrue(os.path.islink(bfile)) + def test_need_proxy(self): """ Test if proxy is needed