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