summaryrefslogtreecommitdiff
path: root/src/install-xpi
diff options
context:
space:
mode:
authorBenjamin Drung <bdrung@ubuntu.com>2010-04-06 16:19:32 +0200
committerBenjamin Drung <bdrung@ubuntu.com>2010-04-06 16:19:32 +0200
commitd9f031708c37825bf95d3db43bf65304d5f37da2 (patch)
tree50147c0abd9218d2860ac6edaee679326a8a6b03 /src/install-xpi
parent7dd58a382d9d8a7081b9bfc5af5a42ab9977d6bf (diff)
* install-xpi will create a system preference file in /etc; add
--disable-system-prefs to disable the new behavior (Closes: #558490, LP: #535544) - update man/install-xpi.1 - update src/install-xpi - update src/xpi.mk
Diffstat (limited to 'src/install-xpi')
-rwxr-xr-xsrc/install-xpi30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/install-xpi b/src/install-xpi
index 74aae57..9b22644 100755
--- a/src/install-xpi
+++ b/src/install-xpi
@@ -87,7 +87,7 @@ def incompatible_apps(target_applications):
return incompatible_apps
def install_xpi(script_name, package, xpi_file, exclude, install_dir, links,
- correct_permissions, remove_licenses, verbose=False):
+ correct_permissions, remove_licenses, system_prefs, 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)
@@ -146,6 +146,29 @@ def install_xpi(script_name, package, xpi_file, exclude, install_dir, links,
print "%s: correct permission from %s to %s of %s" % (script_name, oct(mode), oct(0755), name)
os.chmod(filename, 0755)
+ # create a system preference file in /etc
+ if system_prefs:
+ # search for preference files
+ preferences = filter(lambda f: os.path.dirname(f) == os.path.join("defaults", "preferences") and f.endswith(".js"), xpi_content)
+ if len(preferences) > 0:
+ prefdir = os.path.join("etc", "xul-ext")
+ full_prefdir = os.path.join("debian", package, prefdir)
+ if not os.path.exists(full_prefdir):
+ os.makedirs(full_prefdir)
+ prefname = package.replace("xul-ext-", "") + ".js"
+ # create system preference file
+ f = open(os.path.join(full_prefdir, prefname), "w")
+ f.write("// Place your preferences for " + package + " in this file.\n")
+ f.write("// You can override here the preferences specified in\n")
+ map(lambda x: f.write("// " + os.path.join("/", install_dir, x) + "\n"), preferences)
+ f.close()
+ link_source = os.path.join(prefdir, prefname)
+ link_target = os.path.join(install_dir, "defaults", "preferences", "000system.js")
+ command = ["dh_link", "-p" + package, link_source, link_target]
+ if verbose:
+ print " ".join(command)
+ subprocess.call(command)
+
# get symlinks list
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"))
@@ -176,6 +199,9 @@ if __name__ == "__main__":
epilog = "See %s(1) for more info." % (os.path.basename(sys.argv[0]))
parser = optparse.OptionParser(usage=usage, epilog=epilog)
+ parser.add_option("--disable-system-prefs",
+ help="do not create a system preference file in /etc",
+ dest="system_prefs", action="store_false", default=True)
parser.add_option("-x", "--exclude", metavar="FILE",
help="do not install specified FILE",
dest="exclude", action="append", default=list())
@@ -213,4 +239,4 @@ if __name__ == "__main__":
install_xpi(script_name, options.package, args[0], options.exclude,
options.install_dir, set(options.links), options.correct_permissions,
- options.remove_licenses, options.verbose)
+ options.remove_licenses, options.system_prefs, options.verbose)