summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Drung <bdrung@debian.org>2012-04-22 00:55:25 +0200
committerBenjamin Drung <bdrung@debian.org>2012-04-22 00:55:25 +0200
commit17b68c335ca24379a3f41b720b4e80559d6719ec (patch)
tree2fbcc5c7afa821b7d65a6823de8c8c139e9bf1eb
parentc9a34d68d39b0f10b5b4ca234f72e41d8201ddf9 (diff)
xpi-repack: Fail nicely if debian/control is missing.
LP: #900687
-rwxr-xr-xxpi-repack13
1 files changed, 9 insertions, 4 deletions
diff --git a/xpi-repack b/xpi-repack
index 8bf5dae..f6705a2 100755
--- a/xpi-repack
+++ b/xpi-repack
@@ -61,7 +61,12 @@ def repack_xpi(package, upstream_version, xpi_file, verbose):
# remove temporary directory
remove_recursive(full_extract_dir)
-def get_source_package_name():
+def get_source_package_name(script_name):
+ if not os.path.isfile("debian/control"):
+ sys.stderr.write(script_name + ": Error: debian/control file is "
+ "missing. Please execute the script in a Debian "
+ "source package or provide a source package name.\n")
+ sys.exit(1)
lines = open("debian/control").readlines()
package_lines = filter(lambda x: x.find("Source:") >= 0, lines)
packages = map(lambda x: x[x.find(":")+1:].strip(), package_lines)
@@ -108,11 +113,11 @@ def main():
else:
assert False, "unhandled option"
- if package is None:
- package = get_source_package_name()
-
script_name = os.path.basename(sys.argv[0])
+ if package is None:
+ package = get_source_package_name(script_name)
+
if len(args) == 0:
print >> sys.stderr, "%s: Error: No xpi file specified." % (script_name)
sys.exit(COMMAND_LINE_SYNTAX_ERROR)