summaryrefslogtreecommitdiffstats
path: root/src/virtBootstrap/sources/docker_source.py
diff options
context:
space:
mode:
authorRadostin Stoyanov <rstoyanov1@gmail.com>2018-04-24 09:03:34 +0100
committerRadostin Stoyanov <rstoyanov1@gmail.com>2018-04-28 23:14:55 +0100
commitf389756a192b6b6ad0951856d8681cc2077ccf6b (patch)
tree37d641bfa3772dafaf8d76b5f86ee345af59a91d /src/virtBootstrap/sources/docker_source.py
parent0f2cbd130965f8f0e3b859779c9a6249ebf07aff (diff)
downloadvirt-bootstrap.git-f389756a192b6b6ad0951856d8681cc2077ccf6b.tar.gz
virt-bootstrap.git-f389756a192b6b6ad0951856d8681cc2077ccf6b.tar.xz
virt-bootstrap.git-f389756a192b6b6ad0951856d8681cc2077ccf6b.zip
docker-source: Support blobs without .tar ext
Since skopeo v0.1.29 [1] blobs are saved without the .tar extension. This commit changes the docker-source module to handle both cases (with or without .tar extension) [1] commit: projectatomic/skopeo@43acc74 Fix skopeo tests with changes to dir transport The dir transport has been changed to save the blobs without the .tar extension Fixes the skopeo tests failing due to this change Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
Diffstat (limited to 'src/virtBootstrap/sources/docker_source.py')
-rw-r--r--src/virtBootstrap/sources/docker_source.py21
1 files changed, 19 insertions, 2 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