create_linux_appimage.sh 4.18 KB
Newer Older
1 2
#!/bin/bash -x

3
#set +e
4

5
if [[ $# -eq 0 ]]; then
6 7
  echo 'create_linux_appimage.sh QGC_SRC_DIR QGC_RELEASE_DIR'
  exit 1
8 9
fi

10 11
QGC_SRC=$1

Valentin Platzgummer's avatar
Valentin Platzgummer committed
12 13
QGC_CUSTOM_APP_NAME="${QGC_CUSTOM_APP_NAME:-QGroundControl}"
QGC_CUSTOM_GENERIC_NAME="${QGC_CUSTOM_GENERIC_NAME:-Ground Control Station}"
14 15 16
QGC_CUSTOM_BINARY_NAME="${QGC_CUSTOM_BINARY_NAME:-QGroundControl}"
QGC_CUSTOM_LINUX_START_SH="${QGC_CUSTOM_LINUX_START_SH:-${QGC_SRC}/deploy/qgroundcontrol-start.sh}"
QGC_CUSTOM_APP_ICON="${QGC_CUSTOM_APP_ICON:-${QGC_SRC}/resources/icons/qgroundcontrol.png}"
Valentin Platzgummer's avatar
Valentin Platzgummer committed
17
QGC_CUSTOM_APP_ICON_NAME="${QGC_CUSTOM_APP_ICON_NAME:-QGroundControl}"
18

19
if [ ! -f ${QGC_SRC}/qgroundcontrol.pro ]; then
20 21
  echo "please specify path to $(QGC_CUSTOM_APP_NAME) source as the 1st argument"
  exit 1
22 23 24
fi

QGC_RELEASE_DIR=$2
25 26 27
if [ ! -f ${QGC_RELEASE_DIR}/${QGC_CUSTOM_BINARY_NAME} ]; then
  echo "please specify path to ${QGC_CUSTOM_BINARY_NAME} release as the 2nd argument"
  exit 1
28 29 30 31 32
fi

OUTPUT_DIR=${3-`pwd`}
echo "Output directory:" ${OUTPUT_DIR}

33
# Generate AppImage using the binaries currently provided by the project.
34
# These require at least GLIBC 2.14, which older distributions might not have.
35 36
# On the other hand, 2.14 is not that recent so maybe we can just live with it.

Valentin Platzgummer's avatar
Valentin Platzgummer committed
37

38
APP=${QGC_CUSTOM_APP_NAME}
39

40 41 42
TMPDIR=`mktemp -d`
APPDIR=${TMPDIR}/$APP".AppDir"
mkdir -p ${APPDIR}
43

44 45
cd ${TMPDIR}
wget -c --quiet http://ftp.us.debian.org/debian/pool/main/u/udev/udev_175-7.2_amd64.deb
DonLakeFlyer's avatar
DonLakeFlyer committed
46
wget -c --quiet http://ftp.us.debian.org/debian/pool/main/s/speech-dispatcher/speech-dispatcher_0.8.8-1_amd64.deb
47 48
wget -c --quiet http://ftp.us.debian.org/debian/pool/main/libs/libsdl2/libsdl2-2.0-0_2.0.2%2bdfsg1-6_amd64.deb

49
cd ${APPDIR}
50 51
find ../ -name *.deb -exec dpkg -x {} . \;

52 53 54 55 56 57
# copy libdirectfb-1.2.so.9
cd ${TMPDIR}
wget -c --quiet http://ftp.us.debian.org/debian/pool/main/d/directfb/libdirectfb-1.2-9_1.2.10.0-5.1_amd64.deb
mkdir libdirectfb
dpkg -x libdirectfb-1.2-9_1.2.10.0-5.1_amd64.deb libdirectfb
cp -L libdirectfb/usr/lib/x86_64-linux-gnu/libdirectfb-1.2.so.9 ${APPDIR}/usr/lib/x86_64-linux-gnu/
58 59 60 61 62 63 64 65
cp -L libdirectfb/usr/lib/x86_64-linux-gnu/libfusion-1.2.so.9 ${APPDIR}/usr/lib/x86_64-linux-gnu/
cp -L libdirectfb/usr/lib/x86_64-linux-gnu/libdirect-1.2.so.9 ${APPDIR}/usr/lib/x86_64-linux-gnu/

# copy libts-0.0-0
wget -c --quiet http://ftp.us.debian.org/debian/pool/main/t/tslib/libts-0.0-0_1.0-11_amd64.deb
mkdir libts
dpkg -x libts-0.0-0_1.0-11_amd64.deb libts
cp -L libts/usr/lib/x86_64-linux-gnu/libts-0.0.so.0 ${APPDIR}/usr/lib/x86_64-linux-gnu/
66

Valentin Platzgummer's avatar
Valentin Platzgummer committed
67 68
# MeasurementComplexItem requirements: libortools.so (inside repo), libprotobuf.so (inside repo), libgeographic.so (must be installed).

Valentin Platzgummer's avatar
Valentin Platzgummer committed
69
# copy libortools.so, etc...
Valentin Platzgummer's avatar
Valentin Platzgummer committed
70
cp -L ${QGC_SRC}/libs/or-tools-src-ubuntu/lib/*.so* ${APPDIR}/usr/lib/x86_64-linux-gnu/ || { echo "libortools.so not found"; exit  1; }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
71 72

# copy boost
Valentin Platzgummer's avatar
Valentin Platzgummer committed
73
cp -L /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 ${APPDIR}/usr/lib/x86_64-linux-gnu/ || { echo "libboost_system.so.1.65.1 not found"; exit  1; }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
74 75

# copy libcrypto
Valentin Platzgummer's avatar
Valentin Platzgummer committed
76
cp -L /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 ${APPDIR}/usr/lib/x86_64-linux-gnu/ || { echo "libcrypto.so.1.1 not found"; exit  1; }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
77 78

# copy libSDL2
Valentin Platzgummer's avatar
Valentin Platzgummer committed
79
cp -L /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0 ${APPDIR}/usr/lib/x86_64-linux-gnu/ || { echo "libSDL2-2.0.so.0 not found"; exit  1; }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
80 81


82
# copy QGroundControl release into appimage
83
rsync -av --exclude=*.cpp --exclude=*.h --exclude=*.o --exclude="CMake*" --exclude="*.cmake" ${QGC_RELEASE_DIR}/* ${APPDIR}/
84
rm -rf ${APPDIR}/package
85
cp ${QGC_CUSTOM_LINUX_START_SH} ${APPDIR}/AppRun
86 87

# copy icon
88
cp ${QGC_CUSTOM_APP_ICON} ${APPDIR}/
89

90
cat > ./QGroundControl.desktop <<\EOF
91 92
[Desktop Entry]
Type=Application
93 94
Name=${QGC_CUSTOM_APP_NAME}
GenericName=${QGC_CUSTOM_GENERIC_NAME}
95
Comment=UAS ground control station
96
Icon=${QGC_CUSTOM_APP_ICON_NAME}
97 98 99 100 101 102
Exec=AppRun
Terminal=false
Categories=Utility;
Keywords=computer;
EOF

103
VERSION=$(strings ${APPDIR}/${QGC_CUSTOM_APP_NAME} | grep '^v[0-9*]\.[0-9*].[0-9*]' | head -n 1)
104
echo ${QGC_CUSTOM_APP_NAME} Version: ${VERSION}
105 106

# Go out of AppImage
107 108
cd ${TMPDIR}
wget -c --quiet "https://github.com/probonopd/AppImageKit/releases/download/5/AppImageAssistant" # (64-bit)
109 110
chmod a+x ./AppImageAssistant

111 112 113
./AppImageAssistant ./$APP.AppDir/ ${TMPDIR}/$APP".AppImage"

cp ${TMPDIR}/$APP".AppImage" ${OUTPUT_DIR}/$APP".AppImage"
114