Mercurial > treepkg
annotate bin/treepkgbuilder.py @ 282:f58f9adb7dc3
Add functions to get SVN logs and extract tag revisions from it. Add
some tests for the log parsing.
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Tue, 04 Aug 2009 10:09:12 +0000 |
parents | 21da92cea416 |
children | 1fcdffbeb9de |
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 |
243
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
2 # Copyright (C) 2007, 2008, 2009 by Intevation GmbH |
177
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 |
192
eaadf5350a1a
Add the add-binaries command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
184
diff
changeset
|
84 class AddBinariesCommand(Command): |
eaadf5350a1a
Add the add-binaries command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
184
diff
changeset
|
85 |
eaadf5350a1a
Add the add-binaries command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
184
diff
changeset
|
86 names = ("add-binaries",) |
eaadf5350a1a
Add the add-binaries command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
184
diff
changeset
|
87 |
eaadf5350a1a
Add the add-binaries command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
184
diff
changeset
|
88 def run(self): |
eaadf5350a1a
Add the add-binaries command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
184
diff
changeset
|
89 builder = self.get_builder() |
eaadf5350a1a
Add the add-binaries command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
184
diff
changeset
|
90 builder.add_binaries_to_extra_pkg(self.rest) |
eaadf5350a1a
Add the add-binaries command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
184
diff
changeset
|
91 |
eaadf5350a1a
Add the add-binaries command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
184
diff
changeset
|
92 |
177
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
93 class UpdateCommand(Command): |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
94 |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
95 names = ("update",) |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
96 |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
97 def run(self): |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
98 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
|
99 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
|
100 |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
101 |
184
83c77307ffb1
Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents:
177
diff
changeset
|
102 class AddKeyCommand(Command): |
83c77307ffb1
Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents:
177
diff
changeset
|
103 |
83c77307ffb1
Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents:
177
diff
changeset
|
104 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
|
105 |
83c77307ffb1
Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents:
177
diff
changeset
|
106 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
|
107 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
|
108 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
|
109 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
|
110 sys.exit(1) |
83c77307ffb1
Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents:
177
diff
changeset
|
111 |
83c77307ffb1
Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents:
177
diff
changeset
|
112 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
|
113 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
|
114 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
|
115 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
|
116 return parser |
83c77307ffb1
Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents:
177
diff
changeset
|
117 |
83c77307ffb1
Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents:
177
diff
changeset
|
118 def run(self): |
83c77307ffb1
Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents:
177
diff
changeset
|
119 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
|
120 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
|
121 |
83c77307ffb1
Add the addkey command to bin/treepkgbuilder.py and a corresponding
Bernhard Herzog <bh@intevation.de>
parents:
177
diff
changeset
|
122 |
201
6624e731e218
Add login command to bin/treepkgbuilder.py and corresponding method in
Bernhard Herzog <bh@intevation.de>
parents:
192
diff
changeset
|
123 class LoginCommand(Command): |
6624e731e218
Add login command to bin/treepkgbuilder.py and corresponding method in
Bernhard Herzog <bh@intevation.de>
parents:
192
diff
changeset
|
124 |
6624e731e218
Add login command to bin/treepkgbuilder.py and corresponding method in
Bernhard Herzog <bh@intevation.de>
parents:
192
diff
changeset
|
125 names = ("login",) |
6624e731e218
Add login command to bin/treepkgbuilder.py and corresponding method in
Bernhard Herzog <bh@intevation.de>
parents:
192
diff
changeset
|
126 |
213
98c5aab790bb
Add --bind-mount option to bin/treepkgbuilder.py's login command and a
Bernhard Herzog <bh@intevation.de>
parents:
210
diff
changeset
|
127 def create_parser(self): |
98c5aab790bb
Add --bind-mount option to bin/treepkgbuilder.py's login command and a
Bernhard Herzog <bh@intevation.de>
parents:
210
diff
changeset
|
128 parser = super(LoginCommand, self).create_parser() |
98c5aab790bb
Add --bind-mount option to bin/treepkgbuilder.py's login command and a
Bernhard Herzog <bh@intevation.de>
parents:
210
diff
changeset
|
129 parser.set_defaults(bind_mount=[]) |
98c5aab790bb
Add --bind-mount option to bin/treepkgbuilder.py's login command and a
Bernhard Herzog <bh@intevation.de>
parents:
210
diff
changeset
|
130 parser.add_option("--bind-mount", action="append", |
98c5aab790bb
Add --bind-mount option to bin/treepkgbuilder.py's login command and a
Bernhard Herzog <bh@intevation.de>
parents:
210
diff
changeset
|
131 help=("Directories to bind-mount in the chroot" |
98c5aab790bb
Add --bind-mount option to bin/treepkgbuilder.py's login command and a
Bernhard Herzog <bh@intevation.de>
parents:
210
diff
changeset
|
132 " environment.")) |
245
21da92cea416
Add --save-after-login option to bin/treepkgbuilder.py and corresponding
Bernhard Herzog <bh@intevation.de>
parents:
243
diff
changeset
|
133 parser.add_option("--save-after-login", action="store_true", |
21da92cea416
Add --save-after-login option to bin/treepkgbuilder.py and corresponding
Bernhard Herzog <bh@intevation.de>
parents:
243
diff
changeset
|
134 help="Copy changes back to the tarball.") |
213
98c5aab790bb
Add --bind-mount option to bin/treepkgbuilder.py's login command and a
Bernhard Herzog <bh@intevation.de>
parents:
210
diff
changeset
|
135 return parser |
98c5aab790bb
Add --bind-mount option to bin/treepkgbuilder.py's login command and a
Bernhard Herzog <bh@intevation.de>
parents:
210
diff
changeset
|
136 |
98c5aab790bb
Add --bind-mount option to bin/treepkgbuilder.py's login command and a
Bernhard Herzog <bh@intevation.de>
parents:
210
diff
changeset
|
137 |
201
6624e731e218
Add login command to bin/treepkgbuilder.py and corresponding method in
Bernhard Herzog <bh@intevation.de>
parents:
192
diff
changeset
|
138 def run(self): |
245
21da92cea416
Add --save-after-login option to bin/treepkgbuilder.py and corresponding
Bernhard Herzog <bh@intevation.de>
parents:
243
diff
changeset
|
139 self.get_builder().login(bindmounts=self.opts.bind_mount, |
21da92cea416
Add --save-after-login option to bin/treepkgbuilder.py and corresponding
Bernhard Herzog <bh@intevation.de>
parents:
243
diff
changeset
|
140 save_after_login=self.opts.save_after_login) |
201
6624e731e218
Add login command to bin/treepkgbuilder.py and corresponding method in
Bernhard Herzog <bh@intevation.de>
parents:
192
diff
changeset
|
141 |
6624e731e218
Add login command to bin/treepkgbuilder.py and corresponding method in
Bernhard Herzog <bh@intevation.de>
parents:
192
diff
changeset
|
142 |
210
63f73bb9c459
Add build command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
201
diff
changeset
|
143 class BuildCommand(Command): |
63f73bb9c459
Add build command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
201
diff
changeset
|
144 |
63f73bb9c459
Add build command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
201
diff
changeset
|
145 names = ("build",) |
63f73bb9c459
Add build command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
201
diff
changeset
|
146 |
63f73bb9c459
Add build command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
201
diff
changeset
|
147 def create_parser(self): |
63f73bb9c459
Add build command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
201
diff
changeset
|
148 parser = super(BuildCommand, self).create_parser() |
63f73bb9c459
Add build command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
201
diff
changeset
|
149 parser.add_option("--logfile", help=("The file for the build log.")) |
63f73bb9c459
Add build command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
201
diff
changeset
|
150 parser.add_option("--binary-dir", |
63f73bb9c459
Add build command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
201
diff
changeset
|
151 help=("Directory for the binary packages.")) |
63f73bb9c459
Add build command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
201
diff
changeset
|
152 return parser |
63f73bb9c459
Add build command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
201
diff
changeset
|
153 |
63f73bb9c459
Add build command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
201
diff
changeset
|
154 def run(self): |
63f73bb9c459
Add build command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
201
diff
changeset
|
155 if len(self.rest) != 1: |
63f73bb9c459
Add build command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
201
diff
changeset
|
156 print >>sys.stderr, "Exactly one .dsc file must be specified" |
63f73bb9c459
Add build command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
201
diff
changeset
|
157 sys.exit(1) |
63f73bb9c459
Add build command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
201
diff
changeset
|
158 dsc_file = self.rest[0] |
63f73bb9c459
Add build command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
201
diff
changeset
|
159 self.get_builder().build(dsc_file, binary_dir=self.opts.binary_dir, |
63f73bb9c459
Add build command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
201
diff
changeset
|
160 logfile=self.opts.logfile) |
63f73bb9c459
Add build command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
201
diff
changeset
|
161 |
63f73bb9c459
Add build command to bin/treepkgbuilder.py
Bernhard Herzog <bh@intevation.de>
parents:
201
diff
changeset
|
162 |
243
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
163 class ExecuteCommand(Command): |
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
164 |
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
165 names = ("execute",) |
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
166 |
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
167 def create_parser(self): |
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
168 parser = super(ExecuteCommand, self).create_parser() |
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
169 parser.add_option("--logfile", help=("Log file.")) |
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
170 parser.add_option("--bind-mount", action="append", |
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
171 help=("Directories to bind-mount in the chroot" |
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
172 " environment.")) |
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
173 return parser |
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
174 |
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
175 def run(self): |
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
176 if not self.rest: |
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
177 print >>sys.stderr, "At least the script file must be specified" |
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
178 sys.exit(1) |
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
179 script = self.rest |
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
180 self.get_builder().run_script(script, bindmounts=self.opts.bind_mount, |
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
181 logfile=self.opts.logfile) |
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
182 |
f4a636ed5d07
Add execute command to treepkgbuilder
Bernhard Herzog <bh@intevation.de>
parents:
213
diff
changeset
|
183 |
177
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
184 class HelpCommand(Command): |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
185 |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
186 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
|
187 |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
188 def run(self): |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
189 print __doc__.rstrip() |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
190 print "Supported commands:" |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
191 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
|
192 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
|
193 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
|
194 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
|
195 |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
196 |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
197 def iter_commands(): |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
198 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
|
199 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
|
200 yield obj |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
201 |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
202 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
|
203 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
|
204 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
|
205 return obj |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
206 return None |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
207 |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
208 |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
209 def main(): |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
210 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
|
211 |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
212 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
|
213 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
|
214 sys.exit(1) |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
215 |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
216 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
|
217 arguments = arguments[1:] |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
218 |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
219 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
|
220 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
|
221 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
|
222 sys.exit(1) |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
223 |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
224 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
|
225 command.run() |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
226 |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
227 |
df7498d0bd9d
Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
228 main() |