2004-10-01 05:43:34 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
import ftplib
|
|
|
|
import shutil
|
|
|
|
|
|
|
|
def firstLines(filename, n):
|
|
|
|
fd = file(filename)
|
|
|
|
lines = []
|
|
|
|
while n:
|
|
|
|
n -= 1
|
|
|
|
lines.append(fd.readline().rstrip('\r\n'))
|
|
|
|
return lines
|
|
|
|
|
|
|
|
def firstLine(filename):
|
|
|
|
return firstLines(filename, 1)[0]
|
|
|
|
|
|
|
|
def error(s):
|
|
|
|
sys.stderr.write(s+'\n')
|
|
|
|
sys.exit(-1)
|
|
|
|
|
|
|
|
def system(sh, errmsg=None):
|
|
|
|
if errmsg is None:
|
2004-10-01 06:32:53 +02:00
|
|
|
errmsg = repr(sh)
|
2004-10-01 05:43:34 +02:00
|
|
|
ret = os.system(sh)
|
2004-10-01 06:32:53 +02:00
|
|
|
if ret:
|
2004-10-01 06:19:50 +02:00
|
|
|
error(errmsg + ' (error code: %s)' % ret)
|
2004-10-01 05:43:34 +02:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2004-10-01 06:32:53 +02:00
|
|
|
if len(sys.argv) < 3:
|
|
|
|
error('Usage: %s <sf username> <version>\n' % sys.argv[0])
|
2004-10-01 05:43:34 +02:00
|
|
|
|
2004-12-12 20:35:05 +01:00
|
|
|
print 'Check version string for validity.'
|
2004-10-01 06:32:53 +02:00
|
|
|
(u, v) = sys.argv[1:]
|
2004-10-01 05:43:34 +02:00
|
|
|
if not re.match(r'^\d+\.\d+\.\d+\w*$', v):
|
|
|
|
error('Invalid version string: '
|
|
|
|
'must be of the form MAJOR.MINOR.PATCHLEVEL.')
|
2004-10-01 06:32:53 +02:00
|
|
|
|
2004-12-10 16:03:28 +01:00
|
|
|
if os.path.exists('supybot'):
|
|
|
|
error('I need to make the directory "supybot" but it already exists.'
|
|
|
|
' Change to an appropriate directory or rmeove the supybot '
|
|
|
|
'directory to continue.')
|
2004-12-12 20:35:05 +01:00
|
|
|
print 'Checking out fresh tree from CVS.'
|
2004-10-01 06:32:53 +02:00
|
|
|
system('cvs -d:ext:%s@cvs.sf.net:/cvsroot/supybot co supybot' % u)
|
|
|
|
os.chdir('supybot')
|
2004-10-01 05:43:34 +02:00
|
|
|
|
2004-12-12 20:35:05 +01:00
|
|
|
print 'Checking RELNOTES version line.'
|
2004-10-01 05:49:19 +02:00
|
|
|
if firstLine('RELNOTES') != 'Version %s' % v:
|
2004-10-01 05:43:34 +02:00
|
|
|
error('Invalid first line in RELNOTES.')
|
|
|
|
|
2004-12-12 20:35:05 +01:00
|
|
|
print 'Checking ChangeLog version line.'
|
2004-10-01 05:43:34 +02:00
|
|
|
(first, _, third) = firstLines('ChangeLog', 3)
|
|
|
|
if not re.match(r'^200\d-\d{2}-\d{2}\s+\w+.*<\S+@\S+>$', first):
|
|
|
|
error('Invalid first line in ChangeLog.')
|
|
|
|
if not re.match(r'^\t\* Version %s!$' % v, third):
|
|
|
|
error('Invalid third line in ChangeLog.')
|
|
|
|
|
2004-12-12 20:35:05 +01:00
|
|
|
print 'Updating version in version files.'
|
2004-10-01 05:43:34 +02:00
|
|
|
versionFiles = ('src/conf.py', 'scripts/supybot', 'setup.py')
|
|
|
|
for fn in versionFiles:
|
2004-10-01 06:19:22 +02:00
|
|
|
sh = 'perl -pi -e "s/^version\s*=.*/version = \'%s\'/" %s' % (v, fn)
|
2004-10-01 05:43:34 +02:00
|
|
|
system(sh, 'Error changing version in %s' % fn)
|
|
|
|
system('cvs commit -m "Updated to %s." %s' % (v, ' '.join(versionFiles)))
|
|
|
|
|
2004-12-12 20:35:05 +01:00
|
|
|
print 'Tagging release.'
|
2004-10-01 05:44:23 +02:00
|
|
|
system('cvs tag -F release-%s' % v.replace('.', '_'))
|
2004-10-01 05:43:34 +02:00
|
|
|
|
2004-12-12 20:35:05 +01:00
|
|
|
print 'Removing test, sandbox, CVS, and .cvsignore.'
|
2004-10-01 05:43:34 +02:00
|
|
|
shutil.rmtree('test')
|
|
|
|
shutil.rmtree('sandbox')
|
|
|
|
system('find . -name CVS | xargs rm -rf')
|
2004-10-01 06:32:53 +02:00
|
|
|
os.remove('.cvsignore')
|
2004-10-01 05:43:34 +02:00
|
|
|
|
|
|
|
os.chdir('..')
|
2004-12-10 16:03:28 +01:00
|
|
|
dirname = 'Supybot-%s' % v
|
2004-12-12 20:35:05 +01:00
|
|
|
print 'Renaming directory to %s.' % dirname
|
2004-12-10 16:03:28 +01:00
|
|
|
if os.path.exists(dirname):
|
|
|
|
shutil.rmtree(dirname)
|
|
|
|
shutil.move('supybot', dirname)
|
2004-10-01 05:43:34 +02:00
|
|
|
|
2004-12-12 20:35:05 +01:00
|
|
|
print 'Creating tarball (gzip).'
|
2004-12-10 16:03:28 +01:00
|
|
|
system('tar czvf Supybot-%s.tar.gz %s' % (v, dirname))
|
2004-12-12 20:35:05 +01:00
|
|
|
print 'Creating tarball (bzip2).'
|
2004-12-10 16:03:28 +01:00
|
|
|
system('tar cjvf Supybot-%s.tar.bz2 %s' % (v, dirname))
|
2004-12-12 20:35:05 +01:00
|
|
|
print 'Creating zip.'
|
2004-12-10 16:03:28 +01:00
|
|
|
system('zip -r Supybot-%s.zip %s' % (v, dirname))
|
2004-10-01 05:43:34 +02:00
|
|
|
|
2004-12-12 20:35:05 +01:00
|
|
|
print 'Uploading package files to upload.sf.net.'
|
2004-10-01 06:32:53 +02:00
|
|
|
ftp = ftplib.FTP('upload.sf.net')
|
|
|
|
ftp.login()
|
|
|
|
ftp.cwd('incoming')
|
2004-12-10 16:03:28 +01:00
|
|
|
for filename in ['Supybot-%s.tar.gz',
|
|
|
|
'Supybot-%s.tar.bz2',
|
|
|
|
'Supybot-%s.zip']:
|
|
|
|
filename = filename % v
|
|
|
|
print 'Uploading %s to SF.net.' % filename
|
|
|
|
ftp.storbinary('STOR %s' % filename, file(filename))
|
2004-10-01 06:32:53 +02:00
|
|
|
ftp.close()
|
2004-10-01 05:43:34 +02:00
|
|
|
|
2004-12-12 20:35:05 +01:00
|
|
|
print 'Copying new version.txt over to project webserver.'
|
|
|
|
system('echo %s > version.txt' % v)
|
|
|
|
system('scp version.txt %s@shell.sf.net:/home/groups/s/su/supybot/htdocs'%u)
|
|
|
|
|
|
|
|
print 'Committing %s+cvs to version files.' % v
|
|
|
|
for fn in versionFiles:
|
|
|
|
sh = 'perl -pi -e "s/^version\s*=.*/version = \'%s\'/" %s' % \
|
|
|
|
(v + '+cvs', fn)
|
|
|
|
system(sh, 'Error changing version in %s' % fn)
|
|
|
|
system('cvs commit -m "Updated to %s." %s' % (v, ' '.join(versionFiles)))
|
|
|
|
|
2004-12-10 16:03:28 +01:00
|
|
|
# This is the part where we do our release on Freshmeat using XMLRPC and
|
|
|
|
# <gasp> ESR's software to do it: http://freshmeat.net/p/freshmeat-submit/
|