summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--man/xpi-repack.18
-rwxr-xr-xxpi-repack23
2 files changed, 21 insertions, 10 deletions
diff --git a/man/xpi-repack.1 b/man/xpi-repack.1
index 50aec84..b58d131 100644
--- a/man/xpi-repack.1
+++ b/man/xpi-repack.1
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2010-2011 Benjamin Drung <bdrung@debian.org>
+.\" Copyright (c) 2010-2014 Benjamin Drung <bdrung@debian.org>
.\"
.\" Permission to use, copy, modify, and/or distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
@@ -42,6 +42,12 @@ used.
The \fIversion\fP will be used for naming the resulting tarball. You have to
specify this parameter.
.TP
+\fB\-f\fR \fIcompression\fP, \fB\-\-format\fR=\fIcompression\fP
+The specified format will be used for compressing the resulting tarball.
+The formats \fIbz2\fR, \fIgz\fR, and \fIxz\fR are suppored. When the parameter
+is omitted, \fIxz\fR will be used for "3.0 (quilt)" source packages and
+\fIgz\fR for all other source package types.
+.TP
\fB\-v\fR, \fB\-\-verbose\fR
Print more information.
.SH AUTHOR
diff --git a/xpi-repack b/xpi-repack
index e65ed59..080b0ad 100755
--- a/xpi-repack
+++ b/xpi-repack
@@ -20,6 +20,7 @@ import subprocess
import sys
import tempfile
+COMPRESSION_FORMATS = ["bz2", "gz", "xz"]
SCRIPT_NAME = "xpi-repack"
@@ -35,7 +36,7 @@ def remove_recursive(path):
os.rmdir(path)
-def repack_xpi(package, upstream_version, xpi_file, verbose):
+def repack_xpi(package, upstream_version, xpi_file, extension, verbose):
# extract xpi file
tmp_dir = tempfile.mkdtemp(prefix=SCRIPT_NAME+".")
try:
@@ -43,16 +44,17 @@ def repack_xpi(package, upstream_version, xpi_file, verbose):
full_extract_dir = os.path.join(tmp_dir, extract_dir)
subprocess.check_call(["xpi-unpack", xpi_file, full_extract_dir])
- # check, if source 3.0 (quilt) format is used
- extension = ".gz"
- if os.path.isfile("debian/source/format"):
- source_format = open("debian/source/format").readline().strip()
- if source_format == "3.0 (quilt)":
- extension = ".bz2"
+ if not extension:
+ # check, if source 3.0 (quilt) format is used
+ extension = "gz"
+ if os.path.isfile("debian/source/format"):
+ source_format = open("debian/source/format").readline().strip()
+ if source_format == "3.0 (quilt)":
+ extension = "xz"
# pack source
directory = os.path.realpath(os.path.dirname(xpi_file))
- tar_file = package + "_" + upstream_version + ".orig.tar" + extension
+ tar_file = package + "_" + upstream_version + ".orig.tar." + extension
full_tar_file = os.path.join(directory, tar_file)
cmd = ["tar", "-ca", "-C", tmp_dir, "-f", full_tar_file, extract_dir]
if verbose:
@@ -83,6 +85,8 @@ def main():
parser.add_argument("-p", "--package", help="specify source package name")
parser.add_argument("-u", "--upstream-version", dest="version",
help="specify the upstream version")
+ parser.add_argument("-f", "--format", choices=COMPRESSION_FORMATS,
+ help="compression format for the produced tarball")
parser.add_argument("-v", "--verbose", action="store_true",
help="print more information")
@@ -94,7 +98,8 @@ def main():
parser.error("Unknown upstream version. "
"You have to specify one with --upstream-version.")
- repack_xpi(args.package, args.version, args.xpi_file, args.verbose)
+ repack_xpi(args.package, args.version, args.xpi_file, args.format,
+ args.verbose)
if __name__ == "__main__":
main()