python-cdd/0000755000000000000000000000000011460375076010026 5ustar python-cdd/debian/0000755000000000000000000000000011460375232011242 5ustar python-cdd/debian/control0000644000000000000000000000143311460375076012654 0ustar Source: python-cdd Section: python Priority: extra Maintainer: Otavio Salvador Uploaders: Martin Fuzzey Build-Depends: debhelper (>= 5.0.37.2), cdbs (>= 0.4.41), python | python-dev | python-all-dev, python-support (>= 0.3) Standards-Version: 3.8.4 VCS-Git: git://projetos.ossystems.com.br/git/python-cdd.git VCS-Browser: http://projetos.ossystems.com.br/repositories/show/python-cdd Package: python-cdd Architecture: all Depends: ${python:Depends}, ${misc:Depends}, python-apt (>= 0.7.93.2) Description: library to make easier to build CDD related applications This is a library that include common things to make easier to build Custom Debian Distributions related applications. . Homepage: http://projetos.ossystems.com.br/projects/show/python-cdd python-cdd/debian/rules0000755000000000000000000000054211460375076012331 0ustar #!/usr/bin/make -f DEB_PYTHON_SYSTEM=pysupport include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/python-distutils.mk configure/python-cdd:: # Fill the vars sed -i "s/version = .*,/version = '$(shell dpkg-parsechangelog | grep '^Version:' | awk '{ print $$2; }')',/g" setup.py clean:: find . -iname *.py? -exec rm {} \; python-cdd/debian/copyright0000644000000000000000000000226211460375076013205 0ustar This package was debianized by Otavio Salvador on Thu, 12 May 2005 18:00:21 -0300. Upstream Authors: Otavio Salvador Nat Budin Free Ekanayaka Vagrant Cascadian Marco Presi Copyright 2002 O.S. Systems This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. On Debian systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/LGPL-2.1'. python-cdd/debian/compat0000644000000000000000000000000211460375076012446 0ustar 5 python-cdd/debian/changelog0000644000000000000000000001070311460375141013114 0ustar python-cdd (0.0.11) unstable; urgency=low [ Martin Fuzzey ] * use hashlib instead of md5, sha (Closes: #595465) -- Otavio Salvador Fri, 22 Oct 2010 18:56:01 -0200 python-cdd (0.0.10) unstable; urgency=low [ Martin Fuzzey ] * python-apt 0.8 API transition (Closes: #572055) [ Otavio Salvador ] * Update to dpkg-source 3.0 (native) format. -- Otavio Salvador Mon, 22 Mar 2010 11:05:43 -0300 python-cdd (0.0.9) unstable; urgency=low [ Martin Fuzzey ] * cdd.PackageList: - Use apt_pkg.VersionCompare. Closes: #511116 * cdd.Package: - Apply patch from Alexander Inyukhin for missing fields. Closes: #502648 -- Otavio Salvador Thu, 22 Jan 2009 08:40:30 -0200 python-cdd (0.0.8) unstable; urgency=low [ Martin Fuzzey ] * cdd.Filesystem: - match() now returns filenames relative to base for coherencey * cdd.PackageList: - Add versionned dependencies - Add missing fields to dump - Add exclude filters - Add field-XXX filter for any package field - Fix dependency resolution (failing unit tests) - Improve unittests to verify package names not just counts. [ Otavio Salvador ] * Add VCS-{Git,Browser} to debian/control. -- Otavio Salvador Wed, 21 May 2008 14:55:05 -0300 python-cdd (0.0.7) unstable; urgency=low * Change build-depends to python | python-dev | python-all-dev, python-support (>= 0.3) to please lintian. * cdd.PackageList: - simplified calc_score method. - fix select_field to avoid walking on every package. -- Otavio Salvador Wed, 13 Jun 2007 17:59:31 -0300 python-cdd (0.0.6) unstable; urgency=high * Use -undef when calling cpp pre-processor to avoid linux and other standard and gcc specific macros to be used. Closes: #399268 -- Otavio Salvador Mon, 11 Dec 2006 07:21:31 -0200 python-cdd (0.0.5) unstable; urgency=low [ Otavio Salvador ] * Add testcase: PackageList: A depends on B | virtualC, D provides virtualC * Fix resolution dependency too pass on previous test * Add testcase: PackageList: META depends on A and D, A depends on B | virtualC, D provides virtualC * Fix resolution dependency too pass on previous test [ Tiago Bortoletto Vaz ] * debian/rules - using pysupport instead of pycentral. By using it, it's not necessary pycompat file anymore, either XS-Python-Version and XB-Python-Version in control file * debian/control - remove XS-Python-Version and XB-Python-Version fields - add build-depends python-support instead of python-central - update debhelper version to (>= 5.0.37.2) * debian/compat - update from 4 to 5 * debian/install - removed since lib/*.py files are installed by python-support -- Otavio Salvador Sun, 17 Sep 2006 17:16:58 -0300 python-cdd (0.0.4) unstable; urgency=low [ Otavio Salvador ] * Pass a dictionary with the broken dependencie content so the user can consult what cannot be resolved. * Bump Standards-Version to 3.7.2: - Move CDBS and related depends to Build-Depends; * Follow new python policy (0.4.1). Closes: #373516 - add XS-Python-Version: all in source package; - add XB-Python-Version: ${python:Versions} in binary package; - build-depends of python-all-dev; - build-depends of python-central; - remove debian/dirs, unneeded; -- Otavio Salvador Wed, 14 Jun 2006 23:40:03 -0300 python-cdd (0.0.3) unstable; urgency=low [ Otavio Salvador ] * Fix package selection to right use the scores. * Use a goodness logic to select packages and then avoid to use brute force to selected the _almost_ minimal package set. * Include a test to ensure that we return the broken package when raising PackageList.BrokenDependencies exception. Fixes #18. -- Otavio Salvador Tue, 17 Jan 2006 10:35:03 -0200 python-cdd (0.0.2) unstable; urgency=low [ Otavio Salvador ] * debian/rules: remove build-essential from Build-Depends field of built control file. * debian/control: remove build-essential from Build-Depends field. * PackageList: add debian-cd tasks to include list while pre-processing include-from filter option. Fixes #19. -- Otavio Salvador Wed, 23 Nov 2005 13:29:30 -0200 python-cdd (0.0.1) unstable; urgency=low * Initial Release. -- Otavio Salvador Wed, 16 Nov 2005 10:44:07 -0200 python-cdd/debian/pycompat0000644000000000000000000000000211460375232013011 0ustar 2 python-cdd/debian/source/0000755000000000000000000000000011460375076012550 5ustar python-cdd/debian/source/format0000644000000000000000000000001511460375076013757 0ustar 3.0 (native) python-cdd/cdd/0000755000000000000000000000000011460375076010560 5ustar python-cdd/cdd/__init__.py0000644000000000000000000000143311460375076012672 0ustar ########################################################################## # # __init__.py: defines this directory as the 'cdd' package. # # Python-CDD is a library to make easier to build applications to # Custom Debian Distributions. # See http://projetos.ossystems.com.br/python-cdd for more information. # # ==================================================================== # Copyright (c) 2002-2005 O.S. Systems. All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. # ######################################################################### # Author: Otavio Salvador import logging log = logging.getLogger("cdd") #log.addHandler(logging.StreamHandler()) python-cdd/cdd/FileSystem.py0000644000000000000000000001415311460375076013222 0ustar ########################################################################## # # FileSystem.py: handle dirs and filesystem operations. # # Python-CDD is a library to make easier to build applications to # Custom Debian Distributions. # See http://projetos.ossystems.com.br/python-cdd for more information. # # ==================================================================== # Copyright (c) 2002-2005 O.S. Systems. All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. # ######################################################################### # Authors: Otavio Salvador # Marco Presi # Free Ekanayaka # Vagrant Cascadian # # Class to handle dirs and filesystem operations. import os import re import hashlib import sys import stat import logging log = logging.getLogger("cdd.FileSystem") from gzip import GzipFile from bz2 import BZ2File # Set the compress format to gzip. GZIP = 2 # Set the compress format to bzip2. BZIP2 = 4 class FileSystem: """ This class provides methods to manage dirs and files. """ def __init__(self, base, *args): """ Initialize the object Parameters: - *base*: the base directory where all methods will run """ self.__errors = [13] others = list(args) self.__base = os.path.join(base, *others) ### add a alias to self.remove method self.unlink = self.remove def exists(self, name): """ Check if a file or directory named 'name' exists inside of base directory. Parameters: - *name*: the name of file or directory to be checked """ return os.path.exists(os.path.join(self.__base, name)) def mkdir(self, name): """ Create a directory 'name' inside of 'base' Parameters: - *name*: the directory name """ log.debug("Creating %s..." % name) dirname = os.path.join(self.__base, name) try: if os.path.isdir(dirname): pass elif not self.exists(name): os.makedirs (dirname) else: log.debug("Unable to create directory %s" % dirname) return False except OSError, (errno,strerror): log.debug("%s" % strerror) return False return True def remove(self, name): """ Remove file 'name' inside of 'base' p.s.: same as FileSystem.unlink Parameters: - *name*: the name of file to be removed """ target = os.path.join(self.__base, name) log.debug("Removing %s" % target) try: os.remove(target) except OSError, (errno, strerror): log.debug(strerror) return False def rmdir(self, name, empty = False): """ Remove a directory and if empty == True it remove all empty between it. Parameters: - *name*: the name of directory to be removed - *empty*: a boolean variable to set if directory is empty (default value: False) """ log.debug("Removing %s" % name) os.rmdir(os.path.join(self.__base, name)) if empty: head, tail = os.path.split(name) if not tail: head, tail = os.path.split(head) while head and tail: log.debug("Removing %s" % head) try: os.rmdir(os.path.join(self.__base, head)) except: break head, tail = os.path.split(head) def base(self): """ Return FileSystem base """ return self.__base def md5sum (self, filename): """ Return md5sum for given file Parameters: - *filename*: the name of file to get md5sum """ try: file_to_hash = open(os.path.join(self.__base, filename), 'r') except IOError: raise md5hash = hashlib.md5() md5hash.update(file_to_hash.read()) file_to_hash.close() return md5hash.hexdigest() def sha1sum (self, filename): """ Return sha1sum for given file Parameters: - *filename*: the name of file to get sha1sum """ try: file_to_hash = open(os.path.join(self.__base, filename), 'r') except IOError: log.debug("Can't open %s for sha1sum." % filename) raise sha1hash = hashlib.sha1() sha1hash.update(file_to_hash.read()) file_to_hash.close() return sha1hash.hexdigest() def size (self, filename): """ Return the size of the given file Parameters: - *filename*: the name of file to get size """ try: size = os.stat(os.path.join(self.__base, filename))[stat.ST_SIZE] except OSError: raise return size def uncompress (self, filename): """ Uncompress a given file Parameters: - *filename*: the name of file to be uncompressed """ log.debug('Uncompressing %s' % filename) for format in (GzipFile, BZ2File): try: compressed_file = format(os.path.join(self.__base, filename),'r') except IOError, msg: raise try: data = compressed_file.read() # We already read all data, go out! break except IOError, msg: pass else: raise IOError, "Invalid format" compressed_file.close() output_file = open(os.path.join(self.__base, filename.rstrip('.gz')), "wb") output_file.write(data) output_file.close() return True def compress (self, filename, format = GZIP): """ Compress a file Parameters: - *filename*: the name of file to be compressed - *format*: the compress format (default value: gzip) """ log.debug('Compressing ' + filename) if format == GZIP: class_ref = GzipFile extension = '.gz' elif format == BZIP2: class_ref = BZ2File extension = '.bz2' else: raise SyntaxError try: input_file = open(os.path.join(self.__base, filename), 'r') output_file = class_ref(os.path.join(self.__base, filename + extension), "wb") except IOError, msg: raise output_file.write(input_file.read()) output_file.close() input_file.close() return True def match (self, expression): """ Find a file which any pattern Parameters: - *expression*: the pattern to be matched Return value: list of matching files RELATIVE to base """ log.debug("Matching a pattern") retfiles = [] comp_exp = re.compile(expression) for root, dirs, files in os.walk(self.__base): for name in files: if comp_exp.findall(name): filename = os.path.join(root[len(self.__base) + 1:], name) retfiles.append(filename) return retfiles python-cdd/cdd/PackageList.py0000644000000000000000000004077611460375076013337 0ustar ########################################################################## # # PackageList.py: manage the Package object list information. # # Python-CDD is a library to make easier to build applications to # Custom Debian Distributions. # See http://projetos.ossystems.com.br/python-cdd for more information. # # ==================================================================== # Copyright (c) 2002-2005 O.S. Systems. All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. # ######################################################################### # Authors: Otavio Salvador # Nat Budin # Free Ekanayaka # Everton J. Carpes """ PackageList classes and functions This file implements a class to represent lists of packages and operations related to those lists, like dependencies resolution and package filtering """ import os import re import sys import logging log = logging.getLogger("cdd.PackageList") import apt_pkg apt_pkg.init_system() # Constants to resolve_depends DEPENDS = 2 # Use Depends field to resolve SUGGESTS = 4 # Use Suggests field to resolve RECOMMENDS = 8 # Use Recommends field to resolve class PackageAlreadyExists(Exception): """ Exception called when someone tries to add a package but it was already included. Parameters: - *package*: The name of package. """ def __init__(self, package): Exception.__init__(self) self.package = package class PackageDoesNotExist(Exception): """ Exception called when someone tries to remove a package that was not included. Parameters: - *package*: The name of package. """ def __init__(self, package): Exception.__init__(self) self.package = package class BrokenDependencies(Exception): """ Exception called when, after trying to solve dependencies, we are left with broken ones. Parameters: - *deps*: List of unresolved dependencies. """ def __init__(self, deps, broken): Exception.__init__(self) self.deps = deps self.broken = broken class InvalidFilter(Exception): """ Exception called when someone try to use a invalid filter option. Parameters: - *option*: The filter option. """ def __init__(self, option): Exception.__init__(self) self.option = option class PackageList: """ This class is used to store a list of packages and provide ways to select subsets of those packages applying filters to the list. It also provides methods to resolve depencencies (Depends, Recommends and Suggests) against a full set of packages and include the needed packages on the list. To make filtering faster the class includes caches by name, subsection and priority. """ def __init__(self, package_list = None): self._name = {} self._subsection = {} self._priority = {} self._provides = {} self._rdepends = {} self._whereis = {} if package_list: for package in package_list.values(): package_from = package_list.whereis(package['Package']) if package_from == self: self.add(package) else: self.add(package, package_from) def __len__(self): return len(self._name) def __getitem__(self, key): return self.get(key) # allow uses like ... if x in y: def __contains__(self, item): return self._name.has_key(item) def has_key(self, key): return self._name.has_key(key) def keys(self): """Returns a copy of the list of package names""" return self._name.keys() def values(self): """Returns a copy of the list of packages""" return self._name.values() def items(self): """Returns a copy of the list of (name, package) pairs""" return self._name.items() def get(self, key): """Returns a package given it's name""" if not self._name.has_key(key): raise PackageDoesNotExist, key return self._name[key] def add(self, package, package_list = None): """ Method to add a package to the list (updating caches). Note that the package is only added if it's name is not already on the list of packages, or else a PackageAlreadyExists exception is raised. """ if self._name.has_key(package['Package']): raise PackageAlreadyExists, package['Package'] # Initialize the need lists if not self._subsection.has_key(package['Section']): self._subsection[package['Section']] = [] if not self._priority.has_key(package['Priority']): self._priority[package['Priority']] = [] # Update all basic cache information self._name[package['Package']] = package self._subsection[package['Section']].append(package) self._priority[package['Priority']].append(package) # Update rdepends cache information if package.has_key('Depends'): for depend in package['Depends']: for pkgname, version, cond in depend: if not self._rdepends.has_key(pkgname): self._rdepends[pkgname] = [] self._rdepends[pkgname].append(package['Package']) # Add our foreign package reference on self._whereis if package_list: self._whereis[package['Package']] = package_list # Update provides information if package.has_key('Provides'): for prov in package['Provides']: if not self._provides.has_key(prov): self._provides[prov] = [] self._provides[prov].append(package) def whereis(self, package): """ Method to get where a package come from. If the package was not on the list a PackageDoesNotExist exception is raised. Parameters: - *package*: package name to be localized """ if not isinstance(package, str): package = self._name[package]['Package'] if not self._name.has_key(package): raise PackageDoesNotExist, package if not self._whereis.has_key(package): return self # package is native return self._whereis[package] # package is foreign def remove(self, package): """ Method to remove a package from the list (updating caches). If the package was not on the list a PackageDoesNotExist exception is raised. Parameters: - *package*: package to be removed """ if isinstance(package, str): if not self._name.has_key(package): raise PackageDoesNotExist, package package = self._name[package] else: if not self._name.has_key(package['Package']): raise PackageDoesNotExist, package['Package'] del self._name[package['Package']] self._subsection[package['Section']].remove(package) self._priority[package['Priority']].remove(package) if package.has_key('Provides'): for prov in package['Provides']: self._provides[prov].remove(package) def extend(self, pkglist): """ Merge packages from pkglist with our list """ for pkg in pkglist.values(): if pkg['Package'] not in self.keys(): self.add(pkg) def orphan_packages(self): """ """ dependencies = {} for package in self.values(): if package.has_key('Depends'): for depend in _virtual_as_alternative(package['Depends'], [self]): for pkgname, pkgver, cond in depend: if not dependencies.has_key(pkgname): dependencies[pkgname] = [] if package['Package'] not in dependencies[pkgname]: dependencies[pkgname].append(package['Package']) orphan_list = self.keys() map(lambda x: orphan_list.remove(x), dependencies.keys()) return orphan_list def resolve_depends(self, pkglist, field=DEPENDS, fastFail=True): """ Resolve our dependencies adding needed packages to our list from the `pkglist`. """ resolve_depends(self, pkglist, field, fastFail) def filter(self, condition, *architectures): """ Return a PackageList that contains only the packages that verify a set of conditions. The condition argument is a dictionary that can have the following keys: - *include-from*: includes packages from the given debian-cd task - *exclude-from*: excludes packages from the given debian-cd task - *subsection*: includes packages that belong to a section that match the given regular expression - *priority*: includes packages that have a priority that match the given regular expression - *name*: includes packages that have a name that match the given regular expression. - *architectures*: architectures to use while processing the include-from and exclude-from conditions. If you left this blank, i386 will be used as default. - *field-XXX*: incldues package that have a control field XXX (eg Tag) that match the givven regular expression - *exclude-subsection* *exclude-priority* *exclude-name* *exclude-field-XXX as above but exclude matching packages If the condition was not on the above list a InvalidFilter exception is raised. """ # Process the given regexp for givin data field. def process_regexp(regexp, cache, field, exclude=False): def addAction(toAdd): try: packages.add(toAdd) except PackageAlreadyExists: pass # We might repeat packages def removeAction(toRemove): if toRemove['Package'] in packages: packages.remove(toRemove['Package']) regexp = re.compile(regexp) if exclude: updateAction = removeAction candidatePackages = packages.values() else: updateAction = addAction candidatePackages = self.values() if cache is not None: for k, v in cache.iteritems(): if k and regexp.match(k): # Add all match packages if isinstance(v, list): for i in v: updateAction(i) else: updateAction(v) if field is not None: for package in candidatePackages: fieldValue = package[field] if fieldValue is not None and regexp.match(fieldValue): updateAction(package) # Process a taskfile for the givin operation. def process_task(filename, operation): for arch in architectures: if arch not in valid_architectures: raise ValueError, "Invalid architecture name." raw = os.popen("cpp -undef -I %s \ -I /usr/share/debian-cd/tasks \ -DARCH_%s %s | \ grep -v \'^$\|^#.*$\' | tr \'\n\' \' \'" % (os.path.dirname(filename), arch, filename), 'r' ).readlines()[0].split() for praw in raw: pkg = self._name.get(praw, None) if operation == 'include-from': if pkg and pkg['Package'] not in packages: packages.add(pkg) else: if pkg and pkg['Package'] in packages: packages.remove(pkg) valid_architectures = ('alpha', 'amd64', 'arm', 'hppa', 'hurd-i386', 'i386', 'ia64', 'm68k', 'mips', 'mipsel', 'powerpc', 's390', 'sh', 'sparc') # Set i386 as default architecture if not len(architectures): architectures = ['i386'] packages = PackageList() condition_found = False cacheForCondition = { "subsection" : self._subsection, "priority" : self._priority, "name" : self._name, } fieldRe = re.compile("field-(.*)") def invokeRegexpFilter(item, value, **kw): fieldMatch = fieldRe.match(item) field = None if fieldMatch is not None: field = fieldMatch.group(1) cache = cacheForCondition.get(item) if cache is None and field is None: raise InvalidFilter, item process_regexp(value, cache, field, **kw) for (item, value) in condition.items(): if item == "include-from": condition_found = True process_task(value, item) continue if item.startswith("exclude-"): continue # we need to do it at end! invokeRegexpFilter(item, value) condition_found = True excludeRe = re.compile("exclude-(.*)") for (item, value) in condition.items(): match = excludeRe.match(item) if match: # If we passed 'exclude-' conditions, we use # our packages as initial state. if not condition_found: for package in self.values(): packages.add(package) condition_found = True if item == "exclude-from": process_task(value, item) else: invokeRegexpFilter(match.group(1), value, exclude=True) return packages def _virtual_as_alternative(original, full_lists): # Replace all dependency of a virtual package with a or'ed list of # real packages new = [] if original: # Package has depends for dep in original: new_dep = [] for (pkgname, pkgver, cond) in dep: found = False for pkglist in full_lists: if pkgname in pkglist._provides: # if there is a non-vitual package, add it if pkgname in pkglist: new_dep.append((pkgname, pkgver, cond)) # add the packages that provide the package for alternative in pkglist._provides[pkgname]: new_dep.append((alternative['Package'], '', '')) found = True # It wasn't a virtual package if not found: new_dep.append((pkgname, pkgver, cond)) new.append(new_dep) return new def resolve_depends(from_list, with_lists, field=DEPENDS, fastFail=True): def calc_scores(package, backtrace=[]): # Calc packages scores depending of its depends number depends = _virtual_as_alternative(package[field], with_lists) for depend in depends: for pkgname, pkgver, cond in depend: if not solutions.has_key(pkgname): for pkglist in with_lists: if pkgname in pkglist: if cond and not allow_version(pkglist[pkgname]["Version"], pkgver, cond): continue if pkgname not in backtrace and pkgname != package["Package"]: backtrace.append(pkgname) solution = Solution(pkgname) solution.pkglist = pkglist solution.score = calc_scores(pkglist[pkgname],backtrace) if pkglist._rdepends.has_key(pkgname): solution.goodness = len(pkglist._rdepends[pkgname]) else: solution.goodness = 0 solutions[pkgname] = solution break # Packages with depends has score 1 plus the minimum score # of all alternatives for its depends score = 1 for depend in depends: depend_score = 0 for pkgname, pkgver, cond in depend: solution = solutions.get(pkgname) if solution is not None: my_score = solution.score if my_score < depend_score or depend_score == 0: depend_score = my_score score += depend_score return score def select_field(package): # Select packages to minimize the total score depends = _virtual_as_alternative(package[field], with_lists) selected = {} for depend in depends: best_solution = Solution() for pkgname, pkgver, cond in depend: # If any alternative is already selected, use it if pkgname in from_list: best_solution.pkgname = pkgname best_solution.pkglist = from_list break if pkgname in selected: best_solution.pkgname = pkgname best_solution.pkglist = None break # Choose the alternative with best goodness and smalest score solution = solutions.get(pkgname) if solution is not None: best_solution.update(solution) if best_solution.pkgname and best_solution.pkgname not in selected: if best_solution.pkgname not in from_list: best_solution.addToList(from_list) selected[best_solution.pkgname] = best_solution.getPackage() else: if depends: if package not in broken: broken.append(package) broken_depends.setdefault(package["Package"], []).append(depend) if fastFail: return False continue for package in selected.itervalues(): select_field(package) # Convert with_list to a list if not isinstance(with_lists, list): with_lists = [with_lists] # Our from_list is also used as alternative with_lists = [from_list] + with_lists # Set field to be use if field == DEPENDS: field = "Depends" elif field == SUGGESTS: field = "Suggests" elif field == RECOMMENDS: field = "Recommends" else: raise SyntaxError, "%s is invalid for field." % field class Solution: def __init__(self, pkgname=None): # Number of depends for package self.pkgname = pkgname self.score = 0 self.goodness = 0 self.pkglist = None def update(self, solution): if self.score == 0 or \ (solution.score < self.score or solution.goodness > self.goodness): self.score = solution.score self.goodness = solution.goodness self.pkglist = solution.pkglist self.pkgname = solution.pkgname def getPackage(self): return self.pkglist[self.pkgname] def addToList(self, pkglist): pkglist.add(self.getPackage(), self.pkglist) solutions = {} # Broken packages broken = [] broken_depends = {} for package in from_list.values(): calc_scores(package) select_field(package) if broken: raise BrokenDependencies(broken, broken_depends) def allow_version(versionA, versionB, operator): return { "<" : lambda a,b : apt_pkg.version_compare(a,b) < 0, "<=" : lambda a,b : apt_pkg.version_compare(a,b) <= 0, "=" : lambda a,b : apt_pkg.version_compare(a,b) == 0, ">=" : lambda a,b : apt_pkg.version_compare(a,b) >= 0, ">" : lambda a,b : apt_pkg.version_compare(a,b) > 0, }[operator](versionA, versionB) python-cdd/cdd/Package.py0000644000000000000000000001127411460375076012472 0ustar ########################################################################## # # Package.py: store the Package object information. # # Python-CDD is a library to make easier to build applications to # Custom Debian Distributions. # See http://projetos.ossystems.com.br/python-cdd for more information. # # ==================================================================== # Copyright (c) 2002-2005 O.S. Systems. All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. # ######################################################################### # Authors: Otavio Salvador # Nat Budin # Free Ekanayaka """ Classes to represent source and binary packages """ import apt_pkg import logging log = logging.getLogger("cdd.FileSystem") class Package: """ This class encapsulates a binary debian package as represented in an apt Packages file. """ def __init__(self, section): self._fields = {} self._fields.update(section) # Handle dependencie fields for field in ('Suggests', 'Recommends', 'Depends', 'Pre-Depends', 'Conflicts'): if self._fields.has_key(field): self._replaceField(field, apt_pkg.parse_depends(self._fields[field])) if self._fields.has_key('Provides'): self._replaceField('Provides', self._fields['Provides'].split(', ')) # Point to the functions self.has_key = self._fields.has_key self.keys = self._fields.keys self.__getitem__ = self._fields.get def _replaceField(self, field, value): self._fields[field + "-orig"] = self._fields[field] self._fields[field] = value def dump(self): """ Return a string containing the package stanza """ keys = self.keys() keys = self.keys() stanzaParts = [] for field in ('Package', 'Essential', 'Priority', 'Section', 'Installed-Size', 'Maintainer', 'Architecture', 'Version', 'Replaces', 'Provides-orig', 'Depends-orig', 'Pre-Depends-orig', 'Suggests-orig', 'Recommends-orig', 'Conflicts-orig', 'Filename', 'Size', 'MD5sum', 'SHA1', 'SHA256', 'Description', 'Tag', 'Build-Essential', 'Kernel-Version', 'Installer-Menu-Item', 'Enhances', 'Homepage', 'Package-Type'): if self._fields.has_key(field): keyName = field if field.endswith('-orig'): keyName = field[:-5] stanzaParts.append("%s: %s" % (keyName, self._fields[field])) keys.remove(field) stanzaParts.append("") stanzaParts.append("") return "\n".join(stanzaParts) def __repr__(self): return "Package: %s" % self["Package"] class SourcePackage(Package): """ This class encapsulates a debian source package as represented in an apt Sources file. The class transforms the `Files` field provided by the Sources file into a list of dictionaries with three fields: `name`, `md5sum` and `size`. """ def __init__(self, section): # First, we load the default information Package.__init__(self, section) # Handle Build-Depends field for field in ('Build-Depends', 'Build-Depends-Indep', 'Build-Conflicts', 'Build-Conflicts-Indep'): if self._fields.has_key(field): self._fields[field + "-orig"] = self._fields[field] self._fields[field] = apt_pkg.parse_src_depends(self._fields[field]) for field in ('Binary', 'Uploaders'): if self._fields.has_key(field): self._fields[field + "-orig"] = self._fields[field] self._fields[field] = self._fields[field].split(', ') # Now, let's do the trick ;-) self._fields['Files-orig'] = "\n " + self._fields['Files'] files = self._fields['Files'].split(' ') self._fields['Files'] = [] for i in range(0, len(files), 3): tmpdict = {} tmpdict['md5sum'] = files[i] tmpdict['size'] = files[i+1] if files[i+2][len(files[i+2])-1:len(files[i+2])] == "\n": tmpdict['name'] = files[i+2][:-1] else: tmpdict['name'] = files[i+2] self._fields['Files'].append(tmpdict) def dump(self): """ Return a string containing the package stanza """ keys = self.keys() stanza = "" for field in ['Package', 'Binary-orig', 'Version', 'Priority', 'Section', 'Maintainer', 'Build-Depends-orig', 'Build-Depends-Indep-orig', 'Build-Conflicts-orig', 'Build-Conflicts-Indep-orig', 'Architecture', 'Standards-Version', 'Format', 'Directory', 'Files-orig', 'Uploaders-orig']: if self._fields.has_key(field): if field.endswith('-orig') and field != 'Files-orig': stanza += field[:-5] + ": " + self._fields[field] + "\n" elif field == 'Files-orig': stanza += field[:-5] + ":" + self._fields[field] + "\n" else: stanza += field + ": " + self._fields[field] + "\n" keys.remove(field) return stanza + "\n" python-cdd/setup.py0000755000000000000000000000204311460375076011542 0ustar ########################################################################## # # setup.py: File to build and install the application. # # Python-CDD is a library to make easier to build applications to # Custom Debian Distributions. # See http://projetos.ossystems.com.br/python-cdd for more information. # # ==================================================================== # Copyright (c) 2002-2005 O.S. Systems. All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. # ######################################################################### # Author: Otavio Salvador from distutils.core import setup setup( name = "python-cdd", version = '0.0.10', author = "Otavio Salvador", author_email = "otavio@debian.org", url = "http://projetos.ossystems.com.br/python-cdd/", license = "GPL", description = "Library to help Custom Debian Distributions related development.", packages = [ 'cdd' ] ) python-cdd/tests/0000755000000000000000000000000011460375076011170 5ustar python-cdd/tests/tests.py0000644000000000000000000000033111460375076012701 0ustar #!/usr/bin/python import unittest import sys sys.path.append('.') import __init__ if not unittest.TextTestRunner(verbosity=2).\ run(__init__.suite()).wasSuccessful(): sys.exit(1) python-cdd/tests/__init__.py0000644000000000000000000000205311460375076013301 0ustar ########################################################################## # # __init__.py: defines this directory as the 'tests' package. # # Python-CDD is a library to make easier to build applications to # Custom Debian Distributions. # See http://projetos.ossystems.com.br/python-cdd for more information. # # ==================================================================== # Copyright (c) 2002-2005 O.S. Systems. All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. # ######################################################################### # Author: Otavio Salvador import unittest import TestBase import TestFileSystem import TestPackage import TestPackageList def suite(): suite = unittest.TestSuite() suite.addTest(TestFileSystem.suite()) suite.addTest(TestPackage.suite()) suite.addTest(TestPackageList.suite()) return suite if __name__ == '__main__': unittest.main(defaultTest='suite') python-cdd/tests/TestPackageList.py0000644000000000000000000003034611460375076014577 0ustar ########################################################################## # # TestPackageList.py: test the PackageList module # # Python-CDD is a library to make easier to build applications to # Custom Debian Distributions. # See http://projetos.ossystems.com.br/python-cdd for more information. # # ==================================================================== # Copyright (c) 2002-2005 O.S. Systems. All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. # ######################################################################### # Authors: Otavio Salvador # Marco Presi # Free Ekanayaka import unittest from TestBase import TestBase from cdd.PackageList import * from cdd import Package class PackageListTests(TestBase): def __read_file (self, class_ref, filename): parse_in = open(filename, 'r') tagfile = apt_pkg.TagFile(parse_in) pkg_list = [] for section in tagfile: pkg = class_ref(section) pkg_list.append(pkg) parse_in.close() return pkg_list def __create_list (self, filename): pkg_list = PackageList() packages = self.__read_file (Package.Package, filename) for package in packages: pkg_list.add(package) return pkg_list def test_1create_list (self): """PackageList: initialization""" pkg_list = self.__create_list(self.aux_file('Packages')) self.failUnless (pkg_list.has_key('3dchess'), "Failed to add a package to the list.") cppkg_list = PackageList(pkg_list) self.failUnless (cppkg_list.has_key('3dchess'), "Failed to copy one list by another") def test_2items_list (self): """PackageList: items""" pkg_list = self.__create_list(self.aux_file('Packages')) self.failUnlessEqual(pkg_list.items()[0][0], '3dchess', "Items return invalid value") def test_2add_package (self): """PackageList: check already exists exception""" pkg_list = self.__create_list(self.aux_file('Packages')) more = self.__read_file (Package.Package, self.aux_file('Packages')) # Adding to the list already existing packages generate self.failUnlessRaises(PackageAlreadyExists, pkg_list.add, more[0]) def test_2get_package (self): """PackageList: get a package by name""" pkg_list = self.__create_list(self.aux_file('Packages')) self.failUnlessRaises(PackageDoesNotExist, pkg_list.get, 'nonono') def test_3remove_package (self): """PackageList: remove a package from the list""" pkg_list = self.__create_list(self.aux_file('Packages')) # Test to remove a non existing package (passing string) self.failUnlessRaises (PackageDoesNotExist, pkg_list.remove, 'fichissimo') # Test to remove a non existing package (passing package object) pkg_aux_list = self.__create_list(self.aux_file('Packages-a-b-c-d-e')) self.failUnlessRaises (PackageDoesNotExist, pkg_list.remove, pkg_aux_list['a']) # Test remove initial_lenght = len(pkg_list) pkg_list.remove('3dchess') self.failIf (len(pkg_list) != (initial_lenght - 1), "Returned an invalid size after removing a package.") pkg_list.remove('3ddesktop') self.failIf (len(pkg_list) != (initial_lenght - 2), "Returned an invalid size after removing a package.") pkg_prov_list = self.__create_list(self.aux_file('Packages-a-b-c-d-e')) pkg_prov_list.remove('c') def test_3extend(self): """PackageList: extend a list with packages form another""" pkg_list = self.__create_list(self.aux_file('Packages-a-d')) pkg_aux_list = self.__create_list(self.aux_file('Packages-a-b-c-d')) pkg_list.extend(pkg_aux_list) self.failUnlessEqual(len(pkg_list), 4, "Extend has included wrong number of packages") def test_4filter_package (self): """PackageList: add a package to list from a filter rule""" pkg_list = self.__create_list(self.aux_file('Packages')) pkg_backup = pkg_list np1 = pkg_list.filter({'priority' : 'important'}) # There is only one package in section graphics self._checkPackageNames(np1, ["3dchess"]) # Test filter by name. np1 = pkg_list.filter({'name':'3dc.*'}) self._checkPackageNames(np1, ["3dchess"]) # Test if filter was changed the orignal list. self.failUnlessEqual(len(pkg_backup), len(pkg_list), "Filter has changed the list!") # Test Include-from. pkg_list2 = self.__create_list(self.aux_file('Packages-a-b-c-d-e')) pkg_backup2 = pkg_list2 np2 = pkg_list2.filter({'include-from':self.aux_file('tasks')}) self._checkPackageNames(np2, ["a", "e"]) # Test Exclude-from. np3 = pkg_list2.filter({'exclude-from':self.aux_file('tasks')}) self._checkPackageNames(np3, ["b", "c", "d"]) # Test if filter was changed the original list. self.failUnless(len(pkg_backup2) == len(pkg_list2), "Filter has changed the list!") # Test filter by subsection. np4 = pkg_list2.filter({'subsection':'devel'}) self._checkPackageNames(np4, ["a"]) # Test if filter was changed the orignal list. self.failUnlessEqual(len(pkg_backup2), len(pkg_list2), "Has changed the list!") # Test if was readded one package np5 = pkg_list.filter({'name':'3dc.*', 'subsection':'games'}) # Test exceptions on filter self.failUnlessRaises(InvalidFilter, pkg_list.filter, {'invalid':'foo'}) # Test wrong architecture self.failUnlessRaises(ValueError, pkg_list.filter, {'include-from':self.aux_file('tasks')}, 'fooarch') # Test filter by negative subsection. got = pkg_list2.filter({'exclude-subsection':'devel', 'exclude-name': 'c'}) self._checkPackageNames(got, ["b", "d", "e"]) # Test filter by positive tag got = pkg_list2.filter({'field-Tag':'.*suite::kde'}) self._checkPackageNames(got, ["a", "b"]) # Test filter by negative tag got = pkg_list2.filter({'exclude-field-Tag':'.*suite::kde'}) self._checkPackageNames(got, ["c", "d", "e"]) def test_5depends_package (self): """PackageList: A depends on B | C, D depends on C""" pkg_list = self.__create_list(self.aux_file('Packages-a-d')) pkg_list_full = self.__create_list(self.aux_file('Packages-a-b-c-d')) pkg_list.resolve_depends(pkg_list_full) self._checkPackageNames(pkg_list, ["a", "c", "d"]) def test_5depends2_package (self): """PackageList: A depends on B | C | D, E depends on D, C provides D""" pkg_list = self.__create_list(self.aux_file('Packages-a-e')) pkg_list_full = self.__create_list(self.aux_file('Packages-a-b-c-d-e')) pkg_list.resolve_depends(pkg_list_full) self._checkPackageNames(pkg_list, ["a", "e", "d"]) def test_5depends_real_or_virtual (self): """PackageList: A depends on B | virtualC, D provides virtualC""" pkg_list = self.__create_list(self.aux_file('Packages-real_or_virtual')) pkg_list_a_d = pkg_list.filter({'name':'a'}) pkg_list_a_d.add(pkg_list['d']) pkg_list_a_d.resolve_depends(pkg_list) self._checkPackageNames(pkg_list_a_d, ["a", "d"]) def test_5depends_real_or_virtual2 (self): """PackageList: META depends on A and D, A depends on B | virtualC, D provides virtualC""" pkg_list = self.__create_list(self.aux_file('Packages-real_or_virtual')) pkg_list_selected = pkg_list.filter({'name':'meta'}) pkg_list_selected.resolve_depends(pkg_list) self._checkPackageNames(pkg_list_selected, ["meta", "a", "d"]) def test_6broken_dependencies (self): """PackageList: broken dependencies""" pkg_list = self.__create_list(self.aux_file('BrokenPackages-a-b--d')) self.failUnlessRaises(BrokenDependencies, pkg_list.resolve_depends, pkg_list) try: pkg_list.resolve_depends(pkg_list) except BrokenDependencies, e: self.failUnlessEqual(e.deps[0]["Package"], "d", "Failed to return the broken package") self.failUnlessEqual(e.broken["d"], [[('c', '', '')]], "Failed to return the broken dependencie group") def test_7unlisted_dependencies (self): """PackageList: unlisted dependencies""" pkg_list = self.__create_list(self.aux_file('Packages-a-d')) pkg_list_full = self.__create_list(self.aux_file('Packages-a-b-c-d-e-f')) # d need c that need e, f | g" pkg_list.resolve_depends(pkg_list_full) self._checkPackageNames(pkg_list, ["a", "d", "c", "e", "f"]) def test_8versioned_dependencies (self): """PackageList: versioned dependencies""" pkg_list = self.__create_list(self.aux_file('Packages-a-d')) pkg_list_wrong_version = self.__create_list(self.aux_file\ ('Packages-versioned-dependencies')) pkg_list_right_version = self.__create_list(self.aux_file\ ('Packages-versioned-dependencies2')) pkg_list.resolve_depends([pkg_list_wrong_version, pkg_list_right_version]) self._checkPackageNames(pkg_list, ["a", "d", "c", "e", "f"]) self.failUnlessEqual(pkg_list['f']['Version'], "0.3") def test_9whereis_dependencie(self): """PackageList: whereis dependencie""" pkg_list = self.__create_list(self.aux_file('Packages-a-b-whereis-c')) pkg_list2 = self.__create_list(self.aux_file('Packages-hereis-c')) pkg_list.resolve_depends(pkg_list2) self.failUnlessEqual(pkg_list.whereis('c'), pkg_list2, "Returned a invalid adress") def test_10invalid_depend_field (self): """PackageList: invalid resolve_depends field""" pkg_list = self.__create_list(self.aux_file('Packages-a-d')) pkg_list_full = self.__create_list(self.aux_file('Packages-a-b-c-d')) pkg_list.resolve_depends(pkg_list_full) self.failUnlessRaises(SyntaxError, pkg_list.resolve_depends, pkg_list_full, 'foo') def test_11orphan(self): """PackageList: orphan denpendencies""" pkg_list = self.__create_list(self.aux_file('Packages-a-b-c-d-e')) self.failUnlessEqual(pkg_list.orphan_packages(), ['a', 'e'], "Returned a wrong list of packages as orphaned") pkg_list2 = self.__create_list(self.aux_file\ ('Packages-a-b-c-d-e-virtualf')) self.failUnlessEqual(pkg_list2.orphan_packages(), ['a', 'e'], "Returned a wrong list of packages as orphaned") def test_12whereis(self): """PackageList: whereis a package?""" pkg_list = self.__create_list(self.aux_file('Packages')) self.failUnlessRaises(PackageDoesNotExist, pkg_list.whereis, 'nonono') pkg_list2 = self.__create_list(self.aux_file('Packages-a-b-c-d')) pkg_list.add(pkg_list2['a'], pkg_list2) self.failUnlessEqual(pkg_list.whereis('3ddesktop'), pkg_list, "Returned a invalid adress") self.failUnlessEqual(pkg_list.whereis('a'), pkg_list2, "Returned a invalid adress") def test_13virtual_looping (self): """PackageList: virtual package looping""" pkg_list = self.__create_list(self.aux_file('VirtualPackagesLooping')) try: pkg_list.resolve_depends(pkg_list) except RuntimeError, e: self.fail("Raised a RuntimeError exception.", e) def _checkPackageNames(self, packages, expectedNames): expectedNames.sort() gotNames = packages.keys() gotNames.sort() self.failUnlessEqual(expectedNames, gotNames) class VersionComparisonTests(unittest.TestCase): def test01(self): """ Simple """ self.failUnless(allow_version("1.0", "1.1", "<")) self.failIf(allow_version("1.1", "1.1", "<")) self.failUnless(allow_version("1.0", "1.1", "<=")) self.failUnless(allow_version("1.1", "1.1", "<=")) self.failUnless(allow_version("2.1", "2.0", ">")) self.failIf(allow_version("2.1", "2.1", ">")) self.failUnless(allow_version("2.1", "2.0", ">=")) self.failUnless(allow_version("2.1", "2.1", ">=")) self.failUnless(allow_version("2.1", "2.1", "=")) def test02(self): """ Multi digit numeric """ self.failUnless(allow_version("1.9", "1.10", "<")) self.failIf(allow_version("1.10", "1.10", "<")) self.failUnless(allow_version("1.9", "1.10", "<=")) self.failUnless(allow_version("1.10", "1.10", "<=")) self.failUnless(allow_version("2.10", "2.9", ">")) self.failIf(allow_version("2.10", "2.10", ">")) self.failUnless(allow_version("2.10", "2.9", ">=")) self.failUnless(allow_version("2.10", "2.10", ">=")) self.failUnless(allow_version("2.10", "2.10", "=")) def test03(self): """ with text """ self.failUnless(allow_version("1.33-3", "1.40.8-2ubuntu2", "<")) def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(PackageListTests, 'test')) suite.addTest(unittest.makeSuite(VersionComparisonTests, 'test')) return suite if __name__ == '__main__': log = logging.getLogger() log_handler = logging.FileHandler(sys.argv[0][:-3] + '.log') log.setLevel(logging.DEBUG) log.addHandler(log_handler) unittest.main() python-cdd/tests/TestBase.py0000644000000000000000000000175311460375076013262 0ustar ########################################################################## # # TestBase.py: a common test class for our specific needs # # Python-CDD is a library to make easier to build applications to # Custom Debian Distributions. # See http://projetos.ossystems.com.br/python-cdd for more information. # # ==================================================================== # Copyright (c) 2002-2005 O.S. Systems. All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. # ######################################################################### # Author: Otavio Salvador from unittest import TestCase from os.path import abspath, join, dirname import sys class TestBase(TestCase): def aux_file(self, filename): current_dir = abspath(dirname(sys.argv[0])) if not current_dir.endswith('tests'): current_dir += '/tests' return join(current_dir, 'aux', filename) python-cdd/tests/TestPackage.py0000644000000000000000000000765111460375076013746 0ustar ########################################################################## # # TestPackage.py: test the Package module # # Python-CDD is a library to make easier to build applications to # Custom Debian Distributions. # See http://projetos.ossystems.com.br/python-cdd for more information. # # ==================================================================== # Copyright (c) 2002-2005 O.S. Systems. All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. # ######################################################################### # Authors: Otavio Salvador # Marco Presi import unittest import apt_pkg from TestBase import TestBase from cdd.Package import * import logging import sys class PackageTests(TestBase): def __read_file(self, class_ref, filename): parse_in = open(filename, 'r') tagfile = apt_pkg.TagFile(parse_in) pkg_list = [] for section in tagfile: pkg = class_ref(section) pkg_list.append(pkg) parse_in.close() return pkg_list def test_1package_init(self): """Package: initialization""" pkg_list = self.__read_file(Package, self.aux_file('Packages')) self.failUnless(pkg_list[0].has_key('Package'), "Failed to read the fields to Package object.") srclist = self.__read_file(SourcePackage, self.aux_file('Sources')) self.failUnless(srclist[0].has_key('Package'), "Failed to read the fields to SourcePackage object.") def test_2cast_fields(self): """Package: fielding casting""" pkg_list = self.__read_file(Package, self.aux_file('Packages')) for field in ('Suggests', 'Recommends', 'Depends', 'Pre-Depends'): if pkg_list[0].has_key(field): self.failUnlessEqual(type(pkg_list[0][field]), list, "Missing casting for the '%s' field." % field) self.failUnlessEqual(type(pkg_list[0][field][0]), list, "Wrong casting for the '%s' field." % field) if pkg_list[0].has_key('Provides'): self.failUnlessEqual(type(pkg_list[0]['Provides']), list) srclist = self.__read_file(SourcePackage, self.aux_file('Sources')) for field in ('Build-Depends', 'Build-Depends-Indep'): if srclist[0].has_key(field): self.failUnlessEqual(type(srclist[0][field]), list, "Missing casting for the '%s' field." % field) self.failUnlessEqual(type(srclist[0][field][0]), list, "Wrong casting for the '%s' field." % field) if srclist[0].has_key('Binary'): self.failUnlessEqual(type(srclist[0]['Binary']), list) if srclist[0].has_key('Files'): self.failUnlessEqual(type(srclist[0]['Files']), list, "Missing Source Files List.") files = [] files = srclist[0]['Files'] for i in range (0, len(files)): self.failUnlessEqual(type(files[i]), dict, "Wrong casting for 'files' field.") for field in ('name', 'md5sum', 'size'): if field == 'name': self.failIfEqual(files[i][field][-1:], '\n' "Didn't remove the newline char.") self.failIfEqual(files[i].has_key(field), False, "Didn't returned the field '%s'." % field) def test_3dump(self): """Package: dump package index""" for classref, filename in ((Package, self.aux_file('Packages')), (SourcePackage, self.aux_file('Sources'))): pkg_list = self.__read_file(classref, filename) pkg_str = "" for pkg in pkg_list: pkg_str += pkg.dump() packages_file = open(filename, 'r') self.failUnlessEqual( pkg_str, packages_file.read(), "Dump generated is invalid: %s %s !=\n%s" % (classref, filename, pkg_str) ) def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(PackageTests, 'test')) return suite if __name__ == '__main__': log = logging.getLogger() log_handler = logging.FileHandler(sys.argv[0][:-3] + '.log') log.setLevel(logging.DEBUG) log.addHandler(log_handler) unittest.main(defaultTest='suite') python-cdd/tests/aux/0000755000000000000000000000000011460375076011765 5ustar python-cdd/tests/aux/Packages-a-b-c-d-e-virtualf0000644000000000000000000000133111460375076016576 0ustar Package: a Version: 0.1 Priority: important Section: devel Maintainer: Nobody Depends: b, d Description: package a This is a test package Package: b Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Description: package a This is a test package Package: c Version: 0.1 Priority: important Provides: f Section: unknown Maintainer: Nobody Description: package a This is a test package Package: d Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Description: package a This is a test package Package: e Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Depends: f Description: package a This is a test package python-cdd/tests/aux/Sources0000644000000000000000000000222611460375076013335 0ustar Package: 3dchess Binary: 3dchess Version: 0.8.1-11 Priority: optional Section: games Maintainer: Stephen Stafford Build-Depends: debhelper, xaw3dg-dev, xlibs-dev Architecture: any Standards-Version: 3.5.9.0 Format: 1.0 Directory: pool/main/3/3dchess Files: ee24555acce059e14a8756cd5635593a 580 3dchess_0.8.1-11.dsc 5390c60953446e541d9455d9c4e38ca1 46371 3dchess_0.8.1.orig.tar.gz 9eac46d2c1664dd09b1e0c9d5e7a72ae 4747 3dchess_0.8.1-11.diff.gz Package: 3ddesktop Binary: 3ddesktop Version: 0.2.9-5 Priority: optional Section: utils Maintainer: Mathias Weyland Build-Depends: debhelper (>> 3.0.0), libxxf86vm-dev, libice-dev, libsm-dev, libx11-dev, libxext-dev, libxi-dev, libxmu-dev, libxt-dev, xlibmesa-dev | libgl-dev, libglu1-xorg-dev | libglu-dev, libimlib2-dev, autotools-dev, dpatch Architecture: any Standards-Version: 3.6.2 Format: 1.0 Directory: pool/main/3/3ddesktop Files: fd395137d79d0a3b2c1eab38ebf78a3b 815 3ddesktop_0.2.9-5.dsc da1e8b0d2c210a441676bbf663e694ee 182278 3ddesktop_0.2.9.orig.tar.gz 246edb643b69814582d8d16408f807a5 21826 3ddesktop_0.2.9-5.diff.gz Uploaders: Pierre Habouzit python-cdd/tests/aux/Packages-hereis-c0000644000000000000000000000022111460375076015116 0ustar Package: c Version: 0.1 Priority: important Section: devel Maintainer: Nobody Depends: Description: package a This is a test package python-cdd/tests/aux/Packages-a-d0000644000000000000000000000045711460375076014073 0ustar Package: a Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Depends: b | c Description: package a This is a test package Package: d Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Depends: c Description: package a This is a test package python-cdd/tests/aux/Packages-a-e0000644000000000000000000000046311460375076014071 0ustar Package: a Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Depends: b | c | d Description: package a This is a test package Package: e Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Depends: d Description: package a This is a test package python-cdd/tests/aux/VirtualPackagesLooping0000644000000000000000000000014611460375076016326 0ustar Package: virtual Provides: virtual Depends: virtual | a Package: a Depends: virtual Provides: virtualpython-cdd/tests/aux/Packages-versioned-dependencies20000644000000000000000000000021211460375076020123 0ustar Package: f Version: 0.3 Priority: important Section: unknown Maintainer: Nobody Description: package a This is a test package python-cdd/tests/aux/Packages-a-b-c-d0000644000000000000000000000112711460375076014525 0ustar Package: a Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Depends: b | c Description: package a This is a test package Package: b Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Depends: Description: package a This is a test package Package: c Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Depends: Description: package a This is a test package Package: d Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Depends: c Description: package a This is a test package python-cdd/tests/aux/Packages-a-b-whereis-c0000644000000000000000000000045111460375076015747 0ustar Package: a Version: 0.1 Priority: important Section: devel Maintainer: Nobody Depends: b,c Description: package a This is a test package Package: b Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Depends: Description: package a This is a test package python-cdd/tests/aux/Packages-versioned-dependencies0000644000000000000000000000160011460375076020043 0ustar Package: a Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Depends: b | c Description: package a This is a test package Package: b Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Description: package a This is a test package Package: c Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Depends: e (= 0.1-1), f (>> 0.2) Description: package a This is a test package Package: d Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Depends: c Description: package a This is a test package Package: e Version: 0.1-1 Priority: important Section: unknown Maintainer: Nobody Description: package a This is a test package Package: f Version: 0.1-1 Priority: important Section: unknown Maintainer: Nobody Description: package a This is a test package python-cdd/tests/aux/tasks0000644000000000000000000000003511460375076013033 0ustar #ifdef ARCH_i386 a e #endif python-cdd/tests/aux/Packages-a-b-c-d-e0000644000000000000000000000154411460375076014752 0ustar Package: a Version: 0.1 Priority: important Section: devel Maintainer: Nobody Depends: b | c | d Description: package a This is a test package Tag: suite::kde, use::testing Package: b Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Description: package a This is a test package Tag: suite::kde, use::testing Package: c Version: 0.1 Priority: important Provides: d Section: unknown Maintainer: Nobody Description: package a This is a test package Tag: suite::gnome, use::testing Package: d Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Description: package a This is a test package Package: e Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Depends: d Description: package a This is a test package Tag: suite::toystory, use::breaking-toys python-cdd/tests/aux/BrokenPackages-a-b--d0000644000000000000000000000070311460375076015522 0ustar Package: a Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Depends: b | c Description: package a This is a test package Package: b Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Depends: Description: package a This is a test package Package: d Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Depends: c Description: package a This is a test package python-cdd/tests/aux/Packages0000644000000000000000000000443711460375076013436 0ustar Package: 3dchess Priority: important Section: games Installed-Size: 152 Maintainer: Stephen Stafford Architecture: i386 Version: 0.8.1-11 Depends: libc6 (>= 2.3.2.ds1-4), xaw3dg (>= 1.5+E-1), xlibs (>> 4.1.0) Filename: pool/main/3/3dchess/3dchess_0.8.1-11_i386.deb Size: 33116 MD5sum: 7248665d99d529342a5cd050a9128ff6 Description: 3D chess for X11 3 dimensional Chess game for X11R6. There are three boards, stacked vertically; 96 pieces of which most are the traditional chess pieces with just a couple of additions; 26 possible directions in which to move. The AI isn't wonderful, but provides a challenging enough game to all but the most highly skilled players. Tag: game::board, game::board:chess, interface::3d, interface::x11, use::gameplaying Package: 3ddesktop Priority: optional Section: utils Installed-Size: 472 Maintainer: Mathias Weyland Architecture: i386 Version: 0.2.9-5 Depends: libc6 (>= 2.3.5-1), libfreetype6 (>= 2.1.5-1), libgcc1 (>= 1:4.0.1), libglu1-xorg | libglu1, libice6 | xlibs (>> 4.1.0), libimlib2, libsm6 | xlibs (>> 4.1.0), libstdc++6 (>= 4.0.1), libx11-6 | xlibs (>> 4.1.0), libxext6 | xlibs (>> 4.1.0), libxi6 | xlibs (>> 4.1.0), libxmu6 | xlibs (>> 4.1.0), libxt6 | xlibs (>> 4.1.0), libxxf86vm1, xlibmesa-gl | libgl1, zlib1g (>= 1:1.2.1) Suggests: xbindkeys Filename: pool/main/3/3ddesktop/3ddesktop_0.2.9-5_i386.deb Size: 82178 MD5sum: d2b2cd49ef0d0528eb1aaf0d9961ef80 Description: "Three-dimensional" desktop switcher 3D-Desktop is an OpenGL program for switching virtual desktops in a seamless 3-dimensional manner. The current desktop is mapped into a fullscreen 3D environment where you may choose other screens. Several different visualization modes are available. A window manager compatible with the GNOME pager standard is required. . The transition from working desktop to fullscreen 3D environment is seamless: when the pager activates you see your current desktop appear to zoom out to a point in space where you can see your other virtual desktops allowing you to select another. . The program is rather memory-hungry and it is CPU intensive, but it's accessible from the command line, which makes it perfect for show floors and impressing your non-UN*X-using friends. Tag: game::toys, interface::3d, use::gameplaying python-cdd/tests/aux/Packages-a-b-c-d-e-f0000644000000000000000000000156111460375076015174 0ustar Package: a Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Depends: b | c Description: package a This is a test package Package: b Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Description: package a This is a test package Package: c Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Depends: e, f | g Description: package a This is a test package Package: d Version: 0.1 Priority: important Section: unknown Maintainer: Nobody Depends: c Description: package a This is a test package Package: e Version: 0.1-1 Priority: important Section: unknown Maintainer: Nobody Description: package a This is a test package Package: f Version: 0.1-1 Priority: important Section: unknown Maintainer: Nobody Description: package a This is a test package python-cdd/tests/aux/Packages-real_or_virtual0000644000000000000000000000043411460375076016616 0ustar Package: a Version: 1 Depends: b | virtualc Architecture: all Description: A Package: b Version: 1 Architecture: all Description: B Package: d Version: 1 Provides: virtualc Architecture: all Description: D Package: meta Version: 1 Depends: a, d Architecture: all Description: meta python-cdd/tests/TestFileSystem.py0000644000000000000000000001627611460375076014502 0ustar ########################################################################## # # TestFileSystem.py: test the FileSystem module # # Python-CDD is a library to make easier to build applications to # Custom Debian Distributions. # See http://projetos.ossystems.com.br/python-cdd for more information. # # ==================================================================== # Copyright (c) 2002-2005 O.S. Systems. All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. # ######################################################################### # Authors: Otavio Salvador # Tiago Bortoletto Vaz import unittest from os import removedirs, unlink, mkdir, rmdir, walk from os.path import exists, abspath, join from gzip import GzipFile from bz2 import BZ2File import sys from cdd import FileSystem import logging class FileSystemTests(unittest.TestCase): def __make_junk_file(self, name): # Make a test file. tmp_filename = join(self.tmpdir, name) tmp_file = file(tmp_filename, 'w') tmp_file.write("Test with a junk content.") tmp_file.close() def setUp(self): # Do all tests inside of testFileSystem.tmp directory self.tmpdir = abspath(sys.path[0]) + '/testFileSystem.tmp' self.fs_obj = FileSystem.FileSystem(abspath(sys.path[0]), 'testFileSystem.tmp') if not exists(self.tmpdir): mkdir(self.tmpdir) def tearDown(self): # Remove all files inside of self.tmpdir. for root, dirs, files in walk(self.tmpdir, topdown=False): for name in files: unlink(join(root, name)) for name in dirs: rmdir(join(root, name)) if exists(self.tmpdir): rmdir(self.tmpdir) def test_1base(self): """FileSystem: check if the base definition match""" self.assert_(self.tmpdir == self.fs_obj.base(), "Base attribut doesn't match.") def test_1base_exists(self): """FileSystem: check if we have the base directory for testing""" self.failUnless(exists(self.tmpdir)) def test_2create(self): """FileSystem: directory creation""" self.fs_obj.mkdir('dir1') # for test: self.fs_obj.mkdir('dir1') self.failIf(not exists(self.tmpdir + '/dir1'), "Failed to create 'dir1' directory.") # do the test without permission to do that: self.fs_objonroot = FileSystem.FileSystem('/') self.failUnlessEqual(self.fs_objonroot.mkdir('/monkey/noaccess'), False) self.__make_junk_file('dir1/foo') self.failUnless(not self.fs_obj.mkdir('dir1/foo'), "Create file with same name of pre-existing file") def test_2remove_dir(self): """FileSystem: remove a directory""" self.fs_obj.mkdir('dir1/dir2/dir3') self.fs_obj.rmdir('dir1/dir2/dir3') self.failUnless(not exists(self.tmpdir + '/dir1/dir2/dir3'), "Failed to remove dir1/dir2/dir3 directory.") self.failUnless(exists(self.tmpdir + '/dir1/dir2'), "Removed dir1/dir2 directory.") def test_2remove_dir2(self): """FileSystem: remove a leaf directory and empty all intermediate ones""" self.fs_obj.mkdir('dir1/dir2/dir3/') self.__make_junk_file('dir1/not_empty') self.fs_obj.rmdir('dir1/dir2/dir3/', True) self.failUnless(not exists(self.tmpdir + '/dir1/dir2/dir3'), "Failed to remove dir1/dir2/dir3 directory.") self.failUnless(not exists(self.tmpdir + '/dir1/dir2'), "Failed to remove dir1/dir2 directory.") self.failUnless(exists(self.tmpdir + '/dir1'), "Removed dir1/ directory but it wasn't empty.") def test_2remove_file(self): """FileSystem: remove a file""" self.__make_junk_file('test_2remove_file') self.fs_obj.remove('test_2remove_file') self.failUnless(not self.fs_obj.remove('test_2remove_file')) self.failUnless(not exists(self.tmpdir + '/test_2remove_file'), 'Cannot remove test_2remove_file file.') def test_3md5sum(self): """FileSystem: md5sum a file""" self.__make_junk_file('test_3md5sum') self.failUnlessEqual(self.fs_obj.md5sum('test_3md5sum'), '1693f3e5f42f21cb0c78d28443e4b6ce', 'Fail to get md5sum of test_3md5sum file.') self.failUnlessRaises(IOError, self.fs_obj.md5sum, 'notexist.no') def test_3sha1sum(self): """FileSystem: sha1sum a file""" self.__make_junk_file('test_3sha1sum') self.failUnlessEqual(self.fs_obj.sha1sum('test_3sha1sum'), '549642be705d216245262436794515491e93185e', 'Fail to get sha1sum of test_3sha1sum file.') self.failUnlessRaises(IOError, self.fs_obj.sha1sum, 'notexist.no') def test_3size(self): """FIleSystem: test size method""" self.__make_junk_file('test_3size') self.failIf(not self.fs_obj.size('test_3size'), 'Error Size.') self.failUnlessRaises(OSError, self.fs_obj.size, 'monkey.ban') def test_4uncompress(self): """FileSystem: uncompress a file""" for class_ref, extension in ((GzipFile, 'gz'), (BZ2File, 'bz2'), (GzipFile, 'bz2'), (BZ2File, 'gz'), (open, 'txt')): file = class_ref(join(self.tmpdir, 'test_3uncompress.' + extension), 'w') file.write('Junk content for test_3uncompress.') file.close() try: self.fs_obj.uncompress('test_3uncompress.' + extension) if class_ref == open: self.fail("We should receive a IOError Exception.") except IOError, msg: if class_ref == open: pass else: self.failUnless(exists(join(self.tmpdir, 'test_3uncompress')), 'Failed to create test_3uncompress file.') unzip_file = open(join(self.tmpdir, 'test_3uncompress'), 'r') unzip_content = unzip_file.read() unzip_file.close() self.failUnlessEqual(unzip_content, 'Junk content for test_3uncompress.', 'Uncompressed file with invalid content.') self.failUnlessRaises(IOError, self.fs_obj.uncompress, 'noexist.no') def test_4compress(self): """FileSystem: compress a file""" for format, class_ref, extension in ((FileSystem.GZIP, GzipFile, 'gz'), (FileSystem.BZIP2, BZ2File, 'bz2')): file = open(join(self.tmpdir, 'test_4compress.txt'), 'w') file.write('Junk content for test_4compress.') file.close() try: self.fs_obj.compress("test_4compress.txt", format) except IOError, msg: self.fail(msg) unzip = class_ref(join(self.tmpdir, 'test_4compress.txt.' + extension), 'r') self.failUnlessEqual(unzip.read(), 'Junk content for test_4compress.', 'Uncompressed file with invalid content.') unzip.close() self.failUnlessRaises(SyntaxError, self.fs_obj.compress, 'noexist.no', 'not') self.failUnlessRaises(IOError, self.fs_obj.compress, 'noexist.no') def test_5match(self): """FileSystem: match a pattern""" self.fs_obj.mkdir('test_5match') file = open(join(self.tmpdir, 'test_5match/foo.txt'), 'w') file.write('Junk content for test_5match.') file.close() for expression, valid in (('foo\.txt$', ['test_5match/foo.txt']), ('bar\.txt$', [])): self.failUnlessEqual(valid, self.fs_obj.match(expression)) def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(FileSystemTests, 'test')) return suite if __name__ == '__main__': log = logging.getLogger() log_handler = logging.FileHandler(sys.argv[0][:-3] + '.log') log.setLevel(logging.DEBUG) log.addHandler(log_handler) unittest.main(defaultTest='suite') python-cdd/doc/0000755000000000000000000000000011460375076010573 5ustar python-cdd/doc/python-cdd.xmi0000644000000000000000000013535711460375076013401 0ustar pyreverse 0.5.2 No Name cdd cdd.Package SourcePackage dump Package keys has_key dump cdd.FileSystem FileSystem unlink exists self name uncompress self filename compress self filename format md5sum self filename mkdir self name remove self name base rmdir self name empty match self expression size self filename sha1sum self filename cdd.PackageList PackageList resolve_depends self pkglist field extend self pkglist keys items get self key whereis self package remove self package filter self condition architectures add self package package_list has_key self key values orphan_packages python-cdd/COPYING0000644000000000000000000006364011460375076011072 0ustar GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! python-cdd/AUTHORS0000644000000000000000000000025311460375076011076 0ustar Otavio Salvador Nat Budin Free Ekanayaka Vagrant Cascadian Marco Presi