[projects/pld-builder.new] srpm_builder: publish a src.rpm only once copied out whole
arekm
arekm at pld-linux.org
Sat Nov 28 21:34:45 CET 2026
commit 037bbbdb7a6dd2a0d492f650797514fec18bc6b8
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Sat Nov 28 20:47:03 2026 +0100
srpm_builder: publish a src.rpm only once copied out whole
A copy out of the chroot failing halfway left a truncated src.rpm in
www/srpms, over one of the same name put there before.
PLD_Builder/srpm_builder.py | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/PLD_Builder/srpm_builder.py b/PLD_Builder/srpm_builder.py
index 49a5195..1882efc 100644
--- a/PLD_Builder/srpm_builder.py
+++ b/PLD_Builder/srpm_builder.py
@@ -73,14 +73,22 @@ def store_binary_request(r):
def transfer_file(r, b):
local = path.srpms_dir + '/' + r.id + "/" + b.src_rpm
- f = b.src_rpm_file
- # export files from chroot
+ # published under its name only once all there: a failed copy leaves a src.rpm put there before as it was.
+ # Not a hidden file, so util.clean_tmp() takes one left by a crash with the rest
+ tmp = None
try:
- chroot.cp(f, outfile = local, rm = True)
+ # a short name: a src.rpm name near the file name limit has no room for more
+ (fdno, tmp) = tempfile.mkstemp(dir=os.path.dirname(local), prefix="srpm-", suffix=".tmp")
+ os.close(fdno)
+ chroot.cp(b.src_rpm_file, outfile = tmp, rm = True)
+ os.chmod(tmp, 0o0644)
+ os.replace(tmp, local)
except OSError as e:
util.append_to(b.logfile, f"error: {e}")
+ if tmp:
+ with contextlib.suppress(OSError):
+ os.unlink(tmp)
return False
- os.chmod(local, 0o0644)
ftp.add(local)
if config.gen_upinfo and 'test-build' not in r.flags:
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/037bbbdb7a6dd2a0d492f650797514fec18bc6b8
More information about the pld-cvs-commit
mailing list