#!/usr/bin/python import os class Package (object): """ Software package. """ def __init__(self, name, version, archive_url, archive_md5): """ name specifies the package's name. version specifies the package's version. archive_url specifies the origin location of the package's source archive. archive_md5 specifies the MD5 sum of the source archive. """ self.__name = name self.__version = version self.__archive_url = archive_url self.__archive_md5 = archive_md5 def name (self): return self.__name def version (self): return self.__version def archive_url(self): return self.__archive_url def archive_md5(self): return self.__archive_md5 def archive_filename(self): os.path.basename(self.archive_url) self.name = property(name , None, None) self.version = property(version , None, None) self.archive_url = property(archive_url , None, None) self.archive_md5 = property(archive_md5 , None, None) self.archive_filename = property(archive_filename, None, None) class BuildManager (object): """ Build manager. """ def __init__(self, root=None, config_dir=None, sources_dir=None, patches_dir=None, packages_dir=None): """ config_dir specifies the location of the package configuration files. sources_dir specifies the location of the source archives. patches_dir specifies the location of the patch files. packages_dir specifies the location of the built packages. If any of config_dir, sources_dir, patches_dir, and packages_dir are None, they will default to the"sources", "patches", and "packages" subdirectories of root. If root is None, it defaults to the current working directory. config_dir, sources_dir and patches_dir may be HTTP URLs. """ if root is None: root = os.getcwd() if config_dir is None: config_dir = os.path.join(root, "config" ) if sources_dir is None: sources_dir = os.path.join(root, "sources" ) if patches_dir is None: patches_dir = os.path.join(root, "patches" ) if packages_dir is None: packages_dir = os.path.join(root, "packages") self.__config_dir = config_dir self.__sources_dir = sources_dir self.__patches_dir = patches_dir self.__packages_dir = packages_dir def config_dir (self): return self.__config_dir def sources_dir (self): return self.__sources_dir def patches_dir (self): return self.__patches_dir def packages_dir(self): return self.__packages_dir self.config_dir = property(config_dir , None, None) self.sources_dir = property(sources_dir , None, None) self.patches_dir = property(patches_dir , None, None) self.packages_dir = property(packages_dir, None, None) def message(self, message): """ Emit a message to standard error. """ marker = "#=#=#=#=#" write(sys.stderr, "%s %s %s\n" % (marker, message, marker)) ## # Do The Right Thing ## manager = BuildManager()