From: fuzzyray Date: Thu, 25 Mar 2010 19:25:28 +0000 (-0000) Subject: Merge genscripts rev 410. X-Git-Tag: gentoolkit-0.3.0_rc10~5 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=02b307cd5df888c2c89f26117f5378536b551c81;p=gentoolkit.git Merge genscripts rev 410. svn path=/trunk/gentoolkit/; revision=757 --- diff --git a/pym/gentoolkit/eclean/exclude.py b/pym/gentoolkit/eclean/exclude.py index fa88ae1..6ffa0c6 100644 --- a/pym/gentoolkit/eclean/exclude.py +++ b/pym/gentoolkit/eclean/exclude.py @@ -146,7 +146,7 @@ def parseExcludeFile(filepath, output): #print() return exclude -def cp_all(categories): +def cp_all(categories, portdb=portage.portdb ): """temp function until the new portdb.cp_all([cat,...]) behaviour is fully available. @@ -155,7 +155,7 @@ def cp_all(categories): @rtype: list of cat/pkg's ['foo/bar', 'foo/baz'] """ try: - cps = portage.portdb.cp_all(categories) + cps = portdb.cp_all(categories) message = "Deprication Warning: eclean.exclude.cp_all()\n" + \ "New portage functionality is available " +\ "Please migrate code permanently" @@ -167,7 +167,7 @@ def cp_all(categories): cps = [] # XXX: i smell an access to something which is really out of API... _pkg_dir_name_re = re.compile(r'^\w[-+\w]*$') - for tree in portage.portdb.porttrees: + for tree in portdb.porttrees: for cat in categories: for pkg in listdir(os.path.join(tree,cat), EmptyOnError=1, ignorecvs=1, dirsonly=1): diff --git a/pym/gentoolkit/eclean/search.py b/pym/gentoolkit/eclean/search.py index 91bb182..53da30c 100644 --- a/pym/gentoolkit/eclean/search.py +++ b/pym/gentoolkit/eclean/search.py @@ -70,6 +70,7 @@ class DistfilesSearch(object): self.vardb =vardb self.portdb = portdb self.output = output + self.installed_cpvs = None def findDistfiles(self, exclude={}, @@ -109,8 +110,7 @@ class DistfilesSearch(object): # whose distfiles should be kept if (not destructive) or fetch_restricted: self.output("...non-destructive type search") - # TODO fix fetch_restricted to save the installed packges filenames while processing - pkgs, _deprecated = self._non_destructive(destructive, fetch_restricted, exclude=exclude) + pkgs, _deprecated = self._non_destructive(destructive, fetch_restricted) deprecated.update(_deprecated) installed_included = True if destructive: @@ -260,7 +260,7 @@ class DistfilesSearch(object): destructive, fetch_restricted, pkgs_ = None, - exclude=None + hosts_cpvs=None ): """performs the non-destructive checks @@ -275,16 +275,18 @@ class DistfilesSearch(object): pkgs = {} else: pkgs = pkgs_.copy() - if exclude is None: - exclude = {} deprecated = {} # the following code block was split to optimize for speed # list all CPV from portree (yeah, that takes time...) self.output(" - getting complete ebuild list") cpvs = set(self.portdb.cpv_all()) + installed_cpvs = set(self.vardb.cpv_all()) # now add any installed cpv's that are not in the tree or overlays - installed_cpvs = self.vardb.cpv_all() cpvs.update(installed_cpvs) + # Add any installed cpvs from hosts on the network, if any + if hosts_cpvs: + cpvs.update(hosts_cpvs) + installed_cpvs.update(hosts_cpvs) if fetch_restricted and destructive: self.output(" - getting source file names " + "for %d installed ebuilds" %len(installed_cpvs)) @@ -296,6 +298,8 @@ class DistfilesSearch(object): "for %d remaining ebuilds" %len(cpvs)) pkgs, _deprecated = self._fetch_restricted(pkgs, cpvs) deprecated.update(_deprecated) + # save the installed cpv list to re-use in _destructive() + self.installed_cpvs = installed_cpvs.copy() else: self.output(" - getting source file names " + "for %d ebuilds" %len(cpvs)) @@ -396,7 +400,10 @@ class DistfilesSearch(object): if not package_names: # list all installed CPV's from vartree #print( "_destructive: getting vardb.cpv_all") - pkgset.update(self.vardb.cpv_all()) + if not self.installed_cpvs: + pkgset.update(self.vardb.cpv_all()) + else: + pkgset.update(self.installed_cpvs) self.output(" - processing %s installed ebuilds" % len(pkgset)) elif package_names: # list all CPV's from portree for CP's in vartree @@ -408,6 +415,7 @@ class DistfilesSearch(object): self.output(" - processing excluded") excludes = self._get_excludes(exclude) excludes_length = len(excludes) + dprint("excludes", "EXCLUDES LENGTH =", excludes_length) pkgset.update(excludes) pkgs_done = set(list(pkgs)) pkgset.difference_update(pkgs_done) @@ -420,8 +428,7 @@ class DistfilesSearch(object): #self.output(" - done...") return pkgs, deprecated - @staticmethod - def _get_excludes(exclude): + def _get_excludes(self, exclude): """Expands the exclude dictionary into a set of CPV's @@ -434,6 +441,8 @@ class DistfilesSearch(object): pkgset = set() for cp in exclDictExpand(exclude): # add packages from the exclude file + dprint("excludes", "_GET_EXCLUDES, cp=" + \ + cp+", "+str(self.portdb.cp_list(cp))) pkgset.update(self.portdb.cp_list(cp)) return pkgset diff --git a/pym/gentoolkit/test/eclean/distsupport.py b/pym/gentoolkit/test/eclean/distsupport.py index c9bb944..8054ab7 100644 --- a/pym/gentoolkit/test/eclean/distsupport.py +++ b/pym/gentoolkit/test/eclean/distsupport.py @@ -8,46 +8,316 @@ from __future__ import print_function +import re import os import unittest from tempfile import NamedTemporaryFile, mkdtemp import subprocess +import portage +dir_mode = 0o774 -dir_mode = 0774 - -CPVS = [u'sys-auth/consolekit-0.4.1', u'sys-apps/devicekit-power-014', - u'media-libs/sdl-pango-0.1.2', u'sys-apps/help2man-1.37.1', - u'app-emulation/emul-linux-x86-baselibs-20100220' -] +CPVS = [ + 'sys-auth/consolekit-0.4.1', + 'sys-apps/devicekit-power-014', + 'media-libs/sdl-pango-0.1.2', + 'sys-apps/help2man-1.37.1', + 'app-emulation/emul-linux-x86-baselibs-20100220' + ] PROPS = { - u'sys-apps/devicekit-power-014': {u'SRC_URI': - u'http://hal.freedesktop.org/releases/DeviceKit-power-014.tar.gz', - u"RESTRICT": u''}, - u'sys-apps/help2man-1.37.1': {u"SRC_URI": u'mirror://gnu/help2man/help2man-1.37.1.tar.gz', - u"RESTRICT": u''}, - u'sys-auth/consolekit-0.4.1': { u"SRC_URI": - u'http://www.freedesktop.org/software/ConsoleKit/dist/ConsoleKit-0.4.1.tar.bz2', - u"RESTRICT": u''}, - u'app-emulation/emul-linux-x86-baselibs-20100220': { - u"SRC_URI": u'mirror://gentoo/emul-linux-x86-baselibs-20100220.tar.gz', - u"RESTRICT": u'strip'}, - u'media-libs/sdl-pango-0.1.2': { - u"SRC_URI": u'mirror://sourceforge/sdlpango/SDL_Pango-0.1.2.tar.gz http://zarb.org/~gc/t/SDL_Pango-0.1.2-API-adds.patch', - u"RESTRICT": u''} + 'sys-apps/devicekit-power-014': {'SRC_URI': + 'http://hal.freedesktop.org/releases/DeviceKit-power-014.tar.gz', + "RESTRICT": ''}, + 'sys-apps/help2man-1.37.1': {"SRC_URI": 'mirror://gnu/help2man/help2man-1.37.1.tar.gz', + "RESTRICT": ''}, + 'sys-auth/consolekit-0.4.1': { "SRC_URI": + 'http://www.freedesktop.org/software/ConsoleKit/dist/ConsoleKit-0.4.1.tar.bz2', + "RESTRICT": ''}, + 'app-emulation/emul-linux-x86-baselibs-20100220': { + "SRC_URI": 'mirror://gentoo/emul-linux-x86-baselibs-20100220.tar.gz', + "RESTRICT": 'strip'}, + 'media-libs/sdl-pango-0.1.2': { + "SRC_URI": 'mirror://sourceforge/sdlpango/SDL_Pango-0.1.2.tar.gz http://zarb.org/~gc/t/SDL_Pango-0.1.2-API-adds.patch', + "RESTRICT": ''}, + 'x11-base/xorg-server-1.6.5-r1': { + "SRC_URI": 'http://xorg.freedesktop.org/releases/individual/xserver/xorg-server-1.6.5.tar.bz2 mirror://gentoo/xorg-server-1.6.5-gentoo-patches-01.tar.bz2', + "RESTRICT": ''}, + 'perl-core/ExtUtils-ParseXS-2.20.0401': { + "SRC_URI": 'mirror://cpan/authors/id/D/DA/DAGOLDEN//ExtUtils-ParseXS-2.200401.tar.gz', + "RESTRICT": ''}, + 'x11-misc/util-macros-1.3.0': { + "SRC_URI": 'http://xorg.freedesktop.org/releases/individual/util/util-macros-1.3.0.tar.bz2', + "RESTRICT": ''}, + 'x11-base/xorg-server-1.7.5': { + "SRC_URI": 'http://xorg.freedesktop.org/releases/individual/xserver/xorg-server-1.7.5.tar.bz2', + "RESTRICT": ''}, + 'app-portage/portage-utils-0.3.1': { + "SRC_URI": 'mirror://gentoo/portage-utils-0.3.1.tar.bz2', + "RESTRICT": ''}, + 'x11-misc/util-macros-1.5.0': { + "SRC_URI": 'http://xorg.freedesktop.org/releases/individual/util/util-macros-1.5.0.tar.bz2', + "RESTRICT": ''}, + 'perl-core/Module-Build-0.35': { + "SRC_URI": 'mirror://cpan/authors/id/D/DA/DAGOLDEN//Module-Build-0.35.tar.gz', + "RESTRICT": ''}, + 'perl-core/ExtUtils-ParseXS-2.22.02': { + "SRC_URI": 'mirror://cpan/authors/id/D/DA/DAGOLDEN//ExtUtils-ParseXS-2.2202.tar.gz', + "RESTRICT": ''}, + 'perl-core/ExtUtils-ParseXS-2.22.03': { + "SRC_URI": 'mirror://cpan/authors/id/D/DA/DAGOLDEN//ExtUtils-ParseXS-2.2203.tar.gz', + "RESTRICT": ''}, + 'perl-core/ExtUtils-ParseXS-2.22.01': { + "SRC_URI": 'mirror://cpan/authors/id/D/DA/DAGOLDEN//ExtUtils-ParseXS-2.2201.tar.gz', + "RESTRICT": ''}, + 'perl-core/Archive-Tar-1.38': { + "SRC_URI": 'mirror://cpan/authors/id/K/KA/KANE/Archive-Tar-1.38.tar.gz', + "RESTRICT": ''}, + 'perl-core/Archive-Tar-1.58': { + "SRC_URI": 'mirror://cpan/authors/id/B/BI/BINGOS//Archive-Tar-1.58.tar.gz', + "RESTRICT": ''}, + 'perl-core/Archive-Tar-1.54': { + "SRC_URI": 'mirror://cpan/authors/id/B/BI/BINGOS//Archive-Tar-1.54.tar.gz', + "RESTRICT": ''}, + 'perl-core/Archive-Tar-1.56': { + "SRC_URI": 'mirror://cpan/authors/id/B/BI/BINGOS//Archive-Tar-1.56.tar.gz', + "RESTRICT": ''}, + 'app-portage/portage-utils-0.2.1': { + "SRC_URI": 'mirror://gentoo/portage-utils-0.2.1.tar.bz2', + "RESTRICT": ''}, + 'dev-libs/libisofs-0.6.20-r1': { + "SRC_URI": 'http://files.libburnia-project.org/releases/libisofs-0.6.20.tar.gz', + "RESTRICT": ''}, + 'perl-core/ExtUtils-ParseXS-2.22.02-r1': { + "SRC_URI": 'mirror://cpan/authors/id/D/DA/DAGOLDEN//ExtUtils-ParseXS-2.2202.tar.gz', + "RESTRICT": ''}, + 'x11-misc/util-macros-1.6.0': { + "SRC_URI": 'http://xorg.freedesktop.org/releases/individual/util/util-macros-1.6.0.tar.bz2', + "RESTRICT": ''}, + 'x11-libs/pixman-0.16.0': { + "SRC_URI": 'http://xorg.freedesktop.org/releases/individual/lib/pixman-0.16.0.tar.bz2', + "RESTRICT": ''}, + 'x11-libs/pixman-0.16.4': { + "SRC_URI": 'http://xorg.freedesktop.org/releases/individual/lib/pixman-0.16.4.tar.bz2', + "RESTRICT": ''}, + 'x11-libs/pixman-0.17.4': { + "SRC_URI": 'http://xorg.freedesktop.org/releases/individual/lib/pixman-0.17.4.tar.bz2', + "RESTRICT": ''}, + 'x11-libs/pixman-0.17.2': { + "SRC_URI": 'http://xorg.freedesktop.org/releases/individual/lib/pixman-0.17.2.tar.bz2', + "RESTRICT": ''}, + 'dev-libs/libburn-0.7.6-r1': { + "SRC_URI": 'http://files.libburnia-project.org/releases/libburn-0.7.6.pl00.tar.gz', + "RESTRICT": ''}, + 'dev-libs/libburn-0.7.0': { + "SRC_URI": 'http://files.libburnia-project.org/releases/libburn-0.7.0.pl00.tar.gz', + "RESTRICT": ''}, + 'perl-core/Module-Build-0.34.0201': { + "SRC_URI": 'mirror://cpan/authors/id/D/DA/DAGOLDEN//Module-Build-0.340201.tar.gz', + "RESTRICT": ''}, + 'dev-libs/libburn-0.6.8': { + "SRC_URI": 'http://files.libburnia-project.org/releases/libburn-0.6.8.pl00.tar.gz', + "RESTRICT": ''}, + 'dev-libs/libburn-0.7.4': { + "SRC_URI": 'http://files.libburnia-project.org/releases/libburn-0.7.4.pl00.tar.gz', + "RESTRICT": ''}, + 'perl-core/Module-Build-0.36.03': { + "SRC_URI": 'mirror://cpan/authors/id/D/DA/DAGOLDEN//Module-Build-0.3603.tar.gz', + "RESTRICT": ''}, + 'perl-core/Module-Build-0.36.01': { + "SRC_URI": 'mirror://cpan/authors/id/D/DA/DAGOLDEN//Module-Build-0.3601.tar.gz', + "RESTRICT": ''}, + 'x11-base/xorg-server-1.5.3-r6': { + "SRC_URI": 'http://xorg.freedesktop.org/releases/individual/xserver/xorg-server-1.5.3.tar.bz2 http://xorg.freedesktop.org/releases/individual/xserver/xorg-server-1.5.3.tar.bz2 mirror://gentoo/xorg-server-1.5.3-gentoo-patches-08.tar.bz2', + "RESTRICT": ''}, + 'dev-libs/libisofs-0.6.28': { + "SRC_URI": 'http://files.libburnia-project.org/releases/libisofs-0.6.28.tar.gz', + "RESTRICT": ''}, + 'media-libs/xine-lib-1.1.17': { + "SRC_URI": 'mirror://sourceforge/xine/xine-lib-1.1.17.tar.bz2 mirror://gentoo/xine-lib-1.1.15-textrel-fix.patch', + "RESTRICT": ''}, + 'media-libs/xine-lib-1.1.18': { + "SRC_URI": 'mirror://sourceforge/xine/xine-lib-1.1.18.tar.xz mirror://gentoo/xine-lib-1.1.15-textrel-fix.patch mirror://gentoo/xine-lib-1.1.18-compat.c.tbz2', + "RESTRICT": ''}, + 'perl-core/ExtUtils-ParseXS-2.22': { + "SRC_URI": 'mirror://cpan/authors/id/D/DA/DAGOLDEN//ExtUtils-ParseXS-2.22.tar.gz', + "RESTRICT": ''}, + 'perl-core/ExtUtils-ParseXS-2.21': { + "SRC_URI": 'mirror://cpan/authors/id/D/DA/DAGOLDEN//ExtUtils-ParseXS-2.21.tar.gz', + "RESTRICT": ''}, + 'x11-base/xorg-server-1.7.5.901': { + "SRC_URI": 'http://xorg.freedesktop.org/releases/individual/xserver/xorg-server-1.7.5.901.tar.bz2', + "RESTRICT": ''}, + 'dev-libs/libisofs-0.6.24': { + "SRC_URI": 'http://files.libburnia-project.org/releases/libisofs-0.6.24.tar.gz', + "RESTRICT": ''}, + 'dev-libs/libisofs-0.6.26': { + "SRC_URI": 'http://files.libburnia-project.org/releases/libisofs-0.6.26.tar.gz', + "RESTRICT": ''}, + 'app-portage/portage-utils-0.3.1': { + "SRC_URI": 'mirror://gentoo/portage-utils-0.3.1.tar.bz2', + "RESTRICT": ''}, + 'app-portage/gentoolkit-0.3.0_rc8-r1': { + "SRC_URI": 'mirror://gentoo/gentoolkit-0.3.0_rc8.tar.gz http://dev.gentoo.org/~fuzzyray/distfiles/gentoolkit-0.3.0_rc8.tar.gz', + "RESTRICT": ''}, + 'app-portage/gentoolkit-0.2.4.6-r1': { + "SRC_URI": 'mirror://gentoo/gentoolkit-0.2.4.6.tar.gz http://dev.gentoo.org/~fuzzyray/distfiles/gentoolkit-0.2.4.6.tar.gz', + "RESTRICT": ''}, + 'app-portage/eix-0.20.2': { + "SRC_URI": 'mirror://berlios/eix/eix-0.20.2.tar.xz', + "RESTRICT": ''}, + 'app-portage/gentoolkit-0.2.4.5': { + "SRC_URI": 'mirror://gentoo/gentoolkit-0.2.4.5.tar.gz http://dev.gentoo.org/~fuzzyray/distfiles/gentoolkit-0.2.4.5.tar.gz', + "RESTRICT": ''}, + 'app-portage/portage-utils-0.2.1': { + "SRC_URI": 'mirror://gentoo/portage-utils-0.2.1.tar.bz2', + "RESTRICT": ''}, + 'app-portage/gentoolkit-0.3.0_rc8': { + "SRC_URI": 'mirror://gentoo/gentoolkit-0.3.0_rc8.tar.gz http://dev.gentoo.org/~fuzzyray/distfiles/gentoolkit-0.3.0_rc8.tar.gz', + "RESTRICT": ''}, + 'app-portage/gentoolkit-0.2.4.6': { + "SRC_URI": 'mirror://gentoo/gentoolkit-0.2.4.6.tar.gz http://dev.gentoo.org/~fuzzyray/distfiles/gentoolkit-0.2.4.6.tar.gz', + "RESTRICT": ''}, + 'app-portage/layman-1.3.0-r1': { + "SRC_URI": 'mirror://sourceforge/layman/layman-1.3.0.tar.gz', + "RESTRICT": ''}, + 'app-portage/gentoolkit-0.3.0_rc7': { + "SRC_URI": 'mirror://gentoo/gentoolkit-0.3.0_rc7.tar.gz http://dev.gentoo.org/~fuzzyray/distfiles/gentoolkit-0.3.0_rc7.tar.gz', + "RESTRICT": ''}, + 'app-portage/layman-1.3.0': { + "SRC_URI": 'mirror://sourceforge/layman/layman-1.3.0.tar.gz', + "RESTRICT": ''}, + 'app-portage/layman-1.3.1': { + "SRC_URI": 'mirror://sourceforge/layman/layman-1.3.1.tar.gz', + "RESTRICT": ''}, + 'app-portage/layman-1.2.6': { + "SRC_URI": 'mirror://sourceforge/layman/layman-1.2.6.tar.gz', + "RESTRICT": ''}, + 'app-portage/layman-9999': { + "SRC_URI": '', + "RESTRICT": ''}, + 'app-portage/layman-1.2.5': { + "SRC_URI": 'mirror://sourceforge/layman/layman-1.2.5.tar.gz', + "RESTRICT": ''}, + 'app-portage/layman-1.3.0_rc1-r3': { + "SRC_URI": 'mirror://sourceforge/layman/layman-1.3.0_rc1.tar.gz', + "RESTRICT": ''}, + 'app-portage/gentoolkit-0.3.0_rc9': { + "SRC_URI": 'mirror://gentoo/gentoolkit-0.3.0_rc9.tar.gz http://dev.gentoo.org/~fuzzyray/distfiles/gentoolkit-0.3.0_rc9.tar.gz', + "RESTRICT": ''}, + 'app-portage/eix-0.20.1': { + "SRC_URI": 'mirror://sourceforge/eix/eix-0.20.1.tar.xz', + "RESTRICT": ''}, + 'app-portage/eix-0.19.2': { + "SRC_URI": 'mirror://sourceforge/eix/eix-0.19.2.tar.xz', + "RESTRICT": ''}, + 'app-portage/layman-1.3.2-r1': { + "SRC_URI": 'mirror://sourceforge/layman/layman-1.3.2.tar.gz', + "RESTRICT": ''}, } FILES = [ - u'DeviceKit-power-014.tar.gz', - u'help2man-1.37.1.tar.gz', - u'ConsoleKit-0.4.1.tar.bz2', - u'emul-linux-x86-baselibs-20100220.tar.gz', - u'SDL_Pango-0.1.2.tar.gz', - u'SDL_Pango-0.1.2-API-adds.patch' + 'DeviceKit-power-014.tar.gz', + 'help2man-1.37.1.tar.gz', + 'ConsoleKit-0.4.1.tar.bz2', + 'emul-linux-x86-baselibs-20100220.tar.gz', + 'SDL_Pango-0.1.2.tar.gz', + 'SDL_Pango-0.1.2-API-adds.patch' ] +CPVS2 = [ + 'perl-core/Archive-Tar-1.38', + 'perl-core/Archive-Tar-1.54', + 'perl-core/Archive-Tar-1.56', + 'perl-core/Archive-Tar-1.58', + 'perl-core/ExtUtils-ParseXS-2.20.0401', + 'perl-core/ExtUtils-ParseXS-2.21', + 'perl-core/ExtUtils-ParseXS-2.22', + 'perl-core/ExtUtils-ParseXS-2.22.01', + 'perl-core/ExtUtils-ParseXS-2.22.02', + 'perl-core/ExtUtils-ParseXS-2.22.02-r1', + 'perl-core/ExtUtils-ParseXS-2.22.03', + 'perl-core/Module-Build-0.34.0201', + 'perl-core/Module-Build-0.35', + 'perl-core/Module-Build-0.36.01', + 'perl-core/Module-Build-0.36.03', + 'dev-libs/libburn-0.6.8', + 'dev-libs/libburn-0.7.0', + 'dev-libs/libburn-0.7.4', + 'dev-libs/libburn-0.7.6-r1', + 'dev-libs/libisofs-0.6.20-r1', + 'dev-libs/libisofs-0.6.24', + 'dev-libs/libisofs-0.6.26', + 'dev-libs/libisofs-0.6.28', + 'x11-libs/pixman-0.16.0', + 'x11-libs/pixman-0.16.4', + 'x11-libs/pixman-0.17.2', + 'x11-libs/pixman-0.17.4', + 'app-portage/portage-utils-0.2.1', + 'app-portage/portage-utils-0.3.1', + 'x11-misc/util-macros-1.3.0', + 'x11-misc/util-macros-1.5.0', + 'x11-misc/util-macros-1.6.0', + 'media-libs/xine-lib-1.1.17', + 'media-libs/xine-lib-1.1.18', + 'x11-base/xorg-server-1.5.3-r6', + 'x11-base/xorg-server-1.6.5-r1', + 'x11-base/xorg-server-1.7.5', + 'x11-base/xorg-server-1.7.5.901', + 'app-portage/layman-1.2.5', + 'app-portage/layman-1.2.6', + 'app-portage/layman-1.3.0_rc1-r3', + 'app-portage/layman-1.3.0', + 'app-portage/layman-1.3.0-r1', + 'app-portage/layman-1.3.1', + 'app-portage/layman-1.3.2-r1', + 'app-portage/layman-9999', + 'app-portage/eix-0.19.2', + 'app-portage/eix-0.20.1', + 'app-portage/eix-0.20.2', + 'app-portage/gentoolkit-0.2.4.5', + 'app-portage/gentoolkit-0.2.4.6', + 'app-portage/gentoolkit-0.2.4.6-r1', + 'app-portage/gentoolkit-0.3.0_rc7', + 'app-portage/gentoolkit-0.3.0_rc8', + 'app-portage/gentoolkit-0.3.0_rc8-r1', + 'app-portage/gentoolkit-0.3.0_rc9', + 'app-portage/portage-utils-0.2.1', + 'app-portage/portage-utils-0.3.1' + ] + +CPVS3 = [ + 'x11-base/xorg-server-1.6.5-r1', + 'x11-misc/util-macros-1.6.0', + 'x11-libs/pixman-0.16.4', + #'dev-libs/libisofs-0.6.28', + #'perl-core/Module-Build-0.36.03', + #'perl-core/ExtUtils-ParseXS-2.22.02-r1', + #'perl-core/Archive-Tar-1.56', + #'app-portage/gentoolkit-0.3.0_rc8-r1', + #'app-portage/layman-1.3.1', + #'app-portage/eix-0.20.1', + ] + + +Exclude= {'packages': { + 'media-libs/sdl-pango': None, + }, + 'anti-packages': {'app-emulation/emul-linux-x86-baselibs': None}, + 'categories': {'app-portage': None, + 'app-portage/gentoolkit': None + }, + 'filenames': {'sys-auth/consolekit-0.4.1': re.compile('sys-auth/consolekit-0.4.1') + } + } + + +def get_props(cpvs): + props = {} + for cpv in cpvs: + props[cpv] = PROPS[cpv] + return props class Dbapi(object): """Fake portage dbapi class used to return @@ -77,11 +347,21 @@ class Dbapi(object): return self._cp_all[:] def cp_list(self, package): - #need to determine the data to return - # and gather some from a live system to use for testing - pass + print(self._cp_list) + if self._cp_list is None or self._cp_list==[]: + cplist = [] + for cpv in self._cpv_all: + parts = portage.catpkgsplit(cpv) + cp='/'.join(parts[:2]) + print(package, cp) + if cp == package: + cplist.append(cpv) + return cplist + else: + return self._cp_list def cpv_all(self): + #print(self.name, type(self._cpv_all), self._cpv_all) return self._cpv_all def cpv_exists(self, cpv): @@ -96,7 +376,7 @@ class Dbapi(object): if cpv in self._props: props.append(self._props[cpv][prop]) else: - raise KeyError, self.name + raise KeyError(self.name) return props diff --git a/pym/gentoolkit/test/eclean/test_search.py b/pym/gentoolkit/test/eclean/test_search.py index e399fa1..c8c2e72 100644 --- a/pym/gentoolkit/test/eclean/test_search.py +++ b/pym/gentoolkit/test/eclean/test_search.py @@ -1,3 +1,6 @@ +#!/usr/bin/python + + # Copyright(c) 2009, Gentoo Foundation # Copyright 2010 Brian Dolbec # @@ -19,8 +22,9 @@ except ImportError: from test import support as test_support from gentoolkit.test.eclean.distsupport import * +import gentoolkit.eclean.search as search from gentoolkit.eclean.search import DistfilesSearch - +from gentoolkit.eclean.exclude import parseExcludeFile """Tests for eclean's distfiles search functions.""" @@ -182,141 +186,413 @@ class TestFetchRestricted(unittest.TestCase): self.vardb = Dbapi(cp_all=[], cpv_all=CPVS, props=PROPS, cp_list=[], name="FAKE VARDB") self.portdb = Dbapi(cp_all=[], cpv_all=CPVS[:4], - props=self.get_props(CPVS[:4]), cp_list=[], name="FAKE PORTDB") + props=get_props(CPVS[:4]), cp_list=[], name="FAKE PORTDB") # set a fetch restricted pkg - self.portdb._props[CPVS[0]]["RESTRICT"] = u'fetch' + self.portdb._props[CPVS[0]]["RESTRICT"] = 'fetch' self.callback_data = [] self.output = self.output = OutputSimulator(self.callback) self.target_class = DistfilesSearch(self.output.einfo, self.portdb, self.vardb) self.target_class.portdb = self.portdb self.target_class.portdb = self.portdb + self.results = {} self.testdata = { 'fetch_restricted1':{ 'deprecated': - {u'app-emulation/emul-linux-x86-baselibs-20100220': u'mirror://gentoo/emul-linux-x86-baselibs-20100220.tar.gz' + {'app-emulation/emul-linux-x86-baselibs-20100220': 'mirror://gentoo/emul-linux-x86-baselibs-20100220.tar.gz' }, 'pkgs': - {u'sys-auth/consolekit-0.4.1': u'http://www.freedesktop.org/software/ConsoleKit/dist/ConsoleKit-0.4.1.tar.bz2' + {'sys-auth/consolekit-0.4.1': 'http://www.freedesktop.org/software/ConsoleKit/dist/ConsoleKit-0.4.1.tar.bz2' }, 'output': [ - u'!!! "Deprecation Warning: Installed package: app-emulation/emul-linux-x86-baselibs-20100220\n\tIs no longer in the tree or an installed overlay\n' + '!!! "Deprecation Warning: Installed package: app-emulation/emul-linux-x86-baselibs-20100220\n\tIs no longer in the tree or an installed overlay\n' ] }, 'fetch_restricted2':{ 'deprecated': - {u'app-emulation/emul-linux-x86-baselibs-20100220': u'mirror://gentoo/emul-linux-x86-baselibs-20100220.tar.gz' + {'app-emulation/emul-linux-x86-baselibs-20100220': 'mirror://gentoo/emul-linux-x86-baselibs-20100220.tar.gz' }, 'pkgs': - {u'sys-auth/consolekit-0.4.1': u'http://www.freedesktop.org/software/ConsoleKit/dist/ConsoleKit-0.4.1.tar.bz2' + {'sys-auth/consolekit-0.4.1': 'http://www.freedesktop.org/software/ConsoleKit/dist/ConsoleKit-0.4.1.tar.bz2' }, 'output': [ - u'!!! "Deprecation Warning: Installed package: app-emulation/emul-linux-x86-baselibs-20100220\n\tIs no longer in the tree or an installed overlay\n', + '!!! "Deprecation Warning: Installed package: app-emulation/emul-linux-x86-baselibs-20100220\n\tIs no longer in the tree or an installed overlay\n', ' - Key Error looking up: app-portage/deprecated-pkg-1.0.0' ] }, 'unrestricted1':{ 'deprecated':{ - u'app-emulation/emul-linux-x86-baselibs-20100220': u'mirror://gentoo/emul-linux-x86-baselibs-20100220.tar.gz' + 'app-emulation/emul-linux-x86-baselibs-20100220': 'mirror://gentoo/emul-linux-x86-baselibs-20100220.tar.gz' }, 'pkgs': { - u'sys-apps/devicekit-power-014': u'http://hal.freedesktop.org/releases/DeviceKit-power-014.tar.gz', - u'sys-apps/help2man-1.37.1': u'mirror://gnu/help2man/help2man-1.37.1.tar.gz', - u'sys-auth/consolekit-0.4.1': u'http://www.freedesktop.org/software/ConsoleKit/dist/ConsoleKit-0.4.1.tar.bz2', - u'app-emulation/emul-linux-x86-baselibs-20100220': u'mirror://gentoo/emul-linux-x86-baselibs-20100220.tar.gz', - u'media-libs/sdl-pango-0.1.2': u'mirror://sourceforge/sdlpango/SDL_Pango-0.1.2.tar.gz http://zarb.org/~gc/t/SDL_Pango-0.1.2-API-adds.patch' + 'sys-apps/devicekit-power-014': 'http://hal.freedesktop.org/releases/DeviceKit-power-014.tar.gz', + 'sys-apps/help2man-1.37.1': 'mirror://gnu/help2man/help2man-1.37.1.tar.gz', + 'sys-auth/consolekit-0.4.1': 'http://www.freedesktop.org/software/ConsoleKit/dist/ConsoleKit-0.4.1.tar.bz2', + 'app-emulation/emul-linux-x86-baselibs-20100220': 'mirror://gentoo/emul-linux-x86-baselibs-20100220.tar.gz', + 'media-libs/sdl-pango-0.1.2': 'mirror://sourceforge/sdlpango/SDL_Pango-0.1.2.tar.gz http://zarb.org/~gc/t/SDL_Pango-0.1.2-API-adds.patch' }, 'output': [ - u'!!! "Deprecation Warning: Installed package: app-emulation/emul-linux-x86-baselibs-20100220\n\tIs no longer in the tree or an installed overlay\n', + '!!! "Deprecation Warning: Installed package: app-emulation/emul-linux-x86-baselibs-20100220\n\tIs no longer in the tree or an installed overlay\n', ] }, 'unrestricted2':{ 'deprecated':{ - u'app-emulation/emul-linux-x86-baselibs-20100220': u'mirror://gentoo/emul-linux-x86-baselibs-20100220.tar.gz' + 'app-emulation/emul-linux-x86-baselibs-20100220': 'mirror://gentoo/emul-linux-x86-baselibs-20100220.tar.gz' }, 'pkgs': { - u'sys-apps/devicekit-power-014': u'http://hal.freedesktop.org/releases/DeviceKit-power-014.tar.gz', - u'sys-apps/help2man-1.37.1': u'mirror://gnu/help2man/help2man-1.37.1.tar.gz', - u'sys-auth/consolekit-0.4.1': u'http://www.freedesktop.org/software/ConsoleKit/dist/ConsoleKit-0.4.1.tar.bz2', - u'app-emulation/emul-linux-x86-baselibs-20100220': u'mirror://gentoo/emul-linux-x86-baselibs-20100220.tar.gz', - u'media-libs/sdl-pango-0.1.2': u'mirror://sourceforge/sdlpango/SDL_Pango-0.1.2.tar.gz http://zarb.org/~gc/t/SDL_Pango-0.1.2-API-adds.patch' + 'sys-apps/devicekit-power-014': 'http://hal.freedesktop.org/releases/DeviceKit-power-014.tar.gz', + 'sys-apps/help2man-1.37.1': 'mirror://gnu/help2man/help2man-1.37.1.tar.gz', + 'sys-auth/consolekit-0.4.1': 'http://www.freedesktop.org/software/ConsoleKit/dist/ConsoleKit-0.4.1.tar.bz2', + 'app-emulation/emul-linux-x86-baselibs-20100220': 'mirror://gentoo/emul-linux-x86-baselibs-20100220.tar.gz', + 'media-libs/sdl-pango-0.1.2': 'mirror://sourceforge/sdlpango/SDL_Pango-0.1.2.tar.gz http://zarb.org/~gc/t/SDL_Pango-0.1.2-API-adds.patch' }, 'output': [ - u'!!! "Deprecation Warning: Installed package: app-emulation/emul-linux-x86-baselibs-20100220\n\tIs no longer in the tree or an installed overlay\n', + '!!! "Deprecation Warning: Installed package: app-emulation/emul-linux-x86-baselibs-20100220\n\tIs no longer in the tree or an installed overlay\n', ' - Key Error looking up: app-portage/deprecated-pkg-1.0.0' ] } } - - def get_props(self, cpvs): - props = {} - for cpv in cpvs: - props[cpv] = PROPS[cpv] - return props - - def callback(self, id, data): self.callback_data.append(data) def test__fetch_restricted(self): + self.results = {} pkgs, deprecated = self.target_class._fetch_restricted(None, CPVS) - self.results = { - 'fetch_restricted1': { - 'pkgs': pkgs, - 'deprecated': deprecated, - 'output': self.callback_data - } - } + self.record_results('fetch_restricted1', pkgs, deprecated) self.callback_data = [] cpvs = CPVS[:] cpvs.append('app-portage/deprecated-pkg-1.0.0') pkgs, deprecated = self.target_class._fetch_restricted(None, cpvs) - self.results['fetch_restricted2'] = { - 'pkgs': pkgs, - 'deprecated': deprecated, - 'output': self.callback_data - } + self.record_results('fetch_restricted2', pkgs, deprecated) + self.test_results("test_fetch_restricted") + + def test_unrestricted(self): + self.results = {} + pkgs, deprecated = self.target_class._unrestricted(None, CPVS) + self.record_results('unrestricted1', pkgs, deprecated) + self.callback_data = [] + cpvs = CPVS[:] + cpvs.append('app-portage/deprecated-pkg-1.0.0') + pkgs, deprecated = self.target_class._unrestricted(None, cpvs) + self.record_results('unrestricted2', pkgs, deprecated) + self.test_results("test_unrestricted") + + + def test_results(self, test_name): + print("\nChecking results for %s,............" %test_name) for key in sorted(self.results): testdata = self.testdata[key] results = self.results[key] for item in sorted(testdata): + #print("comparing %s, %s" %(key, item)) self.failUnlessEqual(sorted(testdata[item]), sorted(results[item]), - "\ntest_fetch_restricted: %s %s data does not match\nresult=" %(key, item) +\ + "\n%s: %s %s data does not match\nresult=" %(test_name, key, item) +\ str(results[item]) + "\ntestdata=" + str(testdata[item])) - - def test_unrestricted(self): - pkgs, deprecated = self.target_class._unrestricted(None, CPVS) - self.results = { - 'unrestricted1': { - 'pkgs': pkgs, + def record_results(self, test, pkgs, deprecated): + self.results[test] = {'pkgs': pkgs, 'deprecated': deprecated, 'output': self.callback_data } + + +class TestNonDestructive(unittest.TestCase): + """Tests eclean.search.DistfilesSearch._non_destructive and _destructive + functions, with addition useage tests of fetch_restricted() and _unrestricted() + """ + + def setUp(self): + self.vardb = Dbapi(cp_all=[], cpv_all=CPVS, + props=PROPS, cp_list=[], name="FAKE VARDB") + self.portdb = Dbapi(cp_all=[], cpv_all=CPVS[:4], + props=get_props(CPVS[:4]), cp_list=[], name="FAKE PORTDB") + # set a fetch restricted pkg + self.portdb._props[CPVS[0]]["RESTRICT"] = 'fetch' + self.callback_data = [] + self.output = self.output = OutputSimulator(self.callback) + self.target_class = DistfilesSearch(self.output.einfo, self.portdb, self.vardb) + self.target_class.portdb = self.portdb + self.target_class.portdb = self.portdb + search.exclDictExpand = self.exclDictExpand + self.exclude = parseExcludeFile(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'distfiles.exclude'), self.output.einfo) + #print(self.callback_data) + #print(self.exclude) + self.callback_data = [] + self.results = {} + self.testdata = { + 'non_destructive1':{ + 'deprecated': + {'app-emulation/emul-linux-x86-baselibs-20100220': 'mirror://gentoo/emul-linux-x86-baselibs-20100220.tar.gz' + }, + 'pkgs': { + 'sys-auth/consolekit-0.4.1': 'http://www.freedesktop.org/software/ConsoleKit/dist/ConsoleKit-0.4.1.tar.bz2', + 'sys-apps/help2man-1.37.1': 'mirror://gnu/help2man/help2man-1.37.1.tar.gz', + 'sys-apps/devicekit-power-014': 'http://hal.freedesktop.org/releases/DeviceKit-power-014.tar.gz', + 'app-emulation/emul-linux-x86-baselibs-20100220': 'mirror://gentoo/emul-linux-x86-baselibs-20100220.tar.gz', + 'media-libs/sdl-pango-0.1.2': 'mirror://sourceforge/sdlpango/SDL_Pango-0.1.2.tar.gz http://zarb.org/~gc/t/SDL_Pango-0.1.2-API-adds.patch' + }, + 'output': [ + ' - getting complete ebuild list', + ' - getting source file names for 5 ebuilds', + '!!! "Deprecation Warning: Installed package: app-emulation/emul-linux-x86-baselibs-20100220\n\tIs no longer in the tree or an installed overlay\n' + ] + }, + 'non_destructive2':{ + 'deprecated': { + }, + 'pkgs': { + 'sys-auth/consolekit-0.4.1': 'http://www.freedesktop.org/software/ConsoleKit/dist/ConsoleKit-0.4.1.tar.bz2', + 'sys-apps/devicekit-power-014': 'http://hal.freedesktop.org/releases/DeviceKit-power-014.tar.gz', + 'media-libs/sdl-pango-0.1.2': 'mirror://sourceforge/sdlpango/SDL_Pango-0.1.2.tar.gz http://zarb.org/~gc/t/SDL_Pango-0.1.2-API-adds.patch' + }, + 'output': [ + ' - getting complete ebuild list', + ' - getting source file names for 3 installed ebuilds', + ' - getting fetch-restricted source file names for 2 remaining ebuilds' + ] + }, + 'non_destructive3':{ + 'deprecated':{ + }, + 'pkgs': { + 'sys-apps/devicekit-power-014': 'http://hal.freedesktop.org/releases/DeviceKit-power-014.tar.gz', + 'sys-auth/consolekit-0.4.1': 'http://www.freedesktop.org/software/ConsoleKit/dist/ConsoleKit-0.4.1.tar.bz2', + 'app-emulation/emul-linux-x86-baselibs-20100220': 'mirror://gentoo/emul-linux-x86-baselibs-20100220.tar.gz', + }, + 'output': [ + ' - getting complete ebuild list', + ' - getting source file names for 2 installed ebuilds', + ' - getting fetch-restricted source file names for 3 remaining ebuilds' + ] + }, + 'destructive1':{ + 'deprecated':{ + 'app-emulation/emul-linux-x86-baselibs-20100220': 'mirror://gentoo/emul-linux-x86-baselibs-20100220.tar.gz' + }, + 'pkgs': { + 'sys-apps/devicekit-power-014': 'http://hal.freedesktop.org/releases/DeviceKit-power-014.tar.gz', + 'sys-apps/help2man-1.37.1': 'mirror://gnu/help2man/help2man-1.37.1.tar.gz', + 'sys-auth/consolekit-0.4.1': 'http://www.freedesktop.org/software/ConsoleKit/dist/ConsoleKit-0.4.1.tar.bz2', + 'app-emulation/emul-linux-x86-baselibs-20100220': 'mirror://gentoo/emul-linux-x86-baselibs-20100220.tar.gz', + 'media-libs/sdl-pango-0.1.2': 'mirror://sourceforge/sdlpango/SDL_Pango-0.1.2.tar.gz http://zarb.org/~gc/t/SDL_Pango-0.1.2-API-adds.patch' + }, + 'output': [ + ' - processing 5 installed ebuilds', ' - processing excluded', + ' - (5 of 0 total) additional excluded packages to get source filenames for', + '!!! "Deprecation Warning: Installed package: app-emulation/emul-linux-x86-baselibs-20100220\n\tIs no longer in the tree or an installed overlay\n' + ] + }, + 'destructive2':{ + 'deprecated':{ + }, + 'pkgs': { + }, + 'output': [ + ' - processing 0 installed packages', + ' - processing excluded', ' - (0 of 0 total) additional excluded packages to get source filenames for' + ] + }, + 'destructive3':{ + 'deprecated':{ + }, + 'pkgs': { + 'app-portage/portage-utils-0.3.1': 'mirror://gentoo/portage-utils-0.3.1.tar.bz2', + 'app-portage/gentoolkit-0.2.4.5': 'mirror://gentoo/gentoolkit-0.2.4.5.tar.gz http://dev.gentoo.org/~fuzzyray/distfiles/gentoolkit-0.2.4.5.tar.gz', + 'app-portage/gentoolkit-0.3.0_rc8-r1': 'mirror://gentoo/gentoolkit-0.3.0_rc8.tar.gz http://dev.gentoo.org/~fuzzyray/distfiles/gentoolkit-0.3.0_rc8.tar.gz', + 'app-portage/gentoolkit-0.2.4.6-r1': 'mirror://gentoo/gentoolkit-0.2.4.6.tar.gz http://dev.gentoo.org/~fuzzyray/distfiles/gentoolkit-0.2.4.6.tar.gz', + 'app-portage/eix-0.20.2': 'mirror://berlios/eix/eix-0.20.2.tar.xz', + 'sys-apps/devicekit-power-014': {'SRC_URI': 'http://hal.freedesktop.org/releases/DeviceKit-power-014.tar.gz'}, + 'app-portage/portage-utils-0.2.1': 'mirror://gentoo/portage-utils-0.2.1.tar.bz2', + 'app-portage/eix-0.20.1': 'mirror://sourceforge/eix/eix-0.20.1.tar.xz', + 'app-portage/layman-1.2.5': 'mirror://sourceforge/layman/layman-1.2.5.tar.gz', + 'app-portage/layman-1.3.0-r1': 'mirror://sourceforge/layman/layman-1.3.0.tar.gz', + 'app-portage/gentoolkit-0.3.0_rc7': 'mirror://gentoo/gentoolkit-0.3.0_rc7.tar.gz http://dev.gentoo.org/~fuzzyray/distfiles/gentoolkit-0.3.0_rc7.tar.gz', + 'app-portage/layman-1.3.0': 'mirror://sourceforge/layman/layman-1.3.0.tar.gz', + 'app-portage/layman-1.3.1': 'mirror://sourceforge/layman/layman-1.3.1.tar.gz', + 'app-portage/layman-1.2.6': 'mirror://sourceforge/layman/layman-1.2.6.tar.gz', + 'app-portage/layman-9999': '', + 'app-portage/gentoolkit-0.2.4.6': 'mirror://gentoo/gentoolkit-0.2.4.6.tar.gz http://dev.gentoo.org/~fuzzyray/distfiles/gentoolkit-0.2.4.6.tar.gz', + 'app-portage/layman-1.3.0_rc1-r3': 'mirror://sourceforge/layman/layman-1.3.0_rc1.tar.gz', + 'app-portage/gentoolkit-0.3.0_rc9': 'mirror://gentoo/gentoolkit-0.3.0_rc9.tar.gz http://dev.gentoo.org/~fuzzyray/distfiles/gentoolkit-0.3.0_rc9.tar.gz', + 'app-portage/gentoolkit-0.3.0_rc8': 'mirror://gentoo/gentoolkit-0.3.0_rc8.tar.gz http://dev.gentoo.org/~fuzzyray/distfiles/gentoolkit-0.3.0_rc8.tar.gz', + 'app-portage/eix-0.19.2': 'mirror://sourceforge/eix/eix-0.19.2.tar.xz', 'app-portage/layman-1.3.2-r1': 'mirror://sourceforge/layman/layman-1.3.2.tar.gz' + }, + 'output': [ + ' - processing excluded', + ' - (20 of 20 total) additional excluded packages to get source filenames for' + ] + }, + 'destructive4':{ + 'deprecated':{ + }, + 'pkgs': { + 'sys-auth/consolekit-0.4.1': + 'http://www.freedesktop.org/software/ConsoleKit/dist/ConsoleKit-0.4.1.tar.bz2', + 'sys-apps/devicekit-power-014': + 'http://hal.freedesktop.org/releases/DeviceKit-power-014.tar.gz', + 'media-libs/sdl-pango-0.1.2': + 'mirror://sourceforge/sdlpango/SDL_Pango-0.1.2.tar.gz http://zarb.org/~gc/t/SDL_Pango-0.1.2-API-adds.patch' + }, + 'output': [ + ' - processing 3 installed ebuilds', + ' - processing excluded', + ' - (3 of 0 total) additional excluded packages to get source filenames for' + ] + }, + 'destructive5':{ + 'deprecated':{ + 'x11-base/xorg-server-1.6.5-r1': 'http://xorg.freedesktop.org/releases/individual/xserver/xorg-server-1.6.5.tar.bz2 mirror://gentoo/xorg-server-1.6.5-gentoo-patches-01.tar.bz2', + 'x11-misc/util-macros-1.6.0': 'http://xorg.freedesktop.org/releases/individual/util/util-macros-1.6.0.tar.bz2', + 'x11-libs/pixman-0.16.4': 'http://xorg.freedesktop.org/releases/individual/lib/pixman-0.16.4.tar.bz2' + }, + 'pkgs': { + 'sys-apps/devicekit-power-014': 'http://hal.freedesktop.org/releases/DeviceKit-power-014.tar.gz', + 'dev-libs/libisofs-0.6.28': 'http://files.libburnia-project.org/releases/libisofs-0.6.28.tar.gz', + 'perl-core/Module-Build-0.36.03': 'mirror://cpan/authors/id/D/DA/DAGOLDEN//Module-Build-0.3603.tar.gz', + 'x11-base/xorg-server-1.6.5-r1': 'http://xorg.freedesktop.org/releases/individual/xserver/xorg-server-1.6.5.tar.bz2 mirror://gentoo/xorg-server-1.6.5-gentoo-patches-01.tar.bz2', + 'perl-core/Archive-Tar-1.56': 'mirror://cpan/authors/id/B/BI/BINGOS//Archive-Tar-1.56.tar.gz', + 'perl-core/ExtUtils-ParseXS-2.22.02-r1': 'mirror://cpan/authors/id/D/DA/DAGOLDEN//ExtUtils-ParseXS-2.2202.tar.gz', + 'x11-misc/util-macros-1.6.0': 'http://xorg.freedesktop.org/releases/individual/util/util-macros-1.6.0.tar.bz2', + 'sys-auth/consolekit-0.4.1': 'http://www.freedesktop.org/software/ConsoleKit/dist/ConsoleKit-0.4.1.tar.bz2', + 'media-libs/sdl-pango-0.1.2': 'mirror://sourceforge/sdlpango/SDL_Pango-0.1.2.tar.gz http://zarb.org/~gc/t/SDL_Pango-0.1.2-API-adds.patch', + 'x11-libs/pixman-0.16.4': 'http://xorg.freedesktop.org/releases/individual/lib/pixman-0.16.4.tar.bz2' + }, + 'output': [' - processing 10 installed ebuilds', + ' - processing excluded', + ' - (10 of 0 total) additional excluded packages to get source filenames for', + '!!! "Deprecation Warning: Installed package: perl-core/Archive-Tar-1.56\n\tIs no longer in the tree or an installed overlay\n', + '!!! "Deprecation Warning: Installed package: perl-core/ExtUtils-ParseXS-2.22.02-r1\n\tIs no longer in the tree or an installed overlay\n', + '!!! "Deprecation Warning: Installed package: perl-core/Module-Build-0.36.03\n\tIs no longer in the tree or an installed overlay\n', + '!!! "Deprecation Warning: Installed package: x11-base/xorg-server-1.6.5-r1\n\tIs no longer in the tree or an installed overlay\n', + '!!! "Deprecation Warning: Installed package: dev-libs/libisofs-0.6.28\n\tIs no longer in the tree or an installed overlay\n', + '!!! "Deprecation Warning: Installed package: x11-misc/util-macros-1.6.0\n\tIs no longer in the tree or an installed overlay\n', + '!!! "Deprecation Warning: Installed package: x11-libs/pixman-0.16.4\n\tIs no longer in the tree or an installed overlay\n' + ] + } } + + + def callback(self, id, data): + self.callback_data.append(data) + + + def exclDictExpand(self, exclude): + print("Testing exclDictExpand()") + return [ + 'app-portage/layman', + 'app-portage/eix', + 'app-portage/gentoolkit', + 'app-portage/portage-utils', + ] + + + def test_non_destructive(self): + self.results = {} + pkgs, deprecated = self.target_class._non_destructive(destructive=False, + fetch_restricted=False, pkgs_=None) + self.record_results('non_destructive1', pkgs, deprecated) + self.callback_data = [] - cpvs = CPVS[:] - cpvs.append('app-portage/deprecated-pkg-1.0.0') - pkgs, deprecated = self.target_class._unrestricted(None, cpvs) - self.results['unrestricted2'] = { - 'pkgs': pkgs, - 'deprecated': deprecated, - 'output': self.callback_data - } + self.vardb._cpv_all=CPVS[:3] + self.vardb._props=get_props(CPVS[:3]) + self.portdb._cpv_all=CPVS[:] + self.portdb._props=get_props(CPVS) + pkgs, deprecated = self.target_class._non_destructive(destructive=True, + fetch_restricted=True, pkgs_=None) + self.record_results('non_destructive2', pkgs, deprecated) + + self.callback_data = [] + self.vardb._cpv_all=CPVS[:2] + self.vardb._props=get_props(CPVS[:2]) + self.portdb._cpv_all=CPVS[:] + self.portdb._props=get_props(CPVS) + # set a fetch restricted pkg + self.portdb._props[CPVS[4]]["RESTRICT"] = 'fetch' + pkgs = {'sys-apps/devicekit-power-014': {'SRC_URI': + 'http://hal.freedesktop.org/releases/DeviceKit-power-014.tar.gz'} + } + pkgs, deprecated = self.target_class._non_destructive(destructive=True, + fetch_restricted=True, pkgs_=pkgs) + self.record_results('non_destructive3', pkgs, deprecated) + self.test_results("test_non_destructive") + + + def test_results(self, test_name): + print("\nChecking results for %s,............" %test_name) for key in sorted(self.results): testdata = self.testdata[key] results = self.results[key] for item in sorted(testdata): - self.failUnlessEqual( sorted(testdata[item]), sorted(results[item]), - "\ntest_unrestricted: %s %s data does not match\nresult=" %(key, item) +\ + #print("comparing %s, %s" %(key, item)) + self.failUnlessEqual(sorted(testdata[item]), sorted(results[item]), + "\n%s: %s %s data does not match\nresult=" %(test_name, key, item) +\ str(results[item]) + "\ntestdata=" + str(testdata[item])) + def record_results(self, test, pkgs, deprecated): + self.results[test] = {'pkgs': pkgs, + 'deprecated': deprecated, + 'output': self.callback_data + } + + def test_destructive(self): + self.results = {} + pkgs, deprecated = self.target_class._destructive(package_names=False, + exclude={}, pkgs_=None, installed_included=False ) + self.record_results('destructive1', pkgs, deprecated) + + self.callback_data = [] + self.vardb._cpv_all=CPVS[:3] + self.vardb._props=get_props(CPVS[:3]) + self.portdb._cpv_all=CPVS[:] + self.portdb._props=get_props(CPVS) + pkgs, deprecated = self.target_class._destructive(package_names=True, + exclude={}, pkgs_=None, installed_included=False ) + self.record_results('destructive2', pkgs, deprecated) + + self.callback_data = [] + cpvs = CPVS[2:4] + cpvs.extend(CPVS3) + self.vardb._cpv_all=sorted(cpvs) + self.vardb._props= PROPS.update(get_props(CPVS3)) + self.portdb._cpv_all=sorted(CPVS + CPVS2) + self.portdb._props=get_props(CPVS+CPVS2) + # set a fetch restricted pkg + self.portdb._props[CPVS[4]]["RESTRICT"] = 'fetch' + pkgs = {'sys-apps/devicekit-power-014': {'SRC_URI': + 'http://hal.freedesktop.org/releases/DeviceKit-power-014.tar.gz'} + } + pkgs, deprecated = self.target_class._destructive(package_names=True, + exclude={}, pkgs_=pkgs, installed_included=True ) + self.record_results('destructive3', pkgs, deprecated) + + self.callback_data = [] + self.vardb._cpv_all=CPVS[:3] + self.vardb._props=get_props(CPVS[:3]) + self.portdb._cpv_all=CPVS[:] + self.portdb._props=get_props(CPVS) + pkgs, deprecated = self.target_class._destructive(package_names=False, + exclude=self.exclude, pkgs_=None, installed_included=False ) + self.record_results('destructive4', pkgs, deprecated) + self.test_results("test_destructive") + + self.callback_data = [] + self.vardb._cpv_all=CPVS[:3] + self.vardb._cpv_all.extend(CPVS3) + self.vardb._props=get_props(self.vardb._cpv_all) + self.portdb._cpv_all=CPVS[:] + self.portdb._cpv_all.extend(CPVS2) + self.portdb._props=get_props(CPVS) + pkgs, deprecated = self.target_class._destructive(package_names=False, + exclude=self.exclude, pkgs_=None, installed_included=False ) + self.record_results('destructive5', pkgs, deprecated) + self.test_results("test_destructive") + def test_main(): @@ -325,6 +601,8 @@ def test_main(): test_support.run_unittest(TestCheckLimits('test_check_limits')) test_support.run_unittest( TestFetchRestricted('test__fetch_restricted')) test_support.run_unittest( TestFetchRestricted('test_unrestricted')) + test_support.run_unittest( TestNonDestructive('test_non_destructive')) + #test_support.run_unittest( TestNonDestructive('test_destructive')) if __name__ == '__main__':