build-image.sh 9.57 KB
Newer Older
1
2
3
4
5
6
7
#!/bin/bash

# Halt on errors and be verbose about what we are doing
set -e
set -x

# Read in our parameters
8
9
export BUILD_PREFIX=$1
export KDENLIVE_SOURCES=$2
10
11
12

# Save some frequently referenced locations in variables for ease of use / updating
export APPDIR=$BUILD_PREFIX/kdenlive.appdir
13
export PLUGINS=$APPDIR/usr/plugins/
14
15
16
17
18
export APPIMAGEPLUGINS=$APPDIR/usr/plugins/

mkdir -p $APPDIR
mkdir -p $APPDIR/usr/share/kdenlive
mkdir -p $APPDIR/usr/lib
19
mkdir -p $APPDIR/usr/lib/va
20
21
mkdir -p $PLUGINS
mkdir -p $APPDIR/usr/plugins
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

# qjsonparser, used to add metadata to the plugins needs to work in a en_US.UTF-8 environment.
# That's not always the case, so make sure it is
export LC_ALL=en_US.UTF-8
export LANG=en_us.UTF-8

# We want to use $prefix/deps/usr/ for all our dependencies
export DEPS_INSTALL_PREFIX=$BUILD_PREFIX/deps/usr/
export DOWNLOADS_DIR=$BUILD_PREFIX/downloads/

# Setup variables needed to help everything find what we built
export LD_LIBRARY_PATH=$DEPS_INSTALL_PREFIX/lib/:$DEPS_INSTALL_PREFIX/lib/x86_64-linux-gnu/:$APPDIR/usr/lib/:$LD_LIBRARY_PATH
export PATH=$DEPS_INSTALL_PREFIX/bin/:$PATH
export PKG_CONFIG_PATH=$DEPS_INSTALL_PREFIX/share/pkgconfig/:$DEPS_INSTALL_PREFIX/lib/pkgconfig/:/usr/lib/pkgconfig/:$PKG_CONFIG_PATH
export CMAKE_PREFIX_PATH=$DEPS_INSTALL_PREFIX:$CMAKE_PREFIX_PATH

# Switch over to our build prefix
cd $BUILD_PREFIX

#
# Now we can get the process started!
#

# Step 1: Copy over all the resources provided by dependencies that we need
cp -r $DEPS_INSTALL_PREFIX/share/kf5 $APPDIR/usr/share
47
48
cp -r $DEPS_INSTALL_PREFIX/share/kstyle $APPDIR/usr/share
cp -r $DEPS_INSTALL_PREFIX/share/plasma $APPDIR/usr/share
49
50
cp -r $DEPS_INSTALL_PREFIX/share/alsa $APPDIR/usr/share
cp -r $DEPS_INSTALL_PREFIX/share/kservices5 $APPDIR/usr/share
51
cp -r $DEPS_INSTALL_PREFIX/share/kservicetypes5 $APPDIR/usr/share
52
#cp -r $DEPS_INSTALL_PREFIX/share/qt5 $APPDIR/usr/share
53
cp -r $DEPS_INSTALL_PREFIX/share/mime $APPDIR/usr/share
54
55
56
57
58
59
60
61
62
63

if [ -d $DEPS_INSTALL_PREFIX/share/color-schemes ] ; then
    cp -r $DEPS_INSTALL_PREFIX/share/color-schemes $APPDIR/usr/share
fi

if [ -d $DEPS_INSTALL_PREFIX/share/icons/breeze ] ; then
    cp -r $DEPS_INSTALL_PREFIX/share/icons/breeze $APPDIR/usr/share/icons
    cp -r $DEPS_INSTALL_PREFIX/share/icons/breeze-dark $APPDIR/usr/share/icons
fi

64
cp -r $DEPS_INSTALL_PREFIX/translations $APPDIR/usr/
65
66

# TO remove once we switch to the newer Qt5.12 Appimage dependency
67
# cp -r $DEPS_INSTALL_PREFIX/openssl/lib/*  $APPDIR/usr/lib
68

