Put each release in its own sub-directory
[0release.git] / 0release
blob63df5e139c19526e21d9d9f4a885a49cac974423
1 #!/usr/bin/env python
2 # Copyright (C) 2007, 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.8'
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("-k", "--key", help="GPG key to use for signing", action='store', metavar='KEYID')
17 parser.add_option("-v", "--verbose", help="more verbose output", action='count')
18 parser.add_option("-r", "--release", help="make a new release", action='store_true')
19 parser.add_option("", "--archive-dir-public-url", help="remote directory for releases", metavar='URL')
20 parser.add_option("", "--master-feed-file", help="local file to extend with new releases", metavar='PATH')
21 parser.add_option("", "--archive-upload-command", help="shell command to upload releases", metavar='COMMAND')
22 parser.add_option("", "--master-feed-upload-command", help="shell command to upload feed", metavar='COMMAND')
23 parser.add_option("", "--public-scm-repository", help="the name of the repository to push to", metavar='REPOS')
24 parser.add_option("-V", "--version", help="display version information", action='store_true')
26 (options, args) = parser.parse_args()
28 if options.version:
29 print "0release (zero-install) " + version
30 print "Copyright (C) 2007 Thomas Leonard"
31 print "This program comes with ABSOLUTELY NO WARRANTY,"
32 print "to the extent permitted by law."
33 print "You may redistribute copies of this program"
34 print "under the terms of the GNU General Public License."
35 print "For more information about these matters, see the file named COPYING."
36 sys.exit(0)
38 if options.verbose:
39 import logging
40 logger = logging.getLogger()
41 if options.verbose == 1:
42 logger.setLevel(logging.INFO)
43 else:
44 logger.setLevel(logging.DEBUG)
46 if len(args) != 1:
47 parser.print_help()
48 sys.exit(1)
50 local_feed_path = args[0]
52 try:
53 if not os.path.exists(local_feed_path):
54 raise SafeException("Local feed file '%s' does not exist" % local_feed_path)
56 iface = model.Interface(model.canonical_iface_uri(local_feed_path))
57 reader.update(iface, local_feed_path, local = True)
59 if options.release:
60 import release
61 release.do_release(iface, options)
62 else:
63 import setup
64 setup.init_releases_directory(iface)
65 except KeyboardInterrupt, ex:
66 print >>sys.stderr, "Interrupted"
67 sys.exit(1)
68 except OSError, ex:
69 if options.verbose: raise
70 print >>sys.stderr, str(ex)
71 sys.exit(1)
72 except IOError, ex:
73 if options.verbose: raise
74 print >>sys.stderr, str(ex)
75 sys.exit(1)
76 except SafeException, ex:
77 if options.verbose: raise
78 print >>sys.stderr, str(ex)
79 sys.exit(1)