558490 tags + patch
thanks

attached is a patch implementing a change in install-xpi that
automatically finds files named defaults/preferences/*.js and moves them
into /etc/mozilla-extensions/, with a corresponding symlink.

if the file has a generic name (defaults.js, prefs.js, or
preferences.js) then the configfile is named after the package (e.g.
xul-ext-fubar.js.  Otherwise, it should retain its name as created by
the upstream extension author.  in either case, the link pointing back
to it retains its expected name.

Let me know if there are any problems with the patch.

Regards,

        --dkg
--- src/install-xpi	2010-03-10 02:02:32.000000000 -0500
+++ /usr/bin/install-xpi	2010-02-04 14:44:44.000000000 -0500
@@ -86,7 +86,7 @@
 	incompatible_apps = filter(lambda x: x in app_list, incompatible_apps)
 	return incompatible_apps
 
-def install_xpi(script_name, package, xpi_file, exclude, install_dir, links, correct_permissions, remove_licenses, verbose, move_prefs_to_etc):
+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)
@@ -144,33 +144,6 @@
 						print "%s: correct permission from %s to %s of %s" % (script_name, oct(mode), oct(0755), name)
 						os.chmod(filename, 0755)
 
-	if move_prefs_to_etc:
-		for name in xpi_content:
-			(leadingdir, basename) = os.path.split(name)
-			if leadingdir == os.path.join('defaults', 'preferences') and basename.endswith('.js'):
-				filename = os.path.join(copy_dir, name)
-				if os.path.exists(filename):
-					prefdir = os.path.join('debian', package, 'etc')
-					if not os.path.exists(prefdir):
-						os.mkdir(prefdir)
-					prefdir = os.path.join(prefdir, 'mozilla-extensions') # is this the right spot?
-					if not os.path.exists(prefdir):
-						os.mkdir(prefdir)
-					if basename in ('defaults.js', 'prefs.js', 'preferences.js'): # avoid storing generic names in /etc
-						targname = package + '.js'
-					else:
-						targname = basename
-					targpath = os.path.join(prefdir, targname)
-					if not os.path.exists(targpath):
-						# move file to prefdir
-						os.rename(filename, targpath)
-						# create reverse link
-						linktarg = os.path.join('etc', 'mozilla-extensions', targname)
-						linksrc = os.path.join(install_dir, 'defaults', 'preferences', basename)
-						command = ["dh_link", "-p" + package, linktarg, linksrc]
-						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"))
@@ -200,24 +173,23 @@
 	print >> output, """Usage: %s [options] <xpi-file>
 
 Options:
-  -x, --exclude=<file>	 do not install specified file
+  -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
+  -p, --package=<value>        install the extension into specified package
       --preserve-permissions   do not adjust the file permissions
   -r, --remove-license-files   do not install license files
-      --leave-prefs-alone      do not transfer preference files to /etc
 
 General options:
-  -h, --help		   display this help and exit
-  -v, --verbose		print more information
+  -h, --help                   display this help and exit
+  -v, --verbose                print more information
 
 See %s(1) for more info.""" % (os.path.basename(sys.argv[0]), os.path.basename(sys.argv[0]))
 
 if __name__ == "__main__":
 	try:
 		long_opts = ["exclude", "help", "install-dir", "link", "package",
-				"preserve-permissions", "remove-license-files", "verbose", "leave-prefs-alone"]
+				"preserve-permissions", "remove-license-files", "verbose"]
 		opts, args = getopt.gnu_getopt(sys.argv[1:], "hi:l:p:rvx:", long_opts)
 	except getopt.GetoptError, e:
 		# print help information and exit:
@@ -232,7 +204,6 @@
 	remove_licenses = False
 	verbose = False
 	exclude = list()
-	move_prefs_to_etc = True
 
 	for o, a in opts:
 		if o in ("-x", "--exclude"):
@@ -252,8 +223,6 @@
 			remove_licenses = True
 		elif o in ("-v", "--verbose"):
 			verbose = True
-		elif o in ("leave-prefs-alone"):
-			move_prefs_to_etc = False
 		else:
 			assert False, "unhandled option"
 
@@ -272,4 +241,4 @@
 	if verbose:
 		print script_name + ": Install %s into package %s." % (args[0], package)
 
-	install_xpi(script_name, package, args[0], exclude, install_dir, links, correct_permissions, remove_licenses, verbose, move_prefs_to_etc)
+	install_xpi(script_name, package, args[0], exclude, install_dir, links, correct_permissions, remove_licenses, verbose)

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to