[projects/pld-builder.new] builder: use argparse in the entry points, add --help

arekm arekm at pld-linux.org
Mon Oct 26 17:18:27 CET 2026


commit a06165311d58fd82cb944a29d7f0d7393cb32e9a
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Sat Oct 24 11:07:59 2026 +0200

    builder: use argparse in the entry points, add --help
    
    The bin/ wrappers pass their arguments through.

 PLD_Builder/file_sender.py            |  3 +++
 PLD_Builder/load_balancer.py          |  3 +++
 PLD_Builder/maintainer.py             |  3 +++
 PLD_Builder/request_fetcher.py        |  3 +++
 PLD_Builder/request_handler.py        |  3 +++
 PLD_Builder/request_handler_server.py | 10 +++++-----
 PLD_Builder/rpm_builder.py            | 11 +++++------
 PLD_Builder/srpm_builder.py           |  2 ++
 bin/file-sender.sh                    |  2 +-
 bin/load-balancer.sh                  |  2 +-
 bin/maintainer.sh                     |  2 +-
 bin/request-fetcher.sh                |  2 +-
 bin/request-handler.sh                |  2 +-
 bin/rpm-builder.sh                    |  2 +-
 bin/src-builder.sh                    |  2 +-
 15 files changed, 34 insertions(+), 18 deletions(-)
---
diff --git a/PLD_Builder/file_sender.py b/PLD_Builder/file_sender.py
index 35c07ed..924dfde 100644
--- a/PLD_Builder/file_sender.py
+++ b/PLD_Builder/file_sender.py
@@ -1,5 +1,6 @@
 # vi: ts=8 sts=4 sw=4 et
 
+import argparse
 import glob
 import os
 import re
@@ -197,4 +198,6 @@ def main():
     maybe_flush_queue(path.ftp_queue_dir)
 
 if __name__ == '__main__':
+    argparse.ArgumentParser(
+        description='Send queued notifications, buildlogs and packages to their targets.').parse_args()
     loop.run_loop(main)
diff --git a/PLD_Builder/load_balancer.py b/PLD_Builder/load_balancer.py
index 3adda4d..8ef6f13 100644
--- a/PLD_Builder/load_balancer.py
+++ b/PLD_Builder/load_balancer.py
@@ -1,5 +1,6 @@
 # vi: ts=8 sts=4 sw=4 et
 
+import argparse
 import os
 import sys
 import time
@@ -64,4 +65,6 @@ def main():
         pass
 
 if __name__ == '__main__':
+    argparse.ArgumentParser(
+        description='Run the rpm builder for every binary builder, in fair-queue order.').parse_args()
     loop.run_loop(main)
diff --git a/PLD_Builder/maintainer.py b/PLD_Builder/maintainer.py
index abd2bc7..5782295 100644
--- a/PLD_Builder/maintainer.py
+++ b/PLD_Builder/maintainer.py
@@ -1,5 +1,6 @@
 # vi: ts=8 sts=4 sw=4 et
 
+import argparse
 import datetime
 import os
 import sys
@@ -62,6 +63,8 @@ def handle_bin():
     chroot.run("poldek --mo=nodiff --mkidxz -s /spools/ready")
 
 if __name__ == '__main__':
+    argparse.ArgumentParser(
+        description='Send rpm -qa of the chroots and expire old builds, src.rpms and cached rpms.').parse_args()
     init_conf()
     bb=config.binary_builders[:]
     clean_dir(path.spool_dir+'/builds', 2592000) # a month
diff --git a/PLD_Builder/request_fetcher.py b/PLD_Builder/request_fetcher.py
index 89cf24e..b88793d 100644
--- a/PLD_Builder/request_fetcher.py
+++ b/PLD_Builder/request_fetcher.py
@@ -1,5 +1,6 @@
 # vi: ts=8 sts=4 sw=4 et
 
+import argparse
 import gzip
 import os
 import shutil
@@ -130,6 +131,8 @@ def main():
     lck.close()
 
 if __name__ == '__main__':
+    argparse.ArgumentParser(
+        description='Fetch new requests from the src builder into the binary builder queues.').parse_args()
     # http connection is established (and few bytes transferred through it)
     # each $secs seconds.
     loop.run_loop(main, secs = 10)
diff --git a/PLD_Builder/request_handler.py b/PLD_Builder/request_handler.py
index 355162f..8d720c7 100644
--- a/PLD_Builder/request_handler.py
+++ b/PLD_Builder/request_handler.py
@@ -1,5 +1,6 @@
 # vi: ts=8 sts=4 sw=4 et
 
+import argparse
 import os
 import sys
 import time
@@ -225,4 +226,6 @@ def main():
     sys.exit(handle_request_main(sys.stdin.read()) != HTTPStatus.OK)
 
 if __name__ == '__main__':
+    argparse.ArgumentParser(
+        description='Verify and queue a signed request read from standard input.').parse_args()
     wrap.wrap(main)
diff --git a/PLD_Builder/request_handler_server.py b/PLD_Builder/request_handler_server.py
index 9adf687..30a2109 100644
--- a/PLD_Builder/request_handler_server.py
+++ b/PLD_Builder/request_handler_server.py
@@ -1,3 +1,4 @@
+import argparse
 import os
 import re
 import signal
@@ -162,8 +163,7 @@ def main(srv_ssl=False):
     server.server_close()
 
 if __name__ == '__main__':
