Skip to content

Commit a323b7f

Browse files
committed
Merge branch 'removing-tar--delete' into 'master'
chore: (processm.tools) removing tar --delete from export_pruned_image See merge request processm-team/processm!331 Former-commit-id: 61a0c79d0a35ab5bad7c8914cf740c0273a15059
2 parents 9c8eeba + 0564290 commit a323b7f

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

processm.tools/src/main/python/export_pruned_image.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ def get_blobs(image: str) -> list[str]:
1515

1616

1717
def exclude_blobs(image: str, exclude: list[str]):
18+
exclude = set(exclude)
1819
with subprocess.Popen(["docker", "save", image], stdout=subprocess.PIPE) as docker, \
19-
subprocess.Popen(["tar", "--delete", '--no-xattrs'] + exclude, stdin=docker.stdout,
20-
stderr=subprocess.DEVNULL):
21-
# This error redirection is ugly, but tar spams with information that a member was not found in the archive
22-
pass
20+
tarfile.open(mode="r|", fileobj=docker.stdout) as intar, \
21+
tarfile.open(mode="w|", fileobj=sys.stdout.buffer) as outtar:
22+
while (item := intar.next()) is not None:
23+
if item.name not in exclude:
24+
outtar.addfile(item, fileobj=intar.extractfile(item))
2325

2426

2527
def main(base_image: str, reference_images: list[str]):

0 commit comments

Comments
 (0)