This repository has been archived by the owner on Apr 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 309
/
make-package.sh
executable file
·149 lines (119 loc) · 4.46 KB
/
make-package.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash
# Package build into a signed .dmg file
# set $GEM_HOME/bin/ for CocoaPods.
PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:$GEM_HOME/bin"; export PATH
version=$(cat version)
echo "make clean build"
make clean build | ruby files/extra/reduce-logs.rb
if [ ${PIPESTATUS[0]} -ne 0 ]; then
exit 99
fi
# --------------------------------------------------
# https://developer.apple.com/library/mac/documentation/Darwin/Conceptual/KEXTConcept/KEXTConceptPackaging/packaging_tutorial.html
echo "Copy Files"
rm -rf pkgroot
mkdir -p pkgroot
mkdir -p "pkgroot/Applications"
cp -R "src/core/server/build/Release/Karabiner.app" "pkgroot/Applications"
basedir="pkgroot/Applications/Karabiner.app/Contents/Applications"
mkdir -p "$basedir"
for d in \
"src/util/AXNotifier/build/Release/Karabiner_AXNotifier.app" \
"src/util/EventViewer/build/Release/EventViewer.app" \
"src/util/multitouchextension/build/Release/Karabiner_multitouchextension.app" \
"src/util/preferences/build/Release/Karabiner Preferences.app" \
;
do
cp -R "$d" "$basedir"
done
basedir="pkgroot/Applications/Karabiner.app/Contents/Applications/Utilities"
mkdir -p "$basedir"
cp -R files/Utilities/*.app "$basedir"
basedir="pkgroot/Applications/Karabiner.app/Contents/Library/bin"
mkdir -p "$basedir"
cp -R src/util/cli/build/Release/karabiner "$basedir"
cp -R src/util/read-symbolichotkeys/build/Release/read-symbolichotkeys "$basedir"
basedir="pkgroot/Applications/Karabiner.app/Contents/Library/utilities/bin"
mkdir -p "$basedir"
cp -R src/util/warp-mouse-cursor-position/build/Release/warp-mouse-cursor-position "$basedir"
cp -R src/util/post-hid-event/build/Release/post-hid-event "$basedir"
basedir="pkgroot/Applications/Karabiner.app/Contents/Library/vendor/bin"
mkdir -p "$basedir"
cp -R src/vendor/blueutil/build/Release/blueutil "$basedir"
mkdir -p "pkgroot/Library"
cp -R files/LaunchDaemons "pkgroot/Library"
basedir="pkgroot/Library/Application Support/org.pqrs/Karabiner"
mkdir -p "$basedir"
cp -R src/core/kext/build/Release/Karabiner.kext "$basedir/Karabiner.signed.kext"
cp -R pkginfo/Scripts/preinstall "$basedir/uninstall_core.sh"
for f in \
files/extra/setpermissions.sh \
files/extra/startup.sh \
files/extra/uninstall.sh \
files/extra/uninstaller.applescript \
;
do
cp -R "$f" "$basedir"
done
basedir="pkgroot/Library/Application Support/org.pqrs/Karabiner/updater"
mkdir -p "$basedir"
cp -R src/util/updater/build/Release/Karabiner.app "$basedir"
# Sign with Developer ID
bash files/extra/codesign.sh "pkgroot"
# Setting file permissions.
#
# Note:
# If target files are already exists in system disk,
# PackageMaker uses their permissions.
#
# For example:
# If /Applications/Karabiner.app permission is 0777 by accidental reasons,
# the directory permission will be 0777 in Archive.bom
# even if we set this directory permission to 0755 by setpermissions.sh.
#
# Then, we need to repair file permissions in postinstall script.
# Please also see postinstall.
#
sh "files/extra/setpermissions.sh" pkgroot
sh "files/extra/setpermissions.sh" pkginfo
chmod 755 \
pkginfo/Scripts/postinstall \
pkginfo/Scripts/preinstall \
pkginfo/fixbom.rb
# --------------------------------------------------
echo "Create pkg"
pkgName="Karabiner.sparkle_guided.pkg"
pkgIdentifier="org.pqrs.driver.Karabiner"
archiveName="Karabiner-${version}"
rm -rf $archiveName
mkdir $archiveName
pkgbuild \
--root pkgroot \
--component-plist pkginfo/pkgbuild.plist \
--scripts pkginfo/Scripts \
--identifier $pkgIdentifier \
--version $version \
--install-location "/" \
$archiveName/Installer.pkg
echo "Fix Archive.bom"
pkgutil --expand $archiveName/Installer.pkg $archiveName/expanded
ruby pkginfo/fixbom.rb $archiveName/expanded/Bom pkgroot/
pkgutil --flatten $archiveName/expanded $archiveName/Installer.pkg
rm -r $archiveName/expanded
productbuild \
--distribution pkginfo/Distribution.xml \
--package-path $archiveName \
$archiveName/$pkgName
rm -f $archiveName/Installer.pkg
# --------------------------------------------------
echo "Sign with Developer ID"
bash files/extra/codesign-pkg.sh $archiveName/$pkgName
# --------------------------------------------------
echo "Make Archive"
# Note:
# Some third vendor archiver fails to extract zip archive.
# Therefore, we use dmg instead of zip.
rm -f $archiveName.dmg
hdiutil create -nospotlight $archiveName.dmg -srcfolder $archiveName
rm -rf $archiveName
chmod 644 $archiveName.dmg