commit:     2bf6fcfa9060f2490d77e4c5ea3dcd596e6b4c6b
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 19 21:11:56 2015 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Mon Oct 19 21:11:56 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=2bf6fcfa

eclean: Add option to allow for missing PKGDIR. Bug 551266

Added -i, --ignore-failure to ignore a missing PKGDIR error and exit
cleanly.  This was requested by the Chromium OS project, since they
run eclean in an automated process and the directory may not exist yet.

References: http://crbug.com/323420

 man/eclean.1                    | 3 ++-
 pym/gentoolkit/eclean/cli.py    | 9 ++++++---
 pym/gentoolkit/eclean/search.py | 2 ++
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/man/eclean.1 b/man/eclean.1
index 1668b5e..8547c03 100644
--- a/man/eclean.1
+++ b/man/eclean.1
@@ -106,7 +106,8 @@ etc.
 Units are: G, M, K and B.
 .SS "Options for the 'packages' action"
 .TP
-There is no specific option for this action.
+\fB\-i, \-\-ignore\-failure\fP         ignore the failure to locate PKGDIR
+This is only useful when scripting to ignore an otherwise fatal error.
 .SH "EXCLUSION FILES"
 Exclusions files are lists of packages names or categories you want to protect
 in particular.  This may be useful to protect more binary packages for some 
system

diff --git a/pym/gentoolkit/eclean/cli.py b/pym/gentoolkit/eclean/cli.py
index 95d4c06..1c8e66f 100644
--- a/pym/gentoolkit/eclean/cli.py
+++ b/pym/gentoolkit/eclean/cli.py
@@ -147,7 +147,8 @@ def printUsage(_error=None, help=None):
        or help in ('all','packages'):
                print( "Available", yellow("options"),"for the",
                                green("packages"),"action:", file=out)
-               print( yellow(" NONE  :)"), file=out)
+               print( yellow(" -i, --ignore-failure")+
+                       "             - ignore failure to locate PKGDIR", 
file=out)
                print( file=out)
        if _error in ('distfiles-options', 'merged-distfiles-options') \
        or help in ('all','distfiles'):
@@ -262,6 +263,8 @@ def parseArgs(options={}):
                                options['size-limit'] = parseSize(a)
                        elif o in ("-v", "--verbose") and not options['quiet']:
                                        options['verbose'] = True
+                       elif o in ("-i", "--ignore-failure"):
+                               options['ignore-failure'] = True
                        else:
                                return_code = False
                # sanity check of --deep only options:
@@ -286,8 +289,8 @@ def parseArgs(options={}):
                "time-limit=", "package-names", "help", "version",  "verbose"]
        getopt_options['short']['distfiles'] = "fs:"
        getopt_options['long']['distfiles'] = ["fetch-restricted", 
"size-limit="]
-       getopt_options['short']['packages'] = ""
-       getopt_options['long']['packages'] = [""]
+       getopt_options['short']['packages'] = "i"
+       getopt_options['long']['packages'] = ["ignore-failure"]
        # set default options, except 'nocolor', which is set in main()
        options['interactive'] = False
        options['pretend'] = False

diff --git a/pym/gentoolkit/eclean/search.py b/pym/gentoolkit/eclean/search.py
index 1a83fd4..f771ffc 100644
--- a/pym/gentoolkit/eclean/search.py
+++ b/pym/gentoolkit/eclean/search.py
@@ -532,6 +532,8 @@ def findPackages(
                test = os.listdir(pkgdir)
                del test
        except EnvironmentError as er:
+               if options['ignore-failure']:
+                       exit(0)
                print( pp.error("Error accessing PKGDIR." ), file=sys.stderr)
                print( pp.error("(Check your make.conf file and 
environment)."), file=sys.stderr)
                print( pp.error("Error: %s" %str(er)), file=sys.stderr)

Reply via email to