build-image.sh 5.64 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
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

# Save some frequently referenced locations in variables for ease of use / updating
export APPDIR=$BUILD_PREFIX/kdenlive.appdir
export PLUGINS=$APPDIR/usr/lib/plugins/
export APPIMAGEPLUGINS=$APPDIR/usr/plugins/

mkdir -p $APPDIR
mkdir -p $APPDIR/usr/share/kdenlive
mkdir -p $APPDIR/usr/lib


# 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 0: place the translations where ki18n and Qt look for them
if [ -d $APPDIR/usr/share/locale ] ; then
    mv $APPDIR/usr/share/locale $APPDIR/usr/share/kdenlive
fi

# Step 1: Copy over all the resources provided by dependencies that we need
cp -r $DEPS_INSTALL_PREFIX/share/locale $APPDIR/usr/share/kdenlive
cp -r $DEPS_INSTALL_PREFIX/share/kf5 $APPDIR/usr/share
cp -r $DEPS_INSTALL_PREFIX/share/mime $APPDIR/usr/share
52
53
54
55
56
57
58
59
60
61

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

62
63
64
65
cp -r $DEPS_INSTALL_PREFIX/translations $APPDIR/usr/
cp -r $DEPS_INSTALL_PREFIX/openssl/lib/*  $APPDIR/usr/lib
cp -r $DEPS_INSTALL_PREFIX/share/mlt  $APPDIR/usr/share
cp -r $DEPS_INSTALL_PREFIX/lib/mlt  $APPDIR/usr/lib
66
cp -r $DEPS_INSTALL_PREFIX/lib/frei0r-1  $APPDIR/usr/lib
67
cp -r $DEPS_INSTALL_PREFIX/bin/melt  $APPDIR/usr/bin
68
69
cp -r $DEPS_INSTALL_PREFIX/bin/ffmpeg  $APPDIR/usr/bin
cp -r $DEPS_INSTALL_PREFIX/bin/ffplay  $APPDIR/usr/bin
70
cp -r $DEPS_INSTALL_PREFIX/bin/ffprobe  $APPDIR/usr/bin
71
cp -r $DEPS_INSTALL_PREFIX/plugins/kf5  $APPDIR/usr/plugins
72

Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
73
74
75
76
mkdir -p $APPDIR/usr/libexec

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

77
cp $(ldconfig -p | grep libGL.so.1 | cut -d ">" -f 2 | xargs) $APPDIR/usr/lib/
78
#cp $(ldconfig -p | grep libGLU.so.1 | cut -d ">" -f 2 | xargs) $APPDIR/usr/lib/
79
80

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

82
if [ -d $APPDIR/usr/lib/x86_64-linux-gnu/plugins ] ; then
83
    mv $APPDIR/usr/lib/x86_64-linux-gnu/plugins/*  $APPDIR/usr/lib/plugins
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
84
85
    rm -rf $APPDIR/usr/lib/x86_64-linux-gnu/
fi
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105

# Step 3: Update the rpath in the various plugins we have to make sure they'll be loadable in an Appimage context
#for lib in $PLUGINS/*.so*; do
#  patchelf --set-rpath '$ORIGIN/../lib' $lib;
#done

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

# Step 4: Move plugins to loadable location in AppImage

# Make sure our plugin directory already exists
if [ ! -d $APPIMAGEPLUGINS ] ; then
    mkdir -p $APPIMAGEPLUGINS
fi

# mv $PLUGINS/* $APPIMAGEPLUGINS

# Step 5: Build the image!!!
106
107
linuxdeployqt $APPDIR/usr/bin/ffmpeg
linuxdeployqt $APPDIR/usr/bin/ffplay
108
linuxdeployqt $APPDIR/usr/bin/ffprobe
109
110
111
112
113
114
115
linuxdeployqt $APPDIR/usr/bin/melt

linuxdeployqt $APPDIR/usr/share/applications/org.kde.kdenlive.desktop \
  -executable=$APPDIR/usr/bin/kdenlive \
  -qmldir=$DEPS_INSTALL_PREFIX/qml \
  -verbose=2 \
  -bundle-non-qt-libs \
116
  -extra-plugins=$APPDIR/usr/lib/mlt,$APPDIR/usr/plugins \
Jean-Baptiste Mardelle's avatar
Jean-Baptiste Mardelle committed
117
  -exclude-libs=libnss3.so,libnssutil3.so,libGL.so.1
118
119
120

#  -appimage \

121
122
123
124
125
rm $APPDIR/usr/lib/libGL.so.1

# libxcb should be removed
rm $APPDIR/usr/lib/libxcb*

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
rm  $APPDIR/AppRun

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

DIR="\`dirname \"\$0\"\`" 
DIR="\`( cd \"\$DIR\" && pwd )\`"
export APPDIR=\$DIR


export LD_LIBRARY_PATH=\$DIR/usr/lib/:\$LD_LIBRARY_PATH
export XDG_DATA_DIRS=\$DIR/usr/share/:\$XDG_DATA_DIRS
export XDG_CONFIG_HOME=\$HOME/.config/
export PATH=\$DIR/usr/bin:\$PATH
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
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
export XDG_CURRENT_DESKTOP=


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
cd $BUILD_PREFIX/kdenlive-build
159
KDENLIVE_VERSION=$(grep "KDENLIVE_VERSION" config-kdenlive.h | cut -d '"' -f 2)
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179

# Also find out the revision of Git we built
# Then use that to generate a combined name we'll distribute
cd $KDENLIVE_SOURCES
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