Exemple #1
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 test_determine_binary_file_type(self):
        """lp.archiveuploader.utils.determine_binary_file_type should work."""
        # .deb -> DEB
        self.assertEquals(
            determine_binary_file_type('foo_1.0-1_all.deb'),
            BinaryPackageFileType.DEB)

        # .ddeb -> DDEB
        self.assertEquals(
            determine_binary_file_type('foo_1.0-1_all.ddeb'),
            BinaryPackageFileType.DDEB)

        # .udeb -> UDEB
        self.assertEquals(
            determine_binary_file_type('foo_1.0-1_all.udeb'),
            BinaryPackageFileType.UDEB)

        self.assertEquals(determine_binary_file_type('foo_1.0'), None)
        self.assertEquals(determine_binary_file_type('foo_1.0.notdeb'), None)
Exemple #3
0
    def test_determine_binary_file_type(self):
        """lp.archiveuploader.utils.determine_binary_file_type should work."""
        # .deb -> DEB
        self.assertEqual(
            determine_binary_file_type('foo_1.0-1_all.deb'),
            BinaryPackageFileType.DEB)

        # .ddeb -> DDEB
        self.assertEqual(
            determine_binary_file_type('foo_1.0-1_all.ddeb'),
            BinaryPackageFileType.DDEB)

        # .udeb -> UDEB
        self.assertEqual(
            determine_binary_file_type('foo_1.0-1_all.udeb'),
            BinaryPackageFileType.UDEB)

        self.assertEqual(determine_binary_file_type('foo_1.0'), None)
        self.assertEqual(determine_binary_file_type('foo_1.0.notdeb'), None)
Exemple #4
0
    def createBinaryPackage(self, bin, srcpkg, distroarchinfo, archtag):
        """Create a new binarypackage."""
        fdir, fname = os.path.split(bin.filename)
        to_upload = check_not_in_librarian(fname, bin.archive_root, fdir)
        fname, path = to_upload[0]

        componentID = self.distro_handler.getComponentByName(bin.component).id
        sectionID = self.distro_handler.ensureSection(bin.section).id
        architecturespecific = (bin.architecture != "all")

        bin_name = getUtility(IBinaryPackageNameSet).ensure(bin.package)
        build = self.ensureBuild(bin, srcpkg, distroarchinfo, archtag)

        # Create the binarypackage entry on lp db.
        binpkg = BinaryPackageRelease(
            binarypackagename=bin_name.id,
            component=componentID,
            version=bin.version,
            description=bin.description,
            summary=bin.summary,
            build=build.id,
            binpackageformat=getBinaryPackageFormat(bin.filename),
            section=sectionID,
            priority=prioritymap[bin.priority],
            shlibdeps=bin.shlibs,
            depends=bin.depends,
            suggests=bin.suggests,
            recommends=bin.recommends,
            conflicts=bin.conflicts,
            replaces=bin.replaces,
            provides=bin.provides,
            pre_depends=bin.pre_depends,
            enhances=bin.enhances,
            breaks=bin.breaks,
            essential=bin.essential,
            installedsize=bin.installed_size,
            architecturespecific=architecturespecific,
            )
        log.info('Binary Package Release %s (%s) created' %
                 (bin_name.name, bin.version))

        alias = getLibraryAlias(path, fname)
        BinaryPackageFile(
            binarypackagerelease=binpkg.id,
            libraryfile=alias,
            filetype=determine_binary_file_type(fname))
        log.info('Package file %s included into library' % fname)

        # Return the binarypackage object.
        return binpkg
    def createBinaryPackage(self, bin, srcpkg, distroarchinfo, archtag):
        """Create a new binarypackage."""
        fdir, fname = os.path.split(bin.filename)
        to_upload = check_not_in_librarian(fname, bin.archive_root, fdir)
        fname, path = to_upload[0]

        componentID = self.distro_handler.getComponentByName(bin.component).id
        sectionID = self.distro_handler.ensureSection(bin.section).id
        architecturespecific = (bin.architecture != "all")

        bin_name = getUtility(IBinaryPackageNameSet).ensure(bin.package)
        build = self.ensureBuild(bin, srcpkg, distroarchinfo, archtag)

        # Create the binarypackage entry on lp db.
        binpkg = BinaryPackageRelease(
            binarypackagename=bin_name.id,
            component=componentID,
            version=bin.version,
            description=bin.description,
            summary=bin.summary,
            build=build.id,
            binpackageformat=getBinaryPackageFormat(bin.filename),
            section=sectionID,
            priority=prioritymap[bin.priority],
            shlibdeps=bin.shlibs,
            depends=bin.depends,
            suggests=bin.suggests,
            recommends=bin.recommends,
            conflicts=bin.conflicts,
            replaces=bin.replaces,
            provides=bin.provides,
            pre_depends=bin.pre_depends,
            enhances=bin.enhances,
            breaks=bin.breaks,
            essential=bin.essential,
            installedsize=bin.installed_size,
            architecturespecific=architecturespecific,
        )
        log.info('Binary Package Release %s (%s) created' %
                 (bin_name.name, bin.version))

        alias = getLibraryAlias(path, fname)
        BinaryPackageFile(binarypackagerelease=binpkg.id,
                          libraryfile=alias,
                          filetype=determine_binary_file_type(fname))
        log.info('Package file %s included into library' % fname)

        # Return the binarypackage object.
        return binpkg
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