diff -pruN 0.47/amo-changelog 0.48/amo-changelog --- 0.47/amo-changelog 2016-07-19 22:34:27.000000000 +0000 +++ 0.48/amo-changelog 2018-05-18 06:09:40.000000000 +0000 @@ -26,7 +26,7 @@ import urllib2 import xml.etree.cElementTree as etree URL_TEMPLATE = "https://addons.mozilla.org/en-US/addon/{ext}/versions/format:rss" -OUTGOING_HREF = re.compile(r'href="https?://outgoing\.mozilla\.org/v\d+/\w+/(.+?)"') +OUTGOING_HREF = re.compile(r'href="https?://outgoing.*?moz.*?/v\d+/\w+/(.+?)"') HTML_HEAD = "\n{title}\n\n" HTML_FOOT = "\n" diff -pruN 0.47/debian/changelog 0.48/debian/changelog --- 0.47/debian/changelog 2016-07-19 22:52:59.000000000 +0000 +++ 0.48/debian/changelog 2018-05-18 06:24:28.000000000 +0000 @@ -1,3 +1,11 @@ +mozilla-devscripts (0.48) unstable; urgency=medium + + * Team upload. + * Add a dh_webext(1) addon to support WebExtensions. + (Eventually will close #866997, currently WIP.) + + -- Ximin Luo Thu, 17 May 2018 23:24:28 -0700 + mozilla-devscripts (0.47) unstable; urgency=low * When using the xul_ext dh buildsystem, params passed to diff -pruN 0.47/debian/control 0.48/debian/control --- 0.47/debian/control 2016-07-19 22:34:27.000000000 +0000 +++ 0.48/debian/control 2018-05-18 06:23:28.000000000 +0000 @@ -5,9 +5,8 @@ Maintainer: Debian Mozilla Extension Mai Uploaders: Benjamin Drung , Andrea Veri , Sean Whitton Build-Depends: debhelper (>= 9), python-all (>= 2.6.6-3~), python-librdf Standards-Version: 3.9.8 -X-Python-Version: >= 2.6 -VCS-Browser: https://anonscm.debian.org/cgit/pkg-mozext/mozilla-devscripts.git/ -VCS-Git: https://anonscm.debian.org/git/pkg-mozext/mozilla-devscripts.git +VCS-Browser: https://salsa.debian.org/webext-team/webext-devscripts +VCS-Git: https://salsa.debian.org/webext-team/webext-devscripts.git Package: mozilla-devscripts Architecture: all diff -pruN 0.47/debian/copyright 0.48/debian/copyright --- 0.47/debian/copyright 2016-07-19 22:34:27.000000000 +0000 +++ 0.48/debian/copyright 2018-05-18 06:21:31.000000000 +0000 @@ -35,6 +35,10 @@ Files: perl/Debian/Buildsystem/xul_ext.p Copyright: 2010, Mike Hommey License: GPL-2+ +Files: dh_webext perl/Debian/Sequence/webext.pm +Copyright: 2017, Ximin Luo +License: GPL-2+ + License: ISC Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above diff -pruN 0.47/dh_webext 0.48/dh_webext --- 0.47/dh_webext 1970-01-01 00:00:00.000000000 +0000 +++ 0.48/dh_webext 2018-05-18 06:13:35.000000000 +0000 @@ -0,0 +1,154 @@ +#!/usr/bin/python + +# Copyright (c) 2017, Ximin Luo +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +from __future__ import print_function + +import argparse +import json +import os +import shlex +import subprocess +import sys + +self_script = "dh_webext" + +app_packages_debian = { + "gecko": [ + "firefox", + #"thunderbird", thunderbird does not support webext yet + ], + "chromium": ["chromium"], +} + +app_extension_paths = { + "gecko": [ + "/usr/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}", + #"/usr/share/mozilla/extensions/{3550f703-e582-4d05-9a08-453d09bdfdc6}", thunderbird does not support webext yet + ], + "chromium": ["/usr/share/chromium/extensions"], +} + +def log(*args): + print(self_script + ":", *args) + +def run(cmdline, verbose=False): + if verbose: + print(" ", " ".join(shlex.quote(a) for a in cmdline)) + subprocess.check_call(cmdline) + +def get_all_packages(): + lines = open("debian/control").readlines() + package_lines = [x for x in lines if x.find("Package:") >= 0] + packages = [p[p.find(":")+1:].strip() for p in package_lines] + return packages + +def generate_substvars(package, name, supported, verbose=False): + ext_name = name + for prefix in ("webext-",): + if ext_name.startswith(prefix): + ext_name = ext_name[len(prefix):] + + filename = "debian/%s.substvars" % package + # TODO: read old file and merge the new values in + + lines = [] + debian_apps = sorted(set(deb for app in supported + for deb in app_packages_debian[app])) + + # TODO: depends, recommends, breaks + + enhances = debian_apps + lines.append("webext:Enhances=" + ", ".join(enhances) + "\n") + + provided = [prefix + "-" + ext_name for prefix in debian_apps] + lines.append("webext:Provides=" + ", ".join(provided) + "\n") + + with open(filename, 'w+') as fp: + fp.writelines(lines) + +def install_for_app(extname, appname, appextname, supported, verbose=False): + for p in app_extension_paths[appname]: + run(["dh_link", "/usr/share/webext/%s" % extname, + os.path.join(p, appextname)], verbose=verbose) + supported.append(appname) + +def install_webext(*args): + parser = argparse.ArgumentParser( + description="Debhelper command to install an unpacked WebExtension") + parser.add_argument( + "-p", "--package", dest="packages", metavar="PACKAGE", action="append", default=[], + help="calculate substvars only for the specified PACKAGE") + parser.add_argument( + "-v", "--verbose", action="store_true", dest="verbose", default=False, + help="print more information") + parser.add_argument( + 'home', metavar='PATH', default='.', + help='Path to the main directory. (Default: %(default)s)') + parser.add_argument( + 'name', metavar='NAME', nargs='?', default=None, + help='Short name of the extension.') + # TODO: need to handle/ignore other debhelper options, see dh_xul-ext + # for an example and `man debhelper` "COMMON DEBHELPER OPTIONS" for full list + # TODO: import any useful options like -x from install-xpi + args = parser.parse_args(args) + args.packages = args.packages or get_all_packages() + + home = args.home + name = args.name + manifest = os.path.join(home, "manifest.json") + if not os.path.exists(manifest): + raise ValueError("does not exist: %s" % manifest) + + with open(manifest) as fp: + manifest = json.load(fp) + + if name is None: + name = manifest["name"] + if name.startswith("_"): + raise ValueError("name in manifest.json starts with _, please give actual name to %s" % self_script) + + run(["dh_install", "-X.git", "-Xdebian", home, + "usr/share/webext/%s" % name], verbose=args.verbose) + + supported = [] + + for appname, details in manifest["applications"].items(): + if appname in app_extension_paths: + install_for_app(name, appname, details["id"], supported, args.verbose) + else: + log("unrecognised application in manifest: %s", appname) + + if "minimum_chrome_version" in manifest: + install_for_app(name, "chromium", name, supported, args.verbose) + + if os.path.exists("debian/install-webext"): + with open("debian/install-webext") as install_fp: + for line in install_fp.readlines(): + line = line.rstrip("\n") + if " " in line: + appname, extid = line.split(" ") + else: + appname, extid = line, name + install_for_app(name, appname, extid, supported, args.verbose) + + for package in args.packages: + generate_substvars(package, name, supported, args.verbose) + + return 0 + return 1 + +if __name__ == '__main__': + sys.exit(install_webext(*sys.argv[1:])) diff -pruN 0.47/perl/Debian/Sequence/webext.pm 0.48/perl/Debian/Sequence/webext.pm --- 0.47/perl/Debian/Sequence/webext.pm 1970-01-01 00:00:00.000000000 +0000 +++ 0.48/perl/Debian/Sequence/webext.pm 2018-05-18 06:13:35.000000000 +0000 @@ -0,0 +1,8 @@ +#!/usr/bin/perl +use warnings; +use strict; +use Debian::Debhelper::Dh_Lib; + +insert_after("dh_install", "dh_webext"); + +1; diff -pruN 0.47/setup.py 0.48/setup.py --- 0.47/setup.py 2016-07-19 22:34:27.000000000 +0000 +++ 0.48/setup.py 2018-05-18 06:19:56.000000000 +0000 @@ -21,6 +21,7 @@ def get_debian_version(): SCRIPTS = [ 'amo-changelog', 'dh_xul-ext', + 'dh_webext', 'install-xpi', 'xpi-pack', 'xpi-repack', @@ -39,6 +40,8 @@ if __name__ == '__main__': ('share/man/man1', glob.glob("man/*.1")), ('share/mozilla-devscripts', ['data/xpi.mk'] + glob.glob('data/xul-app-data.csv.*')), ('share/perl5/Debian/Debhelper/Buildsystem', ['perl/Debian/Buildsystem/xul_ext.pm']), - ('share/perl5/Debian/Debhelper/Sequence', ['perl/Debian/Sequence/xul_ext.pm']), + ('share/perl5/Debian/Debhelper/Sequence', + ['perl/Debian/Sequence/xul_ext.pm', + 'perl/Debian/Sequence/webext.pm']), ], )