diff --git a/install/build_osx.sh b/install/build_osx.sh index a8259a43..44883fdf 100755 --- a/install/build_osx.sh +++ b/install/build_osx.sh @@ -9,12 +9,17 @@ rm -rf $ROOT/build $ROOT/dist &>/dev/null 2>&1 # build the .app echo Building OnionShare.app -pyinstaller install/pyinstaller.spec +pyinstaller $ROOT/install/pyinstaller.spec + +# create a symlink of onionshare-gui called onionshare, for the CLI version +cd $ROOT/dist/OnionShare.app/Contents/MacOS +ln -s onionshare-gui onionshare +cd $ROOT if [ "$1" = "--release" ]; then mkdir -p dist - APP_PATH="build/OnionShare.app" - PKG_PATH="dist/OnionShare.pkg" + APP_PATH="$ROOT/dist/OnionShare.app" + PKG_PATH="$ROOT/dist/OnionShare.pkg" IDENTITY_NAME_APPLICATION="Developer ID Application: Micah Lee" IDENTITY_NAME_INSTALLER="Developer ID Installer: Micah Lee" diff --git a/install/pyinstaller.spec b/install/pyinstaller.spec index de88dd09..1b8be28c 100644 --- a/install/pyinstaller.spec +++ b/install/pyinstaller.spec @@ -6,7 +6,7 @@ p = platform.system() version = open('share/version.txt').read().strip() a = Analysis( - ['scripts/onionshare-gui'], + ['scripts/onionshare-pyinstaller'], pathex=['.'], binaries=None, datas=[ @@ -33,7 +33,7 @@ exe = EXE( pyz, a.scripts, exclude_binaries=True, - name='onionshare', + name='onionshare-gui', debug=False, strip=False, upx=True, @@ -46,7 +46,7 @@ coll = COLLECT( a.datas, strip=False, upx=True, - name='onionshare') + name='onionshare-gui') if p == 'Darwin': app = BUNDLE( diff --git a/install/scripts/onionshare-pyinstaller b/install/scripts/onionshare-pyinstaller new file mode 100644 index 00000000..c9552120 --- /dev/null +++ b/install/scripts/onionshare-pyinstaller @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +OnionShare | https://onionshare.org/ + +Copyright (C) 2017 Micah Lee + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" +import sys, os, platform + +# In macOS, allow both CLI and GUI depending on the filename of the binary +# being executed +if platform.system() == 'Darwin': + # If the binary being executed is called 'onionshare', use CLI + basename = os.path.basename(sys.argv[0]) + if basename == 'onionshare': + import onionshare + onionshare.main() + + # Otherwise, use GUI + else: + import onionshare_gui + onionshare_gui.main() + +# Unfortunately this trick won't work in Windows because I want to set +# console=False in the PyInstaller spec file, so there isn't a command prompt +# open in the background every you run the GUI. Hopefully Windows can get +# a built-in CLI when PyInstaller 3.3 comes out: +# https://pyinstaller.readthedocs.io/en/stable/spec-files.html#multipackage-bundles +else: + import onionshare_gui + onionshare_gui.main()