From f389756a192b6b6ad0951856d8681cc2077ccf6b Mon Sep 17 00:00:00 2001 From: Radostin Stoyanov Date: Tue, 24 Apr 2018 09:03:34 +0100 Subject: 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 --- src/virtBootstrap/sources/docker_source.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/virtBootstrap/sources/docker_source.py') 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 -- cgit