summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/virtBootstrap/sources/docker_source.py21
-rw-r--r--tests/docker_source.py6
2 files changed, 22 insertions, 5 deletions
diff --git a/src/virtBootstrap/sources/docker_source.py b/src/virtBootstrap/sources/docker_source.py
index 715e560..5b6378f 100644
--- a/src/virtBootstrap/sources/docker_source.py
+++ b/src/virtBootstrap/sources/docker_source.py
@@ -107,7 +107,7 @@ class DockerSource(object):
self.checksums.append([sum_type, layer_sum]) # Store checksums
# Layers are tar files with hashsum used as name
- file_path = os.path.join(self.images_dir, layer_sum + '.tar')
+ file_path = os.path.join(self.images_dir, layer_sum)
# Store 'file path' and set placeholder for 'size'
self.layers.append([file_path, None])
@@ -158,6 +158,17 @@ class DockerSource(object):
utils.copytree(dest_dir, self.images_dir)
shutil.rmtree(dest_dir)
+ # Old versions of skopeo use '.tar' extension to blobs.
+ # Make sure we use the correct file name.
+ for i in range(len(self.layers)):
+ path = self.layers[i][0]
+ if not os.path.exists(path):
+ if os.path.exists(path + '.tar'):
+ self.layers[i][0] += '.tar'
+ else:
+ raise ValueError('Blob %s does not exist.' % path)
+
+
def parse_output(self, proc):
"""
Read stdout from skopeo's process asynchconosly.
@@ -258,8 +269,14 @@ class DockerSource(object):
sum_type, sum_expected = checksum
logger.debug("Checking layer: %s", path)
- if not (os.path.exists(path)
+ if (os.path.exists(path)
and utils.checksum(path, sum_type, sum_expected)):
+ continue
+ if (not path.endswith('.tar')
+ and os.path.exists(path + '.tar')
+ and utils.checksum(path + '.tar', sum_type, sum_expected)):
+ self.layers[index][0] += '.tar'
+ else:
return False
return True
diff --git a/tests/docker_source.py b/tests/docker_source.py
index 0521322..585b9d2 100644
--- a/tests/docker_source.py
+++ b/tests/docker_source.py
@@ -368,9 +368,9 @@ class TestDockerSource(unittest.TestCase):
}
expected_result = [
- ['/images_path/a7050fc1.tar', None],
- ['/images_path/c6ff40b6.tar', None],
- ['/images_path/75c416ea.tar', None]
+ ['/images_path/a7050fc1', None],
+ ['/images_path/c6ff40b6', None],
+ ['/images_path/75c416ea', None]
]
with mock.patch('os.path.getsize') as m_getsize: