[Pkg-mozext-commits] [SCM] Collection of development scripts used for XUL extensions. branch, master, updated. 0.23-82-g2f3f4f5
Benjamin Drung
bdrung at debian.org
Sat Jan 19 01:30:39 UTC 2013
The following commit has been merged in the master branch:
commit f0437c38b9faa188a35f712811eaef346998641d
Author: Benjamin Drung <bdrung at debian.org>
Date: Sat Jan 19 02:17:03 2013 +0100
install-xpi: Search in the parent directories for a debian/ directory.
This change make install-xpi work with debhelper's --sourcedirectory parameter.
Closes: #698033
diff --git a/install-xpi b/install-xpi
index 495492d..a05c462 100755
--- a/install-xpi
+++ b/install-xpi
@@ -37,17 +37,30 @@ LICENSE_PATTERN_LIST = (
COMMAND_LINE_SYNTAX_ERROR = 1
XPI_FILE_DOES_NOT_EXISTS = 2
-def check_package_directory(script_name):
- """Check if the debian/ directory and files like debian/control exist."""
- if not os.path.isdir("debian"):
- sys.stderr.write(script_name + ": Error: Failed to find debian/ "
- "directory. Please execute the script in a Debian "
- "source package.\n")
- sys.exit(1)
- if not os.path.isfile("debian/control"):
+def get_debian_directory(script_name):
+ """Return the path to the debian/ directory.
+
+ Search for a debian/ directory in the current working directory and crawling
+ up the parent directories until one is found. The script will fail if no
+ debian/ directory is found or the debian/ directory does not contain a
+ control file."""
+ base_directory = os.getcwd()
+ while not os.path.isdir(os.path.join(base_directory, "debian")):
+ parent_directory = os.path.split(base_directory)[0]
+ if base_directory == parent_directory:
+ sys.stderr.write(script_name + ": Error: Failed to find a debian/ "
+ "directory. Please execute this script inside a "
+ "Debian source package.\n")
+ sys.exit(1)
+ else:
+ base_directory = parent_directory
+ package_directory = os.path.join(base_directory, "debian")
+ # Check if debian/control exists.
+ if not os.path.isfile(os.path.join(package_directory, "control")):
sys.stderr.write(script_name + ": Error: debian/control file is "
"missing.\n")
sys.exit(1)
+ return package_directory
def get_query_field_id_as_list(rdf_path, query_string):
ret = []
@@ -71,8 +84,8 @@ def get_extension_id(install_rdf):
"SELECT ?id WHERE {?x em:targetApplication [] . ?x em:id ?id }"))
return extension_ids.pop()
-def get_arch(package):
- lines = open("debian/control").readlines()
+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)
packages = map(lambda x: x[x.find(":")+1:].strip(), package_lines)
architecture_lines = filter(lambda x: x.find("Architecture:") >= 0, lines)
@@ -95,7 +108,8 @@ def get_xul_apps():
return rows
def install_xpi(script_name, package, xpi_file, exclude, install_dir, links,
- correct_permissions, remove_licenses, system_prefs, 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." % \
@@ -105,14 +119,14 @@ def install_xpi(script_name, package, xpi_file, exclude, install_dir, links,
xpi_content = zfobj.namelist()
# determine installation directory
- if get_arch(package) == "all":
+ if get_arch(package, debian_directory) == "all":
lib_share_dir = "share"
else:
lib_share_dir = "lib"
if install_dir is None:
install_dir = os.path.join("usr", lib_share_dir, "xul-ext",
package.replace("xul-ext-", ""))
- copy_dir = os.path.join("debian", package, install_dir.strip("/"))
+ copy_dir = os.path.join(debian_directory, package, install_dir.strip("/"))
if verbose:
print "%s: install directory: %s" % (script_name, install_dir)
@@ -165,15 +179,16 @@ def install_xpi(script_name, package, xpi_file, exclude, install_dir, links,
f.endswith(".js"), xpi_content)
if len(preferences) > 0:
prefdir = os.path.join("etc", "xul-ext")
- full_prefdir = os.path.join("debian", package, prefdir)
+ full_prefdir = os.path.join(debian_directory, 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")
- if os.path.isfile(os.path.join("debian", package + ".js")):
+ config_file = os.path.join(debian_directory, package + ".js")
+ if os.path.isfile(config_file):
# use debian/package.js as configuration file if it exists
- content = open(os.path.join("debian", package + ".js")).read()
+ content = open(config_file).read()
# replace @INSTALLDIR@ by the actual installation directory
content = content.replace("@INSTALLDIR@",
os.path.join("/", install_dir))
@@ -210,8 +225,8 @@ def install_xpi(script_name, package, xpi_file, exclude, install_dir, links,
print " ".join(command)
subprocess.call(command)
-def get_first_package():
- lines = open("debian/control").readlines()
+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]
@@ -256,10 +271,10 @@ def main():
(script_name, ", ".join(args))
sys.exit(COMMAND_LINE_SYNTAX_ERROR)
- check_package_directory(script_name)
+ debian_directory = get_debian_directory(script_name)
if options.package is None:
- options.package = get_first_package()
+ options.package = get_first_package(debian_directory)
if options.verbose:
print script_name + ": Install %s into package %s." % \
@@ -268,7 +283,7 @@ def main():
install_xpi(script_name, options.package, args[0], options.exclude,
options.install_dir, set(options.links),
options.correct_permissions, options.remove_licenses,
- options.system_prefs, options.verbose)
+ options.system_prefs, debian_directory, options.verbose)
if __name__ == "__main__":
main()
--
Collection of development scripts used for XUL extensions.
More information about the Pkg-mozext-commits
mailing list