[projects/pld-ftp-admin] pfa-genindex: exit with 1 when an index tool fails
arekm
arekm at pld-linux.org
Tue Oct 27 10:56:12 CET 2026
commit ed731f07f41926b9d169fe6bc09050239fd154b6
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Mon Oct 26 23:21:48 2026 +0100
pfa-genindex: exit with 1 when an index tool fails
The exit status of poldek, createrepo_c and the comps.xml checkout was
ignored, so a failed index went unnoticed. The other indexes are still
built and each failure is listed on stderr at the end.
bin/pfa-genindex | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/bin/pfa-genindex b/bin/pfa-genindex
index 798dfda..0eed1ea 100755
--- a/bin/pfa-genindex
+++ b/bin/pfa-genindex
@@ -86,6 +86,16 @@ home = os.environ['HOME']
os.umask(0o022)
os.nice(19)
+failed = []
+
+
+def run(what, cmd):
+ # keep building the other indexes; every failure is reported at the end
+ rc = os.waitstatus_to_exitcode(os.system(cmd))
+ if rc != 0:
+ failed.append(f'{what} exited with {rc}')
+
+
if do_poldek:
poldek = f'{ftp_dir}.stat/bin/poldek-new --cachedir={home}/tmp/poldek --conf {ftp_dir}.stat/etc/poldek.conf --mkidxz'
@@ -94,12 +104,12 @@ if do_poldek:
for arch in all_ftp_archs:
print(f'\ngenerate poldek index for {arch}')
print(f'{poldek} -s {ftp_dir}{tree}/{arch}/RPMS/ --mkidxz --mkidx-type pndir')
- os.system(f'{poldek} -s {ftp_dir}{tree}/{arch}/RPMS/ --mkidxz --mkidx-type pndir')
+ run(f'{tree}/{arch}: poldek', f'{poldek} -s {ftp_dir}{tree}/{arch}/RPMS/ --mkidxz --mkidx-type pndir')
if arch != 'noarch' and config.separate_debuginfo:
- os.system(f'{poldek} -s {ftp_dir}{tree}/{arch}/debuginfo/ --mkidxz --mkidx-type pndir')
+ run(f'{tree}/{arch}: poldek', f'{poldek} -s {ftp_dir}{tree}/{arch}/debuginfo/ --mkidxz --mkidx-type pndir')
if do_yum:
- os.system(f'{"" if quiet else "set -x;"} cd {ftp_dir}.stat/repodata && git checkout {"--quiet" if quiet else ""} HEAD repodata/comps.xml')
+ run('comps.xml checkout', f'{"" if quiet else "set -x;"} cd {ftp_dir}.stat/repodata && git checkout {"--quiet" if quiet else ""} HEAD repodata/comps.xml')
yum = f'{ftp_dir}.stat/bin/createrepo_c --database --update --skip-stat --workers=12 --xz --groupfile={ftp_dir}.stat/repodata/comps.xml'
comps_file = f'{ftp_dir}.stat/repodata/comps.xml'
for tree in trees:
@@ -119,9 +129,13 @@ if do_yum:
print("repodata indexes already fresh")
continue
print(f'{"" if quiet else "time"} {yum} --cachedir={cachedir}-{arch} {archdir}/RPMS')
- os.system(f'{"" if quiet else "time"} {yum} --cachedir={cachedir}-{arch} {archdir}/RPMS')
+ run(f'{tree}/{arch}: createrepo_c', f'{"" if quiet else "time"} {yum} --cachedir={cachedir}-{arch} {archdir}/RPMS')
if arch != 'noarch' and config.separate_debuginfo:
- os.system(f'{"" if quiet else "time"} {yum} --cachedir={cachedir}-{arch} {archdir}/debuginfo')
+ run(f'{tree}/{arch}: createrepo_c', f'{"" if quiet else "time"} {yum} --cachedir={cachedir}-{arch} {archdir}/debuginfo')
for tree in trees:
ftpio.unlock(tree)
+
+for failure in failed:
+ print(f"ERR: {failure}", file=sys.stderr)
+sys.exit(1 if failed else 0)
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/pld-ftp-admin.git/commitdiff/9da94db07ea316d05f5466d10ac4e10519ad6d46
More information about the pld-cvs-commit
mailing list