added a minimal release helper script
This commit is contained in:
92
do_release.py
Normal file
92
do_release.py
Normal file
@@ -0,0 +1,92 @@
|
||||
#/usr/bin/python
|
||||
#
|
||||
# A first simplistic try at a release helper script
|
||||
# Derek Feichtinger <derek.feichtinger@psi.ch>
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
import shutil
|
||||
#from distutils.version import StrictVersion
|
||||
# StrictVersion('10.4.10') > StrictVersion('10.4.9')
|
||||
# or use distribute package:
|
||||
#from pkg_resources import parse_version
|
||||
#parse_version('1.4') > parse_version('1.4-rc2')
|
||||
|
||||
import ldapuserdir
|
||||
|
||||
def git_is_current():
|
||||
sp = subprocess.Popen(['git', 'status', '--porcelain',
|
||||
'--untracked-files=no'],
|
||||
shell = False,
|
||||
stdout = subprocess.PIPE,
|
||||
stderr = subprocess.PIPE)
|
||||
(stdout, stderr) = sp.communicate()
|
||||
if sp.returncode != 0:
|
||||
raise RuntimeError(stderr)
|
||||
if stdout.strip() == '':
|
||||
return True
|
||||
return False
|
||||
|
||||
def git_describe():
|
||||
sp = subprocess.Popen(['git','describe'],
|
||||
shell = False,
|
||||
stdout = subprocess.PIPE,
|
||||
stderr = subprocess.PIPE)
|
||||
(stdout, stderr) = sp.communicate()
|
||||
if sp.returncode != 0:
|
||||
raise RuntimeError(stderr)
|
||||
return stdout.strip()
|
||||
|
||||
if not git_is_current():
|
||||
sys.stderr.write('Error: Repository is not current compared to ' +
|
||||
'working environment.\nRefusing to release\n')
|
||||
sys.exit(0)
|
||||
|
||||
git_d = git_describe()
|
||||
if git_d != 'v' + ldapuserdir.__version__:
|
||||
sys.stderr.write('Git-describe (%s) differs from internal package' +
|
||||
'version (%s)\n' % (git_d, ldapuserdir.__version__))
|
||||
sys.stderr.write('You need to tag the distribution')
|
||||
sys.exit(0)
|
||||
|
||||
# make backup of current setup.cfg
|
||||
shutil.copy('setup.cfg','setup.cfg.bup')
|
||||
|
||||
# add options needed for the distribution
|
||||
fd = open('setup.cfg','a')
|
||||
fd.write("""
|
||||
[build]
|
||||
/usr/bin/python
|
||||
|
||||
[install]
|
||||
prefix=/usr
|
||||
|
||||
[bdist_rpm]
|
||||
Release=1.el6
|
||||
Group=Applications/Internet
|
||||
Vendor=PSI
|
||||
Packager=Derek Feichtinger
|
||||
#Provides
|
||||
Requires=python-ldap
|
||||
License=PSI
|
||||
#Conflicts
|
||||
#Obsoletes
|
||||
#Distribution
|
||||
#BuildRequires
|
||||
#Icon
|
||||
""")
|
||||
fd.close()
|
||||
|
||||
# Run the RPM build
|
||||
sp = subprocess.Popen(['python','setup.py','bdist_rpm'],
|
||||
shell = False,
|
||||
stdout = subprocess.PIPE,
|
||||
stderr = subprocess.PIPE)
|
||||
(stdout, stderr) = sp.communicate()
|
||||
if sp.returncode != 0:
|
||||
raise RuntimeError(stderr)
|
||||
sys.stdout.write(stdout)
|
||||
|
||||
shutil.copy('setup.cfg','setup.cfg.rpm')
|
||||
shutil.copy('setup.cfg.bup','setup.cfg')
|
||||
Reference in New Issue
Block a user