forked from FedoraQt/MediaWriter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·217 lines (180 loc) · 8.15 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/bin/bash -xe
# Usage
# ./build.sh - installs all the necessary packages and composes an installer (FMW-setup.exe)
# ./build.sh local - builds the mediawriter.exe binary itself and then composes the installer
# ./build.sh install - just installs the necessary packages
#
# The script will try to sign all binaries using your code signing certificate.
# You can provide the path to it using the $CERTPATH variable, the file then
# has to be named authenticode.pfx
# You have to provide the $CERTPASS with the path to a file containing the passphrase to your
# certificate (beware of the trailing last new line symbol)
opt_local=false
opt_install=false
opt_debug=false
opt_nosign=false
while test $# -gt 0
do
case "$1" in
local) opt_local=true
;;
install) opt_install=true
;;
debug) opt_debug=true
;;
nosign) opt_nosign=true
;;
esac
shift
done
pushd $(dirname $0) >/dev/null
SCRIPTDIR=$(pwd -P)
popd >/dev/null
ROOTPATH=$(realpath "$SCRIPTDIR/../../")
BUILDPATH="$ROOTPATH/build"
MEDIAWRITER="$BUILDPATH/app/release/mediawriter.exe"
HELPER="$BUILDPATH/app/release/helper.exe"
if ! $opt_nosign; then
if [ -z "$CERTPATH" ]; then
CERTPATH=~
fi
if [ -z "$CERTPASS" ]; then
CERTPASS="$CERTPATH/authenticode.pass"
fi
fi
PACKAGES="cmake mingw32-filesystem mingw32-qt5-qtbase mingw32-qt5-qtdeclarative mingw32-qt5-qtquickcontrols2 mingw32-qt5-qtwinextras mingw32-xz-libs mingw32-libadwaita-qt5 mingw32-qt5-qtwinextras mingw32-qt5-qtsvg mingw32-nsis osslsigncode wine-core.i686 mingw32-angleproject wine-systemd"
if ! $opt_local; then
PACKAGES="$PACKAGES mingw32-mediawriter"
fi
if $opt_install; then
echo "=== Installing dependencies"
dnf install $PACKAGES
exit $?
fi
echo "=== Checking dependencies"
DEPENDENCIES=0
for i in $PACKAGES; do
rpm -V $i
if [ $? -ne 0 ]; then
if [ "$i" == "osslsigncode" ]; then
opt_nosign=true
else
DEPENDENCIES=1
fi
fi
done
if [ $DEPENDENCIES -ne 0 ]; then exit 1; fi
BINARIES="libstdc++-6.dll libgcc_s_dw2-1.dll libssp-0.dll iconv.dll libwinpthread-1.dll libcrypto-1_1.dll libssl-1_1.dll libpng16-16.dll liblzma-5.dll libharfbuzz-0.dll libpcre-1.dll libintl-8.dll iconv.dll libpcre2-16-0.dll libfreetype-6.dll libbz2-1.dll libjpeg-62.dll libEGL.dll libglib-2.0-0.dll libGLESv2.dll zlib1.dll libadwaitaqtpriv-1.dll libadwaitaqt-1.dll Qt5Core.dll Qt5Gui.dll Qt5Network.dll Qt5Qml.dll Qt5QmlModels.dll Qt5Quick.dll Qt5QuickControls2.dll Qt5QuickShapes.dll Qt5QuickTemplates2.dll Qt5QmlWorkerScript.dll Qt5Svg.dll Qt5Widgets.dll Qt5WinExtras.dll"
PLUGINS="imageformats/qjpeg.dll imageformats/qsvg.dll platforms/qwindows.dll"
QMLMODULES="Qt QtQml QtQuick/Controls QtQuick/Controls.2 QtQuick/Dialogs QtQuick/Extras QtQuick/Layouts QtQuick/PrivateWidgets QtQuick/Shapes QtQuick/Templates.2 QtQuick/Window.2 QtQuick.2"
INSTALL_PREFIX=$(mingw32-qmake-qt5 -query QT_INSTALL_PREFIX)
BIN_PREFIX=$(mingw32-qmake-qt5 -query QT_INSTALL_BINS)
PLUGIN_PREFIX=$(mingw32-qmake-qt5 -query QT_INSTALL_PLUGINS)
QML_PREFIX=$(mingw32-qmake-qt5 -query QT_INSTALL_QML)
export WINEPREFIX="$BUILDPATH/wineprefix"
export WINEDEBUG="-all"
mkdir -p "$BUILDPATH"
mkdir -p "$WINEPREFIX"
pushd "$BUILDPATH" >/dev/null
VERSION_FULL=''
if $opt_local; then
VERSION_FULL=$(git describe --tags)
if $opt_debug; then
INSTALLER="$SCRIPTDIR/FedoraMediaWriter-win32-${VERSION_FULL}-debug.exe"
else
INSTALLER="$SCRIPTDIR/FedoraMediaWriter-win32-${VERSION_FULL}.exe"
fi
else
VERSION_FULL=$(rpm -q mingw32-mediawriter --queryformat '%{VERSION}\n')
INSTALLER="$SCRIPTDIR/FedoraMediaWriter-win32-${VERSION_FULL}.exe"
fi
VERSION_STRIPPED=$(sed "s/-.*//" <<< "${VERSION_FULL}")
VERSION_MAJOR=$(cut -d. -f1 <<< "${VERSION_STRIPPED}")
VERSION_MINOR=$(cut -d. -f2 <<< "${VERSION_STRIPPED}")
VERSION_BUILD=$(cut -d. -f3 <<< "${VERSION_STRIPPED}")
if $opt_local; then
echo "=== Building"
if [ "2" == "debug" ]; then
mingw32-cmake ..
else
mingw32-cmake ..
fi
mingw32-make -j9 > /dev/null
# FIXME just a workaround for Adwaita theme not being build and placed to correct location
# without installation
mkdir -p $BUILDPATH/app/release/QtQuick/Controls.2/org.fedoraproject.AdwaitaTheme
mkdir -p $BUILDPATH/app/release/org/fedoraproject/AdwaitaTheme
cp -r ../src/theme/qml/* $BUILDPATH/app/release/QtQuick/Controls.2/org.fedoraproject.AdwaitaTheme
cp -r ../src/theme/qmldir $BUILDPATH/app/release/org/fedoraproject/AdwaitaTheme
cp -r $BUILDPATH/src/theme/adwaitathemeplugin.dll $BUILDPATH/app/release/org/fedoraproject/AdwaitaTheme
cp -r $BUILDPATH/src/app/helper.exe $BUILDPATH/app/release/
cp -r $BUILDPATH/src/app/mediawriter.exe $BUILDPATH/app/release/
else
mkdir -p "app/release"
echo "=== Getting distribution binary"
cp "$BIN_PREFIX/mediawriter.exe" app/release
cp "$INSTALL_PREFIX/libexec/mediawriter/helper.exe" app/release
mkdir -p $BUILDPATH/app/release/QtQuick/Controls.2/org.fedoraproject.AdwaitaTheme
mkdir -p $BUILDPATH/app/release/org/fedoraproject/AdwaitaTheme
cp -r $QML_PREFIX/org/fedoraproject/AdwaitaTheme/* $BUILDPATH/app/release/org/fedoraproject/AdwaitaTheme/
cp -r $QML_PREFIX/QtQuick/Controls.2/org.fedoraproject.AdwaitaTheme/* $BUILDPATH/app/release/QtQuick/Controls.2/org.fedoraproject.AdwaitaTheme/
fi
pushd "app/release" >/dev/null
if [ ! -f "$MEDIAWRITER" ] || [ ! -f "$HELPER" ]; then
echo "$MEDIAWRITER or $HELPER doesn't exist."
exit 1
fi
echo "=== Removing object and MOC files"
rm -f *.cpp
rm -f *.o
echo "=== Copying dlls"
for i in $BINARIES; do
mkdir -p $(dirname $i)
cp -r "${BIN_PREFIX}/${i}" "$(dirname $i)"
done
if $opt_debug; then
for i in $BINARIES; do
mkdir -p $(dirname $i)
cp -r "${BIN_PREFIX}/${i}.debug" "$(dirname $i)"
done
fi
echo "=== Copying plugins"
for i in $PLUGINS; do
mkdir -p $(dirname $i)
cp -r "${PLUGIN_PREFIX}/${i}" "$(dirname $i)"
done
echo "=== Copying QML modules"
for i in $QMLMODULES; do
mkdir -p $(dirname $i)
cp -r "${QML_PREFIX}/${i}" "$(dirname $i)"
done
#echo "=== Compressing binaries"
#upx $(find . -name "*.exe")
#upx $(find . -name "*.dll")
# See http://stackoverflow.com/questions/18287960/signing-windows-application-on-linux-based-distros for details
echo "=== Signing binaries"
if ! $opt_nosign; then
osslsigncode sign -pkcs12 $CERTPATH/authenticode.pfx -readpass "$CERTPASS" -h sha256 -n "Fedora Media Writer" -i https://getfedora.org -t http://timestamp.comodoca.com/authenticode -in "$MEDIAWRITER" -out "$MEDIAWRITER.signed" >/dev/null
mv "$MEDIAWRITER.signed" "$MEDIAWRITER"
osslsigncode sign -pkcs12 $CERTPATH/authenticode.pfx -readpass "$CERTPASS" -h sha256 -n "Fedora Media Writer" -i https://getfedora.org -t http://timestamp.comodoca.com/authenticode -in "$HELPER" -out "$HELPER.signed" >/dev/null
mv "$HELPER.signed" "$HELPER"
fi
popd >/dev/null
popd >/dev/null
echo "=== Composing installer"
unix2dos < "$ROOTPATH/LICENSE.GPL-2" > "$BUILDPATH/app/release/LICENSE.GPL-2.txt"
unix2dos < "$ROOTPATH/LICENSE.LGPL-2" > "$BUILDPATH/app/release/LICENSE.LGPL-2.txt"
INSTALLED_SIZE=$(du -k -d0 "$BUILDPATH/app/release" | cut -f1)
cp "$SCRIPTDIR/mediawriter.nsi" "$SCRIPTDIR/mediawriter.tmp.nsi"
sed -i "s/#!define VERSIONMAJOR/!define VERSIONMAJOR ${VERSION_MAJOR}/" "$SCRIPTDIR/mediawriter.tmp.nsi"
sed -i "s/#!define VERSIONMINOR/!define VERSIONMINOR ${VERSION_MINOR}/" "$SCRIPTDIR/mediawriter.tmp.nsi"
sed -i "s/#!define VERSIONBUILD/!define VERSIONBUILD ${VERSION_BUILD}/" "$SCRIPTDIR/mediawriter.tmp.nsi"
sed -i "s/#!define INSTALLSIZE/!define INSTALLSIZE ${INSTALLED_SIZE}/" "$SCRIPTDIR/mediawriter.tmp.nsi"
makensis -DCERTPATH="$CERTPATH" -DCERTPASS="$CERTPASS" "$SCRIPTDIR/mediawriter.tmp.nsi" >/dev/null
rm "$SCRIPTDIR/mediawriter.tmp.nsi"
mv "$SCRIPTDIR/FMW-setup.exe" "$INSTALLER"
if ! $opt_nosign; then
osslsigncode sign -pkcs12 $CERTPATH//authenticode.pfx -readpass "$CERTPASS" -h sha256 -n "Fedora Media Writer" -i https://getfedora.org -t http://timestamp.comodoca.com/authenticode -in "$INSTALLER" -out "$INSTALLER.signed" >/dev/null
mv "$INSTALLER.signed" "$INSTALLER"
fi
echo "=== Installer is located in $INSTALLER"