diff options
Diffstat (limited to 'pym')
-rw-r--r-- | pym/portage/sets/dbapi.py | 4 | ||||
-rw-r--r-- | pym/portage/tests/lint/test_bash_syntax.py | 42 | ||||
-rw-r--r-- | pym/repoman/herdbase.py | 12 | ||||
-rw-r--r-- | pym/repoman/utilities.py | 3 |
4 files changed, 56 insertions, 5 deletions
diff --git a/pym/portage/sets/dbapi.py b/pym/portage/sets/dbapi.py index 5bd7e1688..8bacb72fc 100644 --- a/pym/portage/sets/dbapi.py +++ b/pym/portage/sets/dbapi.py @@ -1,4 +1,4 @@ -# Copyright 2007 Gentoo Foundation +# Copyright 2007-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import time @@ -328,7 +328,7 @@ class RebuiltBinaries(EverythingSet): bin_build_time, = self._bindb.aux_get(cpv, self._aux_keys) except KeyError: return False - return inst_build_time != bin_build_time + return bool(bin_build_time and (inst_build_time != bin_build_time)) def singleBuilder(cls, options, settings, trees): return RebuiltBinaries(trees["vartree"].dbapi, diff --git a/pym/portage/tests/lint/test_bash_syntax.py b/pym/portage/tests/lint/test_bash_syntax.py new file mode 100644 index 000000000..aef8d74f1 --- /dev/null +++ b/pym/portage/tests/lint/test_bash_syntax.py @@ -0,0 +1,42 @@ +# Copyright 2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +import stat + +from portage.const import BASH_BINARY, PORTAGE_BIN_PATH +from portage.tests import TestCase +from portage import os +from portage import subprocess_getstatusoutput +from portage import _encodings +from portage import _shell_quote +from portage import _unicode_decode, _unicode_encode + +class BashSyntaxTestCase(TestCase): + + def testBashSyntax(self): + for parent, dirs, files in os.walk(PORTAGE_BIN_PATH): + parent = _unicode_decode(parent, + encoding=_encodings['fs'], errors='strict') + for x in files: + x = _unicode_decode(x, + encoding=_encodings['fs'], errors='strict') + ext = x.split('.')[-1] + if ext in ('.py', '.pyc', '.pyo'): + continue + x = os.path.join(parent, x) + st = os.lstat(x) + if not stat.S_ISREG(st.st_mode): + continue + + # Check for bash shebang + f = open(_unicode_encode(x, + encoding=_encodings['fs'], errors='strict'), 'rb') + line = _unicode_decode(f.readline(), + encoding=_encodings['content'], errors='replace') + f.close() + if line[:2] == '#!' and \ + 'bash' in line: + cmd = "%s -n %s" % (_shell_quote(BASH_BINARY), _shell_quote(x)) + status, output = subprocess_getstatusoutput(cmd) + self.assertEqual(os.WIFEXITED(status) and \ + os.WEXITSTATUS(status) == os.EX_OK, True, msg=output) diff --git a/pym/repoman/herdbase.py b/pym/repoman/herdbase.py index 924839a61..6f92abfb8 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 cd7f5ea87..719e910d7 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): |