4 from tempfile import mkdtemp
5 from os import mkdir, system
9 def compare_header(refspec, altspec):
10 refhdr = refspec.packages()[0].header()
11 althdr = altspec.packages()[0].header()
13 refname = refhdr[rpm.RPMTAG_NAME]
14 altname = althdr[rpm.RPMTAG_NAME]
16 refver = refhdr[rpm.RPMTAG_VERSION]
17 altver = althdr[rpm.RPMTAG_VERSION]
19 reflic = refhdr[rpm.RPMTAG_LICENSE]
20 altlic = althdr[rpm.RPMTAG_LICENSE]
22 refurl = refhdr[rpm.RPMTAG_URL]
23 alturl = althdr[rpm.RPMTAG_URL]
26 print "WARNING: different version: '%s': '%s' != '%s': '%s'" % (refname, refver, altname, altver)
29 print "WARNING: different license: '%s': '%s' != '%s': '%s'" % (refname, reflic, altname, altlic)
32 print "WARNING: different URL: '%s': '%s' != '%s': '%s'" % (refname, refurl, altname, alturl)
34 def compare_sources(refspec, altspec):
39 for src in refspec.sources():
40 if src[2] == rpm.RPMBUILD_ISSOURCE:
42 offset = uri.rfind("/")
44 baseuri = uri[0:offset]
45 srcname = uri[offset+1:]
49 refsrc.append([baseuri, srcname])
50 refsrcname.append(srcname)
52 for src in altspec.sources():
53 if src[2] == rpm.RPMBUILD_ISSOURCE:
55 offset = uri.rfind("/")
57 baseuri = uri[0:offset]
58 srcname = uri[offset+1:]
62 altsrc.append([baseuri, srcname])
63 altsrcname.append(srcname)
67 if not s[1] in altsrcname:
68 print "WARNING: missing source: '%s'" % s[1]
70 if not s[1] in refsrcname:
71 print "WARNING: extra source: '%s'" % s[1]
78 print "WARNING: different base URI for source '%s': '%s' != '%s'" % (s1[1], s1[0], s2[0])
81 def compare_patches(refspec, altspec):
84 for src in refspec.sources():
85 if src[2] == rpm.RPMBUILD_ISPATCH:
86 refpatch.append(src[0])
87 for src in altspec.sources():
88 if src[2] == rpm.RPMBUILD_ISPATCH:
89 altpatch.append(src[0])
93 print "WARNING missing patch '%s'" % p
97 print "WARNING extra patch '%s'" % p
99 scratchdir = mkdtemp("rpm-source-compare")
101 if len(sys.argv) != 3:
102 print "syntax: %s REFERENCE-SPEC ALTERNATE-SPEC" % sys.argv[0]
105 refspecfile = sys.argv[1]
106 altspecfile = sys.argv[2]
110 refspec = ts.parseSpec(refspecfile)
111 altspec = ts.parseSpec(altspecfile)
113 compare_header(refspec, altspec)
114 compare_sources(refspec, altspec)
115 compare_patches(refspec, altspec)