Release 0.12
[0release.git] / 0release
blobe1580830d0b29914aa31cf97503e4aefc63da08f
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
8 sys.path.insert(1, os.environ['0RELEASE_ZEROINSTALL'])
9 from zeroinstall import SafeException
10 from zeroinstall.injector import reader, model
12 version = '0.12'
14 parser = OptionParser(usage = """usage: %prog [options] LOCAL-FEED
16 Run this command from a new empty directory to set things up.""")
18 parser.add_option("", "--builders", help="comma-separated list of builders for binaries", metavar='LIST')
19 parser.add_option("", "--build-slave", help="compile a binary a source release candidate", action='store_true')
20 parser.add_option("-k", "--key", help="GPG key to use for signing", action='store', metavar='KEYID')
21 parser.add_option("-v", "--verbose", help="more verbose output", action='count')
22 parser.add_option("-r", "--release", help="make a new release", action='store_true')
23 parser.add_option("", "--archive-dir-public-url", help="remote directory for releases", metavar='URL')
24 parser.add_option("", "--master-feed-file", help="local file to extend with new releases", metavar='PATH')
25 parser.add_option("", "--archive-upload-command", help="shell command to upload releases", metavar='COMMAND')
26 parser.add_option("", "--master-feed-upload-command", help="shell command to upload feed", metavar='COMMAND')
27 parser.add_option("", "--public-scm-repository", help="the name of the repository to push to", metavar='REPOS')
28 parser.add_option("-V", "--version", help="display version information", action='store_true')
30 (options, args) = parser.parse_args()
32 if options.version:
33 print "0release (zero-install) " + version
34 print "Copyright (C) 2009 Thomas Leonard"
35 print "This program comes with ABSOLUTELY NO WARRANTY,"
36 print "to the extent permitted by law."
37 print "You may redistribute copies of this program"
38 print "under the terms of the GNU General Public License."
39 print "For more information about these matters, see the file named COPYING."
40 sys.exit(0)
42 if options.verbose:
43 import logging
44 logger = logging.getLogger()
45 if options.verbose == 1:
46 logger.setLevel(logging.INFO)
47 else:
48 logger.setLevel(logging.DEBUG)
50 if options.build_slave:
51 if len(args) != 4:
52 parser.print_help()
53 sys.exit(1)
54 src_feed, archive_file, archive_dir_public_url, target_feed = args
55 import compile
56 compile.build_slave(src_feed, archive_file, archive_dir_public_url, target_feed)
57 sys.exit(0)
59 if len(args) != 1:
60 parser.print_help()
61 sys.exit(1)
63 local_feed_path = args[0]
65 try:
66 if not os.path.exists(local_feed_path):
67 raise SafeException("Local feed file '%s' does not exist" % local_feed_path)
69 iface = model.Interface(model.canonical_iface_uri(local_feed_path))
70 reader.update(iface, local_feed_path, local = True)
72 if options.release:
73 import release
74 release.do_release(iface, options)
75 else:
76 import setup
77 setup.init_releases_directory(iface)
78 except KeyboardInterrupt, ex:
79 print >>sys.stderr, "Interrupted"
80 sys.exit(1)
81 except OSError, ex:
82 if options.verbose: raise
83 print >>sys.stderr, str(ex)
84 sys.exit(1)
85 except IOError, ex:
86 if options.verbose: raise
87 print >>sys.stderr, str(ex)
88 sys.exit(1)
89 except SafeException, ex:
90 if options.verbose: raise
91 print >>sys.stderr, str(ex)
92 sys.exit(1)