Remember whether we already ran the unit-tests
[0release.git] / 0release
blobf644fffa46fb5a9db49176762e3ab54ce8d7cefb
1 #!/usr/bin/env python
2 # Copyright (C) 2009, Thomas Leonard
3 # See the README file for details, or visit http://0install.net.
5 from optparse import OptionParser
6 import os, sys
7 from zeroinstall import SafeException
8 from zeroinstall.injector import reader, model
10 version = '0.9'
12 parser = OptionParser(usage = """usage: %prog [options] LOCAL-FEED
14 Run this command from a new empty directory to set things up.""")
16 parser.add_option("", "--build-slave", help="compile a binary a source release candidate", action='store_true')
17 parser.add_option("-k", "--key", help="GPG key to use for signing", action='store', metavar='KEYID')
18 parser.add_option("-v", "--verbose", help="more verbose output", action='count')
19 parser.add_option("-r", "--release", help="make a new release", action='store_true')
20 parser.add_option("", "--archive-dir-public-url", help="remote directory for releases", metavar='URL')
21 parser.add_option("", "--master-feed-file", help="local file to extend with new releases", metavar='PATH')
22 parser.add_option("", "--archive-upload-command", help="shell command to upload releases", metavar='COMMAND')
23 parser.add_option("", "--master-feed-upload-command", help="shell command to upload feed", metavar='COMMAND')
24 parser.add_option("", "--public-scm-repository", help="the name of the repository to push to", metavar='REPOS')
25 parser.add_option("-V", "--version", help="display version information", action='store_true')
27 (options, args) = parser.parse_args()
29 if options.version:
30 print "0release (zero-install) " + version
31 print "Copyright (C) 2009 Thomas Leonard"
32 print "This program comes with ABSOLUTELY NO WARRANTY,"
33 print "to the extent permitted by law."
34 print "You may redistribute copies of this program"
35 print "under the terms of the GNU General Public License."
36 print "For more information about these matters, see the file named COPYING."
37 sys.exit(0)
39 if options.verbose:
40 import logging
41 logger = logging.getLogger()
42 if options.verbose == 1:
43 logger.setLevel(logging.INFO)
44 else:
45 logger.setLevel(logging.DEBUG)
47 if options.build_slave:
48 if len(args) != 4:
49 parser.print_help()
50 sys.exit(1)
51 src_feed, archive_file, archive_dir_public_url, target_feed = args
52 import compile
53 compile.build_slave(src_feed, archive_file, archive_dir_public_url, target_feed)
54 sys.exit(0)
56 if len(args) != 1:
57 parser.print_help()
58 sys.exit(1)
60 local_feed_path = args[0]
62 try:
63 if not os.path.exists(local_feed_path):
64 raise SafeException("Local feed file '%s' does not exist" % local_feed_path)
66 iface = model.Interface(model.canonical_iface_uri(local_feed_path))
67 reader.update(iface, local_feed_path, local = True)
69 if options.release:
70 import release
71 release.do_release(iface, options)
72 else:
73 import setup
74 setup.init_releases_directory(iface)
75 except KeyboardInterrupt, ex:
76 print >>sys.stderr, "Interrupted"
77 sys.exit(1)
78 except OSError, ex:
79 if options.verbose: raise
80 print >>sys.stderr, str(ex)
81 sys.exit(1)
82 except IOError, ex:
83 if options.verbose: raise
84 print >>sys.stderr, str(ex)
85 sys.exit(1)
86 except SafeException, ex:
87 if options.verbose: raise
88 print >>sys.stderr, str(ex)
89 sys.exit(1)