Example #1
0
    def __init__(self,
                 pkg_cache,
                 pkg_name,
                 version=None,
                 release="stable",
                 arch="amd64",
                 work_dir=".",
                 create_patch_tarball=False):
        """
        Relies on a pre-initialized DebianPackageCache instance being passed
        in as the first parameter.

        Initializes a DebianSource instance, where pkg_name is the name of a
        source package in the Debian archive and release specifies the Debian
        release name (e.g. "stretch").

        If version is not specified, the latest available version will be
        selected.
        """
        self.name = pkg_name
        self.version = DebianPackageVersion(version) if version else None
        self.release = release
        self.arch = arch
        self.files = {}
        self.patches = None
        self.packages = []
        self.work_dir = os.path.abspath(work_dir)
        self.copyright = None

        self.create_patch_tarball = create_patch_tarball
        self._cache = pkg_cache

        try:
            if self.version:
                self.metadata = self._cache.source[self.name][self.version]
            else:
                self.version, self.metadata = \
                    max(self._cache.source[self.name].items())
        except KeyError:
            raise BoltError(
                "package '{}' version '{}' not found in cache.".format(
                    self.name, self.version or "latest"))
        #end try

        for line in self.metadata.get("Checksums-Sha256", "").splitlines():
            sha256sum, size, filename = line\
                .strip()\
                .split()
            self.files[filename] = (sha256sum, size)
Example #2
0
    def __init__(self,
                 pkg_cache,
                 pkg_name,
                 version=None,
                 release="stable",
                 arch="amd64",
                 work_dir="."):
        """
        Relies on a pre-initialized DebianPackageCache instance being passed
        in as the first parameter.

        Initializes a DebianPackage instance where pkg_name is the name of
        a Debian binary package in the Debian package archive.

        If version is not specified, the latest available version will be
        selected.
        """
        self.name = pkg_name
        self.version = DebianPackageVersion(version) if version else None
        self.release = release
        self.arch = arch
        self.contents = []
        self.work_dir = os.path.abspath(work_dir)
        self._cache = pkg_cache

        try:
            if self.version:
                self.metadata = \
                    self._cache.binary[self.name][self.version.full]
            else:
                self.version, self.metadata = \
                    max(self._cache.binary[self.name].items())
        except KeyError:
            raise BoltError(
                "package '{}' version '{}' not found in cache.".format(
                    self.name, self.version or "latest"))
Example #3
0
 def __iter__(self):
     for version in super().keys():
         yield DebianPackageVersion(version)
Example #4
0
 def items(self):
     for version, pkg_obj in super().items():
         yield DebianPackageVersion(version), pkg_obj
 def __iter__(self):
     for version in self._dict.keys():
         yield DebianPackageVersion(version)
 def items(self):
     for version, pkg_obj in self._dict.items():
         yield DebianPackageVersion(version), pkg_obj