summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorRaul Cuza <raulcuza@gmail.com>2011-07-01 17:08:50 -0400
committerRaul Cuza <raulcuza@gmail.com>2011-07-06 13:37:59 -0400
commit0b24ff7603b4f8d2b00de8438559b131fa6d1ca4 (patch)
tree9e6448522e2d8c08d7736d491cdb19a5c70ad6c3 /tools
parent10062ac0c03974695fdd8a8db89dd90bfd4180bb (diff)
downloadbcfg2-0b24ff7603b4f8d2b00de8438559b131fa6d1ca4.tar.gz
bcfg2-0b24ff7603b4f8d2b00de8438559b131fa6d1ca4.tar.bz2
bcfg2-0b24ff7603b4f8d2b00de8438559b131fa6d1ca4.zip
Refactor export.py to use main() clause.
Minimal testing has been done to compare export.py and export2.py.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/export2.py125
1 files changed, 125 insertions, 0 deletions
diff --git a/tools/export2.py b/tools/export2.py
new file mode 100755
index 000000000..9fa920d18
--- /dev/null
+++ b/tools/export2.py
@@ -0,0 +1,125 @@
+#!/usr/bin/env python
+# encoding: utf-8
+
+"""
+Second attempt to make our export script more portable than export.sh
+"""
+
+import fileinput
+from subprocess import Popen, PIPE
+import sys
+
+# py3k compatibility
+try:
+ from email.Utils import formatdate
+except ImportError:
+ from email.utils import formatdate
+
+def run(command):
+ return Popen(command, shell=True, stdout=PIPE).communicate()
+
+def find_and_replace(f, iftest, rline, startswith=False):
+ for line in fileinput.input(f, inplace=1):
+ if startswith:
+ if line.startswith(iftest):
+ line = line.replace(line, rline)
+ sys.stdout.write(line)
+ else:
+ if iftest in line and line != "Version: %{version}\n":
+ line = line.replace(line, rline)
+ sys.stdout.write(line)
+
+
+if __name__ == '__main__':
+ pkgname = 'bcfg2'
+ ftphost = 'terra.mcs.anl.gov'
+ ftpdir = '/mcs/ftp/pub/bcfg'
+
+ # py3k compatibility
+ try:
+ version = raw_input("Please enter the version you are tagging (e.g. 1.0.0): ")
+ name = raw_input("Your name: ")
+ email = raw_input("Your email: ")
+ except NameError:
+ version = input("Please enter the version you are tagging (e.g. 1.0.0): ")
+ name = input("Your name: ")
+ email = input("Your email: ")
+
+ tarname = '/tmp/%s-%s.tar.gz' % (pkgname, version)
+
+ # update the version
+ majorver = version[:5]
+ minorver = version[5:]
+
+ newchangelog = \
+ """bcfg2 (%s%s-0.0) unstable; urgency=low
+
+ * New upstream release
+
+ -- %s <%s> %s
+
+ """ % (majorver, minorver, name, email, formatdate(localtime=True))
+
+
+ # write out the new debian changelog
+ with open('debian/changelog', 'r+') as f:
+ old = f.read()
+ f.seek(0)
+ f.write(newchangelog + old)
+ f.close()
+ quit()
+ # Update redhat directory versions
+ with open('redhat/VERSION', 'w') as f:
+ f.write("%s\n" % majorver)
+ f.close()
+ with open('redhat/RELEASE', 'w') as f:
+ f.write("0.0%s\n" % minorver)
+ f.close()
+ # update solaris version
+ find_and_replace('solaris/Makefile', 'VERS=',
+ 'VERS=%s-1\n' % version, startswith=True)
+ find_and_replace('solaris/pkginfo.bcfg2', 'VERSION=',
+ 'VERSION="%s"\n' % version, startswith=True)
+ find_and_replace('solaris/pkginfo.bcfg2-server', 'VERSION=',
+ 'VERSION="%s"\n' % version, startswith=True)
+ # set new version in setup.py
+ find_and_replace('setup.py', 'version=', ' version="%s",\n' % version)
+ # replace version in misc/bcfg2.spec
+ find_and_replace('misc/bcfg2.spec', 'Version:',
+ 'Version: %s\n' % version)
+ # update the version in reports
+ find_and_replace('src/lib/Server/Reports/reports/templates/base.html',
+ 'Bcfg2 Version', ' <span>Bcfg2 Version %s</span>\n' % version)
+ # update the version in the docs
+ find_and_replace('doc/conf.py', 'version =',
+ 'version = \'%s\'\n' % majorver[0:3], startswith=True)
+ find_and_replace('doc/conf.py', 'release =',
+ 'release = \'%s\'\n' % (majorver), startswith=True)
+
+ # tag the release
+ #FIXME: do this using python-dulwich
+ cmd = "git commit -asm 'Version bump to %s'" % version
+ output = run(cmd)[0].strip()
+ # NOTE: This will use the default email address key. If you want to sign the tag
+ # using a different key, you will need to set 'signingkey' to the proper
+ # value in the [user] section of your git configuration.
+ cmd = "git tag -s v%s -m 'tagged %s release'" % (version, version)
+ output = run(cmd)[0].strip()
+ cmd = "git archive --format=tar --prefix=%s-%s/ v%s | gzip > %s" % \
+ (pkgname, version, version, tarname)
+ output = run(cmd)[0].strip()
+ cmd = "gpg --armor --output %s.gpg --detach-sig %s" % (tarname, tarname)
+ output = run(cmd)[0].strip()
+
+ # upload release to ftp
+ cmd = "scp %s* terra.mcs.anl.gov:/mcs/ftp/pub/bcfg/" % tarname
+ output = run(cmd)[0].strip()
+
+
+
+
+
+
+
+
+