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