def compare_iso9660_files(path1, path2, source=None): differences = [] # compare metadata differences.append(Difference.from_command(ISO9660PVD, path1, path2)) for extension in (None, 'joliet', 'rockridge'): differences.append(Difference.from_command(ISO9660Listing, path1, path2, command_args=(extension,))) # compare files contained in image files1 = get_iso9660_names(path1) files2 = get_iso9660_names(path2) with make_temp_directory() as temp_dir1: with make_temp_directory() as temp_dir2: for name in sorted(set(files1).intersection(files2)): logger.debug('extract file %s' % name) in_path1 = os.path.join(temp_dir1, os.path.basename(name)) in_path2 = os.path.join(temp_dir2, os.path.basename(name)) with open(in_path1, 'w') as dest: extract_from_iso9660(path1, name, dest) with open(in_path2, 'w') as dest: extract_from_iso9660(path2, name, dest) differences.append(debbindiff.comparators.compare_files( in_path1, in_path2, source=name)) return differences
def compare_iso9660_files(path1, path2, source=None): differences = [] # compare metadata difference = Difference.from_command(ISO9660PVD, path1, path2) if difference: differences.append(difference) for extension in (None, 'joliet', 'rockridge'): difference = Difference.from_command(ISO9660Listing, path1, path2, command_args=(extension, )) if difference: differences.append(difference) # compare files contained in image files1 = get_iso9660_names(path1) files2 = get_iso9660_names(path2) with make_temp_directory() as temp_dir1: with make_temp_directory() as temp_dir2: for name in sorted(set(files1).intersection(files2)): logger.debug('extract file %s' % name) in_path1 = os.path.join(temp_dir1, os.path.basename(name)) in_path2 = os.path.join(temp_dir2, os.path.basename(name)) with open(in_path1, 'w') as dest: extract_from_iso9660(path1, name, dest) with open(in_path2, 'w') as dest: extract_from_iso9660(path2, name, dest) differences.extend( debbindiff.comparators.compare_files(in_path1, in_path2, source=name)) return differences
def compare_squashfs_files(path1, path2, source=None): differences = [] # compare metadata difference = Difference.from_command(SquashfsSuperblock, path1, path2) if difference: differences.append(difference) difference = Difference.from_command(SquashfsListing, path1, path2) if difference: differences.append(difference) # compare files contained in archive files1 = get_squashfs_names(path1) files2 = get_squashfs_names(path2) with make_temp_directory() as temp_dir1: with make_temp_directory() as temp_dir2: extract_squashfs(path1, temp_dir1) extract_squashfs(path2, temp_dir2) for member in sorted(set(files1).intersection(set(files2))): in_path1 = os.path.join(temp_dir1, member) in_path2 = os.path.join(temp_dir2, member) if not os.path.isfile(in_path1) or not os.path.isfile(in_path2): continue differences.extend(debbindiff.comparators.compare_files( in_path1, in_path2, source=member)) return differences
def compare_zip_files(path1, path2, source=None): differences = [] try: with ZipFile(path1, 'r') as zip1: with ZipFile(path2, 'r') as zip2: # look up differences in content with make_temp_directory() as temp_dir1: with make_temp_directory() as temp_dir2: for name in sorted( set(zip1.namelist()).intersection( zip2.namelist())): # skip directories if name.endswith('/'): continue logger.debug('extract member %s', name) in_path1 = zip1.extract(name, temp_dir1) in_path2 = zip2.extract(name, temp_dir2) differences.extend( debbindiff.comparators.compare_files( in_path1, in_path2, source=name)) os.unlink(in_path1) os.unlink(in_path2) # look up differences in metadata difference = Difference.from_command(Zipinfo, path1, path2) if not difference: # search harder difference = Difference.from_command( ZipinfoVerbose, path1, path2) if difference: differences.append(difference) except BadZipfile: logger.debug('Either %s or %s is not a zip file.' % (path1, path2)) # we'll fallback on binary comparison return differences
def compare_zip_files(path1, path2, source=None): differences = [] try: with ZipFile(path1, 'r') as zip1: with ZipFile(path2, 'r') as zip2: # look up differences in content with make_temp_directory() as temp_dir1: with make_temp_directory() as temp_dir2: for name in sorted(set(zip1.namelist()) .intersection(zip2.namelist())): # skip directories if name.endswith('/'): continue logger.debug('extract member %s', name) in_path1 = zip1.extract(name, temp_dir1) in_path2 = zip2.extract(name, temp_dir2) differences.append( debbindiff.comparators.compare_files( in_path1, in_path2, source=name)) os.unlink(in_path1) os.unlink(in_path2) # look up differences in metadata difference = Difference.from_command(Zipinfo, path1, path2) if not difference: # search harder difference = Difference.from_command(ZipinfoVerbose, path1, path2) differences.append(difference) except BadZipfile: logger.debug('Either %s or %s is not a zip file.' % (path1, path2)) # we'll fallback on binary comparison return differences
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
def compare_pdf_files(path1, path2, source=None): differences = [] difference = Difference.from_command(Pdftotext, path1, path2) if difference: differences.append(difference) difference = Difference.from_command(Pdftk, path1, path2) if difference: differences.append(difference) return differences
def _compare_elf_data(path1, path2, source=None): differences = [] difference = Difference.from_command(ReadelfAll, path1, path2) if difference: differences.append(difference) difference = Difference.from_command(ReadelfDebugDump, path1, path2) if difference: differences.append(difference) difference = Difference.from_command(ObjdumpDisassemble, path1, path2) if difference: differences.append(difference) return differences
def compare_cpio_files(path1, path2, source=None): differences = [] difference = Difference.from_command( CpioContent, path1, path2, source="file list") if difference: differences.append(difference) # compare files contained in archive content1 = get_cpio_names(path1) content2 = get_cpio_names(path2) with make_temp_directory() as temp_dir1: with make_temp_directory() as temp_dir2: extract_cpio_archive(path1, temp_dir1) extract_cpio_archive(path2, temp_dir2) files1 = content1.splitlines(1) files2 = content2.splitlines(1) for member in sorted(set(files1).intersection(set(files2))): in_path1 = os.path.join(temp_dir1, member) in_path2 = os.path.join(temp_dir2, member) if not os.path.isfile(in_path1) or not os.path.isfile(in_path2): continue differences.extend(debbindiff.comparators.compare_files( in_path1, in_path2, source=member)) return differences
def compare_cpio_files(path1, path2, source=None): differences = [] difference = Difference.from_command(CpioContent, path1, path2, source="file list") if difference: differences.append(difference) # compare files contained in archive content1 = get_cpio_names(path1) content2 = get_cpio_names(path2) with make_temp_directory() as temp_dir1: with make_temp_directory() as temp_dir2: extract_cpio_archive(path1, temp_dir1) extract_cpio_archive(path2, temp_dir2) files1 = content1.splitlines(1) files2 = content2.splitlines(1) for member in sorted(set(files1).intersection(set(files2))): in_path1 = os.path.join(temp_dir1, member) in_path2 = os.path.join(temp_dir2, member) if not os.path.isfile(in_path1) or not os.path.isfile( in_path2): continue differences.extend( debbindiff.comparators.compare_files(in_path1, in_path2, source=member)) return differences
def compare_hi_files(path1, path2, source=None): return [Difference.from_command(ShowIface, path1, path2)]
def compare_mo_files(path1, path2, source=None): return [Difference.from_command(Msgunfmt, path1, path2)]
def compare_ttf_files(path1, path2, source=None): return [Difference.from_command(Showttf, path1, path2)]
def compare_ttf_files(path1, path2, source=None): difference = Difference.from_command(Showttf, path1, path2) if not difference: return [] return [difference]
def compare_mo_files(path1, path2, source=None): difference = Difference.from_command(Msgunfmt, path1, path2) if not difference: return [] return [difference]
def compare_mo_files(path1, path2, source=None): difference = Difference.from_command(Msgunfmt, path1, path2) if not difference: return [] return [difference]
def compare_png_files(path1, path2, source=None): difference = Difference.from_command(Sng, path1, path2, source='sng') if not difference: return [] return [difference]
def compare_png_files(path1, path2, source=None): return [Difference.from_command(Sng, path1, path2, source='sng')]
def compare_class_files(path1, path2, source=None): return [Difference.from_command(Javap, path1, path2)]