Exemplo n.º 1
0
    def store_yaml(self, state, project, repository, arch):
        if not self.store_project or not self.store_package:
            return

        state_yaml = yaml.dump(state, default_flow_style=False)
        comment = 'Updated rebuild infos for {}/{}/{}'.format(project, repository, arch)
        source_file_ensure(self.apiurl, self.store_project, self.store_package,
                           self.store_filename, state_yaml, comment=comment)
    def crawl(self):
        """Main method"""

        leap_pkglist = self.get_packagelist(self.opensuse_project)
        sle_pkglist = self.get_packagelist(self.sle_project, by_project=False)
        # The selected_binarylist[] includes the latest sourcepackage list
        # binary RPMs from the latest sources need to be presented in ftp eventually
        selected_binarylist = []
        # Any existed binary RPMs from any SPx/Leap/Backports
        fullbinarylist = []
        # package_binaries[] is a pre-formated binarylist per each package
        # access to the conotent uses package_binaries['SUSE:SLE-15:Update_libcdio.12032']
        package_binaries = {}

        # Inject binarylist to a list per package name no matter what archtectures was
        for arch in SUPPORTED_ARCHS:
            for prj in leap_pkglist.keys():
                package_binaries = self.get_project_binary_list(prj, DEFAULT_REPOSITORY, arch, package_binaries)

        for pkg in package_binaries.keys():
            if not self.exception_package(pkg):
                fullbinarylist += package_binaries[pkg]

        for prj in leap_pkglist.keys():
            for pkg in leap_pkglist[prj]:
                cands = [prj + "_" + pkg]
                # Handling for SLE forks, or package has different multibuild bits
                # enablility between SLE and openSUSE
                if prj.startswith('openSUSE:') and pkg in sle_pkglist and\
                        not self.is_sle_specific(pkg):
                    cands.append(sle_pkglist[pkg]['Project'] + "_" + sle_pkglist[pkg]['Package'])
                logging.debug(cands)
                for index in cands:
                    if index in package_binaries:
                        selected_binarylist += package_binaries[index]
                    else:
                        logging.info("Can not find binary of %s" % index)

        # Some packages has been obsoleted by new updated package, however
        # there are application still depend on old library when it builds
        # eg. SUSE:SLE-15-SP3:GA has qpdf/libqpdf28 but cups-filter was build
        # in/when SLE15 SP2 which requiring qpdf/libqpdf6, therefore old
        # qpdf/libqpdf6 from SLE15 SP2 should not to be missed.
        for pkg in self.skiplist_ignored:
            selected_binarylist += package_binaries[pkg]

        # Preparing a packagelist for the skipping candidate
        obsoleted = []
        for pkg in fullbinarylist:
            if pkg not in selected_binarylist and pkg not in obsoleted:
                if not self.exception_binary(pkg):
                    obsoleted.append(pkg)

        # Post processing of obsoleted packagelist
        tmp_obsoleted = obsoleted.copy()
        for pkg in tmp_obsoleted:
            # Respect to single-speced python package, when a python2 RPM is
            # considered then a python3 flavor should also be selected to be
            # skipped, if not, don't add it.
            if pkg.startswith('python2-') and re.sub(r'^python2', 'python3', pkg) not in obsoleted:
                obsoleted.remove(pkg)
            # Main RPM must to be skipped if -32 bit RPM or -64bit RPM is
            # considered.
            if pkg.endswith('-32bit') or pkg.endswith('-64bit'):
                main_filename = re.sub('-[36][24]bit', '', pkg)
                if main_filename not in obsoleted:
                    obsoleted.remove(pkg)

        skip_list = ET.Element('group', {'name': 'NON_FTP_PACKAGES'})
        ET.SubElement(skip_list, 'conditional', {'name': 'drop_from_ftp'})
        packagelist = ET.SubElement(skip_list, 'packagelist', {'relationship': 'requires'})
        for pkg in sorted(obsoleted):
            if not self.print_only and self.verbose:
                print(pkg)
            attr = {'name': pkg}
            ET.SubElement(packagelist, 'package', attr)
        if not self.print_only:
            source_file_ensure(self.apiurl, self.upload_project, META_PACKAGE, 'NON_FTP_PACKAGES.group',
                               ET.tostring(skip_list, pretty_print=True, encoding='unicode'),
                               'Update the skip list')
        else:
            print(ET.tostring(skip_list, pretty_print=True,
                  encoding='unicode'))