summaryrefslogtreecommitdiff
path: root/Makefile
blob: 5aea1a2c1a95c45934c9420a5f4768123dc85aae (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
SYSTRAY := 0xacab.org/leap/bitmask-systray.git
STAGING := staging
SYSTRAY_BIN := bitmask-systray
HELPER_BIN := bitmask_helper
APP_NAME := RiseupVPN
BUILD_RELEASE?=no
OSX_CERT = "Developer ID Installer: LEAP Encryption Access Project"
VERSION = $(shell cat version)

# -----------------------------------------------------------------------------
# Windows 
# -----------------------------------------------------------------------------

deps_win:
	choco install -y golang python upx nssm nsis wget 7zip
openvpn_win:
	if not exist staging\openvpn mkdir staging\openvpn
	wget https://build.openvpn.net/downloads/releases/latest/tap-windows-latest-stable.exe -O staging/openvpn/tap-windows.exe
# eventually, this should be built statically and cross compiled in the same pipeline that we build the installer. 
	wget https://downloads.leap.se/thirdparty/windows/openvpn-x86_64-w64-mingw32.tar.bz2 -O staging/openvpn/openvpn.tar.bz2
	7z e -y -ostaging/openvpn/ staging/openvpn/openvpn.tar.bz2
	7z e -y -r -ostaging/openvpn/ staging/openvpn/openvpn.tar *.dll
	7z e -y -r -ostaging/openvpn/ staging/openvpn/openvpn.tar *.exe
	copy .\staging\openvpn\openvpn.exe .\staging
	copy .\staging\openvpn\*.dll .\staging
helper_win:
	go build -ldflags "-s -w" -o $(STAGING)/$(HELPER_BIN).exe .\helper
	upx $(STAGING)/$(HELPER_BIN).exe
systray_win:
	go get -tags "standalone" -u $(SYSTRAY)
	go build -tags "standalone" -ldflags "-H windowsgui -s -w" -o $(STAGING)/$(SYSTRAY_BIN).exe $(SYSTRAY)
build_win: staging\nssm.exe helper_win systray_win
# since it's tedious, I assume you did bootstrap openvpn_win manually already.
	echo "[+] building windows"
	if not exist dist mkdir dist
	make -C win
	"C:\Program Files (x86)\NSIS\makensis.exe" win/RiseupVPN-installer.nsi

# -----------------------------------------------------------------------------
# OSX
# -----------------------------------------------------------------------------

deps_osx:
# TODO - bootstrap homebrew if not there
	brew install python golang make upx
openvpn_osx:
# TODO - the build script is in bitmask-dev/pkg/thirdparty. we can clone from there, or move that stuff here.
# TODO for now we can download it from downloads.leap.se
	echo "[+] downloading openvpn..."
helper_osx:
	go build -ldflags "-s -w" -o $(STAGING)/$(HELPER_BIN) ./helper
	upx $(STAGING)/$(HELPER_BIN)
systray_osx:
	go get -tags "standalone" -u $(SYSTRAY)
	go build -tags "standalone" -o $(STAGING)/$(SYSTRAY_BIN) $(SYSTRAY)
	upx $(STAGING)/$(SYSTRAY_BIN)
bundle_osx:
	mkdir -p dist
	make -C osx
pkg_osx:
	osx/quickpkg --output dist/$(APP_NAME)-$(VERSION)_unsigned.pkg --scripts osx/scripts/ dist/$(APP_NAME).app/
	@if [ $(BUILD_RELEASE) = no ]; then\
		echo "[!] BUILD_RELEASE=no, skipping signature";\
	else\
		echo "[+] Signing the bundle";\
		productsign --sign $(OSX_CERT) dist/$(APP_NAME)-$(VERSION)_unsigned.pkg dist/$(APP_NAME)-$(VERSION).pkg;\
	fi
build_osx: helper_osx systray_osx bundle_osx pkg_osx
	echo "[+] building osx..."

# -----------------------------------------------------------------------------
# Linux 
# -----------------------------------------------------------------------------

build_snap:
# TODO migrate here the snap folder in bitmask-dev.
# We should transition pushing *this one* to edge (via launchpad) for some time, and when it's sufficiently tested
# we can pin this repo as the only source for the snap.
	echo "[+] building snap..."

# -----------------------------------------------------------------------------
# Utils
# -----------------------------------------------------------------------------

clean:
	rm -rf dist/

staging\nssm.exe:
	xcopy /y "C:\ProgramData\chocolatey\lib\NSSM\tools\nssm.exe" $(STAGING)