-    srv_ssl = False
-    if len(sys.argv) == 2 and sys.argv[1] == "ssl":
-        srv_ssl = True
-
-    main(srv_ssl)
+    parser = argparse.ArgumentParser(description='Accept signed requests over http(s) and queue them.')
+    parser.add_argument('mode', nargs='?', choices=['ssl'], help='serve https on ssl_port instead of http')
+    args = parser.parse_args()
+    main(args.mode == 'ssl')
diff --git a/PLD_Builder/rpm_builder.py b/PLD_Builder/rpm_builder.py
index 1ed9281..24c6e33 100644
--- a/PLD_Builder/rpm_builder.py
+++ b/PLD_Builder/rpm_builder.py
@@ -1,5 +1,6 @@
 # vi: ts=8 sts=4 sw=4 et
 
+import argparse
 import contextlib
 import datetime
 import http.client
@@ -420,10 +421,8 @@ def main_for(builder):
         q.write()
     q.unlock()
 
-def main():
-    if len(sys.argv) < 2:
-        raise RuntimeError("fatal: need to have builder name as first arg")
-    return main_for(sys.argv[1])
-
 if __name__ == '__main__':
-    loop.run_loop(main)
+    parser = argparse.ArgumentParser(description='Build rpms for the requests queued for a binary builder.')
+    parser.add_argument('builder', help='binary builder name, as in builder.conf')
+    args = parser.parse_args()
+    loop.run_loop(lambda: main_for(args.builder))
diff --git a/PLD_Builder/srpm_builder.py b/PLD_Builder/srpm_builder.py
index 85ef17e..6b69487 100644
--- a/PLD_Builder/srpm_builder.py
+++ b/PLD_Builder/srpm_builder.py
@@ -1,5 +1,6 @@
 # vi: ts=8 sts=4 sw=4 et
 
+import argparse
 import os
 import tempfile
 import time
@@ -183,4 +184,5 @@ def main():
         status.pop()
 
 if __name__ == '__main__':
+    argparse.ArgumentParser(description='Build src.rpms for the queued requests.').parse_args()
     loop.run_loop(main)
diff --git a/bin/file-sender.sh b/bin/file-sender.sh
index 2da358c..5f0cc46 100755
--- a/bin/file-sender.sh
+++ b/bin/file-sender.sh
@@ -12,4 +12,4 @@ fi
 export BUILDERPATH
 
 cd $BUILDERPATH
-exec python3 PLD_Builder/file_sender.py
+exec python3 PLD_Builder/file_sender.py "$@"
diff --git a/bin/load-balancer.sh b/bin/load-balancer.sh
index 758e519..0570fc4 100755
--- a/bin/load-balancer.sh
+++ b/bin/load-balancer.sh
@@ -12,4 +12,4 @@ fi
 export BUILDERPATH
 
 cd $BUILDERPATH
-exec python3 PLD_Builder/load_balancer.py
+exec python3 PLD_Builder/load_balancer.py "$@"
diff --git a/bin/maintainer.sh b/bin/maintainer.sh
index 8754f85..3979967 100755
--- a/bin/maintainer.sh
+++ b/bin/maintainer.sh
@@ -12,4 +12,4 @@ fi
 export BUILDERPATH
 
 cd $BUILDERPATH
-exec python3 PLD_Builder/maintainer.py
+exec python3 PLD_Builder/maintainer.py "$@"
diff --git a/bin/request-fetcher.sh b/bin/request-fetcher.sh
index edf908c..64bc429 100755
--- a/bin/request-fetcher.sh
+++ b/bin/request-fetcher.sh
@@ -12,4 +12,4 @@ fi
 export BUILDERPATH
 
 cd $BUILDERPATH
-exec python3 PLD_Builder/request_fetcher.py
+exec python3 PLD_Builder/request_fetcher.py "$@"
diff --git a/bin/request-handler.sh b/bin/request-handler.sh
index 6d0a808..6f8c6c5 100755
--- a/bin/request-handler.sh
+++ b/bin/request-handler.sh
@@ -13,7 +13,7 @@ export BUILDERPATH
 if lockfile -r3 $HOME/.builder_request_handler.lock 2>/dev/null; then
 	trap "rm -f $HOME/.builder_request_handler.lock" 1 2 3 13 15
 	cd $BUILDERPATH
-	python3 PLD_Builder/request_handler.py
+	python3 PLD_Builder/request_handler.py "$@"
 	rc=$?
 	rm -f $HOME/.builder_request_handler.lock
 	exit $rc
diff --git a/bin/rpm-builder.sh b/bin/rpm-builder.sh
index 740f019..83bacbb 100755
--- a/bin/rpm-builder.sh
+++ b/bin/rpm-builder.sh
@@ -11,4 +11,4 @@ fi
 export BUILDERPATH
 
 cd $BUILDERPATH
-exec python3 PLD_Builder/rpm_builder.py $1
+exec python3 PLD_Builder/rpm_builder.py "$@"
diff --git a/bin/src-builder.sh b/bin/src-builder.sh
index 07ba29c..c259c48 100755
--- a/bin/src-builder.sh
+++ b/bin/src-builder.sh
@@ -11,4 +11,4 @@ fi
 export BUILDERPATH
 
 cd $BUILDERPATH
-exec python3 PLD_Builder/srpm_builder.py
+exec python3 PLD_Builder/srpm_builder.py "$@"
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/ce9feb3c796ed049b6dd260a50d94d80feb1656d



More information about the pld-cvs-commit mailing list