annotate bin/treepkgbuilder.py @ 185:e1c7cd896310

Rework test/filesupport.py so that test cases always use their own temporary directory. Before, the test cases had to ensure this themselves. Adapt the test cases.
author Bernhard Herzog <bh@intevation.de>
date Thu, 26 Jun 2008 16:23:26 +0000
parents 83c77307ffb1
children eaadf5350a1a
rev   line source
177
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
1 #! /usr/bin/python2.4
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
2 # Copyright (C) 2007, 2008 by Intevation GmbH
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
3 # Authors:
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
4 # Bernhard Herzog <bh@intevation.de>
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
5 #
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
6 # This program is free software under the GPL (>=v2)
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
7 # Read the file COPYING coming with the software for details.
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
8
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
9 """Usage: treepkgbuilder COMMAND [options]
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
10
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
11 Manage the pbuilder environment for a tree packager installation. The
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
12 pbuilder settings are taken from the configuration file, either the
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
13 default treepkg.cfg or the one given with the --config-file option.
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
14 Also, this script assumes that there is only one pbuilder setting for
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
15 all packagers. Use treepkgbuilder COMMAND --help for more details about
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
16 the commands.
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
17 """
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
18
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
19 import sys
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
20
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
21 import treepkgcmd
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
22 from treepkg.options import create_parser
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
23 from treepkg.packager import create_package_track, PackagerGroup
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
24 from treepkg.readconfig import read_config
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
25
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
26
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
27 class Command(object):
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
28
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
29 names = ()
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
30
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
31 def __init__(self, arguments):
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
32 parser = self.create_parser()
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
33 self.opts, self.rest = parser.parse_args(arguments)
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
34
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
35 def create_parser(self):
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
36 return create_parser()
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
37
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
38 def read_config(self):
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
39 self.treepkg_opts, self.packager_opts \
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
40 = read_config(self.opts.config_file)
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
41
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
42 def get_builder(self):
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
43 self.read_config()
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
44 group = PackagerGroup([create_package_track(**opts)
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
45 for opts in self.packager_opts],
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
46 **self.treepkg_opts)
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
47 track = group.get_package_tracks()[0]
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
48 return track.builder
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
49
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
50
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
51
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
52 class InitCommand(Command):
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
53
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
54 names = ("init",)
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
55
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
56 def __init__(self, arguments):
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
57 super(InitCommand, self).__init__(arguments)
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
58 if self.opts.mirrorsite is None:
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
59 print >>sys.stderr, "Missing required option --mirrorsite"
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
60 sys.exit(1)
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
61
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
62 def create_parser(self):
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
63 parser = super(InitCommand, self).create_parser()
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
64 parser.set_defaults(distribution="etch")
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
65 parser.add_option("--mirrorsite",
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
66 help=("The debian mirror site"
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
67 " (pbuilder MIRRORSITE setting). Required."))
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
68 parser.add_option("--othermirror",
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
69 help=("Extra contents of the OTHERMIRROR setting."
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
70 " See the pbuilder documentation for the"
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
71 " format."))
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
72 parser.add_option("--distribution",
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
73 help=("The debian distribution for the pbuilder"
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
74 " chroot. Default is etch."))
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
75 return parser
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
76
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
77 def run(self):
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
78 builder = self.get_builder()
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
79 builder.init_pbuilder(distribution=self.opts.distribution,
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
80 mirrorsite=self.opts.mirrorsite,
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
81 extramirrors=self.opts.othermirror)
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
82
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
83
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
84 class UpdateCommand(Command):
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
85
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
86 names = ("update",)
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
87
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
88 def run(self):
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
89 builder = self.get_builder()
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
90 builder.update(suppress_output=False, log_info=False)
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
91
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
92
184
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
93 class AddKeyCommand(Command):
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
94
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
95 names = ("addkey", "add-key")
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
96
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
97 def __init__(self, arguments):
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
98 super(AddKeyCommand, self).__init__(arguments)
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
99 if not self.opts.key_id:
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
100 print >>sys.stderr, "No key id given"
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
101 sys.exit(1)
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
102
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
103 def create_parser(self):
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
104 parser = super(AddKeyCommand, self).create_parser()
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
105 parser.add_option("--key-id",
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
106 help=("The id of the key to add. Required."))
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
107 return parser
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
108
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
109 def run(self):
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
110 builder = self.get_builder()
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
111 builder.add_apt_key(self.opts.key_id)
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
112
83c77307ffb1 Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents: 177
diff changeset
113
177
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
114 class HelpCommand(Command):
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
115
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
116 names = ("help", "--help", "-h")
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
117
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
118 def run(self):
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
119 print __doc__.rstrip()
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
120 print "Supported commands:"
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
121 commands = sorted((cmd for cmd in iter_commands() if cmd.names),
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
122 key=lambda cmd: cmd.names[0])
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
123 for cmd in commands:
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
124 print " ", " ".join(cmd.names)
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
125
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
126
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
127 def iter_commands():
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
128 for key, obj in globals().items():
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
129 if key.endswith("Command"):
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
130 yield obj
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
131
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
132 def get_command_class(name):
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
133 for obj in iter_commands():
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
134 if name in obj.names:
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
135 return obj
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
136 return None
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
137
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
138
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
139 def main():
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
140 arguments = sys.argv[1:]
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
141
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
142 if len(arguments) < 1:
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
143 print >>sys.stderr, "Missing command"
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
144 sys.exit(1)
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
145
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
146 command_name = arguments[0]
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
147 arguments = arguments[1:]
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
148
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
149 command_class = get_command_class(command_name)
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
150 if command_class is None:
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
151 print >>sys.stderr, "Unknown command %r" % command_name
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
152 sys.exit(1)
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
153
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
154 command = command_class(arguments)
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
155 command.run()
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
156
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
157
df7498d0bd9d Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
158 main()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)