mozextension.eclass: initial support for manifest.json exensions
authorIan Stakenvicius <axs@gentoo.org>
Thu, 25 Jan 2018 19:18:09 +0000 (14:18 -0500)
committerIan Stakenvicius <axs@gentoo.org>
Thu, 25 Jan 2018 19:20:29 +0000 (14:20 -0500)
Thanks to Sven B. for some initial legwork on this.  Work is not complete as
the extension installations should somehow also auto-validate themselves, but
it will at least prevent bugs such as bug 645636

Bug: http://bugs.gentoo.org/645754

eclass/mozextension.eclass

index 9d22166e9d73c2da2ca2954fba3cd0c76ff8ce74..425da7e85bf1af983c0af969d1b848d036b59be3 100644 (file)
@@ -69,10 +69,18 @@ xpi_install() {
        [[ ${#} -ne 1 ]] && die "$FUNCNAME takes exactly one argument, please specify an xpi to unpack"
 
        x="${1}"
-       cd ${x}
+       #cd ${x}
        # determine id for extension
+       if [[ -f "${x}"/install.rdf ]]; then
        emid="$(sed -n -e '/install-manifest/,$ { /em:id/!d; s/.*[\">]\([^\"<>]*\)[\"<].*/\1/; p; q }' "${x}"/install.rdf)" \
-               || die "failed to determine extension id"
+               || die "failed to determine extension id from install.rdf"
+       elif [[ -f "${x}"/manifest.json ]]; then
+               emid="$( sed -n 's/.*"id": "\(.*\)",/\1/p' "${x}"/manifest.json )" \
+                       || die "failed to determine extension id from manifest.json"
+       else
+               die "failed to determine extension id"
+       fi
+
        if [[ -n ${MOZEXTENSION_TARGET} ]]; then
                insinto "${MOZILLA_FIVE_HOME}"/${MOZEXTENSION_TARGET%/}/${emid}
        elif $(mozversion_extension_location) ; then