Example #1
0
 def _cmp(a, b):
     a = Pool.parse_package_id(a)
     b = Pool.parse_package_id(b)
     val = cmp(b[0], a[0])
     if val != 0:
         return val
     return debversion.compare(a[1], b[1])
Example #2
0
        def __contains__(self, version):
            true_results = self.RELATIONS[self.relation]

            if debversion.compare(version, self.version) in true_results:
                return True

            return False
Example #3
0
File: pool.py Project: qrntz/pool
 def _cmp(a, b):
     a = Pool.parse_package_id(a)
     b = Pool.parse_package_id(b)
     val = cmp(b[0], a[0])
     if val != 0:
         return val
     return debversion.compare(a[1], b[1])
Example #4
0
def purge(path, force=False):
    pkgcache = PackageCache(path)

    duplicates = []
    for name, amount in pkgcache.namerefs.items():
        if amount > 1:
            duplicates.append(name)

    newest = {}
    candidates = []
    for name, version in pkgcache.list():
        if name in duplicates:
            if not newest.has_key(name) or \
               debversion.compare(newest[name], version) < 0:
                newest[name] = version
            else:
                candidates.append(pkgcache.getpath(name, version))

    if len(candidates) == 0:
        print "No candidates for deletion"
        return False

    candidates.sort()
    print "Candidates for deletion:"
    for candidate in candidates:
        print "  " + os.path.basename(candidate)

    print "Amount of candidates: %i" % len(candidates)

    if not force:
        print "Do you want to continue [y/N]?",
        if not raw_input() in ['Y', 'y']:
            print "aborted by user"
            return False

    print "Deleting..."
    for candidate in candidates:
        os.remove(candidate)

    return True
Example #5
0
def purge(path, force=False):
    pkgcache = PackageCache(path)

    duplicates = []
    for name, amount in pkgcache.namerefs.items():
        if amount > 1:
            duplicates.append(name)

    newest = {}
    candidates = []
    for name, version in pkgcache.list():
        if name in duplicates:
            if not newest.has_key(name) or \
               debversion.compare(newest[name], version) < 0:
                newest[name] = version
            else:
                candidates.append(pkgcache.getpath(name, version))

    if len(candidates) == 0:
        print "No candidates for deletion"
        return False

    candidates.sort()
    print "Candidates for deletion:"
    for candidate in candidates:
        print "  " + os.path.basename(candidate)

    print "Amount of candidates: %i" % len(candidates)

    if not force:
        print "Do you want to continue [y/N]?",
        if not raw_input() in ['Y', 'y']:
            print "aborted by user"
            return False

    print "Deleting..."
    for candidate in candidates:
        os.remove(candidate)

    return True
Example #6
0
    def _list(self, all_versions):
        """List packages in pool -> list of (name, version) tuples."""
        packages = set()
        for subpool in self.subpools:
            packages |= set(subpool._list(all_versions))

        packages |= set(self.pkgcache.list())
        for stock in self.stocks:
            for path, versions in stock.sources:
                package = basename(path)
                packages |= set([(package, version) for version in versions])

        if all_versions:
            return list(packages)

        newest = {}
        for name, version in packages:
            if not newest.has_key(name) or \
               debversion.compare(newest[name], version) < 0:
                newest[name] = version

        return newest.items()
Example #7
0
File: pool.py Project: qrntz/pool
    def _list(self, all_versions):
        """List packages in pool -> list of (name, version) tuples."""
        packages = set()
        for subpool in self.subpools:
            packages |= set(subpool._list(all_versions))

        packages |= set(self.pkgcache.list())
        for stock in self.stocks:
            for path, versions in stock.sources:
                package = basename(path)
                packages |= set([ (package, version) for version in versions ])

        if all_versions:
            return list(packages)

        newest = {}
        for name, version in packages:
            if not newest.has_key(name) or \
               debversion.compare(newest[name], version) < 0:
                newest[name] = version

        return newest.items()