From 89bb53fe82c048fc322075b67b1bc7048d4fc53d Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Wed, 4 Jul 2018 22:25:15 +0200 Subject: [pkg] move info.plist to template --- Makefile | 49 +++++++++++++++++++++++++++---- osx/Makefile | 2 ++ osx/generate.py | 76 ++++++++++++++++++------------------------------- osx/template-info.plist | 34 ++++++++++++++++++++++ 4 files changed, 108 insertions(+), 53 deletions(-) create mode 100644 osx/Makefile create mode 100644 osx/template-info.plist diff --git a/Makefile b/Makefile index 7e9ec69..4d3b01d 100755 --- a/Makefile +++ b/Makefile @@ -1,5 +1,11 @@ -SYSTRAY := 0xacab.org/leap/bitmask-systray +SYSTRAY := 0xacab.org/leap/bitmask-systray.git STAGING := staging +SYSTRAY_BIN := bitmask-systray +HELPER_BIN := bitmask_helper + +# ----------------------------------------------------------------------------- +# Windows +# ----------------------------------------------------------------------------- deps_win: choco install -y golang python upx nssm nsis wget 7zip @@ -14,21 +20,54 @@ openvpn_win: copy .\staging\openvpn\openvpn.exe .\staging copy .\staging\openvpn\*.dll .\staging helper_win: - go build -ldflags "-s -w" -o $(STAGING)/bitmask_helper.exe .\helper - upx $(STAGING)/bitmask_helper.exe + 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)/bitmask-systray.exe $(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 -build_osx: + +# ----------------------------------------------------------------------------- +# 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) +build_osx: helper_osx systray_osx echo "[+] building osx..." + mkdir -p dist + make -C 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 +# ----------------------------------------------------------------------------- + staging\nssm.exe: xcopy /y "C:\ProgramData\chocolatey\lib\NSSM\tools\nssm.exe" $(STAGING) diff --git a/osx/Makefile b/osx/Makefile new file mode 100644 index 0000000..9742135 --- /dev/null +++ b/osx/Makefile @@ -0,0 +1,2 @@ +generate: + python ./generate.py diff --git a/osx/generate.py b/osx/generate.py index 8982d94..57aa11e 100644 --- a/osx/generate.py +++ b/osx/generate.py @@ -6,15 +6,20 @@ import shutil import sys import stat +from string import Template + # Variables ---------------------------- # TODO consolidate version string for all builds. VERSION = "0.0.1" APP_NAME = "RiseupVPN" BUNDLE_IDENTIFIER = "se.leap.riseupvpn" -ENTRYPOINT = "bitmask-systray" # Do not edit below -------------------- +TEMPLATE = 'template-info.plist' +ENTRYPOINT = 'bitmask-systray' +HELPER = 'bitmask_helper' + here = os.path.split(os.path.abspath(__file__))[0] APP_PATH = os.path.abspath(here + '/../dist/' + APP_NAME + ".app") @@ -22,57 +27,32 @@ STAGING = os.path.abspath(here + '/../staging/') os.makedirs(APP_PATH + "/Contents/MacOS", exist_ok=True) +INFO_PLIST = APP_PATH + '/Contents/Info.plist' + +vardict = { + 'entrypoint': ENTRYPOINT, + 'info_string': APP_NAME + " " + VERSION, + 'bundle_identifier': BUNDLE_IDENTIFIER, + 'bundle_name': APP_NAME, + 'version': VERSION +} + +template = Template(open(TEMPLATE).read()) +with open(INFO_PLIST, 'w') as output: + output.write(template.safe_substitute(vardict)) -f = open(APP_PATH + "/Contents/Info.plist", "w") -f.write(""" - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - %s - CFBundleGetInfoString - %s - CFBundleIconFile - app.icns - CFBundleIdentifier - %s - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - %s - CFBundlePackageType - APPL - CFBundleShortVersionString - %s - CFBundleSignature - ???? - CFBundleVersion - %s - NSAppleScriptEnabled - YES - NSMainNibFile - MainMenu - NSPrincipalClass - NSApplication - - -""" % ( - ENTRYPOINT, - APP_NAME + " " + VERSION, - BUNDLE_IDENTIFIER, - APP_NAME, - APP_NAME + " " + VERSION, - VERSION)) -f.close() f = open(APP_PATH + "/Contents/PkgInfo", "w") f.write("APPL????") f.close() -entrypoint_file = APP_PATH + "/Contents/MacOS/" + ENTRYPOINT -shutil.copyfile(STAGING + '/' + ENTRYPOINT, entrypoint_file) -oldmode = os.stat(entrypoint_file).st_mode -os.chmod(entrypoint_file, oldmode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) +def copy_payload(filename): + destfile = APP_PATH + "/Contents/MacOS/" + filename + shutil.copyfile(STAGING + '/' + filename, destfile) + cmode = os.stat(destfile).st_mode + os.chmod(destfile, cmode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) + +copy_payload(ENTRYPOINT) +copy_payload(HELPER) + diff --git a/osx/template-info.plist b/osx/template-info.plist new file mode 100644 index 0000000..e67ddcc --- /dev/null +++ b/osx/template-info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + $entrypoint + CFBundleGetInfoString + $info_string + CFBundleIconFile + app.icns + CFBundleIdentifier + $bundle_identifier + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $bundle_name + CFBundlePackageType + APPL + CFBundleShortVersionString + $info_string + CFBundleSignature + ???? + CFBundleVersion + $version + NSAppleScriptEnabled + YES + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + -- cgit v1.2.3