Add dist and user installation make targets (#23)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
/browserpass
|
||||
/browserpass-*
|
||||
vendor/
|
||||
dist/
|
||||
|
181
Makefile
181
Makefile
@@ -1,3 +1,11 @@
|
||||
PKG_NAME ?= browserpass
|
||||
|
||||
APP_ID = com.github.browserpass.native
|
||||
OS = $(shell uname -s)
|
||||
|
||||
#######################
|
||||
# For local development
|
||||
|
||||
.PHONY: all
|
||||
all: deps browserpass test
|
||||
|
||||
@@ -11,9 +19,6 @@ browserpass: *.go **/*.go
|
||||
browserpass-linux64: *.go **/*.go
|
||||
env GOOS=linux GOARCH=amd64 go build -o $@
|
||||
|
||||
browserpass-windows64: *.go **/*.go
|
||||
env GOOS=windows GOARCH=amd64 go build -o $@.exe
|
||||
|
||||
browserpass-darwinx64: *.go **/*.go
|
||||
env GOOS=darwin GOARCH=amd64 go build -o $@
|
||||
|
||||
@@ -23,6 +28,176 @@ browserpass-openbsd64: *.go **/*.go
|
||||
browserpass-freebsd64: *.go **/*.go
|
||||
env GOOS=freebsd GOARCH=amd64 go build -o $@
|
||||
|
||||
browserpass-windows64: *.go **/*.go
|
||||
env GOOS=windows GOARCH=amd64 go build -o $@.exe
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
go test ./...
|
||||
|
||||
#######################
|
||||
# For official releases
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f browserpass browserpass-*
|
||||
rm -rf dist vendor
|
||||
|
||||
.PHONY: tarball
|
||||
tarball: clean deps
|
||||
$(eval TMPDIR := $(shell mktemp -d))
|
||||
mkdir -p $(TMPDIR)/browserpass-native
|
||||
cp -r * $(TMPDIR)/browserpass-native
|
||||
|
||||
rm -rf $(TMPDIR)/browserpass-native/.git
|
||||
(cd $(TMPDIR) && tar -czf $(TMPDIR)/browserpass-native-src.tar.gz browserpass-native)
|
||||
|
||||
mkdir -p dist
|
||||
cp $(TMPDIR)/browserpass-native-src.tar.gz dist/
|
||||
rm -rf $(TMPDIR)
|
||||
|
||||
.PHONY: dist
|
||||
dist: clean deps tarball browserpass-linux64 browserpass-darwinx64 browserpass-openbsd64 browserpass-freebsd64 browserpass-windows64
|
||||
mkdir -p dist
|
||||
zip -FS dist/browserpass-linux64 browserpass-linux64 browser-files/* Makefile README.md LICENSE
|
||||
zip -FS dist/browserpass-darwinx64 browserpass-darwinx64 browser-files/* Makefile README.md LICENSE
|
||||
zip -FS dist/browserpass-openbsd64 browserpass-openbsd64 browser-files/* Makefile README.md LICENSE
|
||||
zip -FS dist/browserpass-freebsd64 browserpass-freebsd64 browser-files/* Makefile README.md LICENSE
|
||||
zip -FS dist/browserpass-windows64 browserpass-windows64.exe browser-files/* Makefile README.md LICENSE
|
||||
|
||||
for file in dist/*; do \
|
||||
gpg --detach-sign "$$file"; \
|
||||
done
|
||||
|
||||
#######################
|
||||
# For user installation
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
install -Dm755 -t "$(DESTDIR)/usr/bin/" $(PKG_NAME)
|
||||
install -Dm644 -t "$(DESTDIR)/usr/lib/browserpass/" Makefile
|
||||
install -Dm644 -t "$(DESTDIR)/usr/share/licenses/browserpass/" LICENSE
|
||||
install -Dm644 -t "$(DESTDIR)/usr/share/doc/browserpass/" README.md
|
||||
|
||||
install -Dm644 browser-files/chromium-host.json "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json"
|
||||
install -Dm644 browser-files/chromium-policy.json "$(DESTDIR)/usr/lib/browserpass/policies/chromium/$(APP_ID).json"
|
||||
install -Dm644 browser-files/firefox-host.json "$(DESTDIR)/usr/lib/browserpass/hosts/firefox/$(APP_ID).json"
|
||||
|
||||
sed -i "s|%%replace%%|$(DESTDIR)/usr/bin/$(PKG_NAME)|" "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json"
|
||||
sed -i "s|%%replace%%|$(DESTDIR)/usr/bin/$(PKG_NAME)|" "$(DESTDIR)/usr/lib/browserpass/hosts/firefox/$(APP_ID).json"
|
||||
|
||||
# Browser-specific hosts targets
|
||||
|
||||
.PHONY: hosts-chromium
|
||||
hosts-chromium:
|
||||
@case $(OS) in \
|
||||
Linux) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/etc/chromium/native-messaging-hosts/" ;; \
|
||||
Darwin) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Application Support/Chromium/NativeMessagingHosts/" ;; \
|
||||
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
|
||||
esac
|
||||
|
||||
.PHONY: hosts-chromium-user
|
||||
hosts-chromium-user:
|
||||
@case $(OS) in \
|
||||
Linux|OpenBSD|FreeBSD) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/chromium/NativeMessagingHosts/" ;; \
|
||||
Darwin) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/Chromium/NativeMessagingHosts/" ;; \
|
||||
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
|
||||
esac
|
||||
|
||||
.PHONY: hosts-chrome
|
||||
hosts-chrome:
|
||||
@case $(OS) in \
|
||||
Linux) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/etc/opt/chrome/native-messaging-hosts/" ;; \
|
||||
Darwin) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Google/Chrome/NativeMessagingHosts/" ;; \
|
||||
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
|
||||
esac
|
||||
|
||||
.PHONY: hosts-chrome-user
|
||||
hosts-chrome-user:
|
||||
@case $(OS) in \
|
||||
Linux|OpenBSD|FreeBSD) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/google-chrome/NativeMessagingHosts/" ;; \
|
||||
Darwin) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/Google/Chrome/NativeMessagingHosts/" ;; \
|
||||
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
|
||||
esac
|
||||
|
||||
.PHONY: hosts-vivaldi
|
||||
hosts-vivaldi:
|
||||
@case $(OS) in \
|
||||
Linux) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/etc/opt/vivaldi/native-messaging-hosts/" ;; \
|
||||
Darwin) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Application Support/Vivaldi/NativeMessagingHosts/" ;; \
|
||||
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
|
||||
esac
|
||||
|
||||
.PHONY: hosts-vivaldi-user
|
||||
hosts-vivaldi-user:
|
||||
@case $(OS) in \
|
||||
Linux|OpenBSD|FreeBSD) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/vivaldi/NativeMessagingHosts/" ;; \
|
||||
Darwin) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/Vivaldi/NativeMessagingHosts/" ;; \
|
||||
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
|
||||
esac
|
||||
|
||||
.PHONY: hosts-firefox
|
||||
hosts-firefox:
|
||||
@case $(OS) in \
|
||||
Linux) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/firefox/$(APP_ID).json" "/usr/lib/mozilla/native-messaging-hosts/" ;; \
|
||||
Darwin) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/firefox/$(APP_ID).json" "/Library/Application Support/Mozilla/NativeMessagingHosts/" ;; \
|
||||
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
|
||||
esac
|
||||
|
||||
.PHONY: hosts-firefox-user
|
||||
hosts-firefox-user:
|
||||
@case $(OS) in \
|
||||
Linux|OpenBSD|FreeBSD) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/firefox/$(APP_ID).json" "${HOME}/.mozilla/native-messaging-hosts/" ;; \
|
||||
Darwin) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/firefox/$(APP_ID).json" "${HOME}/Library/Application Support/Mozilla/NativeMessagingHosts/" ;; \
|
||||
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
|
||||
esac
|
||||
|
||||
# Browser-specific policies targets
|
||||
|
||||
.PHONY: policies-chromium
|
||||
policies-chromium:
|
||||
@case $(OS) in \
|
||||
Linux) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/etc/chromium/policies/managed/" ;; \
|
||||
Darwin) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Application Support/Chromium/policies/managed/" ;; \
|
||||
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
|
||||
esac
|
||||
|
||||
.PHONY: policies-chromium-user
|
||||
policies-chromium-user:
|
||||
@case $(OS) in \
|
||||
Linux|OpenBSD|FreeBSD) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/chromium/policies/managed/" ;; \
|
||||
Darwin) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/Chromium/policies/managed/" ;; \
|
||||
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
|
||||
esac
|
||||
|
||||
.PHONY: policies-chrome
|
||||
policies-chrome:
|
||||
@case $(OS) in \
|
||||
Linux) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/etc/opt/chrome/policies/managed/" ;; \
|
||||
Darwin) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Google/Chrome/policies/managed/" ;; \
|
||||
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
|
||||
esac
|
||||
|
||||
.PHONY: policies-chrome-user
|
||||
policies-chrome-user:
|
||||
@case $(OS) in \
|
||||
Linux|OpenBSD|FreeBSD) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/google-chrome/policies/managed/" ;; \
|
||||
Darwin) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/Google/Chrome/policies/managed/" ;; \
|
||||
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
|
||||
esac
|
||||
|
||||
.PHONY: policies-vivaldi
|
||||
policies-vivaldi:
|
||||
@case $(OS) in \
|
||||
Linux) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/etc/opt/vivaldi/policies/managed/" ;; \
|
||||
Darwin) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "/Library/Application Support/Vivaldi/policies/managed/" ;; \
|
||||
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
|
||||
esac
|
||||
|
||||
.PHONY: policies-vivaldi-user
|
||||
policies-vivaldi-user:
|
||||
@case $(OS) in \
|
||||
Linux|OpenBSD|FreeBSD) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/.config/vivaldi/policies/managed/" ;; \
|
||||
Darwin) ln -sf "$(DESTDIR)/usr/lib/browserpass/hosts/chromium/$(APP_ID).json" "${HOME}/Library/Application Support/Vivaldi/policies/managed/" ;; \
|
||||
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \
|
||||
esac
|
||||
|
10
browser-files/chromium-host.json
Normal file
10
browser-files/chromium-host.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "com.github.browserpass.native",
|
||||
"description": "Browserpass native component for the Chromium extension",
|
||||
"path": "%%replace%%",
|
||||
"type": "stdio",
|
||||
"allowed_origins": [
|
||||
"chrome-extension://naepdomgkenhinolocfifgehidddafch/",
|
||||
"chrome-extension://klfoddkbhleoaabpmiigbmpbjfljimgb/"
|
||||
]
|
||||
}
|
5
browser-files/chromium-policy.json
Normal file
5
browser-files/chromium-policy.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"ExtensionInstallForcelist": [
|
||||
"naepdomgkenhinolocfifgehidddafch;https://clients2.google.com/service/update2/crx"
|
||||
]
|
||||
}
|
7
browser-files/firefox-host.json
Normal file
7
browser-files/firefox-host.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "com.github.browserpass.native",
|
||||
"description": "Browserpass native component for the Firefox extension",
|
||||
"path": "%%replace%%",
|
||||
"type": "stdio",
|
||||
"allowed_extensions": ["browserpass@maximbaz.com"]
|
||||
}
|
@@ -6,5 +6,5 @@ import "golang.org/x/sys/unix"
|
||||
|
||||
// Pledge allowed system calls
|
||||
func Pledge(promises string) {
|
||||
unix.Pledge(promises, nil)
|
||||
unix.Pledge(promises, "")
|
||||
}
|
||||
|
Reference in New Issue
Block a user