Skip to content

Commit

Permalink
export.py: handle RPM changelogs, new Bcfg2/version.py; fixed some paths
Browse files Browse the repository at this point in the history
  • Loading branch information
stpierre committed Aug 31, 2012
1 parent 5c11b70 commit dcdaa4a
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions tools/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import sys
# This will need to be replaced with argsparse when we make a 2.7+/3.2+ version
import optparse
import datetime

# py3k compatibility
try:
Expand Down Expand Up @@ -164,6 +165,36 @@ def main():
print(help_message)
quit()

rpmchangelog = ["* %s %s <%s> %s-0.0%s\n" %
(datetime.datetime.now().strftime("%a %b %d %Y"),
name, email,
version_release, version_info['build']),
"- New upstream release\n", "\n"]

# write out the new RPM changelog
specs = ["misc/bcfg2.spec", "redhat/bcfg2.spec.in"]
if options.dryrun:
print("*** Add the following to the top of the %changelog section in %s:\n%s\n"
% (rpmchangelog, " and ".join(specs)))
else:
for fname in specs:
try:
lines = open(fname).readlines()
for lineno in range(len(lines)):
if lines[lineno].startswith("%changelog"):
break
else:
print("No %changelog section found in %s" % fname)
continue
for line in reversed(rpmchangelog):
lines.insert(lineno + 1, line)
open(fname, 'w').write("".join(lines))
except:
err = sys.exc_info()[1]
print("Could not write %s: %s" % (fname, err))
print(help_message)
quit()

# Update redhat directory versions
if options.dryrun:
print("*** Replace redhat/VERIONS content with '%s'."
Expand Down Expand Up @@ -194,12 +225,20 @@ def main():
# set new version in setup.py
find_and_replace('setup.py', 'version=', ' version="%s",\n' % version,
dryrun=options.dryrun)
# set new version in Bcfg2/version.py
find_and_replace('src/lib/Bcfg2/version.py',
'__version__ =',
'__version__ = "%s"\n' % version,
dryrun=options.dryrun)
# replace version in misc/bcfg2.spec
find_and_replace('misc/bcfg2.spec', 'Version:',
'Version: %s\n' % version,
'Version: %s\n' % version_release,
dryrun=options.dryrun)
find_and_replace('misc/bcfg2.spec', 'Release: ',
'Release: 0.0%s\n' % version_info['build'],
dryrun=options.dryrun)
# update the version in reports
find_and_replace('src/lib/Server/Reports/reports/templates/base.html',
find_and_replace('src/lib/Bcfg2/Server/Reports/reports/templates/base.html',
'Bcfg2 Version',
' <span>Bcfg2 Version %s</span>\n' % version,
dryrun=options.dryrun)
Expand Down Expand Up @@ -227,6 +266,11 @@ def main():
version_info['micro']),
startswith=True,
dryrun=options.dryrun)
# update osx Portfile
find_and_replace('osx/macports/Portfile', 'version ',
'version %s\n' % version,
startswith=True,
dryrun=options.dryrun)

# tag the release
#FIXME: do this using python-dulwich
Expand Down

0 comments on commit dcdaa4a

Please sign in to comment.