diff options
author | Ian C <ianc@noddybox.co.uk> | 2024-01-10 10:45:25 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2024-01-10 10:45:25 +0000 |
commit | 740b89c64f16a5d0fda344366985b5754e594501 (patch) | |
tree | c3a7f4518dc08bbde0ad2c1f137323144f7ca51b /exe2app.bash |
Initial attempt. Icons not working.
Diffstat (limited to 'exe2app.bash')
-rwxr-xr-x | exe2app.bash | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/exe2app.bash b/exe2app.bash new file mode 100755 index 0000000..737027b --- /dev/null +++ b/exe2app.bash @@ -0,0 +1,95 @@ +#!/bin/bash + +SCR=$(basename $0) + +unset IFS + +function usage() +{ + echo "$SCR: usage $SCR -x executable " + echo " -i icon" + echo " -o app" + echo " -v version" + echo " -n bundle_identifier" + echo " -c creator_code (4 chars)" +} + +function log() +{ + echo "$SCR: $*" +} + +while getopts x:i:o:v:n:c: arg ; do + case "$arg" in + x) + EXE="$OPTARG" + ;; + i) + ICON="$OPTARG" + ;; + o) + APP="$OPTARG".app + ;; + v) + VERSION="$OPTARG" + ;; + n) + BUNDLE_ID="$OPTARG" + ;; + c) + CREATOR="$OPTARG" + ;; + *) + usage + exit 1 + ;; + esac +done + +if [ -z "$EXE" -o -z "$ICON" -o -z "$APP" \ + -o -z "$VERSION" -o -z "$BUNDLE_ID" -o -z "$CREATOR" ] ; then + usage + exit 1 +fi + +APPNAME=$(basename "$APP" .app) +EXENAME=$(basename "$EXE") + +log Generating $APPNAME from $EXE + +mkdir -p "$APP/Contents" +mkdir -p "$APP/Contents/MacOS" +mkdir -p "$APP/Contents/MacOS/lib" + +# Copy executable +# +cp "$EXE" "$APP/Contents/MacOS" + +# Create icons +# +convert $ICON -resize 512x512 "$APP/Contents/$APPNAME.png" + +# Create the plist file +# +cat > "$APP/Contents/Info.plist" << EOF +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> +<key>CFBundleName</key> +<string>$APPNAME</string> +<key>CFBundleDisplayName</key> +<string>$APPNAME</string> +<key>CFBundleIdentifier</key> +<string>$BUNDLE_ID</string> +<key>CFBundleVersion</key> +<string>$VERSION</string> +<key>CFBundlePackageType</key> +<string>APPL</string> +<key>CFBundleSignature</key> +<string>$CREATOR</string> +<key>CFBundleExecutable</key> +<string>$EXENAME</string> +</dict> +</plist> +EOF |