Make the grep regex more explicit
[user-js.git] / Makefile
blob2aca8a85a612c02d1d33ce948a01408b16202b79
1 SHELL=/bin/bash
3 .PHONY: all
4 all: whatdoesitdo tests
6 .PHONY: whatdoesitdo
7 whatdoesitdo:
8 @# generate the README "What does it do?" section
9 @./gen-readme.sh
11 # To decrease tests verbosity, comment out unneeded targets
12 .PHONY: tests
13 tests: sourceprefs.js checkdeprecated stats acorn bash_syntax shellcheck
15 .PHONY: acorn
16 acorn:
17 acorn --silent user.js
19 locked_user.js: user.js
20 sed 's/^user_pref/lockPref/' $< >| $@
22 systemwide_user.js: user.js
23 sed 's/^user_pref/pref/' $< >| $@
25 .PHONY: bash_syntax
26 bash_syntax:
27 $(foreach i,$(wildcard *.sh),bash -n $(i);)
29 .PHONY: shellcheck
30 shellcheck:
31 shellcheck *.sh
33 # download and sort all known preferences files from Firefox (mozilla-central) source
34 # specify wanted Firefox version/revision below (eg. "tip", "FIREFOX_AURORA_45_BASE", "9577ddeaafd85554c2a855f385a87472a089d5c0"). See https://hg.mozilla.org/mozilla-central/tags
35 SOURCEVERSION=tip
36 FIREFOX_SOURCE_PREFS= \
37 https://hg.mozilla.org/mozilla-central/raw-file/$(SOURCEVERSION)/toolkit/components/telemetry/datareporting-prefs.js \
38 https://hg.mozilla.org/mozilla-central/raw-file/$(SOURCEVERSION)/toolkit/components/telemetry/healthreport-prefs.js \
39 https://hg.mozilla.org/mozilla-central/raw-file/$(SOURCEVERSION)/security/manager/ssl/security-prefs.js \
40 https://hg.mozilla.org/mozilla-central/raw-file/$(SOURCEVERSION)/modules/libpref/init/all.js \
41 https://hg.mozilla.org/mozilla-central/raw-file/$(SOURCEVERSION)/testing/profiles/prefs_general.js \
42 https://hg.mozilla.org/mozilla-central/raw-file/$(SOURCEVERSION)/layout/tools/reftest/reftest-preferences.js \
43 https://hg.mozilla.org/mozilla-central/raw-file/$(SOURCEVERSION)/js/src/tests/user.js \
44 https://hg.mozilla.org/mozilla-central/raw-file/$(SOURCEVERSION)/browser/app/profile/firefox.js \
45 https://hg.mozilla.org/mozilla-central/raw-file/tip/devtools/client/preferences/debugger.js \
46 https://hg.mozilla.org/mozilla-central/raw-file/tip/devtools/client/preferences/devtools.js \
47 https://hg.mozilla.org/mozilla-central/raw-file/tip/browser/branding/unofficial/pref/firefox-branding.js \
48 https://hg.mozilla.org/mozilla-central/raw-file/tip/browser/branding/official/pref/firefox-branding.js \
49 https://hg.mozilla.org/mozilla-central/raw-file/tip/browser/branding/nightly/pref/firefox-branding.js \
50 https://hg.mozilla.org/mozilla-central/raw-file/tip/browser/branding/aurora/pref/firefox-branding.js \
51 https://hg.mozilla.org/mozilla-central/raw-file/tip/browser/locales/en-US/firefox-l10n.js \
52 https://hg.mozilla.org/mozilla-central/raw-file/tip/devtools/client/webide/webide-prefs.js \
53 https://hg.mozilla.org/mozilla-central/raw-file/tip/browser/app/profile/channel-prefs.js
54 sourceprefs.js:
55 @for SOURCEFILE in $(FIREFOX_SOURCE_PREFS); do wget -nv "$$SOURCEFILE" -O - ; done | egrep "(^pref|^user_pref)" | sort --unique >| $@
57 TBBBRANCH=tor-browser-52.6.2esr-7.5-2
58 000-tor-browser.js:
59 wget -nv "https://gitweb.torproject.org/tor-browser.git/plain/browser/app/profile/$@?h=$(TBBBRANCH)" -O $@
61 regex = ^\(user_\)\?pref/s/^.*pref("\([^"]\+\)",\s*\([^)]\+\).*$$
62 .PHONY: tbb-diff
63 tbb-diff: 000-tor-browser.js
64 diff <(sed -n '/$(regex)/\1 = \2/p' user.js | sort) <(sed -n '/$(regex)/\1 = \2/p' $< | sort)
66 .PHONY: tbb-diff-2
67 tbb-diff-2: 000-tor-browser.js
68 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
70 .PHONY: tbb-missing-from-user.js
71 tbb-missing-from-user.js: 000-tor-browser.js
72 comm -13 <(sed -n '/$(regex)/\1/p' user.js | sort) <(sed -n '/$(regex)/\1/p' $< | sort)
74 ######################
76 .PHONY: checknotcovered
77 checknotcovered: sourceprefs.js
78 @# check for preferences present in firefox source but not covered by user.js
79 @# configure ignored preferences in ignore.list
80 @SOURCE_PREFS=$$(egrep '(^pref|^user_pref)' $< | awk -F'"' '{print $$2}'); \
81 for SOURCE_PREF in $$SOURCE_PREFS; do \
82 grep "\"$$SOURCE_PREF\"" user.js ignore.list >/dev/null || echo "Not covered by user.js : $$SOURCE_PREF"; \
83 done | sort --unique
85 .PHONY: checkdeprecated
86 checkdeprecated: sourceprefs.js
87 @# check for preferences in hardened user.js that are no longer present in firefox source
88 @HARDENED_PREFS=$$(egrep "^user_pref" user.js | cut -d'"' -f2); \
89 for HARDENED_PREF in $$HARDENED_PREFS; do \
90 grep "\"$$HARDENED_PREF\"" $< >/dev/null || echo "Deprecated : $$HARDENED_PREF"; \
91 done | sort --unique
93 .PHONY: stats
94 stats: sourceprefs.js
95 @# count preferences number, various stats
96 @echo "$$(egrep "^user_pref" user.js | wc -l | cut -f1) preferences in user.js"
97 @echo "$$(wc -l $< | cut -d" " -f1) preferences in Firefox source"
99 .PHONY: clean
100 clean:
101 @# remove temporary files
102 @# please comment this out when not needed, to minimize load on Mozilla servers
103 @rm -f sourceprefs.js AUTHORS
105 AUTHORS:
106 @# generate an AUTHORS file, ordered by number of commits
107 @# to add extra authors/credits, git commit --allow-empty --author="A U Thor <author@example.com>"
108 @git shortlog -sne | cut -f1 --complement >| $@
110 .PHONY: toc
111 toc:
112 @l2headers=$$(egrep "^## " README.md |cut -d" " -f1 --complement ); \
113 echo "$$l2headers" | while read line; do \
114 anchor=$$(echo "$$line" | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g' | sed 's/\?//g'); \
115 echo "* [$$line](#$$anchor)"; \
116 done