#!/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 CFBundleName $APPNAME CFBundleDisplayName $APPNAME CFBundleIdentifier $BUNDLE_ID CFBundleVersion $VERSION CFBundlePackageType APPL CFBundleSignature $CREATOR CFBundleExecutable $EXENAME EOF