summaryrefslogtreecommitdiffstats
path: root/build.sh
blob: 231b71167e6a55d953b0159d0ab314c876283dbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
base=$(dirname "$0")
dir="$base/tails-download-and-verify"
mirror_dispatcher_url='https://git-tails.immerda.ch/mirror-pool-dispatcher/plain/lib/js/mirror-dispatcher.js'
mirror_dispatcher_file="lib/mirror-dispatcher.js"
pushd "$dir" >/dev/null 2>&1 || (
  echo >&2 "FATAL: Channot chdir to $dir."
  exit 1
)
echo -n "Removing old XPIs... "
rm -f *.xpi >/dev/null && echo "done."
ver=$(egrep '"version": "[0-9]+\.[^"]+"' package.json | sed -re 's/.*"([0-9]+\.[^"]+)".*/\1/')
echo "Importing mirror-dispatcher.js library"
[ -f "$mirror_dispatcher_file" ] || curl \
  --proto -all,https \
  --tlsv1 \
  --output "$mirror_dispatcher_file" \
  "$mirror_dispatcher_url"
echo "Building extension version $ver"
jpm xpi || exit 2
popd
echo "Copying "*.xpi" to $base/www/dave.xpi..."
cp "$dir/"*.xpi "$base/www/dave.xpi" >/dev/null
ver_page="$base/www/download.html"
ver_line=$(egrep '<[a-z][^>]+id="extension-version"[^>]*>[0-9]' $ver_page)
if [ "$ver_line" ] && ! echo "$ver_line" | fgrep "$ver" ; then
  echo "Updating download.html to version $ver..."
  sed -re 's/(<[a-z][^>]+id="extension-version"[^>]*>)[0-9\.rcba]+/\1'$ver'/' $ver_page > $ver_page.upd && mv $ver_page.upd $ver_page
fi
echo "DONE."