annotate test/mocksudopbuilder.py @ 90:6ed1c881ee1b

remove unused import
author Bernhard Herzog <bh@intevation.de>
date Tue, 11 Sep 2007 13:58:28 +0000
parents 98a7d70746a9
children c0ea6cbb0fd2
rev   line source
84
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
1 #! /usr/bin/env python
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
2 # Copyright (C) 2007 by Intevation GmbH
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
3 # Authors:
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
4 # Bernhard Herzog <bh@intevation.de>
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
5 #
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
6 # This program is free software under the GPL (>=v2)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
7 # Read the file COPYING coming with the software for details.
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
8
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
9 """
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
10 Mock sudo that mimics some aspects of sudo pbuilder invocations for test cases
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
11 """
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
12
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
13 import sys
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
14 import os
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
15 import shutil
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
16 import tempfile
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
17 import re
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
18
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
19 from optparse import OptionParser
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
20
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
21 sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
22
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
23 from treepkg.util import extract_value_for_key, writefile
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
24 from treepkg.run import call
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
25 from treepkg.cmdexpand import cmdexpand
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
26
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
27
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
28 def parse_command_line(args):
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
29 if len(args) < 2:
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
30 raise RuntimeError("mocksudopbuilder must be called with at least"
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
31 " two parameters")
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
32 if args[0] != "/usr/sbin/pbuilder":
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
33 raise RuntimeError("mocksudopbuilder must be called with"
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
34 " /usr/sbin/pbuilder as first argument")
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
35
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
36 cmd = args[1]
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
37 if cmd != "build":
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
38 raise RuntimeError("mocksudopbuilder only supports the pbuilder build"
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
39 " command")
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
40
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
41 args = args[2:]
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
42
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
43 parser = OptionParser()
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
44 parser.add_option("--configfile")
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
45 parser.add_option("--logfile")
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
46 parser.add_option("--buildresult")
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
47
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
48 opts, rest = parser.parse_args(args)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
49 return opts, rest
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
50
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
51
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
52 class DSC(object):
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
53
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
54 def __init__(self, filename):
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
55 self.filename = os.path.abspath(filename)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
56 self.parse_dsc_file()
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
57
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
58 def parse_dsc_file(self):
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
59 lines = open(self.filename).readlines()
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
60
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
61 self.source_package = extract_value_for_key(lines, "Source:")
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
62
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
63 raw_binaries = extract_value_for_key(lines, "Binary:")
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
64 self.binaries = [name.strip() for name in raw_binaries.split(",")]
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
65
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
66 version = extract_value_for_key(lines, "Version:")
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
67 match = re.match(r"\d+:", version)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
68 if match:
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
69 version = version[match.end(0):]
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
70 self.version = version
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
71 match = re.search("-([^-]+)$", version)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
72 if match:
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
73 self.base_version = version[:match.start(0)]
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
74 self.revision = match.group(1)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
75 else:
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
76 self.base_version = version
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
77 self.revision = ""
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
78
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
79 self.files = []
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
80 for i in range(len(lines) - 1, -1, -1):
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
81 line = lines[i]
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
82 if line[0] != " ":
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
83 break
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
84 self.files.append(line.split()[-1])
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
85
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
86 def unpack_source_pkg(dsc):
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
87 tempdir = tempfile.mkdtemp()
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
88 call(cmdexpand("dpkg-source -x $filename", filename=dsc.filename),
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
89 cwd=tempdir, stdout=sys.stdout)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
90 return os.path.join(tempdir, dsc.source_package + "-" + dsc.base_version)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
91
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
92 def parse_debian_control(filename):
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
93 packages = []
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
94 lines = [line.strip() for line in open(filename).readlines()]
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
95 while lines:
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
96 try:
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
97 empty_line = lines.index("")
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
98 except ValueError:
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
99 empty_line = len(lines)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
100 paragraph = lines[:empty_line]
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
101 lines = lines[empty_line + 1:]
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
102
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
103 package_name = extract_value_for_key(paragraph, "Package:")
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
104 arch = extract_value_for_key(paragraph, "Architecture:")
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
105 if package_name is not None:
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
106 packages.append((package_name, arch))
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
107 return packages
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
108
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
109 def create_binary_results(buildresult, dsc, packages):
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
110 for name, arch in packages:
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
111 if arch == "any":
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
112 arch = "i386"
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
113 writefile(os.path.join(buildresult,
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
114 "%s_%s_%s.deb" % (name, dsc.version, arch)),
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
115 "")
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
116
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
117 basename = os.path.splitext(os.path.basename(dsc.filename))[0]
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
118 writefile(os.path.join(buildresult, basename + "_i386.changes"), "")
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
119
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
120 def create_source_results(buildresult, dsc):
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
121 dscdir = os.path.dirname(dsc.filename)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
122 shutil.copy(dsc.filename, buildresult)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
123 for name in dsc.files:
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
124 shutil.copy(os.path.join(dscdir, name), buildresult)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
125
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
126 def mock_pbuilder_build(opts, dscfilename):
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
127 dsc = DSC(dscfilename)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
128 print "unpacking source package"
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
129 unpacked_dir = unpack_source_pkg(dsc)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
130 try:
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
131 packages = parse_debian_control(os.path.join(unpacked_dir, "debian",
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
132 "control"))
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
133 create_binary_results(opts.buildresult, dsc, packages)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
134 create_source_results(opts.buildresult, dsc)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
135 finally:
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
136 print "removing tempdir", repr(os.path.dirname(unpacked_dir))
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
137 shutil.rmtree(os.path.dirname(unpacked_dir))
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
138
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
139 def main():
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
140 opts, rest = parse_command_line(sys.argv[1:])
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
141 for optname in ["buildresult"]:
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
142 if getattr(opts, optname) is None:
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
143 raise RuntimeError("Missing required option %r" % optname)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
144 if len(rest) != 1:
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
145 raise RuntimeError("Missing required argument for .dsc file")
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
146 if opts.logfile:
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
147 sys.stdout = open(opts.logfile, "w", 1)
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
148 mock_pbuilder_build(opts, rest[0])
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
149
98a7d70746a9 Make BinaryPackager remove all files that do not belong to the binary
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
150 main()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)