summaryrefslogtreecommitdiff
path: root/Makefile
blob: 374c2a55ce3fb6417e30d8105d09ada5dba6b020 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/usr/bin/make -f
ifeq (beta,$(MAKECMDGOALS))
product=-beta
else
ifeq (nightly,$(MAKECMDGOALS))
product=-nightly
else
ifeq (stable,$(MAKECMDGOALS))
product=
else
ifeq (,$(MAKECMDGOALS))
product=
else
$(error Incorrect target specified.  Specify at most one argument of "beta", "nightly", or "stable")
endif
endif
endif
endif

ifeq (0,$(shell id -u))
ROOT_INSTALL = y
endif

ifdef ROOT_INSTALL
optdir=/opt
bindir=/usr/local/bin
applications_dir=/usr/share/applications
alternatives=alternatives
else
optdir=$(HOME)/.local/opt
bindir=$(HOME)/.local/bin
applications_dir=$(HOME)/.local/share/applications
alternatives=

$(warning Warning: You are not root.  Installing into $(optdir))
endif

os=linux64
lang=en-US
orig_url="https://download.mozilla.org/?product=firefox$(product)-latest-ssl&os=$(os)&lang=$(lang)"

url := $(shell curl -sI $(orig_url) | sed -n 's/^Location: //p')
$(if $(url),,$(error Could not determine url.  orig_url=$(orig_url)))

# Use a path that only trusted users can write into.  So not /tmp.
dldir=$(optdir)

tarball=$(dldir)/$(notdir $(url))
destdir=$(optdir)/$(notdir $(tarball:.tar.bz2=))
tempdir=$(destdir)~tmp

symlink=$(optdir)/firefox
desktop_file=$(applications_dir)/firefox.desktop
global_symlink=$(bindir)/firefox

.DEFAULT_GOAL = install

install_targets = $(symlink) $(global_symlink) $(desktop_file) $(alternatives)
.PHONY: install beta nightly stable $(install_targets)
ifndef UPDATE
# 'sudo make UPDATE=y' is suitable to run from cron (no output if nothing
# changed upstream)
install: $(install_targets)
else
maybe_symlink := $(if $(shell [ "$$(readlink $(symlink))" != "$(notdir $(destdir))" ] && echo y),$(symlink))
install: $(maybe_symlink)
	@:
endif

$(global_symlink):
	mkdir -p $(dir $@)
	ln -sf $(optdir)/firefox/firefox $(dir $@)

alternatives:
	update-alternatives --install /usr/bin/x-www-browser x-www-browser $(optdir)/firefox/firefox 200
	update-alternatives --set x-www-browser $(optdir)/firefox/firefox

$(desktop_file):
	: write file $@ $(file >$@,$(desktop_file_contents))
ifdef ROOT_INSTALL
	if command -v update-desktop-database; then update-desktop-database; fi
endif

$(symlink): $(destdir)
	ln -srnf $(destdir) $@

beta nightly stable: install

$(destdir): $(tarball)
	mkdir -p $(tempdir)
	tar -C $(tempdir) --strip-components=1 -jxf $<
	mv -T $(tempdir) $(destdir)
	@rm $(tarball) || true

.INTERMEDIATE: $(tarball)

$(tarball):
	mkdir -p $(dir $@)
	curl -C- -o $@.partial $(url)
	mv $@.partial $@

FIREFOX_DIR=$(optdir)/firefox
FIREFOX_EXEC=$(FIREFOX_DIR)/firefox
FIREFOX_ICON=$(FIREFOX_DIR)/browser/chrome/icons/default/default128.png

