Merge genscripts revision 191
authorfuzzyray <fuzzyray@gentoo.org>
Tue, 2 Feb 2010 17:06:55 +0000 (17:06 -0000)
committerfuzzyray <fuzzyray@gentoo.org>
Tue, 2 Feb 2010 17:06:55 +0000 (17:06 -0000)
svn path=/trunk/gentoolkit/; revision=737

12 files changed:
TODO
bin/revdep-rebuild
pym/gentoolkit/atom.py
pym/gentoolkit/cpv.py
pym/gentoolkit/dependencies.py
pym/gentoolkit/equery/meta.py
pym/gentoolkit/helpers.py
pym/gentoolkit/metadata.py
pym/gentoolkit/package.py
pym/gentoolkit/test/test_helpers.py
pym/gentoolkit/versionmatch.py
setup.py

diff --git a/TODO b/TODO
index 161546bed833e68d045cbb041cd3f677e6881116..d3e2cb2995d0fd5ef78cc57089e41f35695a8b5c 100644 (file)
--- a/TODO
+++ b/TODO
  - use /etc/gentoolkit/ebump.conf
 
 equery:
-       Tests:
-               +helpers2 (FileOwner._extend_realpaths test probably doesn't clean up)
-       Run pylint and write test to run pylint
-       Write test to compile all modules (full syntax check). Take from portage.
        Add more --debug stuff
        Write tests for Dependencies._parser
+       Profile Dependencies._parser
        Refactor each module to be useful for import. Done modules:
                +depends
                +belongs
@@ -44,7 +41,7 @@ Ebuild changes:
 
 For Next Release:
        - write NEWS file
-    - make CPV.__init__ more strict, it allows some silly stuff
+       - make CPV.__init__ more strict, it allows some silly stuff
        -  $ equery uses '>=sys-apps/portage-2'
          * Searching for >=sys-apps/portage-2 ...
          * Found these USE flags for sys-apps/portage-2.1.6.13:
index 6726c7e03c2a6752a68080e9701109ad59e05701..c5f253861b67e54684dc9028695d0a45377f3d2c 100755 (executable)
@@ -1149,7 +1149,7 @@ cleanup() {
                if [[ -r "$OWNERS_FILE" && -s "$OWNERS_FILE" ]]; then
                        show_unowned_files
                fi
-               [[ $KEEP_TEMP ]] || rm "${FILES[@]}"
+               [[ $KEEP_TEMP ]] || rm -f "${FILES[@]}"
        else
                einfo 'Now you can remove -p (or --pretend) from arguments and re-run revdep-rebuild.'
        fi
index 8c299602da6fa4968f5b8325d31e51d579e1b30b..d32a20b8cfef12421af0210abe6a971b0be7a6e1 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 #
-# Copyright(c) 2009-2010, Gentoo Foundation
+# Copyright 2009-2010 Gentoo Foundation
 #
 # Licensed under the GNU General Public License, v2
 #
@@ -27,20 +27,7 @@ from gentoolkit import errors
 # =======
 
 class Atom(portage.dep.Atom, CPV):
-       """Portage's Atom class with an improvements from pkgcore.
-
-       Gentoolkit's Atom is not backwards compatible with Portage's because we set
-       parts and combinations of parts of cpv as attributes on Atom.cpv instead of
-       putting them directly in Atom's namespace like Portage does, for one.
-       For example:
-       Gentoolkit.Atom: str(atom.cpv)     # cpv string
-                                        atom.cpv.category # category
-       Portage.Atom: atom.cpv      # cpv string
-                                 atom.category # category
-
-       Also, Portage's Atom.slot is a string, whereas
-       Gentoolkit's Atom.slot is a tuple as in pkgcore, since multiple slots are
-               OK
+       """Portage's Atom class with improvements from pkgcore.
 
        portage.dep.Atom provides the following instance variables:
 
@@ -70,7 +57,7 @@ class Atom(portage.dep.Atom, CPV):
                if self.operator is None:
                        self.operator = ''
 
-               self.cpv = CPV(self.cpv)
+               CPV.__init__(self, self.cpv)
 
                # use_conditional is USE flag condition for this Atom to be required:
                # For: !build? ( >=sys-apps/sed-4.0.5 ), use_conditional = '!build'
@@ -84,7 +71,7 @@ class Atom(portage.dep.Atom, CPV):
                if self.operator != other.operator:
                        return False
 
-               if self.cpv != other.cpv:
+               if not CPV.__eq__(self, other):
                        return False
 
                if bool(self.blocker) != bool(other.blocker):
@@ -112,14 +99,10 @@ class Atom(portage.dep.Atom, CPV):
                        return False
 
                # Not supported by Portage Atom yet
-               #return cmp(self.repo_id, other.repo_id)
+               #return cmp(self.repo_name, other.repo_name)
                return True
 
        def __ne__(self, other):
-               if not isinstance(other, self.__class__):
-                       err = "other isn't of %s type, is %s"
-                       raise TypeError(err % (self.__class__, other.__class__))
-
                return not self == other
 
        def __lt__(self, other):
@@ -130,8 +113,8 @@ class Atom(portage.dep.Atom, CPV):
                if self.operator != other.operator:
                        return self.operator < other.operator
 
-               if self.cpv != other.cpv:
-                       return self.cpv < other.cpv
+               if not CPV.__eq__(self, other):
+                       return CPV.__lt__(self, other)
 
                if bool(self.blocker) != bool(other.blocker):
                        # We want non blockers, then blockers, so only return True
@@ -162,7 +145,7 @@ class Atom(portage.dep.Atom, CPV):
                        return this_use < that_use
 
                # Not supported by Portage Atom yet
-               #return cmp(self.repo_id, other.repo_id)
+               #return cmp(self.repo_name, other.repo_name)
 
                return False
 
@@ -217,15 +200,15 @@ class Atom(portage.dep.Atom, CPV):
                @see: L{pkgcore.ebuild.atom}
                """
                # Our "cp" (cat/pkg) must match exactly:
-               if self.cpv.cp != other.cpv.cp:
+               if self.cp != other.cp:
                        # Check to see if one is name only:
                        # Avoid slow partitioning if we're definitely not matching
                        # (yes, this is hackish, but it's faster):
-                       if self.cpv.cp[-1:] != other.cpv.cp[-1:]:
+                       if self.cp[-1:] != other.cp[-1:]:
                                return False
 
-                       if ((not self.cpv.category and self.cpv.name == other.cpv.name) or
-                               (not other.cpv.category and other.cpv.name == self.cpv.name)):
+                       if ((not self.category and self.name == other.name) or
+                               (not other.category and other.name == self.name)):
                                return True
                        return False
 
@@ -238,8 +221,8 @@ class Atom(portage.dep.Atom, CPV):
                        return False
 
                # TODO: Uncomment when Portage's Atom supports repo
-               #if (self.repo_id is not None and other.repo_id is not None and
-               #       self.repo_id != other.repo_id):
+               #if (self.repo_name is not None and other.repo_name is not None and
+               #       self.repo_name != other.repo_name):
                #       return False
 
                # Use deps are similar: if one of us forces a flag on and the
@@ -273,29 +256,29 @@ class Atom(portage.dep.Atom, CPV):
                # If one of us is an exact match we intersect if the other matches it:
                if self.operator == '=':
                        if other.operator == '=*':
-                               return self.cpv.fullversion.startswith(other.cpv.fullversion)
-                       return VersionMatch(other.cpv, op=other.operator).match(self.cpv)
+                               return self.fullversion.startswith(other.fullversion)
+                       return VersionMatch(other, op=other.operator).match(self)
                if other.operator == '=':
                        if self.operator == '=*':
-                               return other.cpv.fullversion.startswith(self.cpv.fullversion)
-                       return VersionMatch(self.cpv, op=self.operator).match(other.cpv)
+                               return other.fullversion.startswith(self.fullversion)
+                       return VersionMatch(self, op=self.operator).match(other)
 
                # If we are both ~ matches we match if we are identical:
                if self.operator == other.operator == '~':
-                       return (self.cpv.version == other.cpv.version and
-                               self.cpv.revision == other.cpv.revision)
+                       return (self.version == other.version and
+                               self.revision == other.revision)
 
                # If we are both glob matches we match if one of us matches the other.
                if self.operator == other.operator == '=*':
-                       return (self.cpv.fullversion.startswith(other.cpv.fullversion) or
-                               other.cpv.fullversion.startswith(self.cpv.fullversion))
+                       return (self.fullversion.startswith(other.fullversion) or
+                               other.fullversion.startswith(self.fullversion))
 
                # If one of us is a glob match and the other a ~ we match if the glob
                # matches the ~ (ignoring a revision on the glob):
                if self.operator == '=*' and other.operator == '~':
-                       return other.cpv.fullversion.startswith(self.cpv.version)
+                       return other.fullversion.startswith(self.version)
                if other.operator == '=*' and self.operator == '~':
-                       return self.cpv.fullversion.startswith(other.cpv.version)
+                       return self.fullversion.startswith(other.version)
 
                # If we get here at least one of us is a <, <=, > or >=:
                if self.operator in ('<', '<=', '>', '>='):
@@ -313,42 +296,42 @@ class Atom(portage.dep.Atom, CPV):
                        # match the other's endpoint (just checking one endpoint
                        # is not enough, it would give a false positive on <=2 vs >2)
                        return (
-                               VersionMatch(other.cpv, op=other.operator).match(ranged.cpv) and
-                               VersionMatch(ranged.cpv, op=ranged.operator).match(other.cpv)
+                               VersionMatch(other, op=other.operator).match(ranged) and
+                               VersionMatch(ranged, op=ranged.operator).match(other)
                        )
 
                if other.operator == '~':
                        # Other definitely matches its own version. If ranged also
                        # does we're done:
-                       if VersionMatch(ranged.cpv, op=ranged.operator).match(other.cpv):
+                       if VersionMatch(ranged, op=ranged.operator).match(other):
                                return True
                        # The only other case where we intersect is if ranged is a
                        # > or >= on other's version and a nonzero revision. In
                        # that case other will match ranged. Be careful not to
                        # give a false positive for ~2 vs <2 here:
                        return (ranged.operator in ('>', '>=') and
-                               VersionMatch(other.cpv, op=other.operator).match(ranged.cpv))
+                               VersionMatch(other, op=other.operator).match(ranged))
 
                if other.operator == '=*':
                        # a glob match definitely matches its own version, so if
                        # ranged does too we're done:
-                       if VersionMatch(ranged.cpv, op=ranged.operator).match(other.cpv):
+                       if VersionMatch(ranged, op=ranged.operator).match(other):
                                return True
                        if '<' in ranged.operator:
                                # If other.revision is not defined then other does not
                                # match anything smaller than its own fullversion:
-                               if other.cpv.revision:
+                               if other.revision:
                                        return False
 
                                # If other.revision is defined then we can always
                                # construct a package smaller than other.fullversion by
                                # tagging e.g. an _alpha1 on.
-                               return ranged.cpv.fullversion.startswith(other.cpv.version)
+                               return ranged.fullversion.startswith(other.version)
                        else:
                                # Remaining cases where this intersects: there is a
                                # package greater than ranged.fullversion and
                                # other.fullversion that they both match.
-                               return ranged.cpv.fullversion.startswith(other.cpv.version)
+                               return ranged.fullversion.startswith(other.version)
 
                # Handled all possible ops.
                raise NotImplementedError(
index 31a9a9fe277ebc213d2c4b5b4d03f411b5a33851..f390e4546dc80593a66cf61178fb717f0c70167f 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 #
-# Copyright(c) 2009-2010, Gentoo Foundation
+# Copyright 2009-2010 Gentoo Foundation
 #
 # Licensed under the GNU General Public License, v2
 #
@@ -40,7 +40,7 @@ class CPV(object):
        """
 
        def __init__(self, cpv):
-               self.scpv = cpv
+               self.cpv = cpv
 
                values = split_cpv(cpv)
                self.category = values[0]
@@ -61,16 +61,10 @@ class CPV(object):
 
        def __eq__(self, other):
                if not isinstance(other, self.__class__):
-                       raise TypeError("other isn't of %s type, is %s" % (
-                               self.__class__, other.__class__)
-                       )
-               return self.scpv == other.scpv
+                       return False
+               return self.cpv == other.cpv
 
        def __ne__(self, other):
-               if not isinstance(other, self.__class__):
-                       raise TypeError("other isn't of %s type, is %s" % (
-                               self.__class__, other.__class__)
-                       )
                return not self == other
 
        def __lt__(self, other):
@@ -118,7 +112,7 @@ class CPV(object):
                return "<%s %r>" % (self.__class__.__name__, str(self))
 
        def __str__(self):
-               return self.scpv
+               return self.cpv
 
 
 # =========
index 3a3c7348b4057a8cab6ccd330be1a436c1f28081..2d5e28bcb9312063a43c4973f3030d9c02379652 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright(c) 2009, Gentoo Foundation
+# Copyright 2009-2010 Gentoo Foundation
 #
 # Licensed under the GNU General Public License, v2
 #
@@ -41,12 +41,12 @@ class Dependencies(CPV):
        """
        def __init__(self, cpv, op='', parser=None):
                if isinstance(cpv, CPV):
-                       self.cpv = cpv
+                       self.__dict__.update(cpv.__dict__)
                else:
-                       self.cpv = CPV(cpv)
+                       CPV.__init__(self, cpv)
 
                self.operator = op
-               self.atom = self.operator + str(self.cpv)
+               self.atom = self.operator + self.cpv
                self.use = []
                self.depatom = str()
 
@@ -74,9 +74,9 @@ class Dependencies(CPV):
                # Try to use the Portage tree first, since emerge only uses the tree
                # when calculating dependencies
                try:
-                       result = PORTDB.aux_get(str(self.cpv), envvars)
+                       result = PORTDB.aux_get(self.cpv, envvars)
                except KeyError:
-                       result = VARDB.aux_get(str(self.cpv), envvars)
+                       result = VARDB.aux_get(self.cpv, envvars)
                return result
 
        def get_depend(self):
@@ -153,7 +153,7 @@ class Dependencies(CPV):
                        except KeyError:
                                pkgdep = find_best_match(dep.atom)
                                depcache[dep.atom] = pkgdep
-                       if pkgdep and str(pkgdep.cpv) in seen:
+                       if pkgdep and pkgdep.cpv in seen:
                                continue
                        if depth < max_depth or max_depth <= 0:
 
@@ -162,7 +162,7 @@ class Dependencies(CPV):
                                if not pkgdep:
                                        continue
 
-                               seen.add(str(pkgdep.cpv))
+                               seen.add(pkgdep.cpv)
                                result.append((
                                        depth,
                                        pkgdep.deps.graph_depends(
@@ -264,11 +264,11 @@ class Dependencies(CPV):
                        # Do not call if we have already called ourselves.
                        if (
                                dep_is_displayed and not only_direct and
-                               str(pkgdep.cpv) not in seen and
+                               pkgdep.cpv not in seen and
                                (depth < max_depth or max_depth == -1)
                        ):
 
-                               seen.add(str(pkgdep.cpv))
+                               seen.add(pkgdep.cpv)
                                result.append(
                                        pkgdep.graph_reverse_depends(
                                                pkgset=pkgset,
index c0a6c4c7aedea53921a924d949276391a734ec0e..19c23a6c63532e4ab3aa8f87d3a831c775bf87a2 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright(c) 2009-2010, Gentoo Foundation
+# Copyright 2009-2010 Gentoo Foundation
 #
 # Licensed under the GNU General Public License, v2 or higher
 #
@@ -143,8 +143,10 @@ def format_maintainers(maints):
                maintstr = maint.email
                if CONFIG['verbose']:
                        maintstr += " (%s)" % (maint.name,) if maint.name else ''
-                       maintstr += "\n%s" % (maint.description,) \
-                               if maint.description else ''
+                       maintstr += " - %s" % (maint.restrict,) if maint.restrict else ''
+                       maintstr += "\n%s" % (
+                               (maint.description,) if maint.description else ''
+                       )
                result.append(maintstr)
 
        return result
@@ -231,7 +233,7 @@ def format_keywords(keywords):
 def format_keywords_line(pkg, fmtd_keywords, slot, verstr_len):
        """Format the entire keywords line for display."""
 
-       ver = pkg.cpv.fullversion
+       ver = pkg.fullversion
        result = "%s:%s: %s" % (ver, pp.slot(slot), fmtd_keywords)
        if CONFIG['verbose'] and fmtd_keywords:
                result = format_line(fmtd_keywords, "%s:%s: " % (ver, pp.slot(slot)),
@@ -249,8 +251,8 @@ def call_format_functions(matches):
        ref_pkg = get_reference_pkg(matches)
 
        if CONFIG['verbose']:
-               repo = ref_pkg.repo_id()
-               print " * %s [%s]" % (pp.cpv(ref_pkg.cpv.cp), pp.section(repo))
+               repo = ref_pkg.repo_name()
+               print " * %s [%s]" % (pp.cpv(ref_pkg.cp), pp.section(repo))
 
        got_opts = False
        if any(QUERY_OPTS.values()):
@@ -294,7 +296,7 @@ def call_format_functions(matches):
 
                for match in matches:
                        slot = match.environment('SLOT')
-                       verstr_len = len(match.cpv.fullversion) + len(slot)
+                       verstr_len = len(match.fullversion) + len(slot)
                        fmtd_keywords = format_keywords(keyword_map[match])
                        keywords_line = format_keywords_line(
                                match, fmtd_keywords, slot, verstr_len
index ee3e5bf51aae1fa797aa683f30e19a9fc4a960c6..1f25666b42e35073d747faa2b1ca50c9b05b897e 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright(c) 2009-2010, Gentoo Foundation
+# Copyright 2009-2010 Gentoo Foundation
 #
 # Licensed under the GNU General Public License, v2 or higher
 #
@@ -114,7 +114,7 @@ class ChangeLog(object):
                for entry_set in self.indexed_entries:
                        i, entry = entry_set
                        # VersionMatch doesn't store .cp, so we'll force it to match here:
-                       i.cpv.cp = atom.cpv.cp
+                       i.cp = atom.cp
                        if atom.intersects(i):
                                result.append(entry)
 
index 33fdcaf4cef359bd8268de24c8c3d310502a9ba0..93538b3e7b972b903eba723c1c424a7a56f177e5 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 #
-# Copyright(c) 2009-2010, Gentoo Foundation
+# Copyright 2009-2010 Gentoo Foundation
 #
 # Licensed under the GNU General Public License, v2
 #
@@ -64,7 +64,8 @@ class _Maintainer(object):
        @ivar description: Description of what a maintainer does. Gentoo only.
        @type restrict: str or None
        @ivar restrict: e.g. &gt;=portage-2.2 means only maintains versions
-               of Portage greater than 2.2.
+               of Portage greater than 2.2. Should be DEPEND string with < and >
+               converted to &lt; and &gt; respectively. 
        @type status: str or None
        @ivar status: If set, either 'active' or 'inactive'. Upstream only.
        """
@@ -208,6 +209,7 @@ class MetaData(object):
                        try:
                                self._herdstree = etree.parse(herds_path)
                        except IOError:
+                               # For some trees, herds.xml may not exist. Bug #300108.
                                return None
 
                # Some special herds are not listed in herds.xml
@@ -224,7 +226,7 @@ class MetaData(object):
                @type include_email: bool
                @keyword include_email: if True, also look up the herd's email
                @rtype: list
-               @return: if include_email is False, return a list of string;
+               @return: if include_email is False, return a list of strings;
                         if include_email is True, return a list of tuples containing:
                                         [('herd1', 'herd1@gentoo.org'), ('no-herd', None);
                """
index ee8c83ed5a7c97bd3da1c287c5adb2012220ac5c..fb68965428f22641e8a553142e7674efd36df87e 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 #
-# Copyright(c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
-# Copyright(c) 2004-2009, Gentoo Foundation
+# Copyright 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
+# Copyright 2004-2010 Gentoo Foundation
 #
 # Licensed under the GNU General Public License, v2
 #
@@ -54,14 +54,14 @@ class Package(CPV):
 
        def __init__(self, cpv):
                if isinstance(cpv, CPV):
-                       self.cpv = cpv
+                       self.__dict__.update(cpv.__dict__)
                else:
-                       self.cpv = CPV(cpv)
+                       CPV.__init__(self, cpv)
                del cpv
 
-               if not all(getattr(self.cpv, x) for x in ('category', 'version')):
+               if not all(hasattr(self, x) for x in ('category', 'version')):
                        # CPV allows some things that Package must not
-                       raise errors.GentoolkitInvalidPackage(str(self.cpv))
+                       raise errors.GentoolkitInvalidPackage(self.cpv)
 
                # Set dynamically
                self._package_path = None
@@ -71,30 +71,16 @@ class Package(CPV):
                self._portdir_path = None
 
        def __repr__(self):
-               return "<%s %r>" % (self.__class__.__name__, str(self.cpv))
-
-       def __eq__(self, other):
-               if not hasattr(other, 'cpv'):
-                       return False
-               return self.cpv == other.cpv
-
-       def __ne__(self, other):
-               return not self == other
-
-       def __lt__(self, other):
-               return self.cpv < other.cpv
-
-       def __gt__(self, other):
-               return self.cpv > other.cpv
+               return "<%s %r>" % (self.__class__.__name__, self.cpv)
 
        def __hash__(self):
-               return hash(str(self.cpv))
+               return hash(self.cpv)
 
        def __contains__(self, key):
-               return key in str(self.cpv)
+               return key in self.cpv
 
        def __str__(self):
-               return str(self.cpv)
+               return self.cpv
 
        @property
        def metadata(self):
@@ -114,8 +100,8 @@ class Package(CPV):
 
                if self._dblink is None:
                        self._dblink = portage.dblink(
-                               self.cpv.category,
-                               "%s-%s" % (self.cpv.name, self.cpv.fullversion),
+                               self.category,
+                               "%s-%s" % (self.name, self.fullversion),
                                settings["ROOT"],
                                settings
                        )
@@ -131,7 +117,7 @@ class Package(CPV):
 
                return self._deps
 
-       def environment(self, envvars, prefer_vdb=True, no_fallback=False):
+       def environment(self, envvars, prefer_vdb=True, fallback=True):
                """Returns one or more of the predefined environment variables.
 
                Available envvars are:
@@ -157,8 +143,8 @@ class Package(CPV):
                @keyword prefer_vdb: if True, look in the vardb before portdb, else
                        reverse order. Specifically KEYWORDS will get more recent
                        information by preferring portdb.
-               @type no_fallback: bool
-               @keyword no_fallback: query only the preferred db
+               @type fallback: bool
+               @keyword fallback: query only the preferred db if False
                @rtype: str or list
                @return: str if envvars is str, list if envvars is array
                @raise KeyError: if key is not found in requested db(s)
@@ -170,23 +156,23 @@ class Package(CPV):
                        envvars = (envvars,)
                if prefer_vdb:
                        try:
-                               result = VARDB.aux_get(str(self.cpv), envvars)
+                               result = VARDB.aux_get(self.cpv, envvars)
                        except KeyError:
                                try:
-                                       if no_fallback:
+                                       if nofallback:
                                                raise KeyError
-                                       result = PORTDB.aux_get(str(self.cpv), envvars)
+                                       result = PORTDB.aux_get(self.cpv, envvars)
                                except KeyError:
                                        err = "aux_get returned unexpected results"
                                        raise errors.GentoolkitFatalError(err)
                else:
                        try:
-                               result = PORTDB.aux_get(str(self.cpv), envvars)
+                               result = PORTDB.aux_get(self.cpv, envvars)
                        except KeyError:
                                try:
-                                       if no_fallback:
+                                       if nofallback:
                                                raise KeyError
-                                       result = VARDB.aux_get(str(self.cpv), envvars)
+                                       result = VARDB.aux_get(self.cpv, envvars)
                                except KeyError:
                                        err = "aux_get returned unexpected results"
                                        raise errors.GentoolkitFatalError(err)
@@ -198,7 +184,7 @@ class Package(CPV):
        def exists(self):
                """Return True if package exists in the Portage tree, else False"""
 
-               return bool(PORTDB.cpv_exists(str(self.cpv)))
+               return bool(PORTDB.cpv_exists(self.cpv))
 
        @staticmethod
        def settings(key):
@@ -228,7 +214,7 @@ class Package(CPV):
                if settings.locked:
                        settings.unlock()
                try:
-                       result = portage.getmaskingstatus(str(self.cpv),
+                       result = portage.getmaskingstatus(self.cpv,
                                settings=settings,
                                portdb=PORTDB)
                except KeyError:
@@ -247,7 +233,7 @@ class Package(CPV):
                """
 
                try:
-                       result = portage.getmaskingreason(str(self.cpv),
+                       result = portage.getmaskingreason(self.cpv,
                                settings=settings,
                                portdb=PORTDB,
                                return_location=True)
@@ -271,8 +257,8 @@ class Package(CPV):
                """
 
                if in_vartree:
-                       return VARDB.findname(str(self.cpv))
-               return PORTDB.findname(str(self.cpv))
+                       return VARDB.findname(self.cpv)
+               return PORTDB.findname(self.cpv)
 
        def package_path(self, in_vartree=False):
                """Return the path to where the ebuilds and other files reside."""
@@ -281,14 +267,26 @@ class Package(CPV):
                        return self.dblink.getpath()
                return os.sep.join(self.ebuild_path().split(os.sep)[:-1])
 
-       def repo_id(self):
-               """Using the package path, determine the repository id.
+       def repo_name(self, fallback=True):
+               """Determine the repository name.
 
+               @type fallback: bool
+               @param fallback: if the repo_name file does not exist, return the
+                       repository name from the path
                @rtype: str
-               @return: /usr/<THIS>portage</THIS>/category/name/
+               @return: output of the repository metadata file, which stores the 
+                       repo_name variable, or try to get the name of the repo from
+                       the path.
+               @raise GentoolkitFatalError: if fallback is False and repo_name is
+                       not specified by the repository.
                """
 
-               return self.package_path().split(os.sep)[-3]
+               try:
+                       return self.environment('repository')
+               except errors.GentoolkitFatalError:
+                       if fallback:
+                               return self.package_path().split(os.sep)[-3]
+                       raise
 
        def use(self):
                """Returns the USE flags active at time of installation."""
@@ -311,11 +309,15 @@ class Package(CPV):
                @return: (size, number of files in total, number of uncounted files)
                """
 
-               contents = self.parsed_contents()
+               seen = set()
+               content_stats = (os.lstat(x) for x in self.parsed_contents())
+               # Remove hardlinks by checking for duplicate inodes. Bug #301026.
+               unique_file_stats = (x for x in content_stats if x.st_ino not in seen
+                       and not seen.add(x.st_ino))
                size = n_uncounted = n_files = 0
-               for cfile in contents:
+               for st in unique_file_stats:
                        try:
-                               size += os.lstat(cfile).st_size
+                               size += st.st_size
                                n_files += 1
                        except OSError:
                                n_uncounted += 1
@@ -329,7 +331,7 @@ class Package(CPV):
        def is_overlay(self):
                """Returns True if the package is in an overlay."""
 
-               ebuild, tree = PORTDB.findname2(str(self.cpv))
+               ebuild, tree = PORTDB.findname2(self.cpv)
                if not ebuild:
                        return None
                if self._portdir_path is None:
@@ -341,8 +343,8 @@ class Package(CPV):
                Note: We blindly assume that the package actually exists on disk
                somewhere."""
 
-               unmasked = PORTDB.xmatch("match-visible", str(self.cpv))
-               return str(self.cpv) not in unmasked
+               unmasked = PORTDB.xmatch("match-visible", self.cpv)
+               return self.cpv not in unmasked
 
 
 class PackageFormatter(object):
index e46e03bc5332a435fdf14f71fce1fe68275d82ea..2291efdb836bb32233836bd458c0d003de1b7843 100644 (file)
@@ -7,6 +7,51 @@ from test import test_support
 from gentoolkit import helpers
 
 
+class TestChangeLog(unittest.TestCase):
+
+       def setUp(self):
+               pass
+
+       def tearDown(self):
+               pass
+
+       def test_split_changelog(self):
+               changelog = """
+*portage-2.1.6.2 (20 Dec 2008)
+
+  20 Dec 2008; Zac Medico <zmedico@gentoo.org> +portage-2.1.6.2.ebuild:
+  2.1.6.2 bump. This fixes bug #251591 (repoman inherit.autotools false
+  positives) and bug #251616 (performance issue in build log search regex
+  makes emerge appear to hang). Bug #216231 tracks all bugs fixed since
+  2.1.4.x.
+
+  20 Dec 2008; Zac Medico <zmedico@gentoo.org> -portage-2.1.6.ebuild,
+  -portage-2.1.6.1.ebuild, -portage-2.2_rc17.ebuild:
+  Remove old versions.
+
+
+*portage-2.1.6.1 (12 Dec 2008)
+
+  12 Dec 2008; Zac Medico <zmedico@gentoo.org> +portage-2.1.6.1.ebuild:
+  2.1.6.1 bump. This fixes bug #250148 (emerge hangs with selinux if ebuild
+  spawns a daemon), bug #250166 (trigger download when generating manifest
+  if file size differs from existing entry), and bug #250212 (new repoman
+  upstream.workaround category for emake -j1 warnings). Bug #216231 tracks
+  all bugs fixed since 2.1.4.x.
+
+
+*portage-2.1.6 (07 Dec 2008)
+
+  07 Dec 2008; Zac Medico <zmedico@gentoo.org> +portage-2.1.6.ebuild:
+  2.1.6 final release. This fixes bug #249586. Bug #216231 tracks all bugs
+  fixed since 2.1.4.x.
+
+  07 Dec 2008; Zac Medico <zmedico@gentoo.org> -portage-2.1.6_rc1.ebuild,
+  -portage-2.1.6_rc2.ebuild, -portage-2.1.6_rc3.ebuild,
+  -portage-2.2_rc16.ebuild:
+  Remove old versions.
+               """
+
 class TestFileOwner(unittest.TestCase):
 
        def setUp(self):
index e3afe69363542887a92ad141a6e5f50904ff78d3..c081de016d27782a9e9cc7cfa3edbde4cf699eff 100644 (file)
@@ -1,9 +1,9 @@
 #! /usr/bin/python
 #
-# Copyright(c) 2009-2010 Gentoo Foundation
+# Copyright 2009-2010 Gentoo Foundation
 # Licensed under the GNU General Public License, v2
 #
-# Copyright(c): 2005-2007 Brian Harring <ferringb@gmail.com>
+# Copyright 2005-2007 Brian Harring <ferringb@gmail.com>
 # License: GPL2/BSD
 #
 # $Header$
@@ -43,8 +43,10 @@ class VersionMatch(object):
                @keyword op: operator
                """
 
-               if not isinstance(cpv, CPV):
-                       raise ValueError("cpv must be a gentoolkit.cpv.CPV instance")
+               if not isinstance(cpv, (CPV, self.__class__)):
+                       err = "cpv must be a gentoolkit.cpv.CPV "
+                       err += "or gentoolkit.versionmatch.VersionMatch instance"
+                       raise ValueError(err)
                self.cpv = cpv
                self.operator = op
                self.version = cpv.version
index ba06995b1c58fbda63ac0d6139ccf925e8242951..094102ba571b158151d25f3fd778e17f7c47a914 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -41,6 +41,7 @@ class set_version(core.Command):
 
        def run(self):
                ver = 'svn' if __version__ == '9999' else __version__
+               print "Setting version to %s" % ver
                def sub(files, pattern):
                        for f in files:
                                updated_file = []