Added unit tests for version attribute.
[zeroinstall.git] / makedist
blob3fce1eed4d889bc533e92e80187db1e9b925fc88
1 #!/usr/bin/env python
2 import zeroinstall, sys, os, shutil, time
3 from zeroinstall.injector import iface_cache, model
5 os.system('svn status')
7 trunk_url = 'https://svn.sourceforge.net/svnroot/zero-install/trunk/0launch'
8 releases_url = 'https://svn.sourceforge.net/svnroot/zero-install/releases/0launch'
10 publish_url = 'http://0install.net/2006/interfaces/0publish'
12 def run(prog, *args):
13 if os.spawnlp(os.P_WAIT, prog, prog, *args):
14 raise Exception('Command failed: %s %s' % (prog, ' '.join(args)))
16 for line in os.popen('dpkg-parsechangelog'):
17 if line.startswith('Version: '):
18 deb_version = line.split(' ', 1)[1].strip()
19 break
20 else:
21 raise Exception('Failed to get deb version!')
23 print "\nDebian version: " + deb_version + " (hint: debchange -i)"
25 gui_iface_path = 'zeroinstall/0launch-gui/injector-gui.xml'
26 gui_iface = iface_cache.iface_cache.get_interface(os.path.abspath(gui_iface_path))
27 assert len(gui_iface.implementations) == 1
28 gui_impl = gui_iface.implementations.values()[0]
30 if gui_impl.get_version() != zeroinstall.version:
31 print "GUI version is '%s'; should be '%s'" % (gui_impl.get_version(), zeroinstall.version)
32 sys.exit(1)
34 name = 'injector-' + zeroinstall.version
35 package_name = 'zeroinstall-' + name
36 a = raw_input("Release " + name + "? [y/N]")
37 if not a or a not in 'Yy':
38 sys.exit(0)
40 if gui_impl.upstream_stability == model.testing:
41 run('0launch', publish_url, '--stable', gui_iface_path)
42 run('0launch', publish_url, '--set-released', time.strftime('%Y-%m-%d'), gui_iface_path)
44 if os.system('cd tests && ./testall.py'):
45 print "ERROR: Unit test failure. Stop"
46 sys.exit(1)
48 print "Checking for existing release..."
49 if os.system('svn ls ' + releases_url + '/' + name + ' >/dev/null') == 0:
50 print "WARNING: releases/" + name + " already exists"
51 a = raw_input("Overwrite " + name + "? [y/N]")
52 if not a or a not in 'Yy':
53 sys.exit(0)
54 os.system('svn rm ' + releases_url + '/' + name + ' -m overwrite')
57 print "Branching..."
59 if os.system('svn cp -m "Released ' + name + '" ' +
60 trunk_url + ' ' + releases_url + '/' + name):
61 print "Failed to make release"
62 sys.exit(1)
64 if os.path.isdir(package_name):
65 shutil.rmtree(package_name)
66 os.system('svn export ' + releases_url + '/' + name + ' ' + package_name)
67 os.system('svn up')
68 os.chdir(package_name)
69 os.system('python setup.py sdist')
70 os.system('dpkg-buildpackage -k59A53CC1 -rfakeroot')
72 print "Tarball is", package_name + '/dist/' + package_name + '.tar.gz'