]> sigrok.org Git - sigrok-util.git/blame - cross-compile/appimage/sigrok-native-appimage
sigrok-native-appimage: Don't add the glibc version to the filename.
[sigrok-util.git] / cross-compile / appimage / sigrok-native-appimage
CommitLineData
54207903 1#!/bin/bash
3d2ed47b
UH
2##
3## Copyright (C) 2016 Simon Peter
ea193494 4## Copyright (C) 2017-2018 Uwe Hermann <uwe@hermann-uwe.de>
3d2ed47b
UH
5## This file is licensed under the terms of the MIT license.
6##
54207903 7
ea193494 8# Bundle PulseView/sigrok-cli (and deps) as an AppImage for x86_64/i386 Linux.
3d2ed47b 9# Note: This assumes the full sigrok stack has been installed into $PREFIX.
54207903 10
3d2ed47b 11PREFIX=$HOME/sr
54207903 12
a8115a71
UH
13APPIMAGEKIT_OUTDIR=$HOME/AppImageKit/out
14
8c7df980 15# ARCH=i386
54207903 16ARCH=x86_64
17
90badf4c
UH
18PYVER=3.4
19
a8115a71
UH
20########################################################################
21# You usually don't have to change anything below this line
22########################################################################
23
ea193494
UH
24if [ "x$1" = "xsigrok-cli" ]; then
25 APP=sigrok-cli
26else
27 APP=PulseView
28fi
3d2ed47b
UH
29LOWERAPP=${APP,,}
30
a8115a71
UH
31export STATIC_FILES=`pwd`/contrib
32
33# Add $APPIMAGEKIT_OUTDIR so we can find all the binaries there.
34export PATH=$APPIMAGEKIT_OUTDIR:$PATH
35
3d2ed47b
UH
36A="./$APP/$APP.AppDir"
37mkdir -p $A/usr/bin $A/usr/lib $A/usr/share
54207903 38cd ./$APP
39
9cacd19e 40. $STATIC_FILES/functions.sh
54207903 41
42########################################################################
3d2ed47b 43# Get build products from $PREFIX
54207903 44########################################################################
45
54207903 46cd $APP.AppDir/
47
ea193494 48cp $PREFIX/bin/$LOWERAPP usr/bin/
54207903 49chmod a+x usr/bin/*
3d2ed47b
UH
50cp $PREFIX/lib/lib*.so* usr/lib/
51cp -r $PREFIX/share/libsigrokdecode usr/share/
52cp -r $PREFIX/share/sigrok-firmware usr/share/
ea193494
UH
53mkdir -p usr/share/applications
54cp $PREFIX/share/applications/org.sigrok.$APP.desktop usr/share/applications
fe8f66a9
UH
55cp -r $PREFIX/share/icons usr/share/
56cp -r $PREFIX/share/metainfo usr/share/
57cp -r $PREFIX/share/mime usr/share/
54207903 58
ea193494
UH
59# Drop unneeded stuff.
60if [ "x$1" = "xsigrok-cli" ]; then
61 rm -f usr/lib/libsigc*
62 rm -f usr/lib/libglibmm*
63 rm -f usr/lib/libsigrokcxx*
64 rm -f usr/share/icons/hicolor/*/apps/pulseview.*
65 rm -f usr/share/metainfo/org.sigrok.PulseView.appdata.xml
66else
67 rm -f usr/share/icons/hicolor/scalable/apps/sigrok-cli.svg
68fi
69
54207903 70# Reduce binary size
71strip usr/bin/*
72strip usr/lib/*
73
74########################################################################
75# AppRun is the main launcher that gets executed when AppImage is run
76########################################################################
77
a8115a71 78cp $APPIMAGEKIT_OUTDIR/AppRun .
54207903 79
80########################################################################
81# Copy desktop and icon file to AppDir for AppRun to pick them up
82########################################################################
83
ea193494
UH
84cp $PREFIX/share/applications/org.sigrok.$APP.desktop .
85cp $PREFIX/share/icons/hicolor/scalable/apps/$LOWERAPP.svg .
54207903 86
54207903 87########################################################################
88# Copy in the dependencies that cannot be assumed to be available
89# on all target systems
90########################################################################
91
54207903 92copy_deps
93
ea193494
UH
94if [ "x$1" != "xsigrok-cli" ]; then
95 # Get all Qt5 plugins (won't be copied automatically).
96 QT5PLUGINS=/usr/lib/$ARCH-linux-gnu/qt5/plugins # Host (+ AppRun) path.
97 mkdir -p .$QT5PLUGINS
98 cp -r $QT5PLUGINS/accessible .$QT5PLUGINS
99 cp -r $QT5PLUGINS/generic .$QT5PLUGINS
100 cp -r $QT5PLUGINS/iconengines .$QT5PLUGINS
101 cp -r $QT5PLUGINS/imageformats .$QT5PLUGINS
102 cp -r $QT5PLUGINS/platforminputcontexts .$QT5PLUGINS
103 cp -r $QT5PLUGINS/platforms .$QT5PLUGINS
104
105 # Get some additional dependencies of the Qt5 plugins.
106 ldd .$QT5PLUGINS/platforms/libqxcb.so | grep "=>" | awk '{print $3}' | xargs -I '{}' cp -v '{}' ./usr/lib || true
107 ldd .$QT5PLUGINS/imageformats/libqsvg.so | grep "=>" | awk '{print $3}' | xargs -I '{}' cp -v '{}' ./usr/lib || true
108fi
6e8a37a4 109
90badf4c 110# Python 3
9118290a 111cp /usr/lib/$ARCH-linux-gnu/libpython$PYVER* ./usr/lib
90badf4c
UH
112mkdir -p ./usr/share/pyshared
113cp -r /usr/lib/python$PYVER/* ./usr/share/pyshared # AppRun expects this path.
114
9118290a 115cp -r ./usr/share/pyshared/plat-$ARCH-linux-gnu/* ./usr/share/pyshared
90badf4c 116
54207903 117########################################################################
118# Delete stuff that should not go into the AppImage
119########################################################################
120
54207903 121move_lib
9118290a
UH
122mv ./usr/lib/$ARCH-linux-gnu/* usr/lib/
123rm -r ./usr/lib/$ARCH-linux-gnu/
54207903 124
e163385a
UH
125delete_blacklisted
126
3d2ed47b
UH
127# Remove some incorrectly/unintentionally copied files.
128rm -r ./home
129
54207903 130########################################################################
35accad0 131# Determine the version of the app
54207903 132########################################################################
133
35accad0 134VERSION="NIGHTLY"
54207903 135echo $VERSION
136
137########################################################################
138# Patch away absolute paths; it would be nice if they were relative
139########################################################################
140
8fa1956a 141find usr/ -type f -executable -exec sed -i -e "s|/usr|././|g" {} \;
54207903 142
143########################################################################
144# AppDir complete
145# Now packaging it as an AppImage
146########################################################################
147
148cd ..
149
837d376b
UH
150VERSION=$VERSION $APPIMAGEKIT_OUTDIR/appimagetool ./$APP.AppDir/
151mkdir -p ../out/ || true
152mv *.AppImage* ../out/