69
70
cp -r $DEPS_INSTALL_PREFIX/share/mlt  $APPDIR/usr/share
cp -r $DEPS_INSTALL_PREFIX/lib/mlt  $APPDIR/usr/lib
71
cp -r $DEPS_INSTALL_PREFIX/lib/libharfbuzz*  $APPDIR/usr/lib
72
cp -r $DEPS_INSTALL_PREFIX/lib/libfribidi*  $APPDIR/usr/lib
73
cp -r $DEPS_INSTALL_PREFIX/lib/libpango*  $APPDIR/usr/lib
74
cp -r $DEPS_INSTALL_PREFIX/lib/ladspa  $APPDIR/usr/lib || true
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
75
cp -r $DEPS_INSTALL_PREFIX/lib/libmlt*  $APPDIR/usr/lib
76
cp -r $DEPS_INSTALL_PREFIX/lib/frei0r-1  $APPDIR/usr/lib
77
cp -r $DEPS_INSTALL_PREFIX/bin/melt  $APPDIR/usr/bin
78
79
cp -r $DEPS_INSTALL_PREFIX/bin/ffmpeg  $APPDIR/usr/bin
cp -r $DEPS_INSTALL_PREFIX/bin/ffplay  $APPDIR/usr/bin
80
cp -r $DEPS_INSTALL_PREFIX/bin/ffprobe  $APPDIR/usr/bin
81
cp -r $DEPS_INSTALL_PREFIX/bin/kbuildsycoca5  $APPDIR/usr/bin
82
cp -r $DEPS_INSTALL_PREFIX/plugins/kf5  $APPIMAGEPLUGINS
83
cp -r $DEPS_INSTALL_PREFIX/plugins/styles  $APPIMAGEPLUGINS
84
cp -r $DEPS_INSTALL_PREFIX/plugins/audio  $APPIMAGEPLUGINS
85
86
cp -r $DEPS_INSTALL_PREFIX/plugins/org.kde.kdecoration2 $APPIMAGEPLUGINS
cp -r $DEPS_INSTALL_PREFIX/plugins/kstyle_breeze_config.so $APPIMAGEPLUGINS
87

88
#cp $BUILD_PREFIX/deps-build/ext_bigshot/ext_bigshot-prefix/src/ext_bigshot-build/*.so $APPDIR/usr/lib/frei0r-1 || true
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
89
90
91
92
mkdir -p $APPDIR/usr/libexec

