Skip to content

Commit 7414989

Browse files
CI/appimage: add x86_64 AppImage workflow
Signed-off-by: Bindea Cristian <[email protected]>
1 parent 6b1dde5 commit 7414989

File tree

10 files changed

+256
-30
lines changed

10 files changed

+256
-30
lines changed

Diff for: .github/workflows/build_ubuntu_appimage.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Osc x86_64 AppImage Build
2+
3+
on: [push, pull_request]
4+
5+
env:
6+
BUILD_HOST: ubuntu-22.04
7+
USERNAME: github-actions
8+
9+
jobs:
10+
11+
build_scopy_x86-64_appimage:
12+
runs-on: ubuntu-22.04
13+
container:
14+
image: cristianbindea/osc-ubuntu20:latest
15+
options: --user root
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
set-safe-directory: 'true'
21+
fetch-depth: '0'
22+
23+
- name: Create Osc AppImage
24+
shell: bash
25+
run: |
26+
cd $GITHUB_WORKSPACE
27+
./CI/appimage_x86_64/build_osc.sh
28+
./CI/appimage_x86_64/create_appimage.sh get_tools create_appdir create_appimage move_appimage
29+
30+
- name: Set short git commit SHA
31+
shell: bash
32+
run: |
33+
cd $GITHUB_WORKSPACE
34+
git config --global --add safe.directory $GITHUB_WORKSPACE
35+
echo "commit_sha=$(git rev-parse --short ${{ github.sha }})" >> "$GITHUB_ENV"
36+
37+
- uses: actions/upload-artifact@v4
38+
with:
39+
name: osc-linux-x86_64-${{ env.commit_sha }}
40+
path: ${{ github.workspace }}/ADI_IIO_Oscilloscope-x86_64.AppImage

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ adi-osc.desktop
2222
org.adi.pkexec.osc.policy
2323
osc-wrapper
2424
.vscode
25+
CI/appimage_x86_64/staging

Diff for: CI/appimage_x86_64/.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!install_deps.sh

Diff for: CI/appimage_x86_64/AppRun

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
export APPDIR="$(dirname "$(readlink -f "$0")")"
3+
export LD_LIBRARY_PATH="$APPDIR/usr/lib:$LD_LIBRARY_PATH"
4+
export PATH="$APPDIR/usr/bin/:$PATH"
5+
cd $APPDIR/usr/bin/
6+
exec osc

Diff for: CI/appimage_x86_64/build_osc.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
set -xe
4+
5+
SRC_DIR=$(git rev-parse --show-toplevel 2>/dev/null ) || \
6+
SRC_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && cd ../../ && pwd )
7+
SRC_SCRIPT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
8+
9+
export NO_STRIP=1
10+
BUILD_FOLDER=$SRC_DIR/build
11+
JOBS="-j14"
12+
13+
git config --global --add safe.directory $SRC_DIR
14+
15+
mkdir -p $BUILD_FOLDER
16+
17+
pushd $BUILD_FOLDER
18+
cmake ../
19+
make $JOBS
20+
popd

