- 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
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:
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
#!/usr/bin/python
#
-# Copyright(c) 2009-2010, Gentoo Foundation
+# Copyright 2009-2010 Gentoo Foundation
#
# Licensed under the GNU General Public License, v2
#
# =======
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:
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'
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):
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):
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
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
@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
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
# 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 ('<', '<=', '>', '>='):
# 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(
#!/usr/bin/python
#
-# Copyright(c) 2009-2010, Gentoo Foundation
+# Copyright 2009-2010 Gentoo Foundation
#
# Licensed under the GNU General Public License, v2
#
"""
def __init__(self, cpv):
- self.scpv = cpv
+ self.cpv = cpv
values = split_cpv(cpv)
self.category = values[0]
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):
return "<%s %r>" % (self.__class__.__name__, str(self))
def __str__(self):
- return self.scpv
+ return self.cpv
# =========
-# Copyright(c) 2009, Gentoo Foundation
+# Copyright 2009-2010 Gentoo Foundation
#
# Licensed under the GNU General Public License, v2
#
"""
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()
# 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):
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:
if not pkgdep:
continue
- seen.add(str(pkgdep.cpv))
+ seen.add(pkgdep.cpv)
result.append((
depth,
pkgdep.deps.graph_depends(
# 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,
-# Copyright(c) 2009-2010, Gentoo Foundation
+# Copyright 2009-2010 Gentoo Foundation
#
# Licensed under the GNU General Public License, v2 or higher
#
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
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)),
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()):
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
-# Copyright(c) 2009-2010, Gentoo Foundation
+# Copyright 2009-2010 Gentoo Foundation
#
# Licensed under the GNU General Public License, v2 or higher
#
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)
#!/usr/bin/python
#
-# Copyright(c) 2009-2010, Gentoo Foundation
+# Copyright 2009-2010 Gentoo Foundation
#
# Licensed under the GNU General Public License, v2
#
@ivar description: Description of what a maintainer does. Gentoo only.
@type restrict: str or None
@ivar restrict: e.g. >=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 < and > respectively.
@type status: str or None
@ivar status: If set, either 'active' or 'inactive'. Upstream only.
"""
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
@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);
"""
#!/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
#
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
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):
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
)
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:
@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)
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 not fallback:
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 not fallback:
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)
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):
if settings.locked:
settings.unlock()
try:
- result = portage.getmaskingstatus(str(self.cpv),
+ result = portage.getmaskingstatus(self.cpv,
settings=settings,
portdb=PORTDB)
except KeyError:
"""
try:
- result = portage.getmaskingreason(str(self.cpv),
+ result = portage.getmaskingreason(self.cpv,
settings=settings,
portdb=PORTDB,
return_location=True)
"""
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."""
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."""
@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
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:
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):
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):
#! /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$
@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
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 = []