forked from puddletag/puddletag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_macos_app_bundle.sh
executable file
·95 lines (79 loc) · 3.04 KB
/
create_macos_app_bundle.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#! /bin/bash
function create_bundle_structure () {
mkdir -p ${bundleMacOSFolder}
mkdir -p ${bundleResourcesFolder}
}
function provide_app_startup_script () {
cp ${1} ${bundleMacOSFolder}/${1##*/}
chmod 755 ${bundleMacOSFolder}/${1##*/}
}
function provide_app_icon () {
$(which sips) -s format icns ${2} --out ${bundleResourcesFolder}/${1}.icns >> /dev/null
}
function create_Info_plist () {
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > ${1}.app/Contents/Info.plist
echo "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" >> ${1}.app/Contents/Info.plist
echo "<plist version=\"1.0\">" >> ${1}.app/Contents/Info.plist
echo "<dict>" >> ${1}.app/Contents/Info.plist
echo " <key>CFBundleName</key>" >> ${1}.app/Contents/Info.plist
echo " <string>${1}</string>" >> ${1}.app/Contents/Info.plist
echo " <key>CFBundleExecutable</key>" >> ${1}.app/Contents/Info.plist
echo " <string>${2##*/}</string>" >> ${1}.app/Contents/Info.plist
if [[ ${3} != "empty" ]]; then
echo " <key>CFBundleIconFile</key>" >> ${1}.app/Contents/Info.plist
echo " <string>${1}.icns</string>" >> ${1}.app/Contents/Info.plist
fi
echo " <key>CFBundleIdentifier</key>" >> ${1}.app/Contents/Info.plist
echo " <string>com.github.keithgg.puddletag</string>" >> ${1}.app/Contents/Info.plist
echo " <key>CFBundleInfoDictionaryVersion</key>" >> ${1}.app/Contents/Info.plist
echo " <string>6.0</string>" >> ${1}.app/Contents/Info.plist
echo " <key>CFBundlePackageType</key>" >> ${1}.app/Contents/Info.plist
echo " <string>APPL</string>" >> ${1}.app/Contents/Info.plist
echo " <key>CFBundleVersion</key>" >> ${1}.app/Contents/Info.plist
echo " <string>1.0</string>" >> ${1}.app/Contents/Info.plist
echo " <key>CFBundleSignature</key>" >> ${1}.app/Contents/Info.plist
echo " <string>PUDDLE</string>" >> ${1}.app/Contents/Info.plist
echo "</dict>" >> ${1}.app/Contents/Info.plist
echo "</plist>" >> ${1}.app/Contents/Info.plist
}
###################################
# Main routine
###################################
appIcon="empty"
while [[ $# > 1 ]]; do
key="${1}"
case $key in
-n|--name)
appName="${2}"
shift # past argument
;;
-i|--icon)
appIcon="${2}"
shift # past argument
;;
-s|--script)
appStartupScript="${2}"
shift # past argument
;;
*)
echo "Unknown argument \"${key}\"."
show_help_message
shift # past argument
;;
esac
shift # past argument or value
done
if [[ ! $(which sips) ]]; then
appIcon="empty"
fi
# internal vars
bundleMacOSFolder=${appName}.app/Contents/MacOS
bundleResourcesFolder=${appName}.app/Contents/Resources
# create the bundle
create_bundle_structure
provide_app_startup_script ${appStartupScript}
if [[ ${appIcon} != "empty" ]]; then
provide_app_icon ${appName} ${appIcon}
fi
create_Info_plist ${appName} ${appStartupScript} ${appIcon}
# EoF