summaryrefslogtreecommitdiffstats
path: root/tools/install-mozilla-extension.sh
diff options
context:
space:
mode:
authorOlivier Blin <blino@mageia.org>2011-03-15 13:58:31 +0000
committerOlivier Blin <blino@mageia.org>2011-03-15 13:58:31 +0000
commit4c4328833cb84e7e5e4eccbb385c9d4851bfd7b5 (patch)
treef6d8d18d835eb7a25088d351663a29c5058532d5 /tools/install-mozilla-extension.sh
downloaddraklive-config-4c4328833cb84e7e5e4eccbb385c9d4851bfd7b5.tar
draklive-config-4c4328833cb84e7e5e4eccbb385c9d4851bfd7b5.tar.gz
draklive-config-4c4328833cb84e7e5e4eccbb385c9d4851bfd7b5.tar.bz2
draklive-config-4c4328833cb84e7e5e4eccbb385c9d4851bfd7b5.tar.xz
draklive-config-4c4328833cb84e7e5e4eccbb385c9d4851bfd7b5.zip
import initial live config
Diffstat (limited to 'tools/install-mozilla-extension.sh')
-rwxr-xr-xtools/install-mozilla-extension.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/tools/install-mozilla-extension.sh b/tools/install-mozilla-extension.sh
new file mode 100755
index 0000000..4bb4c3b
--- /dev/null
+++ b/tools/install-mozilla-extension.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+extpath=$1
+xpi=$2
+
+if [ -z "$extpath" ]; then
+ echo "usage: $0 <mozilla extension path> [<xpi file>]"
+ exit 1
+fi
+
+xpi_dir="."
+if [ -n "$xpi" ]; then
+ xpi_dir="`basename $xpi`.dir"
+ rm -rf $xpi_dir
+ mkdir -p $xpi_dir
+ unzip -q -d $xpi_dir $xpi
+fi
+
+rdf="$xpi_dir/install.rdf"
+if [ ! -f $rdf ]; then
+ echo "unable to find rdf file"
+ exit 1
+fi
+
+# remove leading newline from some broken rdf files (pt-PT)
+perl -pi -e 's/^\r?\n// if $. == 1' $rdf
+
+hash="$(perl -pe 's/\r\n/\n/g' $rdf | sed -n '/.*em:id="\(.*\)"/{s//\1/p;q}')"
+if [ -z "$hash" ]; then
+ hash="$(perl -pe 's/\r\n/\n/g' $rdf | sed -n '/.*em:id>\(.*\)<\/em:id>.*/{s//\1/p;q}')"
+fi
+if [ -z "$hash" ]; then
+ echo "Failed to find plugin hash."
+ exit 1
+fi
+
+echo "installing $hash in $extpath"
+
+extdir="$extpath/$hash"
+rm -rf $extdir
+mkdir -p "$extdir"
+cp -af $xpi_dir/* "$extdir/"
+
+if [ -n "$xpi" ]; then
+ rm -rf $xpi_dir
+fi