From 7d54e7dfd073c5f8a90a7055fd99d5dccb5277b6 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Thu, 5 Jul 2018 00:17:26 +0200 Subject: [pkg] get openvpn for osx for now I'm skipping the integration of the build step for openvpn. this is done manually, using the thirdparty scripts in bitmask-dev, and uploaded periodically to downloads.leap.se --- Makefile | 3 +-- osx/generate.py | 41 +++++++++++++++++++++++--------- osx/scripts/postinstall | 2 +- osx/scripts/se.leap.bitmask-helper.plist | 2 +- osx/template-helper.plist | 2 +- osx/template-postinstall | 2 +- 6 files changed, 35 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 5aea1a2..1822453 100755 --- a/Makefile +++ b/Makefile @@ -44,9 +44,8 @@ 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..." + wget -O $(STAGING)/openvpn https://downloads.leap.se/thirdparty/osx/openvpn/openvpn helper_osx: go build -ldflags "-s -w" -o $(STAGING)/$(HELPER_BIN) ./helper upx $(STAGING)/$(HELPER_BIN) diff --git a/osx/generate.py b/osx/generate.py index b8a6bec..aec4ea9 100644 --- a/osx/generate.py +++ b/osx/generate.py @@ -1,5 +1,10 @@ #!/usr/bin/python +# Generate bundles for brandable Bitmask Lite. + +# (c) LEAP Encryption Access Project +# (c) Kali Kaneko 2018 + import os import os.path import shutil @@ -19,6 +24,7 @@ here = os.path.split(os.path.abspath(__file__))[0] ENTRYPOINT = 'bitmask-systray' HELPER = 'bitmask_helper' +OPENVPN = 'openvpn' TEMPLATE_INFO = 'template-info.plist' TEMPLATE_HELPER = 'template-helper.plist' TEMPLATE_PREINSTALL = 'template-preinstall' @@ -51,8 +57,11 @@ vardict = { # utils -def copy_payload(filename): - destfile = APP_PATH + "/Contents/MacOS/" + filename +def copy_payload(filename, destfile=None): + if destfile is None: + destfile = APP_PATH + "/Contents/MacOS/" + filename + else: + destfile = APP_PATH + destfile shutil.copyfile(STAGING + '/' + filename, destfile) cmode = os.stat(destfile).st_mode os.chmod(destfile, cmode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) @@ -72,10 +81,10 @@ generate_from_template(TEMPLATE_INFO, INFO_PLIST, vardict) # 2. Generate PkgInfo # ------------------------------------------- -# XXX is this enough? -f = open(APP_PATH + "/Contents/PkgInfo", "w") -f.write("APPL????") -f.close() + +with open(APP_PATH + "/Contents/PkgInfo", "w") as f: + # is this enough? See what PyInstaller does. + f.write("APPL????") # 3. Copy the binary payloads @@ -83,14 +92,25 @@ f.close() copy_payload(ENTRYPOINT) copy_payload(HELPER) +copy_payload(OPENVPN, destfile='/Contents/Resources/openvpn.leap') -# 4. Copy the app icon +# 4. Copy the app icon from the assets folder # ----------------------------------------------- + shutil.copyfile(ICON, APP_PATH + '/Contents/Resources/app.icns') # 5. Generate the scripts for the installer # ----------------------------------------------- + +# Watch out that, for now, all the brandings are sharing the same helper name. +# This is intentional: I prefer not to have too many root helpers laying around +# until we consolidate a way of uninstalling and/or updating them. +# This also means that only one of the derivatives will work at a given time +# (ie, uninstall bitmask legacy to use riseupvpn). +# If this bothers you, and it should, let's work on improving uninstall and +# updates. + generate_from_template(TEMPLATE_HELPER, HELPER_PLIST, vardict) generate_from_template(TEMPLATE_PREINSTALL, PREINSTALL, vardict) generate_from_template(TEMPLATE_POSTINSTALL, POSTINSTALL, vardict) @@ -100,13 +120,12 @@ generate_from_template(TEMPLATE_POSTINSTALL, POSTINSTALL, vardict) # ----------------------------------------------- # TODO copy the uninstaller script from bitmask-dev # TODO substitute vars -# TODO this is a bit weak for now. +# this is a bit weak procedure for now. # To begin with, this assumes everything is hardcoded into /Applications/APPNAME.app # We could consider moving the helpers into /usr/local/sbin, so that the plist files # always reference there. -# We're all set here. +# We're all set here +# ------------------ print("[+] Output written to dist/{appname}.app".format(appname=APP_NAME)) - - diff --git a/osx/scripts/postinstall b/osx/scripts/postinstall index 88ce4af..93c5a5a 100755 --- a/osx/scripts/postinstall +++ b/osx/scripts/postinstall @@ -5,7 +5,7 @@ LOG=/tmp/bitmask-install.log -chmod +x /Applications/RiseupVPN.app/Contents/MacOS/bitmask-helper +chmod +x /Applications/RiseupVPN.app/Contents/MacOS/bitmask_helper cp se.leap.bitmask-helper.plist /Library/LaunchDaemons/ \ && echo `date` ":: RiseupVPN post-install: copied bitmask-helper Plist." >> $LOG launchctl load /Library/LaunchDaemons/se.leap.bitmask-helper.plist && echo `date` ":: RiseupVPN post-install: loaded bitmask-helper." >> $LOG diff --git a/osx/scripts/se.leap.bitmask-helper.plist b/osx/scripts/se.leap.bitmask-helper.plist index 9af802b..4fc250a 100644 --- a/osx/scripts/se.leap.bitmask-helper.plist +++ b/osx/scripts/se.leap.bitmask-helper.plist @@ -21,6 +21,6 @@ Label se.leap.BitmaskHelper Program - /Applications/RiseupVPN.app/Contents/MacOS/bitmask-helper + /Applications/RiseupVPN.app/Contents/MacOS/bitmask_helper diff --git a/osx/template-helper.plist b/osx/template-helper.plist index e0f23a1..b911c36 100644 --- a/osx/template-helper.plist +++ b/osx/template-helper.plist @@ -21,6 +21,6 @@ Label se.leap.BitmaskHelper Program - /Applications/$app_name.app/Contents/MacOS/bitmask-helper + /Applications/$app_name.app/Contents/MacOS/bitmask_helper diff --git a/osx/template-postinstall b/osx/template-postinstall index aad3cae..038d7cb 100755 --- a/osx/template-postinstall +++ b/osx/template-postinstall @@ -5,7 +5,7 @@ LOG=/tmp/bitmask-install.log -chmod +x /Applications/$app_name.app/Contents/MacOS/bitmask-helper +chmod +x /Applications/$app_name.app/Contents/MacOS/bitmask_helper cp se.leap.bitmask-helper.plist /Library/LaunchDaemons/ \ && echo `date` ":: $app_name post-install: copied bitmask-helper Plist." >> $LOG launchctl load /Library/LaunchDaemons/se.leap.bitmask-helper.plist && echo `date` ":: $app_name post-install: loaded bitmask-helper." >> $LOG -- cgit v1.2.3