forked from FedoraQt/MediaWriter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·124 lines (107 loc) · 4.44 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
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
#!/bin/bash
set -x
set -e
# TODO: add your Qt location into LD_LIBRARY_PATH
PATH="/usr/local/opt/qt/6.5.2/macos/bin:$PATH"
LD_LIBRARY_PATH="/usr/local/opt/qt/6.5.2/macos/lib:$LD_LIBRARY_PATH"
Qt6_DIR="/usr/local/opt/qt/6.5.2/macos"
# === SIGNING ===
# TODO: set in order to sign binaries
DEVELOPER_ID=""
NOTARIZATION_KEYCHAIN_ITEM="XCODE_NOTARY"
NOTARIZATION_ITUNES_ORGID=""
NOTARIZATION_EMAIL=""
pushd $(dirname $0) >/dev/null
SCRIPTDIR=$(pwd -P)
popd >/dev/null
cd "${SCRIPTDIR}/../.."
if [[ "$TAG_NAME" == "" ]]; then
VERSION=$(git rev-parse HEAD | cut -c 1-8)
else
VERSION="$TAG_NAME"
fi
INSTALLER="$SCRIPTDIR/FedoraMediaWriter-osx-$VERSION.dmg"
function install_deps() {
brew install cmake
brew install xz
mkdir -p /usr/local/opt/qt
pushd /usr/local/opt/qt >/dev/null
pip3 install aqtinstall
aqt install-qt mac desktop 6.5.2 -m qtimageformats
popd >/dev/null
}
function build() {
rm -fr "build"
mkdir -p "build"
echo "=== Building ==="
pushd build >/dev/null
cmake .. -DCREATE_STANDALONE_MAC_BUNDLE=true
make -j9
popd >/dev/null
}
function deps() {
pushd build >/dev/null
echo "=== Checking unresolved library deps ==="
# Look at the binaries and search for dynamic library dependencies that are not included on every system
# So far, this finds only liblzma but in the future it may be necessary for more libs
for binary in "helper" "Fedora Media Writer"; do
otool -L "src/app/Fedora Media Writer.app/Contents/MacOS/$binary" |\
grep -E "^\s" | grep -Ev "AppKit|Metal|Foundation|OpenGL|AGL|DiskArbitration|IOKit|ImageIO|libc\+\+|libobjc|libSystem|@rpath|$(basename $binary)" |\
sed -e 's/[[:space:]]\([^[:space:]]*\).*/\1/' |\
while read library; do
if [[ ! $library == @loader_path/* ]]; then
echo "Copying $(basename $library)"
# fix for newer version of Mac
if [[ "$library" == "/usr/lib/liblzma.5.dylib" && ! -e "$library" ]]; then
cp "/usr/local/lib/liblzma.5.dylib" "src/app/Fedora Media Writer.app/Contents/Frameworks"
else
cp $library "src/app/Fedora Media Writer.app/Contents/Frameworks"
fi
install_name_tool -change "$library" "@executable_path/../Frameworks/$(basename ${library})" "src/app/Fedora Media Writer.app/Contents/MacOS/$binary"
fi
done
done
popd >/dev/null
}
function sign() {
pushd build >/dev/null
echo "=== Signing the package ==="
# sign all frameworks and then the package
find src/app/Fedora\ Media\ Writer.app -name "*framework" | while read framework; do
codesign -s "$DEVELOPER_ID" --deep -v -f "$framework/Versions/Current/" -o runtime
done
codesign -s "$DEVELOPER_ID" --deep -v -f src/app/Fedora\ Media\ Writer.app/Contents/MacOS/Fedora\ Media\ Writer -o runtime
codesign -s "$DEVELOPER_ID" --deep -v -f src/app/Fedora\ Media\ Writer.app/Contents/MacOS/helper -o runtime
codesign -s "$DEVELOPER_ID" --deep -v -f src/app/Fedora\ Media\ Writer.app/ -o runtime
popd >/dev/null
}
function dmg() {
pushd build >/dev/null
echo "=== Creating a disk image ==="
# create the .dmg package - beware, it won't work while FMW is running (blocks partition mounting)
rm -f "../*.dmg"
STAGING_DIR="$SCRIPTDIR/staging"
mkdir -p $STAGING_DIR
cp -R src/app/Fedora\ Media\ Writer.app $STAGING_DIR
ln -s /Applications $STAGING_DIR/Applications
hdiutil create -srcfolder $STAGING_DIR -format UDCO -imagekey zlib-level=9 -scrub -volname FedoraMediaWriter-osx ../FedoraMediaWriter-osx-$VERSION.unnotarized.dmg
rm -rf $STAGING_DIR
popd >/dev/null
}
function notarize() {
echo "=== Submitting for notarization ==="
xcrun altool --notarize-app --primary-bundle-id "org.fedoraproject.mediawriter" --username "${NOTARIZATION_EMAIL}" --password "@keychain:${NOTARIZATION_KEYCHAIN_ITEM}" --asc-provider "${NOTARIZATION_ITUNES_ORGID}" --file "../FedoraMediaWriter-osx-$VERSION.unnotarized.dmg"
echo "DONE. After notarization finished (you'll get an email), run:"
echo "$ xcrun stabler stable app/Fedora\ Media\ Writer.app"
echo "$ hdiutil create -srcfolder app/Fedora\ Media\ Writer.app -format UDCO -imagekey zlib-level=9 -scrub -volname FedoraMediaWriter-osx ../FedoraMediaWriter-osx-$VERSION.dmg"
}
if [[ $# -eq 0 ]]; then
install_deps
build
deps
sign
dmg
notarize
else
$1
fi