mirror of
https://pagure.io/fedora-kickstarts.git
synced 2024-11-26 09:03:09 +00:00
84 lines
2.3 KiB
Plaintext
84 lines
2.3 KiB
Plaintext
|
#!/usr/bin/python
|
||
|
# Given as input two live images, print out differences in their RPM content.
|
||
|
#
|
||
|
# Licensed under the new-BSD license (http://www.opensource.org/licenses/bsd-license.php)
|
||
|
# Copyright (C) 2010 Red Hat, Inc.
|
||
|
# Written by Colin Walters <walters@verbum.org>
|
||
|
|
||
|
import os
|
||
|
import sys
|
||
|
import tempfile
|
||
|
import subprocess
|
||
|
import getopt
|
||
|
|
||
|
|
||
|
def usage(ecode):
|
||
|
print "Usage: %s img1.iso img2.iso" % (sys.argv[0], )
|
||
|
print "Print differences between two live images"
|
||
|
sys.exit(ecode)
|
||
|
|
||
|
def main():
|
||
|
try:
|
||
|
opts,args = getopt.getopt(sys.argv[1:], 'h', ['help', 'debug'])
|
||
|
except getopt.GetoptError, e:
|
||
|
usage(1)
|
||
|
|
||
|
version = None
|
||
|
debug = False
|
||
|
for o,a in opts:
|
||
|
if o in ('-h', '--help'):
|
||
|
usage(0)
|
||
|
elif o in ('--debug', ):
|
||
|
debug = True
|
||
|
|
||
|
if len(args) != 2:
|
||
|
usage(1)
|
||
|
original = args[0]
|
||
|
new = args[1]
|
||
|
|
||
|
mount_temp = tempfile.mkdtemp()
|
||
|
|
||
|
(fd, original_rpmdata) = tempfile.mkstemp()
|
||
|
subprocess.check_call(['../livecd/tools/liveimage-mount', '--mount-hacks', '--chroot',
|
||
|
original, mount_temp, 'rpm', '-qa', '--queryformat="%{NAME} %{SIZE}\n'],
|
||
|
stdout=fd, stderr=sys.stderr)
|
||
|
os.close(fd)
|
||
|
(fd, new_rpmdata) = tempfile.mkstemp()
|
||
|
subprocess.check_call(['../livecd/tools/liveimage-mount', '--mount-hacks', '--chroot',
|
||
|
new, mount_temp, 'rpm', '-qa', '--queryformat="%{NAME} %{SIZE}\n'],
|
||
|
stdout=fd, stderr=sys.stderr)
|
||
|
os.close(fd)
|
||
|
|
||
|
os.rmdir(mount_temp)
|
||
|
|
||
|
original_rpms = {}
|
||
|
new_rpms = {}
|
||
|
|
||
|
def read_rpmdata(filename, data):
|
||
|
f = open(filename)
|
||
|
for line in f:
|
||
|
line = line.strip()
|
||
|
if not line: break
|
||
|
(rpm, size) = line.split(' ', 1)
|
||
|
data[rpm] = int(size)
|
||
|
f.close()
|
||
|
read_rpmdata(original_rpmdata, original_rpms)
|
||
|
read_rpmdata(new_rpmdata, new_rpms)
|
||
|
|
||
|
for rpm in original_rpms:
|
||
|
if rpm in new_rpms:
|
||
|
sizedelta = new_rpms[rpm] - original_rpms[rpm]
|
||
|
print '= %s: %d' % (rpm, sizedelta)
|
||
|
else:
|
||
|
print "- %s %d" % (rpm, original_rpms[rpm])
|
||
|
for rpm in new_rpms:
|
||
|
if rpm in original_rpms:
|
||
|
continue
|
||
|
print "+ %s %d" % (rpm, new_rpms[rpm])
|
||
|
|
||
|
sys.exit(0)
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
main()
|
||
|
|