cp -r $DEPS_INSTALL_PREFIX/lib/x86_64-linux-gnu/libexec/kf5/*  $APPDIR/usr/libexec/

93
94
95
96

#Put translation files where Qt looks for them
cp -r $DEPS_INSTALL_PREFIX/share/locale $APPDIR/usr/share/

97
#libva accel
98
cp -r $DEPS_INSTALL_PREFIX/lib/libva*  $APPDIR/usr/lib  || true
99
cp -r /usr/lib/x86_64-linux-gnu/dri/*_drv_video.so  $APPDIR/usr/lib/va || true
100

101
cp $(ldconfig -p | grep libGL.so.1 | cut -d ">" -f 2 | xargs) $APPDIR/usr/lib/
102
#cp $(ldconfig -p | grep libGLU.so.1 | cut -d ">" -f 2 | xargs) $APPDIR/usr/lib/
103
104

# Step 2: Relocate x64 binaries from the architecture specific directory as required for Appimages
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
105

106
if [ -d $APPDIR/usr/lib/x86_64-linux-gnu/plugins ] ; then
107
    mv $APPDIR/usr/lib/x86_64-linux-gnu/plugins/*  $APPDIR/usr/plugins
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
108
109
    rm -rf $APPDIR/usr/lib/x86_64-linux-gnu/
fi
110
111

# Step 3: Update the rpath in the various plugins we have to make sure they'll be loadable in an Appimage context
112
113
114
115
116
117
118
119
for lib in $APPIMAGEPLUGINS/*.so*; do
  patchelf --set-rpath '$ORIGIN/../lib' $lib;
done

for lib in $APPIMAGEPLUGINS/audio/*.so*; do
  patchelf --set-rpath '$ORIGIN/../../lib' $lib;
done

120
121
122
#for lib in $APPIMAGEPLUGINS/styles/*.so*; do
#  patchelf --set-rpath '$ORIGIN/../../lib' $lib;
#done
123
124
125
126
127

for lib in $APPIMAGEPLUGINS/kf5/*.so*; do
  patchelf --set-rpath '$ORIGIN/../../lib' $lib;
done

128
129
130
#for lib in $APPIMAGEPLUGINS/org.kde.kdecoration2/*.so*; do
#  patchelf --set-rpath '$ORIGIN/../../lib' $lib;
#done
131

132
133
134
135
for lib in $APPDIR/usr/lib/mlt/*.so*; do
  patchelf --set-rpath '$ORIGIN/..' $lib;
done

136

137
138
139
for lib in $APPDIR/usr/lib/libva*.so*; do
  patchelf --set-rpath '$ORIGIN' $lib;
done
140

141
for lib in $APPDIR/usr/lib/va/*.so*; do
142
  patchelf --set-rpath '$ORIGIN/..' $lib || true;
143
done
144
145


146
### GSTREAMER
147
# Requires gstreamer1.0-plugins-good
148
149
150
151
152
153
154
GST_PLUGIN_SRC_DIR=/usr/lib/x86_64-linux-gnu/
mkdir -p $APPDIR/usr/lib/x86_64-linux-gnu
GST_LIB_DEST_DIR=$APPDIR/usr/lib/x86_64-linux-gnu/gstreamer1.0
mkdir -p $GST_LIB_DEST_DIR
GST_PLUGIN_DEST_DIR=$APPDIR/usr/lib/x86_64-linux-gnu/gstreamer1.0/gstreamer-1.0
mkdir -p $GST_PLUGIN_DEST_DIR
cp $GST_PLUGIN_SRC_DIR/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner $GST_PLUGIN_DEST_DIR
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
155
cp $GST_PLUGIN_SRC_DIR/gstreamer-1.0/*.so $GST_LIB_DEST_DIR
156
157
158
159
160
161

rm $GST_LIB_DEST_DIR/libgstegl* || true

for p in $GST_LIB_DEST_DIR/libgst*.so*; do
  patchelf --set-rpath '$ORIGIN/../..' $p;
done
162

163
164
165
### end of GSTREAMER STUFF

# Step 4: Move plugins to loadable location in AppImage
166

167
168
169
170
171
172
173
174
175
# Make sure our plugin directory already exists
if [ ! -d $APPIMAGEPLUGINS ] ; then
    mkdir -p $APPIMAGEPLUGINS
fi

# mv $PLUGINS/* $APPIMAGEPLUGINS

# copy icon
cp $APPDIR/usr/share/icons/breeze/apps/48/kdenlive.svg $APPDIR
176

177
# Step 5: Build the image!!!
178
179
180
181
#linuxdeployqt $APPDIR/usr/bin/ffmpeg
#linuxdeployqt $APPDIR/usr/bin/ffplay
#linuxdeployqt $APPDIR/usr/bin/ffprobe
#linuxdeployqt $APPDIR/usr/bin/melt
182
#linuxdeployqt -executable $APPDIR/usr/lib/va/*.so
183

Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
184

185
186
linuxdeployqt $APPDIR/usr/share/applications/org.kde.kdenlive.desktop \
  -executable=$APPDIR/usr/bin/kdenlive \
187
188
189
  -executable=$APPDIR/usr/lib/libva.so \
  -executable=$APPDIR/usr/lib/libva-drm.so \
  -executable=$APPDIR/usr/lib/libva-x11.so \
190
191
192
  -qmldir=$DEPS_INSTALL_PREFIX/qml \
  -verbose=2 \
  -bundle-non-qt-libs \
193
  -extra-plugins=$APPDIR/usr/lib/mlt,$APPDIR/usr/plugins,$APPDIR/usr/qml,$APPDIR/usr/share/locale \
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
194
  -exclude-libs=libnss3.so,libnssutil3.so,libGL.so.1
195
196
197

#  -appimage \

198
rm $APPDIR/usr/lib/libGL.so.1 || true
199
rm $APPDIR/usr/lib/libasound.so.2 || true
200

201

202
203
204
# libxcb and libxcb-dri{2,3} should be removed
rm $APPDIR/usr/lib/libxcb.so* || true
rm $APPDIR/usr/lib/libxcb-dri{2,3}.so* || true
205
206

rm $APPDIR/usr/lib/libgcrypt.so.20 || true
207

208
209
210
# libdrm-* cause startup crash
rm $APPDIR/usr/lib/libdrm_* || true

211
212
213
214
215
216
217
218
rm  $APPDIR/AppRun

cat > $APPDIR/AppRun << EOF
#!/bin/bash

DIR="\`dirname \"\$0\"\`" 
DIR="\`( cd \"\$DIR\" && pwd )\`"
export APPDIR=\$DIR
219
export LC_ALL=\$LANG
220

221
222
223
224
export APPIMAGE_ORIGINAL_LD_LIBRARY_PATH=\$LD_LIBRARY_PATH
export APPIMAGE_ORIGINAL_QT_PLUGIN_PATH=\$QT_PLUGIN_PATH
export APPIMAGE_ORIGINAL_XDG_DATA_DIRS=\$XDG_DATA_DIRS
export APPIMAGE_ORIGINAL_PATH=\$PATH
225
226

export LD_LIBRARY_PATH=\$DIR/usr/lib/:\$LD_LIBRARY_PATH
227
export QT_PLUGIN_PATH=\$DIR/usr/plugins/
228
229
export XDG_DATA_DIRS=\$DIR/usr/share/:\$XDG_DATA_DIRS
export XDG_CONFIG_HOME=\$HOME/.config/
230
export PATH=\$DIR/usr/bin:\$DIR/usr/lib:\$DIR/usr/lib/libexec/kf5::\$PATH
231
232
233
234
235
236
export KDE_FORK_SLAVES=1

export MLT_REPOSITORY=\$DIR/usr/lib/mlt/
export MLT_DATA=\$DIR/usr/share/mlt/
export MLT_ROOT_DIR=\$DIR/usr/
export LADSPA_PATH=\$DIR/usr/lib/ladspa
237
export LIBVA_DRIVERS_PATH=\$DIR/usr/lib/va
238
239
240
241
export FREI0R_PATH=\$DIR/usr/lib/frei0r-1
export MLT_PROFILES_PATH=\$DIR/usr/share/mlt/profiles/
export MLT_PRESETS_PATH=\$DIR/usr/share/mlt/presets/
export SDL_AUDIODRIVER=pulseaudio
242
243
export GST_PLUGIN_SCANNER=\$DIR/usr/lib/x86_64-linux-gnu/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner
export GST_PLUGIN_PATH=\$DIR/usr/lib/x86_64-linux-gnu/gstreamer1.0/
244

245
246
247
248
249
250
251
252
253
254
export APPIMAGE_ORIGINAL_KDE_FULL_SESSION=\$KDE_FULL_SESSION
export APPIMAGE_ORIGINAL_DESKTOP_SESSION=\$DESKTOP_SESSION
export APPIMAGE_ORIGINAL_XDG_CURRENT_DESKTOP=\$XDG_CURRENT_DESKTOP
export APPIMAGE_ORIGINAL_XDG_SESSION_DESKTOP=\$XDG_SESSION_DESKTOP

export APPIMAGE_STARTUP_LD_LIBRARY_PATH=\$LD_LIBRARY_PATH
export APPIMAGE_STARTUP_QT_PLUGIN_PATH=\$QT_PLUGIN_PATH
export APPIMAGE_STARTUP_XDG_DATA_DIRS=\$XDG_DATA_DIRS
export APPIMAGE_STARTUP_PATH=\$PATH

255
256
257
258
259
kdenlive --config kdenlive-appimagerc \$@
EOF
chmod +x $APPDIR/AppRun

# Step 5: Find out what version of Kdenlive we built and give the Appimage a proper name
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
260
cd $BUILD_PREFIX/kdenlive-build/
261
KDENLIVE_VERSION=$(grep "KDENLIVE_VERSION" config-kdenlive.h | cut -d '"' -f 2)
262
263
264

# Also find out the revision of Git we built
# Then use that to generate a combined name we'll distribute
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
265
cd $KDENLIVE_SOURCES
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
if [[ -d .git ]]; then
	GIT_REVISION=$(git rev-parse --short HEAD)
	VERSION=$KDENLIVE_VERSION-$GIT_REVISION
else
	VERSION=$KDENLIVE_VERSION
fi

# Return to our build root
cd $BUILD_PREFIX

appimagetool $APPDIR

# Generate a new name for the Appimage file and rename it accordingly
APPIMAGE=kdenlive-"$VERSION"-x86_64.appimage
mv Kdenlive-x86_64.AppImage $APPIMAGE