Diff for: CI/appimage_x86_64/create_appimage.sh

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/bash
2+
set -xe
3+
4+
SRC_DIR=$(git rev-parse --show-toplevel 2>/dev/null ) || \
5+
SRC_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && cd ../../ && pwd )
6+
SRC_SCRIPT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
7+
8+
export NO_STRIP=1
9+
BUILD_FOLDER=$SRC_DIR/build
10+
STAGING_AREA=$SRC_SCRIPT/staging
11+
APP_DIR=$STAGING_AREA/OscAppDir
12+
13+
14+
get_tools() {
15+
mkdir -p $STAGING_AREA
16+
pushd $STAGING_AREA
17+
18+
# download tools for creating the AppDir and the AppImage
19+
if [ ! -f linuxdeploy-x86_64.AppImage ];then
20+
wget "https://github.com/linuxdeploy/linuxdeploy/releases/download/1-alpha-20240109-1/linuxdeploy-x86_64.AppImage"
21+
chmod +x linuxdeploy-x86_64.AppImage
22+
fi
23+
24+
if [ ! -f linuxdeploy-plugin-gtk.sh ];then
25+
wget "https://raw.githubusercontent.com/linuxdeploy/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh"
26+
chmod +x linuxdeploy-plugin-gtk.sh
27+
fi
28+
29+
if [ ! -f linuxdeploy-plugin-appimage-x86_64.AppImage ];then
30+
wget https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/1-alpha-20230713-1/linuxdeploy-plugin-appimage-x86_64.AppImage
31+
chmod +x linuxdeploy-plugin-appimage-x86_64.AppImage
32+
fi
33+
34+
popd
35+
}
36+
37+
38+
create_appdir()
39+
{
40+
mkdir -p $STAGING_AREA
41+
pushd $STAGING_AREA
42+
rm -rf $APP_DIR
43+
44+
# inside a docker image you can't run an appimage executable without privileges
45+
# so the solution is to extract the appimage first and only then to run it
46+
export APPIMAGE_EXTRACT_AND_RUN=1
47+
$STAGING_AREA/linuxdeploy-x86_64.AppImage \
48+
--appdir $APP_DIR \
49+
--executable $SRC_DIR/build/osc \
50+
--custom-apprun $SRC_DIR/CI/appimage_x86_64/AppRun \
51+
--desktop-file $SRC_DIR/CI/appimage_x86_64/osc.desktop \
52+
--icon-file $SRC_DIR/build/icons/osc.svg \
53+
--plugin gtk
54+
55+
cp -R $SRC_DIR/build/plugins $APP_DIR/usr/bin
56+
cp -R $SRC_DIR/build/profiles $APP_DIR/usr/bin
57+
cp -R $SRC_DIR/xmls $APP_DIR/usr/bin
58+
cp -R $SRC_DIR/waveforms $APP_DIR/usr/bin
59+
cp -R $SRC_DIR/filters $APP_DIR/usr/bin
60+
cp -R $SRC_DIR/block_diagrams $APP_DIR/usr/bin
61+
cp -R $SRC_DIR/build/glade $APP_DIR/usr/bin
62+
cp $SRC_DIR/build/icons/* $APP_DIR/usr/bin/glade
63+
cp -R $APP_DIR/usr/share/icons $APP_DIR/usr/bin
64+
cp $SRC_DIR/build/styles.css $APP_DIR/usr/bin
65+
66+
cp /usr/local/lib/libad9361.so $APP_DIR/usr/lib
67+
cp /usr/local/lib/libad9166.so $APP_DIR/usr/lib
68+
69+
popd
70+
}
71+
72+
create_appimage(){
73+
pushd $STAGING_AREA
74+
$STAGING_AREA/linuxdeploy-plugin-appimage-x86_64.AppImage --appdir $APP_DIR
75+
popd
76+
}
77+
78+
move_appimage(){
79+
mv $STAGING_AREA/ADI_IIO_Oscilloscope-x86_64.AppImage $SRC_DIR/
80+
chmod +x $SRC_DIR/ADI_IIO_Oscilloscope-x86_64.AppImage
81+
}
82+
83+
for arg in $@; do
84+
$arg
85+
done

Diff for: CI/appimage_x86_64/create_docker_image.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash -ex
2+
3+
SRC_SCRIPT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
4+
5+
docker build -t cristianbindea/osc-ubuntu20:testing -f docker/Dockerfile .
6+
7+
# # build the image using old backend
8+
# DOCKER_BUILDKIT=0 docker build -t cristianbindea/osc-ubuntu20:testing -f docker/Dockerfile .

Diff for: CI/appimage_x86_64/docker/Dockerfile

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM ubuntu:20.04
2+
SHELL ["/bin/bash", "-c"]
3+
4+
ARG USER=runner
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
ENV CI_SCRIPT=ON
7+
8+
ENV TZ=Europe/Bucharest
9+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
10+
RUN apt-get update && \
11+
apt-get -y upgrade && \
12+
apt-get install -y apt-utils sudo tzdata keyboard-configuration software-properties-common
13+
14+
RUN groupadd -g 1000 -r $USER && \
15+
useradd -u 1000 -g 1000 --create-home -r $USER
16+
17+
#Change password
18+
RUN echo "$USER:$USER" | chpasswd
19+
20+
#Make sudo passwordless
21+
RUN echo "${USER} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-$USER && \
22+
usermod -aG sudo $USER && \
23+
usermod -aG plugdev $USER
24+
25+
USER $USER
26+
WORKDIR /home/${USER}/scripts
27+
COPY install_deps.sh .
28+
RUN sudo chown -R $USER:$USER /home/${USER}/scripts
29+
RUN ./install_deps.sh install_apt_pkgs install_gtkdatabox install_libserialport install_libiio install_libad9361 install_libad9166
30+
WORKDIR /home/${USER}
31+
32+
# Clean image
33+
RUN sudo rm -rf /home/${USER}/scripts
34+
RUN sudo rm -rf /var/lib/apt/lists/*
35+
FROM scratch
36+
COPY --from=0 / /

Diff for: CI/appimage_x86_64/install_deps.sh

100644100755
+49-30
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
#!/bin/bash
2-
32
set -xe
43

5-
WORKDIR="/home/$USER"
4+
SRC_DIR=$(git rev-parse --show-toplevel 2>/dev/null ) || \
5+
SRC_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && cd ../../ && pwd )
6+
SRC_SCRIPT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
7+
8+
STAGING_AREA=$SRC_SCRIPT/staging
9+
10+
LIBSERIALPORT_BRANCH="master"
611
LIBIIO_BRANCH="libiio-v0"
712
LIBAD9361_BRANCH="main"
813
LIBAD9166_BRANCH="main"
914

15+
JOBS="-j14"
16+
1017
install_apt_pkgs() {
11-
export APT_PKGS="libglib2.0-dev \
18+
APT_PKGS="libglib2.0-dev \
1219
libgtk-3-dev \
1320
libmatio-dev \
1421
libfftw3-dev \
@@ -25,70 +32,82 @@ install_apt_pkgs() {
2532
libcdk5-dev \
2633
libusb-1.0-0-dev \
2734
autotools-dev \
28-
autoconf
35+
autoconf \
36+
wget \
37+
git \
38+
libtool \
39+
libfuse2 \
40+
dpkg-dev
2941
"
30-
sudo apt-get update
42+
sudo apt-get update
3143
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y $APT_PKGS
3244
}
3345

3446
install_gtkdatabox() {
35-
wget https://downloads.sourceforge.net/project/gtkdatabox/gtkdatabox-1/gtkdatabox-1.0.0.tar.gz
36-
tar xvf gtkdatabox-1.0.0.tar.gz
47+
mkdir -p $STAGING_AREA
48+
pushd $STAGING_AREA
49+
if [ ! -d 'gtkdatabox-1.0.0' ]; then
50+
wget https://downloads.sourceforge.net/project/gtkdatabox/gtkdatabox-1/gtkdatabox-1.0.0.tar.gz
51+
tar xvf gtkdatabox-1.0.0.tar.gz
52+
fi
3753
cd gtkdatabox-1.0.0
3854
./configure
39-
sudo make install
55+
sudo make $JOBS install
56+
popd
4057
}
4158

4259
install_libiio() {
43-
git clone https://github.com/analogdevicesinc/libiio
60+
mkdir -p $STAGING_AREA
61+
pushd $STAGING_AREA
62+
[ -d 'libiio' ] || git clone https://github.com/analogdevicesinc/libiio.git -b $LIBIIO_BRANCH libiio
4463
cd libiio
45-
git checkout $LIBIIO_BRANCH
46-
mkdir build
64+
mkdir -p build
4765
cd build
4866
cmake -DWITH_SERIAL_BACKEND=ON ../
49-
make
67+
make $JOBS
5068
sudo make install
5169
popd
5270
}
5371

5472
install_libad9361() {
55-
pushd $WORKDIR
56-
git clone https://github.com/analogdevicesinc/libad9361-iio
73+
mkdir -p $STAGING_AREA
74+
pushd $STAGING_AREA
75+
[ -d 'libad9361-iio' ] || git clone https://github.com/analogdevicesinc/libad9361-iio.git -b $LIBAD9361_BRANCH libad9361-iio
5776
cd libad9361-iio
58-
git checkout $LIBAD9361_BRANCH
59-
mkdir build
77+
mkdir -p build
6078
cd build
6179
cmake ../
62-
make
80+
make $JOBS
6381
sudo make install
6482
popd
6583
}
6684

6785
install_libad9166 () {
68-
pushd $WORKDIR
69-
git clone https://github.com/analogdevicesinc/libad9166-iio
86+
mkdir -p $STAGING_AREA
87+
pushd $STAGING_AREA
88+
[ -d 'libad9166-iio' ] || git clone https://github.com/analogdevicesinc/libad9166-iio.git -b $LIBAD9166_BRANCH libad9166-iio
7089
cd libad9166-iio
71-
git checkout $LIBAD9166_BRANCH
72-
mkdir build
90+
mkdir -p build
7391
cd build
7492
cmake ../
75-
make
93+
make $JOBS
7694
sudo make install
7795
popd
7896
}
7997

8098
install_libserialport() {
81-
pushd $WORKDIR
82-
git clone https://github.com/sigrokproject/libserialport
99+
mkdir -p $STAGING_AREA
100+
pushd $STAGING_AREA
101+
[ -d 'libserialport' ] || git clone https://github.com/sigrokproject/libserialport -b $LIBSERIALPORT_BRANCH libserialport
83102
cd libserialport
84103
./autogen.sh
85104
./configure
86-
make
105+
make $JOBS
87106
sudo make install
107+
popd
88108

89109
}
90-
build_osc() {
91-
mkdir build && cd build
92-
cmake ../
93-
make -j9
94-
}
110+
111+
for arg in $@; do
112+
$arg
113+
done

Diff for: CI/appimage_x86_64/osc.desktop

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[Desktop Entry]
2+
Version=1.0
3+
Icon=osc
4+
Exec=osc
5+
Terminal=false
6+
Type=Application
7+
Categories=Science
8+
Name=ADI IIO Oscilloscope
9+
GenericName=ADI IIO Oscilloscope

0 commit comments

Comments
 (0)