Пример #1
0
    def test_get_package_xml(self):
        test_pkg_path = "%s/incisura-7.1.4-1.elfake.noarch.rpm" % self.data_dir
        repodata_xml = metadata.get_package_xml(test_pkg_path)
        self.assertTrue(repodata_xml.has_key("primary"))
        self.assertTrue(repodata_xml.has_key("filelists"))
        self.assertTrue(repodata_xml.has_key("other"))

        bad_package_path = "%s/i_dont_exist-7.1.4-1.elfake.noarch.rpm" % self.data_dir
        repodata_xml = metadata.get_package_xml(bad_package_path)
        self.assertEquals(repodata_xml, {})
Пример #2
0
def _migrate_rpm_unit_repodata():
    """
    Looks up rpm unit collection in the db and computes the repodata if not already available;
    If the package path is missing, the repodata if stored as an empty dict.
    """
    query_manager = ContentQueryManager()
    collection = query_manager.get_content_unit_collection(type_id="rpm")
    for rpm_unit in collection.find():
        if "repodata" not in rpm_unit or not rpm_unit["repodata"]:
            # if repodata is not in the schema or repodata is empty
            rpm_unit["repodata"] = metadata.get_package_xml(rpm_unit['_storage_path'])
            collection.save(rpm_unit, safe=True)
    _log.info("Migrated rpms to include rpm metadata")
Пример #3
0
def _migrate_rpm_unit_repodata():
    """
    Looks up rpm unit collection in the db and computes the repodata if not already available;
    If the package path is missing, the repodata if stored as an empty dict.
    """
    query_manager = ContentQueryManager()
    collection = query_manager.get_content_unit_collection(type_id="rpm")
    for rpm_unit in collection.find():
        if "repodata" not in rpm_unit or not rpm_unit["repodata"]:
            # if repodata is not in the schema or repodata is empty
            rpm_unit["repodata"] = metadata.get_package_xml(
                rpm_unit['_storage_path'])
            collection.save(rpm_unit, safe=True)
    _log.info("Migrated rpms to include rpm metadata")
Пример #4
0
                if existing_checksum != unit_key['checksum']:
                    # checksums dont match, remove existing file
                    os.remove(new_path)
                else:
                    _LOG.debug("Existing file is the same ")
            if not os.path.isdir(os.path.dirname(new_path)):
                os.makedirs(os.path.dirname(new_path))
            # copy the unit to the final path
            shutil.copy(file_path, new_path)
        except (IOError, OSError), e:
            msg = "Error copying upload file to final location [%s]; Error %s" % (new_path, e)
            details['errors'].append(msg)
            _LOG.error(msg)
            return False, summary, details
        # get the xml dumps for the pkg
        u.metadata["repodata"] = get_package_xml(new_path)
        conduit.save_unit(u)
        summary['num_units_processed'] = len([file_path])
        summary['num_units_saved'] = len([file_path])
        _LOG.debug("unit %s successfully saved" % u)
        summary["state"] = "FINISHED"
        if len(details['errors']):
            summary['num_errors'] = len(details['errors'])
            summary["state"] = "FAILED"
            return False, summary, details
        _LOG.info("Upload complete with summary: %s; Details: %s" % (summary, details))
        return True, summary, details

    def _upload_unit_erratum(self, repo, unit_key, metadata, conduit, config):
        summary = {'num_units_saved' : 0}
        details = {'errors' : []}