diff --git a/Makefile b/Makefile index 950c6fdcc2aab9306fb7ee820aa0c31bb58c436b..ec642b2a76bac7156d82303441edfbccaeeec05c 100644 --- a/Makefile +++ b/Makefile @@ -57,7 +57,7 @@ dependsCygwin: @choco install -y golang python nssm nsis wget 7zip build: - $(MAKE) _buildparts + echo "XBUILD>", ${XBUILD} ifeq (${XBUILD}, yes) $(MAKE) build_cross_win $(MAKE) build_cross_osx @@ -68,11 +68,14 @@ else ifeq (${XBUILD}, win) else ifeq (${XBUILD}, osx) $(MAKE) build_cross_osx $(MAKE) _build_done +else + $(MAKE) _buildparts endif _buildparts: $(foreach path,$(wildcard cmd/*),build_$(patsubst cmd/%,%,$(path))) build_%: + @echo "PLATFORM: ${PLATFORM}" @mkdir -p build/bin/${PLATFORM} go build -tags $(TAGS) -ldflags "-s -w -X main.version=`git describe --tags` ${EXTRA_LDFLAGS}" -o build/bin/${PLATFORM}/$* ./cmd/$* -@rm -rf build/${PROVIDER}/staging/${PLATFORM} && mkdir -p build/${PROVIDER}/staging/${PLATFORM} @@ -91,7 +94,11 @@ CROSS_WIN_FLAGS = CGO_ENABLED=1 GOARCH=386 GOOS=windows CC="/usr/bin/i686-w64-mi PLATFORM_WIN = PLATFORM=windows EXTRA_LDFLAGS_WIN = EXTRA_LDFLAGS="-H windowsgui" build_cross_win: + @echo "[+] Cross-building for windows..." $(CROSS_WIN_FLAGS) $(PLATFORM_WIN) $(EXTRA_LDFLAGS_WIN) $(MAKE) _buildparts + # workaround for helper: we use the go compiler + @echo "[+] Compiling helper with the Go compiler to work around missing stdout bug..." + cd cmd/bitmask-helper && GOOS=windows GOARCH=386 go build -ldflags "-X main.version=`git describe --tags` -H windowsgui" -o ../../build/bin/windows/bitmask-helper-go CROSS_OSX_FLAGS = MACOSX_DEPLOYMENT_TARGET=10.10 CGO_ENABLED=1 GOOS=darwin CC="o64-clang" PLATFORM_OSX = PLATFORM=darwin diff --git a/branding/templates/makefile/Makefile b/branding/templates/makefile/Makefile index 859118f74d603640d1ffb3e76c002da9ec706fbe..5994e19e0ceffdabf3b66c742e750d364fe1707a 100755 --- a/branding/templates/makefile/Makefile +++ b/branding/templates/makefile/Makefile @@ -37,7 +37,8 @@ else pkg_win: staging/openvpn/openvpn.exe echo "[+] building windows" cp ../bin/windows/bitmask-vpn staging/bitmask-vpn.exe - cp ../bin/windows/bitmask-helper staging/bitmask_helper.exe + #cp ../bin/windows/bitmask-helper staging/bitmask_helper.exe + cp ../bin/windows/bitmask-helper-go staging/helper.exe makensis windows/$(APPNAME)-installer.nsi mv dist/$(APPNAME)-$(VERSION).exe ../../deploy/ endif diff --git a/branding/templates/windows/payload/install b/branding/templates/windows/payload/install index da9a19506bd7f78094afd81da827ed1ffaf4f619..280703ac869d496f1567105fbe0413d8911bb071 100755 --- a/branding/templates/windows/payload/install +++ b/branding/templates/windows/payload/install @@ -1,4 +1,4 @@ -..\staging\bitmask_helper.exe +..\staging\helper.exe ..\staging\bitmask-vpn.exe ..\staging\libcrypto-1_1-x64.dll ..\staging\liblzo2-2.dll diff --git a/branding/templates/windows/payload/uninstall b/branding/templates/windows/payload/uninstall index f0a1687ecd8c12b752e725ccf0445d8f2dfff8c6..bb6cf3965ec033ea727c74d277e67221f38ed27e 100755 --- a/branding/templates/windows/payload/uninstall +++ b/branding/templates/windows/payload/uninstall @@ -1,13 +1,14 @@ icon.ico -openssl.exe -openvpn.exe -ssleay32.dll -libeay32.dll -liblzo2-2.dll -libpkcs11-helper-1.dll +openssl.exe +openvpn.exe +ssleay32.dll +libeay32.dll +liblzo2-2.dll +libpkcs11-helper-1.dll libcrypto-1_1-x64.dll libssl-1_1-x64.dll padlock.dll -bitmask-helper.exe +bitmask_helper.exe bitmask-vpn.exe tap-windows.exe +helper.exe diff --git a/branding/templates/windows/template.nsi b/branding/templates/windows/template.nsi index f6a908db32aa8a29fcf0f9940117b2d8f877b3ff..9c319d05f032aca344a7466c9b0bcb4ff241d1fe 100755 --- a/branding/templates/windows/template.nsi +++ b/branding/templates/windows/template.nsi @@ -61,6 +61,11 @@ Section "InstallFiles" Delete 'C:\Program Files\$applicationName\bitmask_helper.exe' IfErrors 0 noErrorHelper + DetailPrint "Trying to uninstall new helper..." + ClearErrors + Delete 'C:\Program Files\$applicationName\helper.exe' + IfErrors 0 noErrorHelper + ; uninstalling old nssm helper - could fail if it isn't there, or if nssm is not there... ClearErrors DetailPrint "Trying to uninstall an old style helper..." @@ -77,6 +82,12 @@ Section "InstallFiles" IfErrors 0 noErrorHelper DetailPrint "Failed to stop new-style helper, maybe it was not there" + ClearErrors + DetailPrint "Trying to uninstall a new style helper..." + ExecWait '"$INSTDIR\helper.exe" stop' + IfErrors 0 noErrorHelper + DetailPrint "Failed to stop new-style helper, maybe it was not there" + noErrorHelper: ; now we try to delete the systray, locked by the app - just to know if another instance of FoobarVPN is running. @@ -120,14 +131,14 @@ SectionEnd Section "InstallService" DetailPrint "Trying to uninstall previous versions of the (new) helper..." ClearErrors - ExecWait '"$INSTDIR\bitmask_helper.exe" stop' - ExecWait '"$INSTDIR\bitmask_helper.exe" remove' + ExecWait '"$INSTDIR\helper.exe" stop' + ExecWait '"$INSTDIR\helper.exe" remove' IfErrors 0 noError DetailPrint "Could not uninstall a previous version of the (new) helper!" noError: - ExecWait '"$INSTDIR\bitmask_helper.exe" install' - ExecWait '"$INSTDIR\bitmask_helper.exe" start' + ExecWait '"$INSTDIR\helper.exe" install' + ExecWait '"$INSTDIR\helper.exe" start' SectionEnd Section /o "TAP Virtual Ethernet Adapter" SecTAP @@ -147,9 +158,11 @@ Section "Uninstall" ExecWait '"$INSTDIR\bitmask_helper.exe" stop' ExecWait '"$INSTDIR\bitmask_helper.exe" remove' + ExecWait '"$INSTDIR\helper.exe" stop' + ExecWait '"$INSTDIR\helper.exe" remove' + ; now we (try to) remove everything else. kill it with fire! Delete $INSTDIR\nssm.exe ; probably does not exist anymore, but just in case - Delete $INSTDIR\bitmask_helper.exe Delete $INSTDIR\readme.txt Delete $INSTDIR\helper.log Delete $INSTDIR\openvpn.log diff --git a/docker/Makefile b/docker/Makefile index bdcc2b890ea26175b7b8418a4f504af6425f21cc..80ca9dd73cf54ade1e96c1e3bdb06dca5c429196 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -14,10 +14,10 @@ package_win: docker run \ -e XBUILD=win \ -e PROVIDER=riseup \ - -v `python3 -c 'import os; print(os.path.abspath(".."))'`:/bitmask-vpn.orig \ + -v `python3 -c 'import os; print(os.path.abspath(".."))'`:/bitmask-vpn.host \ --cpus="4" \ -it --rm \ $(REGISTRY)/$(IMAGE):latest \ /builder.sh shell: - docker run -v `python3 -c 'import os; print(os.path.abspath(".."))'`:/bitmask-vpn.orig -it --rm $(REGISTRY)/$(IMAGE):latest /bin/bash + docker run -v `python3 -c 'import os; print(os.path.abspath(".."))'`:/bitmask-vpn.host -it --rm $(REGISTRY)/$(IMAGE):latest /bin/bash diff --git a/docker/builder.sh b/docker/builder.sh index dad78001cc3d2fa100ea4047c247ce67a2550045..2767d61fa9a8eb4145e75ebded34fa3559e6e242 100755 --- a/docker/builder.sh +++ b/docker/builder.sh @@ -1,9 +1,11 @@ #!/bin/bash set -e -export DESTDIR=/bitmask-vpn.orig/deploy/ -rm -rf /bitmask-vpn -cp -r /bitmask-vpn.orig /bitmask-vpn -cd /bitmask-vpn +export HOSTDIR=/bitmask-vpn.host +export GUESTDIR=/bitmask-vpn +export DESTDIR="${HOSTDIR}"/deploy/ +rm -rf "${GUESTDIR}" +cp -r "${HOSTDIR}" "${GUESTDIR}" +cd "${GUESTDIR}" make prepare make build case $XBUILD in @@ -17,4 +19,4 @@ case $XBUILD in make packages ;; esac -cp /bitmask-vpn/deploy/* $DESTDIR +cp "${GUESTDIR}"/deploy/* $DESTDIR diff --git a/pkg/helper/windows.go b/pkg/helper/windows.go index 08b01aadd0c3e3016141ad8a25ea7783f1af0206..28727028593fb0c6c9e4173adba4e2410eb7684f 100644 --- a/pkg/helper/windows.go +++ b/pkg/helper/windows.go @@ -30,7 +30,7 @@ import ( ) const ( - svcName = config.BinaryName + `-helper` + svcName = config.BinaryName + `-helper-v2` appPath = `C:\Program Files\` + config.ApplicationName + `\` LogFolder = appPath openvpnPath = appPath + `openvpn.exe`