12-generate-ublock-origin-filter 725 Bytes
Newer Older
1
2
3
4
#!/bin/sh

set -e

anonym's avatar
anonym committed
5
echo "Converting uBlock database dump into sqlite blob"
spriver's avatar
spriver committed
6

anonym's avatar
anonym committed
7
# Import ensure_hook_dependency_is_installed()
8
9
. /usr/local/lib/tails-shell-library/build.sh

anonym's avatar
anonym committed
10
ensure_hook_dependency_is_installed sqlite3
11

12
13
DUMP="/usr/share/tails/ublock-origin/ublock0.dump"
DATABASE="/etc/tor-browser/profile/extension-data/ublock0.sqlite"
14

15
mkdir -p "$(dirname "${DATABASE}")"
16

17
18
19
20
21
# The sed expression simply means: remove all CRLF ("\r\n"). The use
# of labels is simply to make this able to remove multiple CRLF to
# create a single (long) line. In the end, this restores the
# diff-friendly dump to the original sqlite dump.
sed ':a;N;$!ba;s_\r\n__g' "${DUMP}" | sqlite3 "${DATABASE}"
22
23

echo "Created uBlock sqlite blob successfully"