3 # appify -- convert non-interactive shell script into Mac OS X applications
4 # Copyright (C) 2010 Adam Backstrom
5 # Copyright (C) 2015 Alexander Barton <alex@barton.de>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 echo "Usage: $0 [-h] <script.sh> <target.app>"
48 BASENAME=`basename "$SCRIPT"`
50 if [ ! -r "$SCRIPT" ]; then
51 echo "$SCRIPT isn't readable!" 1>&2
55 if [ -e "$TARGET" ]; then
56 echo "$TARGET exists!" 1>&2
60 SCRIPTSIZE=$(ls -l "$SCRIPT" | awk '{print $5}')
62 if [ $SCRIPTSIZE -lt 28 ]; then
63 echo -e "Script smaller than size allowed by OS. Please pad to 28 characters." 1>&2
68 # done checking args; create the app
73 mkdir -p "$TARGET/Contents/MacOS" || exit 1
74 mkdir -p "$TARGET/Contents/Resources" || exit 1
76 cat <<EOF >"$TARGET/Contents/Info.plist"
77 <?xml version="1.0" encoding="UTF-8"?>
78 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
81 <key>CFBundleExecutable</key>
82 <string>${BASENAME}</string>
83 <key>CFBundleIconFile</key>
85 <key>CFBundleInfoDictionaryVersion</key>
87 <key>CFBundlePackageType</key>
89 <key>CFBundleSignature</key>
91 <key>CFBundleVersion</key>
97 cp "$SCRIPT" "$TARGET/Contents/MacOS/$BASENAME" || exit 1
98 chmod 755 "$TARGET/Contents/MacOS/$BASENAME" || exit 1