Merge pull request #543 from nodiscc/disable-vpn-ads
[user-js.git] / Makefile
blob48651ff3d9a9cb5be126ccad147c2bd8292fc7b8
1 SHELL=/bin/bash
3 .PHONY: all
4 all: whatdoesitdo tests
6 ##### INSTALLATION METHODS #####
8 locked_user.js: user.js
9 ######## generate a locked configuration file
10 sed 's/^user_pref/lockPref/' $< >| $@
12 systemwide_user.js: user.js
13 ######## generate a system-wide configuration file
14 sed 's/user_pref(/pref(/' $< >| $@
16 debian_locked.js: user.js
17 ######## generate a locked, system-wide configuration file
18 sed 's/^user_pref(\("[^"]\+"\),\s\+\([^)]\+\));\(\s*\/\/.*\)\?$$/pref(\1, \2, locked);/' $< >| $@
20 # https://github.com/mozilla/policy-templates/blob/master/README.md
21 policies.json:
22 # TODO what does it do?
23 jq -n -M "{\"policies\": {\"OfferToSaveLogins\": false, \"DisableBuiltinPDFViewer\": true, \"DisablePocket\": true, \"DisableFormHistory\": true, \"SanitizeOnShutdown\": true, \"SearchBar\": \"separate\", \"DisableTelemetry\": true, \"Cookies\": {\"AcceptThirdParty\": \"never\", \"ExpireAtSessionEnd\": true}, \"EnableTrackingProtection\": {\"Value\": true}, \"PopupBlocking\": {\"Default\": true}, \"FlashPlugin\": {\"Default\": false}, \"DisableFirefoxStudies\": true}}" >| $@
26 ##### TESTS #####
28 .PHONY: tests
29 tests: sourceprefs.js checkdeprecated stats acorn bash_syntax shellcheck
31 .PHONY: acorn
32 acorn:
33 ######## validate js syntax
34 acorn --silent user.js
36 .PHONY: bash_syntax
37 bash_syntax:
38 ######## check syntax of all bash scripts
39 $(foreach i,$(wildcard *.sh),bash -n $(i);)
41 .PHONY: shellcheck
42 shellcheck:
43 ######## check/lint all shell scripts
44 shellcheck *.sh
47 ##### MAINTENANCE #####
49 TBBBRANCH=tor-browser-68.8.0esr-9.5-1
50 000-tor-browser.js:
51 ######## download Tor Browser custom configuration reference
52 wget -nv "https://gitweb.torproject.org/tor-browser.git/plain/browser/app/profile/firefox.js?h=$(TBBBRANCH)" -O $@
54 regex = ^\(user_\)\?pref/s/^.*pref("\([^"]\+\)",\s*\([^)]\+\).*$$
55 .PHONY: tbb-diff
56 tbb-diff: 000-tor-browser.js
57 ######## differences between values from this user.js and tor browser's values
58 diff <(sed -n '/$(regex)/\1 = \2/p' user.js | sort) <(sed -n '/$(regex)/\1 = \2/p' $< | sort)
60 .PHONY: tbb-diff-2
61 tbb-diff-2: 000-tor-browser.js
62 ######## TODO what does it do?
63 for setting in $$( comm -12 <(sed -n '/$(regex)/\1/p' user.js | sort) <(sed -n '/$(regex)/\1/p' $< | sort)); do diff <(grep "^\(user_\)\?pref(\"$${setting}\"" user.js | sed -n '/$(regex)/\1 = \2/p' | sort) <(grep "^\(user_\)\?pref(\"$${setting}\"" $< | sed -n '/$(regex)/\1 = \2/p' | sort); done
65 .PHONY: tbb-missing-from-user.js
66 tbb-missing-from-user.js: 000-tor-browser.js
67 ######## preferences that are present in tor browser's defaults, but not in this user.js
68 comm -13 <(sed -n '/$(regex)/\1/p' user.js | sort) <(sed -n '/$(regex)/\1/p' $< | sort)
70 # specify wanted Firefox version/revision below (eg. "tip", "FIREFOX_AURORA_45_BASE", "9577ddeaafd85554c2a855f385a87472a089d5c0"). See https://hg.mozilla.org/mozilla-central/tags
71 SOURCEVERSION=tip
72 FIREFOX_SOURCE_PREFS= \
73 https://hg.mozilla.org/mozilla-central/raw-file/$(SOURCEVERSION)/modules/libpref/init/all.js \
74 https://hg.mozilla.org/mozilla-central/raw-file/$(SOURCEVERSION)/testing/profiles/common/user.js \
75 https://hg.mozilla.org/mozilla-central/raw-file/$(SOURCEVERSION)/testing/profiles/reftest/user.js \
76 https://hg.mozilla.org/mozilla-central/raw-file/$(SOURCEVERSION)/js/src/tests/user.js \
77 https://hg.mozilla.org/mozilla-central/raw-file/$(SOURCEVERSION)/browser/app/profile/firefox.js \
78 https://hg.mozilla.org/mozilla-central/raw-file/tip/devtools/client/preferences/debugger.js \
79 https://hg.mozilla.org/mozilla-central/raw-file/tip/browser/branding/unofficial/pref/firefox-branding.js \
80 https://hg.mozilla.org/mozilla-central/raw-file/tip/browser/branding/official/pref/firefox-branding.js \
81 https://hg.mozilla.org/mozilla-central/raw-file/tip/browser/branding/nightly/pref/firefox-branding.js \
82 https://hg.mozilla.org/mozilla-central/raw-file/tip/browser/branding/aurora/pref/firefox-branding.js \
83 https://hg.mozilla.org/mozilla-central/raw-file/tip/browser/locales/en-US/firefox-l10n.js \
84 https://hg.mozilla.org/mozilla-central/raw-file/tip/browser/app/profile/channel-prefs.js
85 sourceprefs.js:
86 ######## download and sort all known preferences files from Firefox (mozilla-central) source
87 @for SOURCEFILE in $(FIREFOX_SOURCE_PREFS); do wget -nv "$$SOURCEFILE" -O - ; done | egrep "(^pref|^user_pref)" | sort --unique >| $@
89 .PHONY: upstream-duplicates
90 upstream-duplicates: sourceprefs.js
91 ######## preferences with common values with default Firefox configuration
92 @sed 's/^pref(/user_pref(/' sourceprefs.js | sed -E "s/[[:space:]]+/ /g" | sort > sourceprefs_sorted.js
93 @grep "^user_pref" user.js | sed -E "s/[[:space:]]+/ /g" | sort > userjs_sorted.js
94 @comm -1 -2 sourceprefs_sorted.js userjs_sorted.js
96 .PHONY: upstream-missing-from-user.js
97 upstream-missing-from-user.js: sourceprefs.js
98 ######## preferences present in firefox source but not covered by user.js
99 ######## configure ignored preferences in ignore.list
100 @SOURCE_PREFS=$$(egrep '(^pref|^user_pref)' $< | awk -F'"' '{print $$2}'); \
101 for SOURCE_PREF in $$SOURCE_PREFS; do \
102 grep "\"$$SOURCE_PREF\"" user.js ignore.list >/dev/null || echo "Not covered by user.js : $$SOURCE_PREF"; \
103 done | sort --unique
105 .PHONY: checkdeprecated
106 upstream-deprecated: sourceprefs.js
107 ######## preferences in hardened user.js that are no longer present in firefox source
108 @HARDENED_PREFS=$$(egrep "^user_pref" user.js | cut -d'"' -f2); \
109 for HARDENED_PREF in $$HARDENED_PREFS; do \
110 grep "\"$$HARDENED_PREF\"" $< >/dev/null || echo "Deprecated : $$HARDENED_PREF"; \
111 done | sort --unique
113 .PHONY: stats
114 stats: sourceprefs.js
115 ######## count preferences number, various stats
116 @echo "$$(egrep "^user_pref" user.js | wc -l | cut -f1) preferences in user.js"
117 @echo "$$(wc -l $< | cut -d" " -f1) preferences in Firefox source"
119 .PHONY: whatdoesitdo
120 whatdoesitdo:
121 ######## generate the README "What does it do?" section
122 @./gen-readme.sh
124 .PHONY: clean
125 clean:
126 ######## generate/update the README "What does it do?" section
127 @rm -f sourceprefs.js sourceprefs_sorted.js userjs_sorted.js 000-tor-browser.js debian_locked.js
129 .PHONY: toc
130 toc:
131 ######## generate the README table of contents
132 @l2headers=$$(egrep "^## " README.md |cut -d" " -f1 --complement ); \
133 echo "$$l2headers" | while read line; do \
134 anchor=$$(echo "$$line" | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g' | sed 's/\?//g'); \
135 echo "* [$$line](#$$anchor)"; \
136 done