/
build.sh
executable file
·92 lines (76 loc) · 2.85 KB
/
build.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
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2014-2019 Paul Colby <git@colby.id.au>
# SPDX-License-Identifier: GPL-3.0-or-later
while [ $# -gt 0 ]; do
case "$1" in
--app) APP="$2" ; shift ;;
--hook) HOOK="$2" ; shift ;;
--version) VERSION="$2" ; shift ;;
esac
shift
done
if [[ -z "$APP" || -z "$HOOK" || -z "$VERSION" ]]; then
echo "Usage: $0 --app <path> --hook <path> --version <a.b.c>" >&2
exit 1
fi
if [ ! -e "$APP" ]; then
echo "App not found: $APP" 2>&1
exit 1
fi
if [ ! -e "$HOOK" ]; then
echo "Hook not found: $HOOK" 2>&1
exit 1
fi
if [ -n "$GITHUB_RUN_NUMBER" ]; then
VERSION="$VERSION.$GITHUB_RUN_NUMBER"
fi
if [ -e /Volumes/Bipolar ]; then
echo 'Already mounted: /Volumes/Bipolar' 2>&1
exit 1
fi
if [ -e Bipolar.app ]; then
if [ "$1" == '--force' ]; then
rm -rf Bipolar.app
else
echo 'Bipolar.app already exists' 2>&1
echo 'Consider using --force'
exit 1
fi
fi
echo 'Copying Bipolar.app'
cp -a "$APP" .
echo 'Running macdeployqt'
macdeployqt Bipolar.app -dmg || exit
echo 'Coverting disk image to read/writable'
[ -e Bipolar-rw.dmg ] && rm -f Bipolar-rw.dmg
hdiutil convert Bipolar.dmg -format UDRW -o Bipolar-rw.dmg || exit
echo 'Adding hook to disk image'
hdiutil attach Bipolar-rw.dmg || exit
mkdir /Volumes/Bipolar/Hook || exit
cp "$HOOK" /Volumes/Bipolar/Hook/ || exit
otool -L '/Volumes/Bipolar/Hook/QtNetwork' | grep -i qt # Debug info only.
# @todo Consider removing this. Current Qt/OSX buildchain set the ID to
# '@rpath/QtNetwork.framework/Versions/5/QtNetwork', which should work fine.
# Whereas back in 2014 it would typically be set to an absolute path on the
# build machine. Anyway, forcing it to be based on '@executable_path/...'
# still seems to work, but we can probably drop it sometime, with testing.
install_name_tool -id \
'@executable_path/../Frameworks/QtNetwork.framework/Versions/5/QtNetwork' \
'/Volumes/Bipolar/Hook/QtNetwork' || exit
# @todo Consider removing this. It actually does nothing now, since current Qt
# versions set the relevant name to '@rpath/QtCore.framework/Versions/5/QtCore'
# so the following `-change` doesn't find anything to change anymore.
install_name_tool -change \
'/usr/local/Qt-5.5.1/lib/QtCore.framework/Versions/5/QtCore' \
'@executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore' \
'/Volumes/Bipolar/Hook/QtNetwork' || exit
otool -L '/Volumes/Bipolar/Hook/QtNetwork' | grep -i qt # Debug info only.
cp install.command /Volumes/Bipolar/Hook || exit
cp README.txt /Volumes/Bipolar/ || exit
hdiutil detach /Volumes/Bipolar/ || exit
echo 'Converting final disk image'
FINALNAME="Bipolar-$VERSION.dmg"
[ -e "$FINALNAME" ] && rm -f "$FINALNAME"
hdiutil convert Bipolar-rw.dmg -format UDZO -o "$FINALNAME"
echo 'Cleaning up Bipolar.app'
rm -rf Bipolar.app Bipolar.dmg Bipolar-rw.dmg