aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2021-03-28 08:43:54 -0700
committerZac Medico <zmedico@gentoo.org>2021-03-28 11:42:07 -0700
commit3d7ed631ecc2f4f75beab3d6d17b75d6fc0ecd3c (patch)
tree4cb8113eaa5e18718af6abed6144e40a54ce6d40
parentrepoman: fix argv inconsistency (diff)
downloadportage-3d7ed631ecc2f4f75beab3d6d17b75d6fc0ecd3c.tar.gz
portage-3d7ed631ecc2f4f75beab3d6d17b75d6fc0ecd3c.tar.bz2
portage-3d7ed631ecc2f4f75beab3d6d17b75d6fc0ecd3c.zip
repoman: split up repoman_main
Signed-off-by: Zac Medico <zmedico@gentoo.org>
-rwxr-xr-xrepoman/lib/repoman/main.py39
1 files changed, 36 insertions, 3 deletions
diff --git a/repoman/lib/repoman/main.py b/repoman/lib/repoman/main.py
index dc791ad71..a694410d7 100755
--- a/repoman/lib/repoman/main.py
+++ b/repoman/lib/repoman/main.py
@@ -3,6 +3,7 @@
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
+import collections
import io
import logging
import sys
@@ -47,7 +48,26 @@ portage.util.initialize_logger(LOGLEVEL)
VALID_VERSIONS = [1,]
+_repoman_main_vars = collections.namedtuple("_repoman_main_vars", (
+ "can_force",
+ "exitcode",
+ "options",
+ "qadata",
+ "repo_settings",
+ "scanner",
+ "vcs_settings",
+))
+
+
def repoman_main(argv):
+ repoman_vars = _repoman_init(argv)
+ if repoman_vars.exitcode is not None:
+ return repoman_vars.exitcode
+ result = _repoman_scan(*repoman_vars)
+ return _handle_result(*repoman_vars, result)
+
+
+def _repoman_init(argv):
config_root = os.environ.get("PORTAGE_CONFIGROOT")
repoman_settings = portage.config(config_root=config_root, local_config=False)
repoman_settings.valid_versions = VALID_VERSIONS
@@ -62,7 +82,7 @@ def repoman_main(argv):
if options.version:
print("Repoman", VERSION, "(portage-%s)" % portage.VERSION)
- sys.exit(0)
+ return _repoman_main_vars(exitcode=0)
logger = logging.getLogger()
@@ -75,10 +95,15 @@ def repoman_main(argv):
# something other than a QA issue) makes it impossible to
# commit (like if Manifest generation fails).
can_force = ExtendedFuture(True)
+ repo_settings, vcs_settings, scanner, qadata = _create_scanner(options, can_force, config_root, repoman_settings)
+ return _repoman_main_vars(can_force, None, options, qadata, repo_settings, scanner, vcs_settings)
+
+
+def _create_scanner(options, can_force, config_root, repoman_settings):
portdir, portdir_overlay, mydir = utilities.FindPortdir(repoman_settings)
if portdir is None:
- sys.exit(1)
+ return (None, None, None, None)
myreporoot = os.path.basename(portdir_overlay)
myreporoot += mydir[len(portdir_overlay):]
@@ -117,6 +142,10 @@ def repoman_main(argv):
# Perform the main checks
scanner = Scanner(repo_settings, myreporoot, config_root, options,
vcs_settings, mydir, env)
+ return repo_settings, vcs_settings, scanner, qadata
+
+
+def _repoman_scan(can_force, exitcode, options, qadata, repo_settings, scanner, vcs_settings):
scanner.scan_pkgs(can_force)
if options.if_modified == "y" and len(scanner.effective_scanlist) < 1:
@@ -142,6 +171,10 @@ def repoman_main(argv):
(result['warn'] and not (options.quiet or options.mode == "scan")):
result['full'] = 0
+ return result
+
+
+def _handle_result(can_force, exitcode, options, qadata, repo_settings, scanner, vcs_settings, result):
commitmessage = None
if options.commitmsg:
commitmessage = options.commitmsg
@@ -190,4 +223,4 @@ def repoman_main(argv):
# perform any other actions
actions.perform(qa_output)
- sys.exit(0)
+ return 0