-
-
Notifications
You must be signed in to change notification settings - Fork 842
/
make-package.sh
executable file
·134 lines (101 loc) · 3.6 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
#!/bin/bash
set -u # forbid undefined variables
set -e # forbid command failure
version=$(cat version)
#
# Build
#
echo "make build"
ruby scripts/reduce-logs.rb 'make build' || exit 99
#
# Copy files
#
echo "Copy Files"
rm -rf pkgroot
mkdir -p pkgroot
basedir="pkgroot/Library/Application Support/org.pqrs/Karabiner-Elements"
mkdir -p "$basedir"
cp version "$basedir/package-version"
cp src/scripts/uninstall.sh "$basedir"
cp src/scripts/uninstall_core.sh "$basedir"
cp src/scripts/repair.sh "$basedir"
cp files/complex_modifications_rules_example.json "$basedir"
cp -R "src/apps/AppIconSwitcher/build/Release/Karabiner-AppIconSwitcher.app" "$basedir"
cp -R "src/apps/Menu/build/Release/Karabiner-Menu.app" "$basedir"
cp -R "src/apps/MultitouchExtension/build/Release/Karabiner-MultitouchExtension.app" "$basedir"
cp -R "src/apps/NotificationWindow/build/Release/Karabiner-NotificationWindow.app" "$basedir"
cp -R "src/apps/ServiceManager-Non-Privileged-Agents/build/Release/Karabiner-Elements Non-Privileged Agents.app" "$basedir"
cp -R "src/apps/ServiceManager-Privileged-Daemons/build/Release/Karabiner-Elements Privileged Daemons.app" "$basedir"
basedir="pkgroot/Library/Application Support/org.pqrs/Karabiner-Elements/scripts"
mkdir -p "$basedir"
cp src/scripts/copy_current_profile_to_system_default_profile.applescript "$basedir"
cp src/scripts/remove_system_default_profile.applescript "$basedir"
cp src/scripts/uninstaller.applescript "$basedir"
basedir="pkgroot/Library/Application Support/org.pqrs/Karabiner-Elements/bin"
mkdir -p "$basedir"
cp src/bin/cli/build/Release/karabiner_cli "$basedir"
cp src/core/console_user_server/build/Release/karabiner_console_user_server "$basedir"
cp src/core/grabber/build/Release/karabiner_grabber "$basedir"
cp src/core/session_monitor/build/Release/karabiner_session_monitor "$basedir"
basedir="pkgroot/Applications"
mkdir -p "$basedir"
cp -R "src/apps/EventViewer/build/Release/Karabiner-EventViewer.app" "$basedir"
cp -R "src/apps/SettingsWindow/build/Release/Karabiner-Elements.app" "$basedir"
#
# Sign with Developer ID
#
bash scripts/codesign.sh "pkgroot"
#
# Update file permissions
#
bash "scripts/setpermissions.sh" pkginfo
bash "scripts/setpermissions.sh" pkgroot
chmod 755 pkginfo/Scripts/postinstall
chmod 755 pkginfo/Scripts/preinstall
#
# Create pkg
#
echo "Create pkg"
pkgName="Karabiner-Elements.pkg"
pkgIdentifier="org.pqrs.Karabiner-Elements"
archiveName="Karabiner-Elements-${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
#
# Copy Karabiner-DriverKit-VirtualHIDDevice.pkg.
#
virtualHIDDeviceDmg=$(ls src/vendor/Karabiner-DriverKit-VirtualHIDDevice/dist/Karabiner-DriverKit-VirtualHIDDevice-*.pkg | sort --version-sort | tail -n 1)
cp $virtualHIDDeviceDmg $archiveName/Karabiner-DriverKit-VirtualHIDDevice.pkg
#
# productbuild
#
productbuild \
--distribution pkginfo/Distribution.xml \
--package-path $archiveName \
$archiveName/$pkgName
rm -f $archiveName/Installer.pkg
rm -f $archiveName/Karabiner-DriverKit-VirtualHIDDevice.pkg
#
# Sign
#
echo "Sign with Developer ID"
bash scripts/codesign-pkg.sh $archiveName/$pkgName
#
# Create dmg
#
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 -fs 'Journaled HFS+' -format ULMO
rm -rf $archiveName
chmod 644 $archiveName.dmg