add script to build macos .app

This commit is contained in:
liamcottle
2024-05-25 03:10:30 +12:00
parent 2fc30dae5c
commit 622c38f3ef
4 changed files with 42 additions and 0 deletions

12
build_macos.sh Normal file
View File

@@ -0,0 +1,12 @@
#!/bin/sh
# build .app for mac
python setup.py bdist_mac
# copy shell script to .app
for DIR in ./build/ReticulumWebChat-*.app/Contents/MacOS; do
cp ./macos/ReticulumWebChat.sh "$DIR/ReticulumWebChat.sh"
chmod +x "$DIR/ReticulumWebChat.sh"
done
# todo codesign?

23
macos/ReticulumWebChat.sh Normal file
View File

@@ -0,0 +1,23 @@
#!/bin/sh
# references for making a macOS .app that runs a shell script
# https://apple.stackexchange.com/a/407885
# https://github.com/Whisky-App/Whisky/issues/107#issuecomment-1592934039
# https://stackoverflow.com/a/71875958
# https://stackoverflow.com/a/5756763
# get path to directory where this script is currently executing from
# we are expecting this to be "ReticulumWebChat.app/Contents/MacOS"
ABSPATH=$(cd "$(dirname "$0")"; pwd -P)
# path to the actual executable that we want to run as a console application (via Terminal)
EXE="$ABSPATH/ReticulumWebChat"
# open actual executable in terminal
# we also provide a custom storage dir within the user home directory
osascript -e "
tell app \"Terminal\"
do script \"$EXE --storage-dir ~/.reticulum-webchat; exit $?\"
activate
end tell
"

BIN
macos/icon.icns Normal file
View File

Binary file not shown.

View File

@@ -41,5 +41,12 @@ setup(
# use a static upgrade code to allow installer to remove existing files on upgrade
'upgrade_code': '{6c69616d-ae73-460c-88e8-399b3134134e}',
},
'bdist_mac': {
'iconfile': "macos/icon.icns",
'plist_items': [
# we want ReticulumWebChat.app to execute ReticulumWebChat.sh instead of the python binary, as we need to launch it via terminal
('CFBundleExecutable', 'ReticulumWebChat.sh'),
],
},
},
)