summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xxpi-repack18
1 files changed, 9 insertions, 9 deletions
diff --git a/xpi-repack b/xpi-repack
index 29aab1f..e65ed59 100755
--- a/xpi-repack
+++ b/xpi-repack
@@ -20,6 +20,8 @@ import subprocess
import sys
import tempfile
+SCRIPT_NAME = "xpi-repack"
+
def remove_recursive(path):
"""equivalent to rm -rf path"""
@@ -33,9 +35,9 @@ def remove_recursive(path):
os.rmdir(path)
-def repack_xpi(script_name, package, upstream_version, xpi_file, verbose):
+def repack_xpi(package, upstream_version, xpi_file, verbose):
# extract xpi file
- tmp_dir = tempfile.mkdtemp(prefix=script_name+".")
+ tmp_dir = tempfile.mkdtemp(prefix=SCRIPT_NAME+".")
try:
extract_dir = package + "-" + upstream_version
full_extract_dir = os.path.join(tmp_dir, extract_dir)
@@ -61,9 +63,9 @@ def repack_xpi(script_name, package, upstream_version, xpi_file, verbose):
remove_recursive(tmp_dir)
-def get_source_package_name(script_name):
+def get_source_package_name():
if not os.path.isfile("debian/control"):
- sys.stderr.write(script_name + ": Error: debian/control file is "
+ 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)
@@ -74,8 +76,7 @@ def get_source_package_name(script_name):
def main():
- script_name = os.path.basename(sys.argv[0])
- epilog = "See {prog}(1) for more info.".format(prog=script_name)
+ epilog = "See {prog}(1) for more info.".format(prog=SCRIPT_NAME)
parser = argparse.ArgumentParser(epilog=epilog)
parser.add_argument("xpi_file", metavar="<xpi-file>",
help=".xpi file that should be repacked")
@@ -88,13 +89,12 @@ def main():
args = parser.parse_args()
if not args.package:
- args.package = get_source_package_name(script_name)
+ args.package = get_source_package_name()
if not args.version:
parser.error("Unknown upstream version. "
"You have to specify one with --upstream-version.")
- repack_xpi(script_name, args.package, args.version, args.xpi_file,
- args.verbose)
+ repack_xpi(args.package, args.version, args.xpi_file, args.verbose)
if __name__ == "__main__":
main()