Ejemplo n.º 1
0
    def test_re_isadeb(self):
        # Verify that the three binary extensions match the regexp.
        for extension in ('deb', 'ddeb', 'udeb'):
            self.assertEqual(
                ('foo-bar', '1.0', 'i386', extension),
                re_isadeb.match('foo-bar_1.0_i386.%s' % extension).groups())

        # Some other extension doesn't match.
        self.assertIs(None, re_isadeb.match('foo-bar_1.0_i386.notdeb'))

        # A missing architecture also doesn't match.
        self.assertIs(None, re_isadeb.match('foo-bar_1.0.deb'))
Ejemplo n.º 2
0
    def test_re_isadeb(self):
        # Verify that the three binary extensions match the regexp.
        for extension in ('deb', 'ddeb', 'udeb'):
            self.assertEquals(
                ('foo-bar', '1.0', 'i386', extension),
                re_isadeb.match('foo-bar_1.0_i386.%s' % extension).groups())

        # Some other extension doesn't match.
        self.assertIs(None, re_isadeb.match('foo-bar_1.0_i386.notdeb'))

        # A missing architecture also doesn't match.
        self.assertIs(None, re_isadeb.match('foo-bar_1.0.deb'))
Ejemplo n.º 3
0
    def published_source_and_binary_files(self):
        """Return list of dictionaries representing published files."""
        files = sorted(
            self.context.getSourceAndBinaryLibraryFiles(),
            key=attrgetter('filename'))
        result = []
        urls = set()
        for library_file in files:
            url = library_file.http_url
            if url in urls:
                # Don't print out the same file multiple times. This
                # actually happens for arch-all builds, and is
                # particularly irritating for PPAs.
                continue
            urls.add(url)

            custom_dict = {}
            custom_dict["filename"] = library_file.filename
            custom_dict["filesize"] = library_file.content.filesize
            if re_isadeb.match(library_file.filename):
                custom_dict['class'] = 'binary'
                custom_dict["url"] = ProxiedLibraryFileAlias(
                    library_file, self.context.archive).http_url
            else:
                custom_dict['class'] = 'source'
                custom_dict["url"] = ProxiedSourceLibraryFileAlias(
                    library_file, self.context).http_url

            result.append(custom_dict)

        return result
Ejemplo n.º 4
0
def determine_file_class_and_name(filename):
    """Determine the name and PackageUploadFile subclass for the filename."""
    source_match = re_issource.match(filename)
    binary_match = re_isadeb.match(filename)
    buildinfo_match = re_isbuildinfo.match(filename)
    if source_match:
        package = source_match.group(1)
        if (determine_source_file_type(filename) == SourcePackageFileType.DSC):
            cls = DSCFile
        else:
            cls = SourceUploadFile
    elif binary_match:
        package = binary_match.group(1)
        cls = {
            BinaryPackageFileType.DEB: DebBinaryUploadFile,
            BinaryPackageFileType.DDEB: DdebBinaryUploadFile,
            BinaryPackageFileType.UDEB: UdebBinaryUploadFile,
        }[determine_binary_file_type(filename)]
    elif buildinfo_match:
        package = buildinfo_match.group(1)
        cls = BuildInfoFile
    else:
        raise CannotDetermineFileTypeError(
            "Could not determine the type of %r" % filename)

    return package, cls
    def verifyPackage(self):
        """Check if the binary is in changesfile and its name is valid."""
        control_package = self.control.get("Package", '')

        # Since DDEBs are generated after the original DEBs are processed
        # and considered by `dpkg-genchanges` they are only half-incorporated
        # the binary upload changes file. DDEBs are only listed in the
        # Files/Checksums-Sha1/ChecksumsSha256 sections and missing from
        # Binary/Description.
        if not self.filename.endswith('.ddeb'):
            if control_package not in self.changes.binaries:
                yield UploadError(
                    "%s: control file lists name as %r, which isn't in "
                    "changes file." % (self.filename, control_package))

        if not re_valid_pkg_name.match(control_package):
            yield UploadError("%s: invalid package name %r." %
                              (self.filename, control_package))

        # Ensure the filename matches the contents of the .deb
        # First check the file package name matches the deb contents.
        binary_match = re_isadeb.match(self.filename)
        file_package = binary_match.group(1)
        if control_package != file_package:
            yield UploadError("%s: package part of filename %r does not match "
                              "package name in the control fields %r" %
                              (self.filename, file_package, control_package))
    def verifyPackage(self):
        """Check if the binary is in changesfile and its name is valid."""
        control_package = self.control.get("Package", '')

        # Since DDEBs are generated after the original DEBs are processed
        # and considered by `dpkg-genchanges` they are only half-incorporated
        # the binary upload changes file. DDEBs are only listed in the
        # Files/Checksums-Sha1/ChecksumsSha256 sections and missing from
        # Binary/Description.
        if not self.filename.endswith('.ddeb'):
            if control_package not in self.changes.binaries:
                yield UploadError(
                    "%s: control file lists name as %r, which isn't in "
                    "changes file." % (self.filename, control_package))

        if not re_valid_pkg_name.match(control_package):
            yield UploadError("%s: invalid package name %r." % (
                self.filename, control_package))

        # Ensure the filename matches the contents of the .deb
        # First check the file package name matches the deb contents.
        binary_match = re_isadeb.match(self.filename)
        file_package = binary_match.group(1)
        if control_package != file_package:
            yield UploadError(
                "%s: package part of filename %r does not match "
                "package name in the control fields %r"
                % (self.filename, file_package, control_package))