define desktop_file_contents
[Desktop Entry]
Name=Firefox
Name[bg]=Firefox
Name[ca]=Firefox
Name[cs]=Firefox
Name[el]=Firefox
Name[es]=Firefox
Name[fa]=Firefox
Name[fi]=Firefox
Name[fr]=Firefox
Name[hu]=Firefox
Name[it]=Firefox
Name[ja]=Firefox
Name[ko]=Firefox
Name[nb]=Firefox
Name[nl]=Firefox
Name[nn]=Firefox
Name[no]=Firefox
Name[pl]=Firefox
Name[pt]=Firefox
Name[pt_BR]=Firefox
Name[ru]=Firefox
Name[sk]=Firefox
Name[sv]=Firefox
Comment=Browse the World Wide Web
Comment[bg]=Сърфиране в Мрежата
Comment[ca]=Navegueu per el web
Comment[cs]=Prohlížení stránek World Wide Webu
Comment[de]=Im Internet surfen
Comment[el]=Περιηγηθείτε στον παγκόσμιο ιστό
Comment[es]=Navegue por la web
Comment[fa]=صفحات شبکه جهانی اینترنت را مرور نمایید
Comment[fi]=Selaa Internetin WWW-sivuja
Comment[fr]=Navigue sur Internet
Comment[hu]=A világháló böngészése
Comment[it]=Esplora il web
Comment[ja]=ウェブを閲覧します
Comment[ko]=웹을 돌아 다닙니다
Comment[nb]=Surf på nettet
Comment[nl]=Verken het internet
Comment[nn]=Surf på nettet
Comment[no]=Surf på nettet
Comment[pl]=Przeglądanie stron WWW 
Comment[pt]=Navegue na Internet
Comment[pt_BR]=Navegue na Internet
Comment[ru]=Обозреватель Всемирной Паутины
Comment[sk]=Prehliadanie internetu
Comment[sv]=Surfa på webben
GenericName=Web Browser
GenericName[bg]=Интернет браузър
GenericName[ca]=Navegador web
GenericName[cs]=Webový prohlížeč
GenericName[de]=Webbrowser
GenericName[el]=Περιηγητής ιστού
GenericName[es]=Navegador web
GenericName[fa]=مرورگر اینترنتی
GenericName[fi]=WWW-selain
GenericName[fr]=Navigateur Web
GenericName[hu]=Webböngésző
GenericName[it]=Browser Web
GenericName[ja]=ウェブ・ブラウザ
GenericName[ko]=웹 브라우저
GenericName[nb]=Nettleser
GenericName[nl]=Webbrowser
GenericName[nn]=Nettlesar
GenericName[no]=Nettleser
GenericName[pl]=Przeglądarka WWW
GenericName[pt]=Navegador Web
GenericName[pt_BR]=Navegador Web
GenericName[ru]=Интернет-браузер
GenericName[sk]=Internetový prehliadač
GenericName[sv]=Webbläsare
X-GNOME-FullName=Firefox Web Browser
X-GNOME-FullName[bg]=Интернет браузър (Firefox)
X-GNOME-FullName[ca]=Navegador web Firefox
X-GNOME-FullName[cs]=Firefox Webový prohlížeč
X-GNOME-FullName[el]=Περιηγήτης Ιστού Firefox
X-GNOME-FullName[es]=Navegador web Firefox
X-GNOME-FullName[fa]=مرورگر اینترنتی Firefox
X-GNOME-FullName[fi]=Firefox-selain
X-GNOME-FullName[fr]=Navigateur Web Firefox
X-GNOME-FullName[hu]=Firefox webböngésző
X-GNOME-FullName[it]=Firefox Browser Web
X-GNOME-FullName[ja]=Firefox ウェブ・ブラウザ
X-GNOME-FullName[ko]=Firefox 웹 브라우저
X-GNOME-FullName[nb]=Firefox Nettleser
X-GNOME-FullName[nl]=Firefox webbrowser
X-GNOME-FullName[nn]=Firefox Nettlesar
X-GNOME-FullName[no]=Firefox Nettleser
X-GNOME-FullName[pl]=Przeglądarka WWW Firefox
X-GNOME-FullName[pt]=Firefox Navegador Web
X-GNOME-FullName[pt_BR]=Navegador Web Firefox
X-GNOME-FullName[ru]=Интернет-браузер Firefox
X-GNOME-FullName[sk]=Internetový prehliadač Firefox
X-GNOME-FullName[sv]=Webbläsaren Firefox
Exec=$(FIREFOX_EXEC) %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=$(FIREFOX_ICON)
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/vnd.mozilla.xul+xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;
StartupWMClass=Firefox
StartupNotify=true
endef