Пример #1
0
def compare_rpm_files(path1, path2, source=None):
    try:
        import rpm
    except ImportError:
        logger.info("Python module rpm not found.")
        return []

    differences = []

    # compare headers
    with make_temp_directory() as rpmdb_dir:
        rpm.addMacro("_dbpath", rpmdb_dir)
        ts = rpm.TransactionSet()
        ts.setVSFlags(-1)
        header1 = get_rpm_header(path1, ts)
        header2 = get_rpm_header(path2, ts)
        difference = Difference.from_unicode(header1,
                                             header2,
                                             path1,
                                             path2,
                                             source="header")
        if difference:
            differences.append(difference)

    # extract cpio archive
    with extract_rpm_payload(path1) as archive1:
        with extract_rpm_payload(path2) as archive2:
            differences.extend(
                debbindiff.comparators.compare_files(archive1,
                                                     archive2,
                                                     source=get_source(
                                                         archive1, archive2)))

    return differences
Пример #2
0
def compare_rpm_files(path1, path2, source=None):
    try:
        import rpm
    except ImportError:
        logger.info("Python module rpm not found.")
        return []

    differences = []

    # compare headers
    with make_temp_directory() as rpmdb_dir:
        rpm.addMacro("_dbpath", rpmdb_dir)
        ts = rpm.TransactionSet()
        ts.setVSFlags(-1)
        header1 = get_rpm_header(path1, ts)
        header2 = get_rpm_header(path2, ts)
        difference = Difference.from_unicode(
                         header1, header2, path1, path2, source="header")
        if difference:
            differences.append(difference)

    # extract cpio archive
    with extract_rpm_payload(path1) as archive1:
        with extract_rpm_payload(path2) as archive2:
            differences.extend(debbindiff.comparators.compare_files(
                archive1, archive2, source=get_source(archive1, archive2)))

    return differences
Пример #3
0
def compare_meta(path1, path2):
    logger.debug('compare_meta(%s, %s)' % (path1, path2))
    differences = []

    try:
        difference = Difference.from_command(Stat, path1, path2)
        if difference:
            differences.append(difference)
    except RequiredToolNotFound:
        logger.warn("'stat' not found! Is PATH wrong?")

    try:
        lsattr1 = lsattr(path1)
        lsattr2 = lsattr(path2)
        difference = Difference.from_unicode(
                         lsattr1, lsattr2, path1, path2, source="lattr")
        if difference:
            differences.append(difference)
    except RequiredToolNotFound:
        logger.info("Unable to find 'lsattr'.")

    try:
        difference = Difference.from_command(Getfacl, path1, path2)
        if difference:
            differences.append(difference)
    except RequiredToolNotFound:
        logger.info("Unable to find 'getfacl'.")
    return differences
Пример #4
0
 def compare_rpm_files(path1, path2, source=None):
     logger.info("Python rpm module not found.")
     difference = compare_binary_files(path1, path2, source)
     if difference:
         difference.comment = (difference.comment or '') + \
             '\nUnable to find Python rpm module. Falling back to binary comparison.'
     return difference
Пример #5
0
 def validate(self, check_hash="sha1", check_signature=True):
     """
     See :meth:`validate_checksums` for ``check_hash``, and
     :meth:`validate_signature` if ``check_signature`` is True.
     """
     self.validate_checksums(check_hash)
     if check_signature:
         self.validate_signature(check_signature)
     else:
         logger.info("Not checking signature")
Пример #6
0
 def validate(self, check_hash="sha1", check_signature=True):
     """
     See :meth:`validate_checksums` for ``check_hash``, and
     :meth:`validate_signature` if ``check_signature`` is True.
     """
     self.validate_checksums(check_hash)
     if check_signature:
         self.validate_signature(check_signature)
     else:
         logger.info("Not checking signature")