forked from pqrs-org/Karabiner-Elements
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-package.sh
executable file
·101 lines (76 loc) · 3.1 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
#!/bin/bash
# Package build into a signed .dmg file
PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"; export PATH
version=$(cat version)
echo "make build"
ruby scripts/reduce-logs.rb 'make build' || exit 99
# --------------------------------------------------
echo "Copy Files"
rm -rf pkgroot
mkdir -p pkgroot
basedir="pkgroot/Library/Application Support/org.pqrs/Karabiner-Elements"
mkdir -p "$basedir"
cp version "$basedir"
cp src/scripts/uninstall.sh "$basedir"
cp src/scripts/uninstall_core.sh "$basedir"
cp files/complex_modifications_rules_example.json "$basedir"
cp -R "src/vendor/Karabiner-VirtualHIDDevice/dist" "$basedir/Karabiner-VirtualHIDDevice"
cp -R "src/apps/Menu/build/Release/Karabiner-Menu.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"
basedir="pkgroot/Library/Application Support/org.pqrs/Karabiner-Elements/updater"
mkdir -p "$basedir"
cp -R "src/apps/Updater/build/Release/Karabiner-Elements.app" "$basedir"
mkdir -p "pkgroot/Library"
cp -R files/LaunchDaemons "pkgroot/Library"
cp -R files/LaunchAgents "pkgroot/Library"
basedir="pkgroot/Applications"
mkdir -p "$basedir"
cp -R "src/apps/PreferencesWindow/build/Release/Karabiner-Elements.app" "$basedir"
cp -R "src/apps/EventViewer/build/Release/Karabiner-EventViewer.app" "$basedir"
# Sign with Developer ID
bash scripts/codesign.sh "pkgroot"
sh "scripts/setpermissions.sh" pkginfo
sh "scripts/setpermissions.sh" pkgroot
chmod 755 pkginfo/Scripts/postinstall
chmod 755 pkginfo/Scripts/preinstall
# --------------------------------------------------
echo "Create pkg"
pkgName="Karabiner-Elements.sparkle_guided.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
productbuild \
--distribution pkginfo/Distribution.xml \
--package-path $archiveName \
$archiveName/$pkgName
rm -f $archiveName/Installer.pkg
# --------------------------------------------------
echo "Sign with Developer ID"
bash scripts/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