commit:     91a9c2da33802f1f71e669bffc7ce940b9f6d450
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 27 20:42:16 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Oct 27 21:27:44 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=91a9c2da

repoman: fix exit code for manifest mode (bug 588752)

When manifest generation fails, report "manifest.bad" violations.

Reported-by: Lars Wendler <polynomial-c <AT> gentoo.org>
Bug: https://bugs.gentoo.org/588752
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 repoman/bin/repoman                            |  2 +-
 repoman/lib/repoman/main.py                    |  9 +++++----
 repoman/lib/repoman/modules/commit/manifest.py | 11 ++++-------
 repoman/lib/repoman/scanner.py                 |  3 ++-
 4 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/repoman/bin/repoman b/repoman/bin/repoman
index 873987f33..7f6187f12 100755
--- a/repoman/bin/repoman
+++ b/repoman/bin/repoman
@@ -42,7 +42,7 @@ from portage.util._eventloop.global_event_loop import 
global_event_loop
 from repoman.main import repoman_main
 
 try:
-       repoman_main(sys.argv[1:])
+       sys.exit(repoman_main(sys.argv[1:]))
 except IOError as e:
        if e.errno == errno.EACCES:
                print("\nRepoman: Need user access")

diff --git a/repoman/lib/repoman/main.py b/repoman/lib/repoman/main.py
index 81e2ff61e..731e8eae2 100755
--- a/repoman/lib/repoman/main.py
+++ b/repoman/lib/repoman/main.py
@@ -133,10 +133,6 @@ def repoman_main(argv):
                'full': options.mode != 'full',
        }
 
-       # early out for manifest generation
-       if options.mode == "manifest":
-               sys.exit(result['fail'])
-
        for x in qadata.qacats:
                if x not in vcs_settings.qatracker.fails:
                        continue
@@ -182,6 +178,11 @@ def repoman_main(argv):
 
        style_file.flush()
        del console_writer, f, style_file
+
+       # early out for manifest generation
+       if options.mode == "manifest":
+               return 1 if result['fail'] else 0
+
        qa_output = qa_output.getvalue()
        qa_output = qa_output.splitlines(True)
 

diff --git a/repoman/lib/repoman/modules/commit/manifest.py 
b/repoman/lib/repoman/modules/commit/manifest.py
index b338a5b40..573710a62 100644
--- a/repoman/lib/repoman/modules/commit/manifest.py
+++ b/repoman/lib/repoman/modules/commit/manifest.py
@@ -30,7 +30,8 @@ class Manifest(object):
                '''Perform a manifest generation for the pkg
 
                @param checkdir: the current package directory
-               @returns: dictionary
+               @rtype: bool
+               @return: True if successful, False otherwise
                '''
                self.generated_manifest = False
                failed = False
@@ -51,7 +52,7 @@ class Manifest(object):
 
                if not self.generated_manifest:
                        writemsg_level(
-                               "Unable to generate manifest.",
+                               "!!! Unable to generate manifest for '%s'.\n" % 
(checkdir,),
                                level=logging.ERROR, noiselevel=-1)
                        failed = True
 
@@ -75,11 +76,7 @@ class Manifest(object):
                                                if distfile in 
self.auto_assumed:
                                                        portage.writemsg_stdout(
                                                                "   %s::%s\n" % 
(pf, distfile))
-                       # continue, skip remaining main loop code
-                       return True
-               elif failed:
-                       sys.exit(1)
-               return False
+               return not failed
 
        def _discard_dist_digests(self, checkdir, fetchlist_dict):
                '''Discard DIST digests for files that exist in DISTDIR

diff --git a/repoman/lib/repoman/scanner.py b/repoman/lib/repoman/scanner.py
index c456bbde9..1b3242a51 100644
--- a/repoman/lib/repoman/scanner.py
+++ b/repoman/lib/repoman/scanner.py
@@ -290,7 +290,8 @@ class Scanner(object):
                                self.vcs_settings.status.check(checkdir, 
checkdir_relative, xpkg)
 
                        if self.generate_manifest:
-                               
manifest.Manifest(**self.kwargs).update_manifest(checkdir)
+                               if not 
manifest.Manifest(**self.kwargs).update_manifest(checkdir):
+                                       
self.qatracker.add_error("manifest.bad", os.path.join(xpkg, 'Manifest'))
                                if self.options.mode == 'manifest':
                                        continue
                        checkdirlist = os.listdir(checkdir)

Reply via email to