firefox-extensions: make the patching logic more pluggable
This commit is contained in:
@@ -19,25 +19,34 @@ let
|
|||||||
inherit extid;
|
inherit extid;
|
||||||
original = addon;
|
original = addon;
|
||||||
};
|
};
|
||||||
builder = writeScript "manifest-fixer" ''
|
unpackPhase = ''
|
||||||
source $stdenv/setup
|
|
||||||
|
|
||||||
UUID="${extid}"
|
UUID="${extid}"
|
||||||
echo "firefox addon $name into $out/$UUID.xpi, remove ${perm}"
|
echo "firefox addon $name into $out/$UUID.xpi, remove ${perm}"
|
||||||
|
|
||||||
# extract the XPI
|
# extract the XPI
|
||||||
mkdir -p "$out/$UUID"
|
mkdir -p "$out/$UUID"
|
||||||
unzip -q "${addon}/$UUID.xpi" -d "$out/$UUID"
|
unzip -q "${addon}/$UUID.xpi" -d "$out/$UUID"
|
||||||
|
'';
|
||||||
|
|
||||||
|
patchPhase = ''
|
||||||
|
runHook prePatch
|
||||||
|
|
||||||
# apply the operation
|
|
||||||
NEW_MANIFEST=$(jq 'del(.permissions[] | select(. == "${perm}"))' "$out/$UUID/manifest.json")
|
NEW_MANIFEST=$(jq 'del(.permissions[] | select(. == "${perm}"))' "$out/$UUID/manifest.json")
|
||||||
echo "$NEW_MANIFEST" > "$out/$UUID/manifest.json"
|
echo "$NEW_MANIFEST" > "$out/$UUID/manifest.json"
|
||||||
|
|
||||||
|
runHook postPatch
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
# repackage the XPI
|
# repackage the XPI
|
||||||
cd "$out/$UUID"
|
cd "$out/$UUID"
|
||||||
zip -r -q -FS "$out/$UUID.xpi" *
|
zip -r -q -FS "$out/$UUID.xpi" *
|
||||||
strip-nondeterminism "$out/$UUID.xpi"
|
strip-nondeterminism "$out/$UUID.xpi"
|
||||||
rm -r "$out/$UUID"
|
rm -r "$out/$UUID"
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
|
Reference in New Issue
Block a user