コード例 #1
0
ファイル: upload.py プロジェクト: ulif/pulp_rpm
def _extract_drpm_data(drpm_filename):
    """
    Extract a dict of information for a given DRPM.

    :param drpm_filename: full path to the package to analyze
    :type  drpm_filename: str

    :return: dict of data about the package
    :rtype:  dict
    """
    drpm_data = dict()

    headers = rpm_parse.drpm_package_info(drpm_filename)

    try:  # "handle" rpm-only drpms (without rpm header)
        rpm_headers = rpm_parse.package_headers(drpm_filename)
    except rpm.error:
        raise RPMOnlyDRPMsAreNotSupported(drpm_filename)

    drpm_data['signing_key'] = rpm_parse.package_signature(rpm_headers)
    drpm_data['arch'] = rpm_headers['arch']

    old_nevr = old_name, old_epoch, old_version, old_release = rpm_parse.nevr(
        headers["old_nevr"])
    new_nevr = new_name, new_epoch, new_version, new_release = rpm_parse.nevr(
        headers["nevr"])

    drpm_data['sequence'] = headers["old_nevr"] + "-" + headers["seq"]

    drpm_data['epoch'] = str(new_epoch)
    drpm_data['oldepoch'] = str(old_epoch)

    drpm_data['version'] = str(new_version)
    drpm_data['oldversion'] = str(old_version)

    drpm_data['release'] = new_release
    drpm_data['oldrelease'] = old_release

    drpm_data['new_package'] = new_name
    drpm_data['size'] = os.stat(drpm_filename)[stat.ST_SIZE]

    old_evr = rpm_parse.nevr_to_evr(*old_nevr)
    new_evr = rpm_parse.nevr_to_evr(*new_nevr)
    drpm_data['filename'] = "drpms/%s-%s_%s.%s.drpm" % (
        new_name, rpm_parse.evr_to_str(*old_evr),
        rpm_parse.evr_to_str(*new_evr), drpm_data['arch'])

    return _encode_as_utf8(drpm_data)
コード例 #2
0
ファイル: upload.py プロジェクト: ulif/pulp_rpm
def _extract_drpm_data(drpm_filename):
    """
    Extract a dict of information for a given DRPM.

    :param drpm_filename: full path to the package to analyze
    :type  drpm_filename: str

    :return: dict of data about the package
    :rtype:  dict
    """
    drpm_data = dict()

    headers = rpm_parse.drpm_package_info(drpm_filename)

    try:  # "handle" rpm-only drpms (without rpm header)
        rpm_headers = rpm_parse.package_headers(drpm_filename)
    except rpm.error:
        raise RPMOnlyDRPMsAreNotSupported(drpm_filename)

    drpm_data['signing_key'] = rpm_parse.package_signature(rpm_headers)
    drpm_data['arch'] = rpm_headers['arch']

    old_nevr = old_name, old_epoch, old_version, old_release = rpm_parse.nevr(headers["old_nevr"])
    new_nevr = new_name, new_epoch, new_version, new_release = rpm_parse.nevr(headers["nevr"])

    drpm_data['sequence'] = headers["old_nevr"] + "-" + headers["seq"]

    drpm_data['epoch'] = str(new_epoch)
    drpm_data['oldepoch'] = str(old_epoch)

    drpm_data['version'] = str(new_version)
    drpm_data['oldversion'] = str(old_version)

    drpm_data['release'] = new_release
    drpm_data['oldrelease'] = old_release

    drpm_data['new_package'] = new_name
    drpm_data['size'] = os.stat(drpm_filename)[stat.ST_SIZE]

    old_evr = rpm_parse.nevr_to_evr(*old_nevr)
    new_evr = rpm_parse.nevr_to_evr(*new_nevr)
    drpm_data['filename'] = "drpms/%s-%s_%s.%s.drpm" % (new_name, rpm_parse.evr_to_str(*old_evr),
                                                        rpm_parse.evr_to_str(*new_evr),
                                                        drpm_data['arch'])

    return _encode_as_utf8(drpm_data)
コード例 #3
0
 def test_nerv_to_evr(self):
     """Test parsing NEVR tuple to EVR tuple."""
     nevr = rpm.nevr("yum-3.4.3-8.fc16")
     evr = nevr[1:]
     self.assertEquals(rpm.nevr_to_evr(*nevr), evr)
コード例 #4
0
ファイル: test_rpm.py プロジェクト: pcreech/pulp_rpm
 def test_nerv_to_evr(self):
     """Test parsing NEVR tuple to EVR tuple."""
     nevr = rpm.nevr("yum-3.4.3-8.fc16")
     evr = nevr[1:]
     self.assertEquals(rpm.nevr_to_evr(*nevr), evr)