Repository navigation
Expand file tree
/
Copy pathpackage_linux_appimage.sh
More file actions
executable file
·227 lines (177 loc) · 6.3 KB
/
Copy pathpackage_linux_appimage.sh
File metadata and controls
executable file
·227 lines (177 loc) · 6.3 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
#!/usr/bin/env bash
set -Eeuo pipefail
IFS=$'\n\t'
# Go to project directory
cd "$(dirname "${BASH_SOURCE[0]}")/../.." > /dev/null 2>&1
#######################################################
# Variables & Functions
PROJECT_DIR="$(pwd -P)"
source .ci/ci_utils.sh
if [[ ! -f "/etc/debian_version" ]]; then
print_fatal "Package script only works on Debian/Ubuntu systems!"
fi
print_help() {
cat << EOF
Usage: $(basename "$0") [options]
This script builds and packages MediaElch in a distributable form for
Linux distributions. It is used by MediaElch authors to release
official MediaElch releases.
DO NOT USE THIS IF YOU'RE AN END-USER
UNLESS YOU KNOW WHAT YOU'RE DOING!
Use .ci/linux/build_linux_release.sh if you want to build MediaElch.
See https://appimage.org/
Options
--no-confirm Package MediaElch without confirm dialog.
EOF
exit
}
confirm_build() {
echo ""
print_important "Do you want to package MediaElch ${ME_VERSION} for Linux with these settings?"
print_important "It is recommended to clean your repository using \"git clean -fdx\"."
read -r -s -p "Press enter to continue, Ctrl+C to cancel"
echo ""
}
parse_params() {
# default values of variables set from params
NO_CONFIRM=0
while :; do
case "${1-}" in
-h | --help)
usage
;;
-v | --verbose)
set -x
;;
--no-confirm)
NO_CONFIRM=1
;;
-?*)
print_fatal "Unknown option: $1"
;;
*)
break
;;
esac
shift
done
return 0
}
parse_params "$@"
#######################################################
# Getting Details
# Check for linux build and packaging dependencies
source .ci/linux/check_linux_dependencies.sh
check_dependencies_linux
check_dependencies_linux_appimage
# Exports required variables
gather_project_and_system_details
if [[ "${NO_CONFIRM}" != "1" ]]; then
confirm_build
fi
echo ""
#######################################################
# Set environment variables
# Workaround for: https://github.com/probonopd/linuxdeployqt/issues/65
unset QTDIR
unset QT_PLUGIN_PATH
unset LD_LIBRARY_PATH
# linuxdeployqt uses $VERSION this for naming the file
VERSION="${ME_VERSION}"
EXTRA_QT_MODULES="qt5dxcb-plugin;svg"
export VERSION
export EXTRA_QT_MODULES
if [[ ! "$PATH" = *"qt"* ]] && [[ ! "$PATH" = *"Qt"* ]]; then
print_fatal "/path/to/qt/bin must be in your \$PATH, e.g. \nexport PATH=\"\$PATH:/usr/lib/x86_64-linux-gnu/qt5/bin\""
fi
#######################################################
# Check that MediaElch is build
if [ ! -d "./build/linux" ] || [ ! -f "./build/linux/.qmake.stash" ] || [ ! -f "./build/linux/MediaElch" ]; then
print_fatal "Build MediaElch before packaging it!"
fi
#######################################################
# Download Dependencies into third_party folder
mkdir -p "${PROJECT_DIR}/third_party/packaging_linux"
cd "${PROJECT_DIR}/third_party/packaging_linux"
#######################################################
# Download linuxdeployqt + Qt plugin
if [[ ! -f linuxdeploy-x86_64.AppImage ]]; then
print_info "Downloading linuxdeploy"
wget --no-verbose https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
chmod u+x linuxdeploy*.AppImage
fi
if [[ ! -d linuxdeploy-extracted ]]; then
print_info "Extracting linuxdeploy"
./linuxdeploy-x86_64.AppImage --appimage-extract
mv squashfs-root linuxdeploy-extracted
fi
if [[ ! -f linuxdeploy-plugin-qt-x86_64.AppImage ]]; then
print_info "Downloading linuxdeployqt"
wget --no-verbose https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage
chmod u+x linuxdeploy*.AppImage
fi
if [[ ! -d linuxdeploy-extracted/plugins/linuxdeploy-plugin-qt ]]; then
print_info "Extracting linuxdeployqt"
./linuxdeploy-plugin-qt-x86_64.AppImage --appimage-extract
mv squashfs-root linuxdeploy-extracted/plugins/linuxdeploy-plugin-qt
cd linuxdeploy-extracted/usr/bin
ln -s ../../plugins/linuxdeploy-plugin-qt/AppRun linuxdeploy-plugin-qt
cd ../../..
fi
#######################################################
# Download and extract ffmpeg
if [[ ! -f "${LINUX_FFMPEG_ARCHIVE_NAME}" ]]; then
print_info "Downloading ffmpeg ${LINUX_FFMPEG_VERSION} from ${LINUX_FFMPEG_URL}"
# Use static ffmpeg
wget --no-verbose --output-document "${LINUX_FFMPEG_ARCHIVE_NAME}" "${LINUX_FFMPEG_URL}"
validate_sha512 "${LINUX_FFMPEG_ARCHIVE_NAME}" "${LINUX_FFMPEG_SHA512}"
fi
if [[ ! -f ffmpeg ]]; then
tar -xJvf "${LINUX_FFMPEG_ARCHIVE_NAME}"
mv "${LINUX_FFMPEG_FOLDER_NAME}/ffmpeg" ./
rm -rf "${LINUX_FFMPEG_FOLDER_NAME}"
fi
#######################################################
# Install MediaElch into subdirectory
cd "${PROJECT_DIR}/build/linux"
print_important "Create an AppImage release"
print_info "Installing MediaElch into subdirectory to create basic AppDir structure"
rm -rf appdir
make INSTALL_ROOT=appdir -j"${JOBS}" install
print_info "Listing appdir"
tree appdir/
#######################################################
# Copy libmediainfo
#
# libmediainfo.so.0 is loaded at runtime that's why
# linuxdeployqt can't detect it and we have to include
# it here.
print_info "Copying libmediainfo.so"
mkdir -p ./appdir/usr/lib
cp /usr/lib/x86_64-linux-gnu/libmediainfo.so.0 ./appdir/usr/lib/
#######################################################
# Copy ffmpeg
print_info "Copying ffmpeg into AppDir"
cp "${PROJECT_DIR}/third_party/packaging_linux/ffmpeg" appdir/usr/bin/
#######################################################
# Create AppImage
print_important "Creating an AppImage for MediaElch ${ME_VERSION_NAME}."
print_important "This takes a while and may seem frozen."
# Run linuxdeploy with following settings:
# - use qt plugin => so that Qt libraries are bundled correctly
# - use appimage plugin => create an AppImage file (essentially just bundles the appdir)
"${PROJECT_DIR}/third_party/packaging_linux/linuxdeploy-extracted/AppRun" \
--appdir appdir \
--verbosity=2 \
--desktop-file appdir/usr/share/applications/MediaElch.desktop \
--plugin qt \
--output appimage
#######################################################
# Finalize AppImage (name, chmod)
cd "${PROJECT_DIR}/build/linux"
print_info "Renaming .AppImage"
chmod +x ./*.AppImage
mv MediaElch*.AppImage "../../MediaElch_linux_${ME_VERSION_NAME}.AppImage"
cd ../..
print_success "Successfully created AppImage: "
print_success " $(pwd)/MediaElch_linux_${ME_VERSION_NAME}.AppImage"