Polish Windows installer (#62)

This commit is contained in:
Maxim Baz
2019-04-20 23:59:27 +02:00
committed by GitHub
parent 54be71414a
commit d3be30743e
4 changed files with 27 additions and 68 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,3 @@
/browserpass /browserpass
/browserpass-* /browserpass-*
dist/ dist/
setup.msi

View File

@@ -1,23 +1,24 @@
BIN ?= browserpass BIN = browserpass
VERSION ?= $(shell cat .version) VERSION = $(shell cat .version)
PREFIX ?= /usr PREFIX ?= /usr
BIN_DIR = $(DESTDIR)$(PREFIX)/bin BIN_DIR = $(DESTDIR)$(PREFIX)/bin
LIB_DIR = $(DESTDIR)$(PREFIX)/lib LIB_DIR = $(DESTDIR)$(PREFIX)/lib
SHARE_DIR = $(DESTDIR)$(PREFIX)/share SHARE_DIR = $(DESTDIR)$(PREFIX)/share
WINDOWS_BIN = C:\\\\\\\\Program Files\\\\\\\\Browserpass\\\\\\\\browserpass-windows64.exe BIN_PATH = $(BIN_DIR)/$(BIN)
BIN_PATH_WINDOWS = C:\\\\\\\\\\\\\\\\Program Files\\\\\\\\\\\\\\\\Browserpass\\\\\\\\\\\\\\\\browserpass-windows64.exe
GO_GCFLAGS := "all=-trimpath=${PWD}" GO_GCFLAGS := "all=-trimpath=${PWD}"
GO_ASMFLAGS := "all=-trimpath=${PWD}" GO_ASMFLAGS := "all=-trimpath=${PWD}"
GO_LDFLAGS := "-extldflags ${LDFLAGS}" GO_LDFLAGS := "-extldflags ${LDFLAGS}"
APP_ID := com.github.browserpass.native APP_ID = com.github.browserpass.native
OS := $(shell uname -s) OS = $(shell uname -s)
# GNU tools # GNU tools
SED := $(shell which gsed 2>/dev/null || which sed 2>/dev/null) SED = $(shell which gsed 2>/dev/null || which sed 2>/dev/null)
INSTALL := $(shell which ginstall 2>/dev/null || which install 2>/dev/null) INSTALL = $(shell which ginstall 2>/dev/null || which install 2>/dev/null)
####################### #######################
# For local development # For local development
@@ -63,16 +64,20 @@ dist: clean browserpass-linux64 browserpass-darwin64 browserpass-openbsd64 brows
$(eval TMP := $(shell mktemp -d)) $(eval TMP := $(shell mktemp -d))
for os in linux64 darwin64 openbsd64 freebsd64 windows64; do \ # Unix installers
for os in linux64 darwin64 openbsd64 freebsd64; do \
mkdir $(TMP)/browserpass-"$$os"-$(VERSION); \ mkdir $(TMP)/browserpass-"$$os"-$(VERSION); \
cp -a browserpass-"$$os"* browser-files Makefile README.md LICENSE $(TMP)/browserpass-"$$os"-$(VERSION); \ cp -a browserpass-"$$os"* browser-files Makefile README.md LICENSE $(TMP)/browserpass-"$$os"-$(VERSION); \
if [ "$$os" = "windows64" ]; then \ (cd $(TMP) && tar -cvzf ${CURDIR}/dist/browserpass-"$$os"-$(VERSION).tar.gz browserpass-"$$os"-$(VERSION)); \
(cd $(TMP) && zip -r ${CURDIR}/dist/browserpass-"$$os"-$(VERSION).zip browserpass-"$$os"-$(VERSION)); \
else \
(cd $(TMP) && tar -cvzf ${CURDIR}/dist/browserpass-"$$os"-$(VERSION).tar.gz browserpass-"$$os"-$(VERSION)); \
fi \
done done
# Windows installer
mkdir $(TMP)/browserpass-windows64-$(VERSION)
cp -a browserpass-windows64.exe browser-files Makefile README.md LICENSE windows-setup.wxs $(TMP)/browserpass-windows64-$(VERSION)
(cd $(TMP)/browserpass-windows64-$(VERSION); \
make BIN_PATH="$(BIN_PATH_WINDOWS)" configure; \
wixl --verbose --arch x64 windows-setup.wxs --output ${CURDIR}/dist/browserpass-windows64-$(VERSION).msi)
rm -rf $(TMP) rm -rf $(TMP)
for file in dist/*; do \ for file in dist/*; do \
@@ -86,12 +91,8 @@ dist: clean browserpass-linux64 browserpass-darwin64 browserpass-openbsd64 brows
.PHONY: configure .PHONY: configure
configure: configure:
$(SED) -i 's|"path": ".*"|"path": "'"$(BIN_DIR)/$(BIN)"'"|' browser-files/chromium-host.json $(SED) -i 's|"path": ".*"|"path": "'"$(BIN_PATH)"'"|' browser-files/chromium-host.json
$(SED) -i 's|"path": ".*"|"path": "'"$(BIN_DIR)/$(BIN)"'"|' browser-files/firefox-host.json $(SED) -i 's|"path": ".*"|"path": "'"$(BIN_PATH)"'"|' browser-files/firefox-host.json
configure-windows:
$(SED) -i 's|"path": ".*"|"path": "'"$(WINDOWS_BIN)"'"|' browser-files/chromium-host.json
$(SED) -i 's|"path": ".*"|"path": "'"$(WINDOWS_BIN)"'"|' browser-files/firefox-host.json
.PHONY: install .PHONY: install
install: install:
@@ -359,6 +360,3 @@ policies-brave-user:
;; \ ;; \
*) echo "The operating system $(OS) is not supported"; exit 1 ;; \ *) echo "The operating system $(OS) is not supported"; exit 1 ;; \
esac esac
setup.msi:
wixl --arch x64 setup.wxs

View File

@@ -10,10 +10,8 @@ This is a host application for [browserpass](https://github.com/browserpass/brow
- [Install via package manager](#install-via-package-manager) - [Install via package manager](#install-via-package-manager)
- [Install manually](#install-manually) - [Install manually](#install-manually)
- [Install on Nix / NixOS](#install-on-nix--nixos) - [Install on Nix / NixOS](#install-on-nix--nixos)
- [Install on Windows](#install-on-windows)
- [Install on Windows through WSL](#install-on-windows-through-wsl) - [Install on Windows through WSL](#install-on-windows-through-wsl)
- [Configure browsers](#configure-browsers) - [Configure browsers](#configure-browsers)
- [Configure browsers on Windows](#configure-browsers-on-windows)
- [Building the app](#building-the-app) - [Building the app](#building-the-app)
- [Build locally](#build-locally) - [Build locally](#build-locally)
- [Build using Docker](#build-using-docker) - [Build using Docker](#build-using-docker)
@@ -62,6 +60,8 @@ Primary key fingerprint: EB4F 9E5A 60D3 2232 BB52 150C 12C8 7A28 FEAC 6B20
Subkey fingerprint: 8053 EB88 879A 68CB 4873 D32B 011F DC52 DA83 9335 Subkey fingerprint: 8053 EB88 879A 68CB 4873 D32B 011F DC52 DA83 9335
``` ```
If you are on Windows, just run the installer, it will install all the necessary files in `C:\Program Files\Browserpass` and it will also [configure browsers](#configure-browsers). You are done!
Unpack the archive. If you decided to compile the application yourself, refer to the [Building the app](#building-the-app) section on how to do so. Once complete, continue with the steps below. Unpack the archive. If you decided to compile the application yourself, refer to the [Building the app](#building-the-app) section on how to do so. Once complete, continue with the steps below.
If you are on macOS, first install the necessary tools: `brew install coreutils gnu-sed`. If you are on macOS, first install the necessary tools: `brew install coreutils gnu-sed`.
@@ -117,18 +117,6 @@ $ nix-env -iA nixpkgs.browserpass # Or nix-env -iA nixos.browserpass on NixOS
$ DESTDIR=~/.nix-profile make -f ~/.nix-profile/lib/browserpass/Makefile <desired make goal> $ DESTDIR=~/.nix-profile make -f ~/.nix-profile/lib/browserpass/Makefile <desired make goal>
``` ```
#### Install on Windows
The Makefile currently does not support Windows, so instead of `sudo make install` you'd have to do a bit of a manual work.
First, copy the contents of the extracted `browserpass-windows64` folder to a permanent location where you want Browserpass to be installed, for the sake of example let's suppose it is `C:\Program Files\Browserpass\`.
Then edit the hosts json files (in our example `C:\Program Files\Browserpass\browser-files\*-host.json`) and replace `%%replace%%` with a full path to `browserpass-windows64.exe` (in our example `C:\\Program Files\\Browserpass\\browserpass-windows64.exe`, **remember to use double backslashes!**).
If you don't have permissions to save the json files, try opening notepad as Administrator first, then open the files.
Finally proceed to the [Configure browsers on Windows](#configure-browsers-on-windows) section.
#### Install on Windows through WSL #### Install on Windows through WSL
If you want to use WSL instead, follow Linux installation steps, then create `%localappdata%\Browserpass\browserpass-wsl.bat` with the following contents: If you want to use WSL instead, follow Linux installation steps, then create `%localappdata%\Browserpass\browserpass-wsl.bat` with the following contents:
@@ -182,41 +170,13 @@ In addition, Chromium-based browsers support the following `make` goals:
| ----------------------------- | ----------------------------------------------------------------------------------------------------------- | | ----------------------------- | ----------------------------------------------------------------------------------------------------------- |
| `make policies-chromium-user` | Automatically install browser extension from Web Store for Chromium browser, for the current user only | | `make policies-chromium-user` | Automatically install browser extension from Web Store for Chromium browser, for the current user only |
| `make policies-chrome-user` | Automatically install browser extension from Web Store for Google Chrome browser, for the current user only | | `make policies-chrome-user` | Automatically install browser extension from Web Store for Google Chrome browser, for the current user only |
| `make policies-brave-user` | Automatically install browser extension from Web Store for Brave browser, for the current user only | | `make policies-brave-user` | Automatically install browser extension from Web Store for Brave browser, for the current user only |
| `make policies-vivaldi-user` | Automatically install browser extension from Web Store for Vivaldi browser, for the current user only | | `make policies-vivaldi-user` | Automatically install browser extension from Web Store for Vivaldi browser, for the current user only |
| `sudo make policies-chromium` | Automatically install browser extension from Web Store for Chromium browser, system-wide | | `sudo make policies-chromium` | Automatically install browser extension from Web Store for Chromium browser, system-wide |
| `sudo make policies-chrome` | Automatically install browser extension from Web Store for Google Chrome browser, system-wide | | `sudo make policies-chrome` | Automatically install browser extension from Web Store for Google Chrome browser, system-wide |
| `sudo make policies-brave` | Automatically install browser extension from Web Store for Brave browser, system-wide | | `sudo make policies-brave` | Automatically install browser extension from Web Store for Brave browser, system-wide |
| `sudo make policies-vivaldi` | Automatically install browser extension from Web Store for Vivaldi browser, system-wide | | `sudo make policies-vivaldi` | Automatically install browser extension from Web Store for Vivaldi browser, system-wide |
#### Configure browsers on Windows
The Makefile currently does not support Windows, so instead of the make goals shown above you'd have to do a bit of a manual work.
Open `regedit` and create a browser-specific subkey, it can be under `HKEY_CURRENT_USER` (`hkcu`) or `HKEY_LOCAL_MACHINE` (`hklm`) depending if you want to configure Browserpass only for your user or for all users respectively:
1. Google Chrome: `hkcu:\Software\Google\Chrome\NativeMessagingHosts\com.github.browserpass.native`
1. Firefox: `hkcu:\Software\Mozilla\NativeMessagingHosts\com.github.browserpass.native`
Inside this subkey create a new property called `(Default)` with the value of the full path to the browser-specific hosts json file, for example:
1. Google Chrome: `C:\Program Files\Browserpass\browser-files\chromium-host.json`
1. Firefox: `C:\Program Files\Browserpass\browser-files\firefox-host.json`
You can automate all of these steps by running the following commands in PowerShell:
```powershell
# Google Chrome
New-Item -Path "hkcu:\Software\Google\Chrome\NativeMessagingHosts\com.github.browserpass.native" -force
New-ItemProperty -Path "hkcu:\Software\Google\Chrome\NativeMessagingHosts\com.github.browserpass.native" -Name "(Default)" -Value "C:\Program Files\Browserpass\browser-files\chromium-host.json"
# Firefox
New-Item -Path "hkcu:\Software\Mozilla\NativeMessagingHosts\com.github.browserpass.native" -force
New-ItemProperty -Path "hkcu:\Software\Mozilla\NativeMessagingHosts\com.github.browserpass.native" -Name "(Default)" -Value "C:\Program Files\Browserpass\browser-files\firefox-host.json"
```
For other browsers, please explore the registry to find the correct location, and peek into Makefile for inspiration.
## Building the app ## Building the app
### Build locally ### Build locally

View File

@@ -13,6 +13,8 @@
<File Id='ChromiumHostJSON' Name='chromium-host.json' Source='browser-files/chromium-host.json' /> <File Id='ChromiumHostJSON' Name='chromium-host.json' Source='browser-files/chromium-host.json' />
<File Id='ChromiumPolicyJSON' Name='chromium-policy.json' Source='browser-files/chromium-policy.json' /> <File Id='ChromiumPolicyJSON' Name='chromium-policy.json' Source='browser-files/chromium-policy.json' />
<File Id='FirefoxHostJSON' Name='firefox-host.json' Source='browser-files/firefox-host.json' /> <File Id='FirefoxHostJSON' Name='firefox-host.json' Source='browser-files/firefox-host.json' />
<File Id='ReadmeMD' Name='README.md' Source='README.md' />
<File Id='LICENSE' Name='LICENSE' Source='LICENSE' />
<RegistryKey Id='ChromeNativeMessaging' Root='HKLM' Key='Software\Google\Chrome\NativeMessagingHosts\com.github.browserpass.native' > <RegistryKey Id='ChromeNativeMessaging' Root='HKLM' Key='Software\Google\Chrome\NativeMessagingHosts\com.github.browserpass.native' >
<RegistryValue Type='string' Name='' Value='C:\Program Files\Browserpass\chromium-host.json'/> <RegistryValue Type='string' Name='' Value='C:\Program Files\Browserpass\chromium-host.json'/>
</RegistryKey> </RegistryKey>
@@ -29,4 +31,4 @@
</Feature> </Feature>
</Product> </Product>
</Wix> </Wix>