-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinux_deploy_qt.sh
More file actions
executable file
·239 lines (212 loc) · 6.45 KB
/
linux_deploy_qt.sh
File metadata and controls
executable file
·239 lines (212 loc) · 6.45 KB
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#!/bin/bash
#--------------------------------------------------------------------------
# Script to deploy qt files for provided executable on linux
#--------------------------------------------------------------------------
myName=$(basename $0 .sh)
myUser=$(id -nu)
myNode=$(hostname -s)
timeStamp=$(date +%H%M%S)
getScriptPath()
{
echo ${0%/*}/
}
realPath()
{
local _path="$1"
local _dirPath="$_path"
if [ ! -d "$_path" ]
then
_dirPath=$(dirname "$_dirPath")
fi
pushd "$_dirPath" &>/dev/null
_dirPath=$(pwd)
popd &>/dev/null
if [ -d "$_path" ]
then
_path="$_dirPath"
else
_path=$_dirPath/$(basename "$_path")
fi
echo "$_path"
}
myPath="$(realPath $(getScriptPath))"
. ${myPath}/lib.sh
executable=
installToDir=
qtDir=$(dirname $(dirname $(which qmake)))
qtImageFormatsDir="plugins/imageformats"
qtPlatformsDir="plugins/platforms"
qtPlatformThemesDir="plugins/platformthemes"
qtTlsDir="plugins/tls"
qtXcbGlIntegrationsDir="plugins/xcbglintegrations"
qtWaylandDecorationClientDir="plugins/wayland-decoration-client"
qtWaylandGraphicsIntegrationClientDir="plugins/wayland-graphics-integration-client"
qtWaylandShellIntegrationDir="plugins/wayland-shell-integration"
onlyQt=false
onlyQtCore=false
print_help()
{
cat <<End-of-help
Usage: $myName
Usage: $myName.sh [OPTION]...
mandatory
--executable=[EXECUTABLE] Path to executable for which resources will be collected
--qt-path=[DIRECTORY] Path to Qt installation (default='$qtDir')
optional
--install-to=[DIRECTORY] Install collected resources to 'DIRECTORY' (default=\$(dirname EXEUTABLE))
--only-qt Install only Qt libraries
--only-core-qt Install only Qt core libraries
--help, -h, -? Print this help and exit
End-of-help
}
while [ $# -gt 0 ]
do
case $1 in
--executable=*)
executable=$(extract_cmd_parameter_value "$1")
;;
--install-to=*)
installToDir=$(extract_cmd_parameter_value "$1")
;;
--qt-path=*)
qtDir=$(extract_cmd_parameter_value "$1")
;;
--only-qt)
onlyQt=true
;;
--only-qt-core)
onlyQtCore=true
;;
--help | -h | -?)
print_help
exit 0
;;
*)
echo_e "Unknown parameter '$1'"
print_help
exit 1
;;
esac
shift
done
if [ -z "$executable" ]
then
echo_e "Missing executable"
exit 1
fi
if [ -z "$qtDir" ]
then
echo_e "Missing path to Qt installation"
exit 1
fi
if [ ! -d "$qtDir" ]
then
echo_e "Qt installation directory '$qtDir' not found"
exit 1
fi
if [ "$onlyQtCore" != "true" ] && [ ! -d "$qtDir/$qtImageFormatsDir" ]
then
echo_e "Qt directory '$qtDir/$qtImageFormatsDir' not found"
exit 1
fi
if [ ! -d "$qtDir/$qtPlatformsDir" ]
then
echo_e "Qt directory '$qtDir/$qtPlatformsDir' not found"
exit 1
fi
if [ "$onlyQtCore" != "true" ] && [ ! -d "$qtDir/$qtPlatformThemesDir" ]
then
echo_e "Qt directory '$qtDir/$qtPlatformThemesDir' not found"
exit 1
fi
if [ ! -d "$qtDir/$qtTlsDir" ]
then
echo_e "Qt directory '$qtDir/$qtTlsDir' not found"
exit 1
fi
if [ "$onlyQtCore" != "true" ] && [ ! -d "$qtDir/$qtXcbGlIntegrationsDir" ]
then
echo_e "Qt directory '$qtDir/$qtXcbGlIntegrationsDir' not found"
exit 1
fi
if [ "$onlyQtCore" != "true" ] && [ -d "$qtDir/$qtWaylandDecorationClientDir" ]
then
hasWayland=true
else
hasWayland=false
fi
echo $executable
executable=$(realPath "$executable")
if [ -z "$installToDir" ]
then
installToDir=$(dirname "$executable")
fi
installToDir=$(realPath "$installToDir")
echo_i "Executable: \"$executable\""
echo_i "Installation directory: \"$installToDir\""
touch_dir "$installToDir/lib" true
touch_dir "$installToDir/$qtPlatformsDir" true
touch_dir "$installToDir/$qtTlsDir" true
if [ "$onlyQtCore" != "true" ]
then
touch_dir "$installToDir/$qtImageFormatsDir" true
touch_dir "$installToDir/$qtPlatformThemesDir" true
touch_dir "$installToDir/$qtXcbGlIntegrationsDir" true
if [ "$hasWayland" = "true" ]
then
touch_dir "$installToDir/$qtWaylandDecorationClientDir" true
touch_dir "$installToDir/$qtWaylandGraphicsIntegrationClientDir" true
touch_dir "$installToDir/$qtWaylandShellIntegrationDir" true
fi
fi
getLibraries()
{
onlyQtGrep=
if [ $onlyQt == "true" ]
then
onlyQtGrep=".*Qt"
fi
local _filesToCheck="$executable $qtDir/$qtPlatformsDir/*.so $qtDir/$qtTlsDir/*.so"
if [ "$onlyQtCore" != "true" ]
then
_filesToCheck+=" $qtDir/$qtImageFormatsDir/*.so $qtDir/$qtPlatformThemesDir/*.so $qtDir/$qtXcbGlIntegrationsDir/*.so"
if [ "$hasWayland" = "true" ]
then
_filesToCheck+=" $qtDir/$qtWaylandDecorationClientDir/*.so $qtDir/$qtWaylandGraphicsIntegrationClientDir/*.so $qtDir/$qtWaylandShellIntegrationDir/*.so"
fi
fi
for lddRecord in $(ldd $_filesToCheck | grep -e "^\s*lib$onlyQtGrep" | sed 's/^\s\+//;s/\s\+=>\s\+/,/;s/\s\+.*//')
do
libraryName=$(echo $lddRecord | cut -d',' -f1)
libraryPath=$(realPath $(echo $lddRecord | cut -d',' -f2))
echo $libraryName,$libraryPath
done
}
for libRecord in $(getLibraries | sort -u)
do
libraryName=$(echo $libRecord | cut -d',' -f1)
libraryPath=$(echo $libRecord | cut -d',' -f2)
cp -v $libraryPath "$installToDir/lib/$libraryName"
if [ $? -ne 0 ]
then
echo_e "Failed to copy library '$libraryPath' to '$installToDir/lib/$libraryName'"
fi
done
if [ "$onlyQtCore" != "true" ]
then
cp -v "$qtDir/$qtImageFormatsDir/"*.so "$installToDir/$qtImageFormatsDir" && \
cp -v "$qtDir/$qtPlatformThemesDir/"*.so "$installToDir/$qtPlatformThemesDir" && \
cp -v "$qtDir/$qtXcbGlIntegrationsDir/"*.so "$installToDir/$qtXcbGlIntegrationsDir"
if [ "$hasWayland" = "true" ]
then
cp -v "$qtDir/$qtWaylandDecorationClientDir/"*.so "$installToDir/$qtWaylandDecorationClientDir" && \
cp -v "$qtDir/$qtWaylandGraphicsIntegrationClientDir/"*.so "$installToDir/$qtWaylandGraphicsIntegrationClientDir" && \
cp -v "$qtDir/$qtWaylandShellIntegrationDir/"*.so "$installToDir/$qtWaylandShellIntegrationDir"
fi
fi && \
cp -v "$qtDir/$qtPlatformsDir/"*.so "$installToDir/$qtPlatformsDir" && \
cp -v "$qtDir/$qtTlsDir/"*.so "$installToDir/$qtTlsDir"
if [ $? -ne 0 ]
then
echo_e "Failed to copy Qt plugins"
fi