def get_ppa_file_key(path):
    split_path = os.path.normpath(urllib.unquote(path)).split('/')
    if len(split_path) != 9:
        return None

    if re_isadeb.match(split_path[8]) is None:
        return None

    return tuple(split_path[1:4]) + (split_path[8],)
def get_ppa_file_key(path):
    split_path = os.path.normpath(urllib.unquote(path)).split('/')
    if len(split_path) != 9:
        return None

    if re_isadeb.match(split_path[8]) is None:
        return None

    return tuple(split_path[1:4]) + (split_path[8], )
    def verifyVersion(self):
        """Check if control version is valid matches the filename version.

        Binary version  doesn't need to match the changesfile version,
        because the changesfile version refers to the SOURCE version.
        """
        if not re_valid_version.match(self.control_version):
            yield UploadError("%s: invalid version number %r." %
                              (self.filename, self.control_version))

        binary_match = re_isadeb.match(self.filename)
        filename_version = binary_match.group(2)
        control_version_chopped = re_no_epoch.sub('', self.control_version)
        if filename_version != control_version_chopped:
            yield UploadError("%s: should be %s according to control file." %
                              (filename_version, control_version_chopped))
Ejemplo n.º 10
0
    def verifyVersion(self):
        """Check if control version is valid matches the filename version.

        Binary version  doesn't need to match the changesfile version,
        because the changesfile version refers to the SOURCE version.
        """
        if not re_valid_version.match(self.control_version):
            yield UploadError("%s: invalid version number %r."
                              % (self.filename, self.control_version))

        binary_match = re_isadeb.match(self.filename)
        filename_version = binary_match.group(2)
        control_version_chopped = re_no_epoch.sub('', self.control_version)
        if filename_version != control_version_chopped:
            yield UploadError("%s: should be %s according to control file."
                              % (filename_version, control_version_chopped))
Ejemplo n.º 11
0
    def __init__(self, filepath, md5, size, component_and_section,
                 priority_name, package, version, changes, policy, logger):

        PackageUploadFile.__init__(self, filepath, md5, size,
                                   component_and_section, priority_name,
                                   package, version, changes, policy, logger)

        if self.priority_name not in self.priority_map:
            default_priority = 'extra'
            self.logger.warn(
                "Unable to grok priority %r, overriding it with %s" %
                (self.priority_name, default_priority))
            self.priority_name = default_priority

        # Yeah, this is weird. Where else can I discover this without
        # unpacking the deb file, though?
        binary_match = re_isadeb.match(self.filename)
        self.architecture = binary_match.group(3)
Ejemplo n.º 12
0
    def __init__(self, filepath, md5, size, component_and_section,
                 priority_name, package, version, changes, policy, logger):

        PackageUploadFile.__init__(
            self, filepath, md5, size, component_and_section,
            priority_name, package, version, changes, policy, logger)

        if self.priority_name not in self.priority_map:
            default_priority = 'extra'
            self.logger.warn(
                 "Unable to grok priority %r, overriding it with %s"
                 % (self.priority_name, default_priority))
            self.priority_name = default_priority

        # Yeah, this is weird. Where else can I discover this without
        # unpacking the deb file, though?
        binary_match = re_isadeb.match(self.filename)
        self.architecture = binary_match.group(3)
Ejemplo n.º 13
0
def determine_file_class_and_name(filename):
    """Determine the name and PackageUploadFile subclass for the filename."""
    source_match = re_issource.match(filename)
    binary_match = re_isadeb.match(filename)
    if source_match:
        package = source_match.group(1)
        if determine_source_file_type(filename) == SourcePackageFileType.DSC:
            cls = DSCFile
        else:
            cls = SourceUploadFile
    elif binary_match:
        package = binary_match.group(1)
        cls = {
            BinaryPackageFileType.DEB: DebBinaryUploadFile,
            BinaryPackageFileType.DDEB: DdebBinaryUploadFile,
            BinaryPackageFileType.UDEB: UdebBinaryUploadFile,
        }[determine_binary_file_type(filename)]
    else:
        raise CannotDetermineFileTypeError("Could not determine the type of %r" % filename)

    return package, cls