From 5956d6dd468a437b5ad21c5fe5573753039783f9 Mon Sep 17 00:00:00 2001 From: ipavlin98 Date: Tue, 10 Nov 2026 21:08:37 +0300 Subject: [PATCH] Unpack a release archive again when its pin changes instead of reusing the old archive's files --- tools/make_release.py | 8 +++++--- tools/make_release_linux.py | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/make_release.py b/tools/make_release.py index 5114d6e1..0f39e959 100644 --- a/tools/make_release.py +++ b/tools/make_release.py @@ -168,10 +168,12 @@ def fetch(name): def unpack(name, member_filter=None): - """Extract a pinned archive into toolchain/release-work/ (once) and return that directory.""" + """Extract a pinned archive into toolchain/release-work/ and return that directory. The stamp holds the pin's + sha256, so a bumped pin unpacks its new archive instead of reusing the old one's files.""" dest = WORK / name stamp = dest / '.unpacked' - if stamp.is_file(): + key = PINS[name][1] + if stamp.is_file() and stamp.read_text() == key: return dest shutil.rmtree(dest, ignore_errors=True) dest.mkdir(parents=True) @@ -182,7 +184,7 @@ def unpack(name, member_filter=None): else: with tarfile.open(path) as t: t.extractall(dest, filter='data') - stamp.write_text('') + stamp.write_text(key) return dest diff --git a/tools/make_release_linux.py b/tools/make_release_linux.py index 10a62204..c1bcbd9d 100644 --- a/tools/make_release_linux.py +++ b/tools/make_release_linux.py @@ -103,9 +103,11 @@ def run(cmd, **kw): def tar_extract(name, dest, members, strip=0): - """Extract only members (path prefixes inside the archive) of a pinned tarball with the system tar, once.""" + """Extract only members (path prefixes inside the archive) of a pinned tarball with the system tar. The stamp holds + the pin's sha256 and the members, so a bumped pin or a changed member list extracts again.""" stamp = dest / '.unpacked' - if stamp.is_file(): + key = '\n'.join((mr.PINS[name][1], str(strip), *members)) + if stamp.is_file() and stamp.read_text() == key: return dest shutil.rmtree(dest, ignore_errors=True) dest.mkdir(parents=True) @@ -114,7 +116,7 @@ def tar_extract(name, dest, members, strip=0): run(['tar', '-xf', path, '-C', dest, f'--strip-components={strip}', '--wildcards', '--no-wildcards-match-slash', *members]) print(f'{name}: unpacked in {time.time() - t0:.0f} s') - stamp.write_text('') + stamp.write_text(key) return dest