forked from pqrs-org/Karabiner-archived
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-package.sh
executable file
·116 lines (98 loc) · 3.18 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
#!/bin/sh
version=$(cat version)
packagemaker=/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
pkgName="KeyRemap4MacBook.pkg"
archiveName="KeyRemap4MacBook-${version}"
make clean build || exit $?
# --------------------------------------------------
# http://developer.apple.com/documentation/Darwin/Conceptual/KEXTConcept/KEXTConceptPackaging/packaging_kext.html
echo "Copy Files"
rm -rf pkgroot
mkdir -p pkgroot
mkdir -p "pkgroot/Applications"
cp -R "src/core/server/build/Release/KeyRemap4MacBook.app" "pkgroot/Applications"
basedir="pkgroot/Applications/KeyRemap4MacBook.app/Contents/Applications"
mkdir -p "$basedir"
for d in \
src/util/EventViewer/build/Release/EventViewer.app \
src/util/cli/build/Release/KeyRemap4MacBook_cli.app \
src/util/multitouchextension/build/Release/KeyRemap4MacBook_multitouchextension.app \
src/util/uninstaller/automator/KeyRemap4MacBookUninstaller.app \
;
do
cp -R "$d" "$basedir"
done
basedir="pkgroot/Applications/KeyRemap4MacBook.app/Contents/Library"
mkdir -p "$basedir"
for d in \
src/core/kext/build/Release/KeyRemap4MacBook.kext \
files/scripts \
;
do
cp -R "$d" "$basedir"
done
basedir="pkgroot/Applications/KeyRemap4MacBook.app/Contents/Library/extra"
mkdir -p "$basedir"
cp -R pkginfo/Resources/preflight "$basedir/uninstall_core.sh"
for f in \
files/extra/launchUninstaller.sh \
files/extra/setpermissions.sh \
files/extra/uninstall.sh \
;
do
cp -R "$f" "$basedir"
done
basedir="pkgroot/Library"
mkdir -p "$basedir"
for d in \
files/LaunchDaemons \
files/LaunchAgents \
;
do
cp -R "$d" "$basedir"
done
# Setting file permissions.
#
# Note:
# If target files are already exists in system disk,
# PackageMaker uses their permissions.
#
# For example:
# If /Applications/KeyRemap4MacBook.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 postflight script.
# Please also see postflight.
#
sh "files/extra/setpermissions.sh" pkgroot
# --------------------------------------------------
echo "Exec PackageMaker"
rm -rf $archiveName/$pkgName
mkdir $archiveName
# Note: Don't add --no-recommend option.
# It might break /Library permission.
# (It overwrites /Library permission with pkgroot/Library permission.)
# - Mac OS X 10.6: /Library is 1775
# - Mac OS X 10.7: /Library is 0755
# - Mac OS X 10.8: /Library is 40755
$packagemaker \
--root pkgroot \
--info pkginfo/Info.plist \
--resources pkginfo/Resources \
--title "KeyRemap4MacBook $version" \
--no-relocate \
--discard-forks \
--out $archiveName/$pkgName
# --------------------------------------------------
echo "Fix Archive.bom"
ruby pkginfo/fixbom.rb $archiveName/$pkgName/Contents/Archive.bom pkgroot/
# --------------------------------------------------
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