#!/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 sudo != printf '%s\n' $$(groups) | grep -F sudo .DEFAULT_GOAL = install ifeq (0,$(shell id -u)) ROOT_INSTALL = y else ifneq (,$(sudo)) ROOT_INSTALL = y .DEFAULT_GOAL = install-sudo endif 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 bin_symlink=$(bindir)/firefox install_targets = $(symlink) $(bin_symlink) $(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) install-sudo: $(sudo) $(MAKE) $(MAKEFLAGS) $(MAKECMDGOALS) else install-sudo: @$(sudo) $(MAKE) $(MAKEFLAGS) $(MAKECMDGOALS) maybe_symlink != [ "$$(readlink $(symlink))" != "$(notdir $(destdir))" ] && printf '%%s\n' "$$(symlink)" install: $(maybe_symlink) @: endif $(bin_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: $(.DEFAULT_GOAL) $(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