]> sigrok.org Git - sigrok-util.git/blob - cross-compile/appimage/bundle.sh
bf72651e3f8e4c91aa440555cb2fec424ec32816
[sigrok-util.git] / cross-compile / appimage / bundle.sh
1 #!/bin/bash
2
3 # (c) 2016 Simon Peter
4 # This file is licensed under the terms of the MIT license.
5 #
6 # Bundle PulseView and its dependencies as an AppImage for x86_64 Linux
7 # TODO: Change it to use build products and libraries from a more mature
8 # distribution such as Debian oldstable, CentOS 6 or Ubuntu Trusty or older.
9
10 APP=PulseView
11 LOWERAPP=${APP,,} 
12
13 ARCH=x86_64
14
15 mkdir -p ./$APP/$APP.AppDir/usr/bin ./$APP/$APP.AppDir/usr/lib
16 cd ./$APP
17
18 wget -q https://github.com/probonopd/AppImages/raw/master/functions.sh -O ./functions.sh
19 . ./functions.sh
20
21 ########################################################################
22 # Get runtime dependencies
23 ########################################################################
24
25 sudo apt-get update
26
27 # The following are installed into the host system so that we can bundle them into the AppImage as dependencies
28 sudo apt-get -y --force-yes install libqt5svg5 libqt5gui5 libboost-thread1.58.0 libboost-test1.58.0 libboost-chrono1.58.0 libboost-atomic1.58.0 libftdi1-2 libzip4
29
30 ########################################################################
31 # Get build products from Jenkins
32 # FIXME: Do the actual building here instead
33 ########################################################################
34
35 wget http://sigrok.org/jenkins/job/pulseview/buildtype=shared,compiler=gcc,platform=native-amd64/ws/_inst/bin/*zip*/bin.zip
36 unzip bin.zip
37
38 FW=$(wget -q "http://sigrok.org/download/binary/sigrok-firmware-fx2lafw/?C=M;O=D" -O - | grep .tar.gz | head -n 1 | cut -d '"' -f 13 | cut -d ">" -f 2 | cut -d "<" -f 1)
39 wget -c "http://sigrok.org/download/binary/sigrok-firmware-fx2lafw/$FW"
40 tar xf sigrok-firmware-fx2lafw-bin-*.tar.gz
41 rm sigrok-firmware-fx2lafw-bin-*.tar.gz
42
43 cd $APP.AppDir/
44
45 mv ../bin/pulseview usr/bin/
46 chmod a+x usr/bin/*
47
48 cd usr/lib/
49 wget http://sigrok.org/jenkins/job/libsigrok/buildtype=shared,compiler=gcc,platform=native-amd64/ws/_inst/lib/libsigrok.so.3
50 wget http://sigrok.org/jenkins/job/libsigrok/buildtype=shared,compiler=gcc,platform=native-amd64/ws/_inst/lib/libsigrokcxx.so.3
51 wget http://sigrok.org/jenkins/job/libserialport/buildtype=shared,compiler=gcc,platform=native-amd64/lastSuccessfulBuild/artifact/_inst/lib/libserialport.so.0
52 cd ../../
53
54 wget "http://sigrok.org/jenkins/job/libsigrokdecode/buildtype=shared,compiler=gcc,platform=native-amd64/lastSuccessfulBuild/artifact/*zip*/archive.zip"
55 unzip archive.zip
56 mv archive/_inst/share/libsigrokdecode usr/share/libsigrokdecode
57 mv archive/_inst/lib/libsigrokdecode.so.3 usr/lib/
58 rm -rf archive*
59
60 # Reduce binary size
61 strip usr/bin/*
62 strip usr/lib/*
63
64 ########################################################################
65 # AppRun is the main launcher that gets executed when AppImage is run
66 ########################################################################
67
68 get_apprun
69
70 ########################################################################
71 # Copy desktop and icon file to AppDir for AppRun to pick them up
72 ########################################################################
73
74 wget http://sigrok.org/jenkins/job/pulseview/buildtype=shared,compiler=gcc,platform=native-amd64/ws/contrib/pulseview.desktop
75 wget -q "http://sigrok.org/gitweb/?p=pulseview.git;a=blob_plain;f=icons/sigrok-logo-notext.png" -O sigrok-logo-notext.png
76
77 ########################################################################
78 # Patch away absolute paths; it would be nice if they were relative
79 ########################################################################
80
81 sed -i -e 's|/home/jenkins_slave/fsroot/workspace/libsigrokdecode/buildtype/shared/compiler/gcc/platform/native-amd64/_inst/share/|.//////////////////////////////////////////////////////////////////////////////////////////////////////////////share/|g' usr/lib/libsigrokdecode.so.3
82
83 ########################################################################
84 # Copy in the dependencies that cannot be assumed to be available
85 # on all target systems
86 ########################################################################
87
88 mkdir -p usr/share/
89 mv ../sigrok-firmware-* usr/share/sigrok-firmware
90
91 copy_deps
92
93 ########################################################################
94 # Delete stuff that should not go into the AppImage
95 ########################################################################
96
97 delete_blacklisted
98 move_lib
99 mv ./usr/lib/x86_64-linux-gnu/* usr/lib/
100 rm -r ./usr/lib/x86_64-linux-gnu/
101
102 ########################################################################
103 # Determine the version of the app; also include needed glibc version
104 ########################################################################
105
106 VER1=$(./AppRun --version | cut -d " "  -f 2)
107 GLIBC_NEEDED=$(glibc_needed)
108 VERSION=$VER1.glibc$GLIBC_NEEDED
109 echo $VERSION
110
111 ########################################################################
112 # Patch away absolute paths; it would be nice if they were relative
113 ########################################################################
114
115 patch_usr
116
117 ########################################################################
118 # AppDir complete
119 # Now packaging it as an AppImage
120 ########################################################################
121
122 cd ..
123
124 generate_appimage