summaryrefslogtreecommitdiff
path: root/install-xpi
diff options
context:
space:
mode:
authorBenjamin Drung <bdrung@debian.org>2014-05-09 23:21:30 +0200
committerBenjamin Drung <bdrung@debian.org>2014-05-09 23:21:30 +0200
commitc63a7398cb92e934318041069c17f46f92b59e24 (patch)
tree542a3d75307acdd632e073ec375e9ae12c67513a /install-xpi
parent0860cda260e942830caafc4bb506acb85f40f311 (diff)
PEP8 fixes.
pep8 --max-line-length=99 amo-changelog dh_xul-ext install-xpi \ moz_version.py moz-version setup.py xpi-repack
Diffstat (limited to 'install-xpi')
-rwxr-xr-xinstall-xpi74
1 files changed, 44 insertions, 30 deletions
diff --git a/install-xpi b/install-xpi
index c8856e8..ec0af31 100755
--- a/install-xpi
+++ b/install-xpi
@@ -37,6 +37,7 @@ LICENSE_PATTERN_LIST = (
COMMAND_LINE_SYNTAX_ERROR = 1
XPI_FILE_DOES_NOT_EXISTS = 2
+
def get_debian_directory(script_name):
"""Return the path to the debian/ directory.
@@ -62,28 +63,36 @@ def get_debian_directory(script_name):
sys.exit(1)
return package_directory
+
def get_query_field_id_as_list(rdf_path, query_string):
ret = []
model = RDF.Model()
parser = RDF.Parser(name="rdfxml")
parser.parse_into_model(model, "file:" + rdf_path)
- query = RDF.Query("PREFIX em: <http://www.mozilla.org/2004/em-rdf#> " + \
+ query = RDF.Query("PREFIX em: <http://www.mozilla.org/2004/em-rdf#> " +
query_string, query_language="sparql")
results = query.execute(model)
for result in results:
ret.append(result["id"].literal_value["string"])
return ret
+
def get_target_applications(install_rdf):
- target_applications = get_query_field_id_as_list(install_rdf,
- "SELECT ?id WHERE { [] em:targetApplication ?x . ?x em:id ?id }")
+ target_applications = get_query_field_id_as_list(
+ install_rdf,
+ "SELECT ?id WHERE { [] em:targetApplication ?x . ?x em:id ?id }"
+ )
return target_applications
+
def get_extension_id(install_rdf):
- extension_ids = set(get_query_field_id_as_list(install_rdf,
- "SELECT ?id WHERE {?x em:targetApplication [] . ?x em:id ?id }"))
+ extension_ids = set(get_query_field_id_as_list(
+ install_rdf,
+ "SELECT ?id WHERE {?x em:targetApplication [] . ?x em:id ?id }"
+ ))
return extension_ids.pop()
+
def get_arch(package, debian_directory):
lines = open(os.path.join(debian_directory, "control")).readlines()
package_lines = filter(lambda x: x.find("Package:") >= 0, lines)
@@ -94,11 +103,13 @@ def get_arch(package, debian_directory):
zip(packages, architectures))[0]
return arch
+
def get_mode(filename):
statinfo = os.stat(filename)
mode = statinfo[stat.ST_MODE]
return mode & 0777
+
def get_xul_apps():
csvfile = open("/usr/share/mozilla-devscripts/xul-app-data.csv")
csv_reader = csv.DictReader(csvfile)
@@ -107,9 +118,10 @@ def get_xul_apps():
rows.append(row)
return rows
+
def install_xpi(script_name, package, xpi_file, exclude, install_dir, links,
- correct_permissions, remove_licenses, system_prefs, debian_directory,
- verbose=False):
+ correct_permissions, remove_licenses, system_prefs,
+ debian_directory, 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." % \
@@ -125,7 +137,7 @@ def install_xpi(script_name, package, xpi_file, exclude, install_dir, links,
lib_share_dir = "lib"
if install_dir is None:
install_dir = os.path.join("usr", lib_share_dir, "xul-ext",
- package.replace("xul-ext-", ""))
+ package.replace("xul-ext-", ""))
copy_dir = os.path.join(debian_directory, package, install_dir.strip("/"))
if verbose:
print "%s: install directory: %s" % (script_name, install_dir)
@@ -175,8 +187,8 @@ def install_xpi(script_name, package, xpi_file, exclude, install_dir, links,
if system_prefs:
# search for preference .js files in defaults/preferences/
pref_dir = os.path.join("defaults", "preferences")
- preferences = filter(lambda f: os.path.dirname(f) == pref_dir and \
- f.endswith(".js"), xpi_content)
+ preferences = filter(lambda f: os.path.dirname(f) == pref_dir and
+ f.endswith(".js"), xpi_content)
if len(preferences) > 0:
prefdir = os.path.join("etc", "xul-ext")
full_prefdir = os.path.join(debian_directory, package, prefdir)
@@ -216,7 +228,7 @@ def install_xpi(script_name, package, xpi_file, exclude, install_dir, links,
target_applications = get_target_applications(filename)
for target_application in target_applications:
destination = os.path.join("/usr", lib_share_dir, "mozilla/extensions",
- target_application, extension_id)
+ target_application, extension_id)
links.add(destination)
# create symlinks
@@ -225,12 +237,14 @@ def install_xpi(script_name, package, xpi_file, exclude, install_dir, links,
print " ".join(command)
subprocess.call(command)
+
def get_first_package(debian_directory):
lines = open(os.path.join(debian_directory, "control")).readlines()
package_lines = filter(lambda x: x.find("Package:") >= 0, lines)
packages = map(lambda x: x[x.find(":")+1:].strip(), package_lines)
return packages[0]
+
def main():
script_name = os.path.basename(sys.argv[0])
usage = "%s [options] <xpi-file>" % (script_name)
@@ -238,28 +252,28 @@ def main():
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)
+ 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())
+ help="do not install specified FILE",
+ dest="exclude", action="append", default=list())
parser.add_option("-i", "--install-dir", metavar="DIRECTORY",
- help="install extension into the specified DIRECTORY",
- dest="install_dir")
+ help="install extension into the specified DIRECTORY",
+ dest="install_dir")
parser.add_option("-l", "--link", metavar="DIRECTORY",
- help="link from DIRECTORY to extension directory",
- dest="links", action="append", default=list())
+ help="link from DIRECTORY to extension directory",
+ dest="links", action="append", default=list())
parser.add_option("-p", "--package", metavar="PACKAGE",
- help="install the extension into specified PACKAGE",
- dest="package", default=None)
- parser.add_option("--preserve-permissions",
- help="do not adjust the file permissions",
- dest="correct_permissions", action="store_false", default=True)
- parser.add_option("-r", "--remove-license-files",
- help="do not install license files",
- dest="remove_licenses", action="store_true", default=False)
+ help="install the extension into specified PACKAGE",
+ dest="package", default=None)
+ parser.add_option("--preserve-permissions", dest="correct_permissions",
+ action="store_false", default=True,
+ help="do not adjust the file permissions")
+ parser.add_option("-r", "--remove-license-files", dest="remove_licenses",
+ action="store_true", default=False,
+ help="do not install license files")
parser.add_option("-v", "--verbose", help="print more information",
- dest="verbose", action="store_true", default=False)
+ dest="verbose", action="store_true", default=False)
(options, args) = parser.parse_args()
@@ -277,8 +291,8 @@ def main():
options.package = get_first_package(debian_directory)
if options.verbose:
- print script_name + ": Install %s into package %s." % \
- (args[0], options.package)
+ print(script_name + ": Install %s into package %s." %
+ (args[0], options.package))
install_xpi(script_name, options.package, args[0], options.exclude,
options.install_dir, set(options.links),