Esempio n. 1
0
File: rpm.py Progetto: ulif/pulp_rpm
def get_package_xml(pkg_path, sumtype=util.TYPE_SHA256):
    """
    Method to generate repo xmls - primary, filelists and other
    for a given rpm.

    :param pkg_path: package path on the filesystem
    :type  pkg_path: str

    :param sumtype: The type of checksum to use for creating the package xml
    :type  sumtype: basestring

    :return:    rpm metadata dictionary or empty if rpm path doesnt exist
    :rtype:     dict
    """
    ts = rpmUtils.transaction.initReadOnlyTransaction()
    try:
        # createrepo raises an exception if sumtype is unicode
        # https://bugzilla.redhat.com/show_bug.cgi?id=1290021
        sumtype_as_str = str(sumtype)
        po = yumbased.CreateRepoPackage(ts, pkg_path, sumtype=sumtype_as_str)
    except Exception, e:
        # I hate this, but yum doesn't use reasonable exceptions like IOError
        # and ValueError.
        _LOGGER.error(str(e))
        return {}
Esempio n. 2
0
def get_package_xml(pkg):
    
    ts = rpmUtils.transaction.initReadOnlyTransaction()
    po = yumbased.CreateRepoPackage(ts, pkg)

    metadata = {'primary' : po.xml_dump_primary_metadata(),
                'filelists': po.xml_dump_filelists_metadata(),
                'other'   : po.xml_dump_other_metadata(),
               }
    return metadata
Esempio n. 3
0
def _migrate_unit(rpm_unit, ts, collection):
    pkg_path = rpm_unit['_storage_path']
    if not os.path.exists(pkg_path):
        # if pkg doesnt exist, we cant get the pkg object, continue
        return
    po = yumbased.CreateRepoPackage(ts, pkg_path)
    for key in ["changelog", "filelist", "files"]:
        if key not in rpm_unit or not rpm_unit[key]:
            value = getattr(po, key)
            if key == "changelog":
                data = map(_decode_changelog, value)
            elif key == "filelist":
                data = map(util.string_to_unicode, value)
            elif key == "files":
                data = _decode_files(value)
            rpm_unit[key] = data
    collection.save(rpm_unit, safe=True)
Esempio n. 4
0
def get_package_xml(pkg_path, sumtype=verification.TYPE_SHA256):
    """
    Method to generate repo xmls - primary, filelists and other
    for a given rpm.

    :param pkg_path: rpm package path on the filesystem
    :type  pkg_path: str

    :param sumtype: The type of checksum to use for creating the package xml
    :type  sumtype: str

    :return:    rpm metadata dictionary or empty if rpm path doesnt exist
    :rtype:     dict
    """
    ts = rpmUtils.transaction.initReadOnlyTransaction()
    try:
        po = yumbased.CreateRepoPackage(ts, pkg_path, sumtype=sumtype)
    except Exception, e:
        # I hate this, but yum doesn't use reasonable exceptions like IOError
        # and ValueError.
        _LOGGER.error(str(e))
        return {}
Esempio n. 5
0
def get_package_xml(pkg_path):
    """
    Method to generate repo xmls - primary, filelists and other
    for a given rpm.

    @param pkg_path: rpm package path on the filesystem
    @type pkg_path: str

    @return rpm metadata dictionary or empty if rpm path doesnt exist
    @rtype {}
    """
    if not os.path.exists(pkg_path):
        _LOG.debug("Package path %s does not exist" % pkg_path)
        return {}
    ts = rpmUtils.transaction.initReadOnlyTransaction()
    po = yumbased.CreateRepoPackage(ts, pkg_path)
    # RHEL6 createrepo throws a ValueError if _cachedir is not set
    po._cachedir = None
    metadata = {'primary' : po.xml_dump_primary_metadata(),
                'filelists': po.xml_dump_filelists_metadata(),
                'other'   : po.xml_dump_other_metadata(),
                }
    return metadata