summaryrefslogtreecommitdiffstats
path: root/config/chroot_local-hooks/12-generate-ublock-origin-filter
blob: 72faba4142a9970037b703d1772c6031eb630cb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

set -e

echo "Converting uBlock database dump into sqlite blob"

# Import ensure_hook_dependency_is_installed()
. /usr/local/lib/tails-shell-library/build.sh

ensure_hook_dependency_is_installed sqlite3

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

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

# 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}"

echo "Created uBlock sqlite blob successfully"