-
-
Notifications
You must be signed in to change notification settings - Fork 52
/
mkMacRESTService.sh
executable file
·119 lines (100 loc) · 3.68 KB
/
mkMacRESTService.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
#!/opt/local/bin/bash
# creates a Mac .pkg installer.
# This script is intended to be called from make mac-dist target
# ensure ~/usr/bin overrides every other TCL installation
PATH=~/usr/bin:$PATH
# check that EcoLab and Tk has been built for extracting a quartz context
if ! nm ecolab/lib/libecolab.a|c++filt|grep NSContext::NSContext|grep T; then
echo "Rebuild EcoLab with MAC_OSX_TK=1"
exit 1
fi
# check that the keychain has been unlocked
if security show-keychain-info|grep "User interaction is not allowed."; then
echo "Unlock the keychain with security unlock-keychain"
exit 1
fi
MAC_DIST_DIR=gui-js/build
version=`cut -f3 -d' ' minskyVersion.h|head -1|tr -d '"'`
if [ $version = '"unknown"' ]; then
version=0.0.0.0
fi
# for some reason arch misreports x64 as i386 on Intel Macs
if [ `arch` = i386 ]; then
target=gui-js/dist/ravel-$version-x64.dmg
else
target=gui-js/dist/ravel-$version-`arch`.dmg
fi
# determine release or beta depending on the number of fields separated by '-' in the version string
numFields=`echo $version|tr - ' '|wc -w`
if [ $numFields -le 1 ]; then
productName=Ravel
else
productName=RavelBeta
fi
rewrite_dylib()
{
local dylib=$1
local target=$2
cp -f $dylib $MAC_DIST_DIR
chmod u+rw $MAC_DIST_DIR/${dylib##*/}
rewrite_dylibs $MAC_DIST_DIR/${dylib##*/}
echo "install_name_tool -change $dylib @loader_path/${dylib##*/} $target"
install_name_tool -change $dylib @loader_path/${dylib##*/} $target
}
rewrite_dylibs()
{
local target=$1
echo "rewrite_dylibs $target"
otool -L $target|grep opt/|cut -f1 -d' '|while read dylib; do
# avoid infinite loops
if [ "${dylib##*/}" == "${target##*/}" ]; then
install_name_tool -change $dylib @loader_path/${dylib##*/} $target
continue
else
rewrite_dylib $dylib $target
fi
done
otool -L $target|grep usr/local|cut -f1 -d' '|while read dylib; do
rewrite_dylib $dylib $target
done
install_name_tool -id @loader_path/${target##*/} $target
}
rm -rf $MAC_DIST_DIR/*.dylib
mkdir -p $MAC_DIST_DIR
rewrite_dylibs $MAC_DIST_DIR/minskyRESTService.node
pushd gui-js
# libravel.so expects certain dylibs in node-addons for legacy
# reasons. Once the Ravel application has moved on, then we can drop
# this, and update the expected location in the Ravel Makefile.
# make a copy here, as creating symlinks in electron-builder seems nigh on impossible
rm -rf node-addons
mkdir node-addons
pushd node-addons
ln -sf ../build/lib*.dylib .
popd
export NX_DAEMON=false # prevent hangs in the following steps
#npm run export:package:mac
npm run build:web
npm run build:electron
npx electron-builder
popd
# npm run export step actually does the code signing. Following is for reference
#codesign -s "Developer ID Application" --options runtime --timestamp --deep $target
# notarytool is introduced from Big Sur onwards, altool has been deprecated.
if [ `sw_vers|grep ProductVersion|tr -s '\t'|cut -f2|cut -f1 -d.` -lt 11 ]; then
xcrun altool --notarize-app --primary-bundle-id Minsky --username [email protected] --password "@keychain:Minsky" --file $target
else
# Note: use xcrun notarytool store-credentials --apple-id \
# [email protected] --team-id 3J798GK5A7 --password "...", and
# specify "NotaryTool" as the profile id. Password can be
# generated at https://appleid.apple.com. You will need to
# generate a new "application password" every time you set up a
# new machine.
xcrun notarytool submit $target --keychain-profile NotaryTool --wait
fi
xcrun stapler staple $target
if [ $? -ne 0 ]; then
echo "Manually staple with:"
echo "xcrun stapler staple $target"
fi
exit