osmith has submitted this change. (
https://gerrit.osmocom.org/c/osmo-ci/+/31926 )
Change subject: obs: lib.args: store argparse result here
......................................................................
obs: lib.args: store argparse result here
Prepare to add more arguments to the OBS scripts, so they can be used
for building the wireshark package in its own OBS project.
It was not so clear to me when writing this initially, but with more and
more arguments getting added: it's not very maintainable to pass each
variable from the argparse result several functions down to where it
gets used... so unfortunately this means the code needs to be refactored
to just use libs.args in the few lines of code where the arguments
actually get used.
This patch adds lib.args, and the next patches refactor existing code to
use it instead of passing parameters, where it makes sense. After that
follow the patches related to adding the wireshark package.
Related: OS#2537
Change-Id: I48853444f1386dfb842c174ebc45f9decc8bec0f
---
M scripts/obs/build_binpkg.py
M scripts/obs/build_srcpkg.py
M scripts/obs/lib/__init__.py
M scripts/obs/update_obs_project.py
4 files changed, 37 insertions(+), 3 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
diff --git a/scripts/obs/build_binpkg.py b/scripts/obs/build_binpkg.py
index a34a699..dcd6cdc 100755
--- a/scripts/obs/build_binpkg.py
+++ b/scripts/obs/build_binpkg.py
@@ -38,7 +38,7 @@
help="package name, e.g. libosmocore")
args = parser.parse_args()
- lib.set_cmds_verbose(args.verbose)
+ lib.set_args(args)
srcdir = f"{lib.config.path_temp}/srcpkgs/{args.package}"
if not os.path.exists(srcdir):
diff --git a/scripts/obs/build_srcpkg.py b/scripts/obs/build_srcpkg.py
index ad21927..869b8ef 100755
--- a/scripts/obs/build_srcpkg.py
+++ b/scripts/obs/build_srcpkg.py
@@ -28,7 +28,7 @@
print("ERROR: specify -m and/or a package. See -h for help.")
exit(1)
- lib.set_cmds_verbose(args.verbose)
+ lib.set_args(args)
if args.docker:
lib.docker.run_in_docker_and_exit("build_srcpkg.py")
diff --git a/scripts/obs/lib/__init__.py b/scripts/obs/lib/__init__.py
index 479c1c1..edf19f4 100644
--- a/scripts/obs/lib/__init__.py
+++ b/scripts/obs/lib/__init__.py
@@ -10,6 +10,10 @@
import inspect
import lib.config
+# Argparse result
+args = None
+
+# Print output of commands as they run, not only on error
cmds_verbose = False
@@ -60,6 +64,12 @@
cmds_verbose = new_val
+def set_args(new_val):
+ global args
+ args = new_val
+ set_cmds_verbose(args.verbose)
+
+
def check_required_programs():
ok = True
diff --git a/scripts/obs/update_obs_project.py b/scripts/obs/update_obs_project.py
index 86cf40a..0ae949b 100755
--- a/scripts/obs/update_obs_project.py
+++ b/scripts/obs/update_obs_project.py
@@ -199,7 +199,7 @@
branch = args.git_branch
packages = parse_packages(args.package)
- lib.set_cmds_verbose(args.verbose)
+ lib.set_args(args)
if args.docker:
lib.docker.run_in_docker_and_exit("update_obs_project.py", True)
--
To view, visit
https://gerrit.osmocom.org/c/osmo-ci/+/31926
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: I48853444f1386dfb842c174ebc45f9decc8bec0f
Gerrit-Change-Number: 31926
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged