From d5ff9c77a391cb5d0e35e0a06643e963aec4e5f4 Mon Sep 17 00:00:00 2001 From: Viktor Dick Date: Mon, 5 Jan 2026 15:50:05 +0100 Subject: [PATCH] Fix source unpacking --- CHANGELOG | 4 ++++ perfact/zodbsync/subcommand.py | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 9f07cac..43c0503 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +25.3.1 + * Create target folder before extracting tar files + * Work around Debian sometimes keeping around files + 25.3.0 * Unpack or copy over additional folders besides __root__ in layer-update * Allow switching over to using tars for layer source without changing the diff --git a/perfact/zodbsync/subcommand.py b/perfact/zodbsync/subcommand.py index 3baa39f..ed6215f 100644 --- a/perfact/zodbsync/subcommand.py +++ b/perfact/zodbsync/subcommand.py @@ -111,12 +111,19 @@ def unpack_source(src, tgt): unpacked, both removing superfluous files in the target. """ targetitems = [] - for entry in os.listdir(src): + srcitems = os.listdir(src) + for entry in srcitems: if entry.startswith('.'): continue path = f'{src}/{entry}' if os.path.isdir(path): # p.e. __root__ or __schema__ as folders + # Sometimes, there might be some residual folder with .dpkg-new + # files or similar, even though this is now supplied as file. + other = [other for other in srcitems + if other.startswith(entry) and other != entry] + if other: + continue targetitems.append(entry) cmd = ['rsync', '-a', '--delete-during', f'{path}/', f'{tgt}/{entry}/'] @@ -124,6 +131,7 @@ def unpack_source(src, tgt): # p.e. __root__.tar.gz -> Unpack to __root__/ basename = entry.split('.')[0] targetitems.append(basename) + os.makedirs(f'{tgt}/{basename}', exist_ok=True) cmd = ['tar', 'xf', path, '-C', f'{tgt}/{basename}/', '--recursive-unlink'] subprocess.run(cmd, check=True)