extras-buildsys/utils distro-rebuild.py,1.5,1.6
Daniel Williams (dcbw)
fedora-extras-commits at redhat.com
Wed Sep 14 16:53:31 UTC 2005
Author: dcbw
Update of /cvs/fedora/extras-buildsys/utils
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv19563/utils
Modified Files:
distro-rebuild.py
Log Message:
2005-09-14 Dan Williams <dcbw at redhat.com>
* utils/distro-rebuild.py
- Optionally add a changelog entry to rebuilt specfile
Index: distro-rebuild.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/utils/distro-rebuild.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- distro-rebuild.py 13 Sep 2005 15:55:56 -0000 1.5
+++ distro-rebuild.py 14 Sep 2005 16:53:29 -0000 1.6
@@ -66,7 +66,13 @@
del srpm_dict
return files_dict
-def rebuild_srpm(name, f):
+def rebuild_srpm(name, f, user=None):
+ ts = rpmUtils.transaction.initReadOnlyTransaction()
+ hdr = rpmUtils.miscutils.hdrFromPackage(ts, f)
+ chlog_ver = "%s-%s.1" % (hdr['version'], hdr['release'])
+ del ts
+ del hdr
+
# Create a temp dir
temp_dir = os.path.join("/tmp", "rebuild", name)
if not os.path.exists(temp_dir):
@@ -96,10 +102,19 @@
specfile_new = specfile+".new"
dst = open(specfile_new, "w")
found = False
+ changelog = False
for line in src:
if line.startswith("Release:"):
line = string.strip(line) + ".1\n"
found = True
+ if line.startswith("%changelog"):
+ changelog = True
+ elif changelog and user:
+ # Add a changelog entry for the rebuild
+ t = time.strftime("%a %b %e %Y")
+ entry = "* %s %s - %s\n- Rebuild\n\n" % (t, user, chlog_ver)
+ dst.write(entry)
+ changelog = False
dst.write(line)
dst.close()
src.close()
@@ -138,12 +153,12 @@
def usage(program):
- print "%s <srpm-dir-path> <target>" % program
+ print "%s <srpm-dir-path> <target> [changelog user]" % program
print ""
if __name__ == '__main__':
- if len(sys.argv) < 3:
+ if len(sys.argv) < 4:
usage(sys.argv[0])
sys.exit(1)
@@ -153,6 +168,9 @@
sys.exit(1)
target = sys.argv[2]
+ user = None
+ if len(sys.argv > 3)
+ user = sys.argv[3]
# Build up a list of all SRPMs in the specified directory
files = find_newest_srpms(search_dir)
@@ -163,9 +181,9 @@
names = files.keys()
names.sort()
for name in names:
- f = files[name]
+ f = names[name]
try:
- (rebuilt_srpm, temp_dir_path) = rebuild_srpm(name, f)
+ (rebuilt_srpm, temp_dir_path) = rebuild_srpm(name, f, user)
except RebuildException, e:
shutil.rmtree(temp_dir_path, ignore_errors=True)
print "RE: %s (%s)" % (f, e)
More information about the fedora-extras-commits
mailing list