summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenjamin Drung <bdrung@ubuntu.com>2010-01-08 01:47:48 +0100
committerBenjamin Drung <bdrung@ubuntu.com>2010-01-08 01:47:48 +0100
commitfbfabd9adcf40c178fb6e2f2e1d3dca9d374236a (patch)
tree91b87b47d9b406fb0e0e2d5bb5ba05ddc7a32c7c /src
parentc27daa564e7cd4926ac3335614b80ea788f686d3 (diff)
- add --install-dir parameter to install-xpi
- update man/install-xpi.1 - update src/install-xpi
Diffstat (limited to 'src')
-rwxr-xr-xsrc/install-xpi39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/install-xpi b/src/install-xpi
index 071507c..31c5f00 100755
--- a/src/install-xpi
+++ b/src/install-xpi
@@ -68,7 +68,7 @@ def get_mode(filename):
mode = st[stat.ST_MODE]
return mode & 0777
-def install_xpi(script_name, package, xpi_file, exclude, links, correct_permissions, remove_licenses, verbose=False):
+def install_xpi(script_name, package, xpi_file, exclude, install_dir, links, correct_permissions, remove_licenses, verbose=False):
# get xpi file content list
if not os.path.isfile(xpi_file):
print >> sys.stderr, "%s: Error: xpi file %s does not exist." % (script_name, xpi_file)
@@ -77,11 +77,13 @@ def install_xpi(script_name, package, xpi_file, exclude, links, correct_permissi
xpi_content = zfobj.namelist()
# determine installation directory
- if get_arch(package) == "all":
- lib_share_dir = "share"
- else:
- lib_share_dir = "lib"
- install_dir = os.path.join("debian", package, "usr", lib_share_dir, package)
+ if install_dir is None:
+ if get_arch(package) == "all":
+ lib_share_dir = "share"
+ else:
+ lib_share_dir = "lib"
+ install_dir = os.path.join("debian", package, "usr", lib_share_dir, package)
+ copy_dir = os.path.join("debian", package, install_dir.strip("/"))
if verbose:
print "%s: install directory: %s" % (script_name, install_dir)
@@ -95,9 +97,9 @@ def install_xpi(script_name, package, xpi_file, exclude, links, correct_permissi
print "%s: exclude license file %s" % (script_name, name)
# create directory and extract xpi file
- if not os.path.isdir(install_dir):
- os.makedirs(install_dir)
- command = ["unzip", "-o", "-d", install_dir, xpi_file]
+ if not os.path.isdir(copy_dir):
+ os.makedirs(copy_dir)
+ command = ["unzip", "-o", "-d", copy_dir, xpi_file]
if len(exclude) > 0:
command.append("-x")
command.extend(exclude)
@@ -107,7 +109,7 @@ def install_xpi(script_name, package, xpi_file, exclude, links, correct_permissi
# correct permissons of files to 644 and directories to 755
if correct_permissions:
for name in xpi_content:
- filename = os.path.join(install_dir, name)
+ filename = os.path.join(copy_dir, name)
if os.path.exists(filename):
mode = get_mode(filename)
if os.path.isdir(filename) and mode != 0755:
@@ -125,16 +127,15 @@ def install_xpi(script_name, package, xpi_file, exclude, links, correct_permissi
os.chmod(filename, 0755)
# get symlinks list
- extension_id = get_extension_id(os.path.join(install_dir, "install.rdf"))
- target_applications = get_target_applications(script_name, os.path.join(install_dir, "install.rdf"))
+ extension_id = get_extension_id(os.path.join(copy_dir, "install.rdf"))
+ target_applications = get_target_applications(script_name, os.path.join(copy_dir, "install.rdf"))
for target_application in target_applications:
destination = os.path.join("/usr/lib/mozilla/extensions/", target_application, extension_id)
links.add(destination)
# create symlinks
- source = os.path.join("/usr", lib_share_dir, package)
for link in links:
- command = ["dh_link", "-p" + package, source, link]
+ command = ["dh_link", "-p" + package, install_dir, link]
print " ".join(command)
subprocess.call(command)
@@ -149,6 +150,7 @@ def usage(output):
Options:
-x, --exclude=<file> do not install specified file
+ -i, --install-dir=<value> install extension into the specified directory
-l, --link=<directory> link from directory to extension directory
-p, --package=<value> install the extension into specified package
--preserve-permissions do not adjust the file permissions
@@ -162,9 +164,9 @@ See %s(1) for more info.""" % (sys.argv[0], os.path.basename(sys.argv[0]))
if __name__ == "__main__":
try:
- long_opts = ["exclude", "help", "link", "package",
+ long_opts = ["exclude", "help", "install-dir", "link", "package",
"preserve-permissions", "remove-license-files", "verbose"]
- opts, args = getopt.gnu_getopt(sys.argv[1:], "hl:p:rvx:", long_opts)
+ opts, args = getopt.gnu_getopt(sys.argv[1:], "hi:l:p:rvx:", long_opts)
except getopt.GetoptError, e:
# print help information and exit:
print >> sys.stderr, str(e) # will print something like "option -a not recognized"
@@ -172,6 +174,7 @@ if __name__ == "__main__":
sys.exit(COMMAND_LINE_SYNTAX_ERROR)
correct_permissions = True
+ install_dir = None
links = set()
package = None
remove_licenses = False
@@ -184,6 +187,8 @@ if __name__ == "__main__":
elif o in ("-h", "--help"):
usage(sys.stdout)
sys.exit()
+ elif o in ("-i", "--install-dir"):
+ install_dir = a
elif o in ("-l", "--link"):
links.add(a)
elif o in ("-p", "--package"):
@@ -212,4 +217,4 @@ if __name__ == "__main__":
if verbose:
print script_name + ": Install %s into package %s." % (args[0], package)
- install_xpi(script_name, package, args[0], exclude, links, correct_permissions, remove_licenses, verbose)
+ install_xpi(script_name, package, args[0], exclude, install_dir, links, correct_permissions, remove_licenses, verbose)