diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-04-02 10:22:38 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-04-02 10:22:38 -0700 |
commit | 7a33618e8189384861b412176a3ddbef240b6777 (patch) | |
tree | 3c13576422a40d36d8f52e2c8d660c4565019b70 | |
parent | Update copyright header. (diff) | |
download | portage-idfetch-7a33618e8189384861b412176a3ddbef240b6777.tar.gz portage-idfetch-7a33618e8189384861b412176a3ddbef240b6777.tar.bz2 portage-idfetch-7a33618e8189384861b412176a3ddbef240b6777.zip |
Handle missing $PORTDIR/metadata/herds.xml. Thanks to Arfrever for reporting.
-rwxr-xr-x | bin/repoman | 9 | ||||
-rw-r--r-- | pym/repoman/herdbase.py | 12 | ||||
-rw-r--r-- | pym/repoman/utilities.py | 3 |
3 files changed, 18 insertions, 6 deletions
diff --git a/bin/repoman b/bin/repoman index ffc4c948..a76bc8de 100755 --- a/bin/repoman +++ b/bin/repoman @@ -68,10 +68,9 @@ import portage.checksum import portage.const import portage.dep portage.dep._dep_check_strict = True -import portage.exception from portage import cvstree, normalize_path from portage import util -from portage.exception import ParseError +from portage.exception import FileNotFound, ParseError, PermissionDenied from portage.manifest import Manifest from portage.process import find_binary, spawn from portage.output import bold, create_color_func, darkgreen, \ @@ -984,8 +983,12 @@ thirdpartymirrors = portage.flatten(list(repoman_settings.thirdpartymirrors().va try: herd_base = make_herd_base(os.path.join(repoman_settings["PORTDIR"], "metadata/herds.xml")) -except (EnvironmentError, ParseError) as e: +except (EnvironmentError, ParseError, PermissionDenied) as e: err(str(e)) +except FileNotFound: + # TODO: Download as we do for metadata.dtd, but add a way to + # disable for non-gentoo repoman users who may not have herds. + herd_base = None for x in scanlist: #ebuilds and digests added to cvs respectively. diff --git a/pym/repoman/herdbase.py b/pym/repoman/herdbase.py index 924839a6..6f92abfb 100644 --- a/pym/repoman/herdbase.py +++ b/pym/repoman/herdbase.py @@ -3,9 +3,10 @@ # Copyright 2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +import errno import xml.etree.ElementTree as ET from xml.parsers.expat import ExpatError -from portage.exception import ParseError +from portage.exception import FileNotFound, ParseError, PermissionDenied __all__ = [ "make_herd_base" @@ -44,7 +45,14 @@ def make_herd_base(filename): xml_tree = ET.parse(filename) except ExpatError as e: raise ParseError("metadata.xml: " + str(e)) - + except EnvironmentError as e: + func_call = "open('%s')" % filename + if e.errno == errno.EACCES: + raise PermissionDenied(func_call) + elif e.errno == errno.ENOENT: + raise FileNotFound(filename) + raise + herds = xml_tree.findall('herd') for h in herds: _herd_name = h.find('name') diff --git a/pym/repoman/utilities.py b/pym/repoman/utilities.py index cd7f5ea8..719e910d 100644 --- a/pym/repoman/utilities.py +++ b/pym/repoman/utilities.py @@ -176,7 +176,8 @@ def check_metadata(metadata_xml_content, herd_base): except (ExpatError, ) as e: raise exception.ParseError("metadata.xml: " + str(e)) - check_metadata_herds(xml_tree, herd_base) + if herd_base is not None: + check_metadata_herds(xml_tree, herd_base) def FindPackagesToScan(settings, startdir, reposplit): |