Skip to content

CI x86 AppImage #533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/build_ubuntu_appimage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Osc x86_64 AppImage Build

on: [push, pull_request]

env:
BUILD_HOST: ubuntu-22.04
USERNAME: github-actions

jobs:

build_osc_x86-64_appimage:
runs-on: ubuntu-22.04
container:
image: cristianbindea/osc-ubuntu20:latest
options: --user root

steps:
- uses: actions/checkout@v4
with:
set-safe-directory: 'true'
fetch-depth: '0'

- name: Create Osc AppImage
shell: bash
run: |
cd $GITHUB_WORKSPACE
./CI/appimage_x86_64/build_osc.sh
./CI/appimage_x86_64/create_appimage.sh get_tools create_appdir create_appimage move_appimage

- name: Set short git commit SHA
shell: bash
run: |
cd $GITHUB_WORKSPACE
git config --global --add safe.directory $GITHUB_WORKSPACE
echo "commit_sha=$(git rev-parse --short ${{ github.sha }})" >> "$GITHUB_ENV"

- uses: actions/upload-artifact@v4
with:
name: osc-linux-x86_64-${{ env.commit_sha }}
path: ${{ github.workspace }}/ADI_IIO_Oscilloscope-x86_64.AppImage
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ adi-osc.desktop
org.adi.pkexec.osc.policy
osc-wrapper
.vscode
CI/appimage_x86_64/staging
2 changes: 2 additions & 0 deletions CI/appimage_x86_64/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!install_deps.sh
6 changes: 6 additions & 0 deletions CI/appimage_x86_64/AppRun
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
export APPDIR="$(dirname "$(readlink -f "$0")")"
export LD_LIBRARY_PATH="$APPDIR/usr/lib:$LD_LIBRARY_PATH"
export PATH="$APPDIR/usr/bin/:$PATH"
cd $APPDIR/usr/bin/
exec osc
20 changes: 20 additions & 0 deletions CI/appimage_x86_64/build_osc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -xe

SRC_DIR=$(git rev-parse --show-toplevel 2>/dev/null ) || \
SRC_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && cd ../../ && pwd )
SRC_SCRIPT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

export NO_STRIP=1
BUILD_FOLDER=$SRC_DIR/build
JOBS="-j14"

git config --global --add safe.directory $SRC_DIR

mkdir -p $BUILD_FOLDER

pushd $BUILD_FOLDER
cmake ../
make $JOBS
popd
87 changes: 87 additions & 0 deletions CI/appimage_x86_64/create_appimage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash
set -xe

SRC_DIR=$(git rev-parse --show-toplevel 2>/dev/null ) || \
SRC_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && cd ../../ && pwd )
SRC_SCRIPT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

export NO_STRIP=1
BUILD_FOLDER=$SRC_DIR/build
STAGING_AREA=$SRC_SCRIPT/staging
APP_DIR=$STAGING_AREA/OscAppDir


get_tools() {
mkdir -p $STAGING_AREA
pushd $STAGING_AREA

# download tools for creating the AppDir and the AppImage
if [ ! -f linuxdeploy-x86_64.AppImage ];then
wget "https://github.com/linuxdeploy/linuxdeploy/releases/download/1-alpha-20240109-1/linuxdeploy-x86_64.AppImage"
chmod +x linuxdeploy-x86_64.AppImage
fi

if [ ! -f linuxdeploy-plugin-gtk.sh ];then
wget "https://raw.githubusercontent.com/linuxdeploy/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh"
chmod +x linuxdeploy-plugin-gtk.sh
fi

if [ ! -f linuxdeploy-plugin-appimage-x86_64.AppImage ];then
wget https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/1-alpha-20230713-1/linuxdeploy-plugin-appimage-x86_64.AppImage
chmod +x linuxdeploy-plugin-appimage-x86_64.AppImage
fi

popd
}


create_appdir()
{
mkdir -p $STAGING_AREA
pushd $STAGING_AREA
rm -rf $APP_DIR

sudo ldconfig

# inside a docker image you can't run an appimage executable without privileges
# so the solution is to extract the appimage first and only then to run it
export APPIMAGE_EXTRACT_AND_RUN=1
$STAGING_AREA/linuxdeploy-x86_64.AppImage \
--appdir $APP_DIR \
--executable $SRC_DIR/build/osc \
--custom-apprun $SRC_DIR/CI/appimage_x86_64/AppRun \
--desktop-file $SRC_DIR/CI/appimage_x86_64/osc.desktop \
--icon-file $SRC_DIR/build/icons/osc.svg \
--plugin gtk

cp -R $SRC_DIR/build/plugins $APP_DIR/usr/bin
cp -R $SRC_DIR/build/profiles $APP_DIR/usr/bin
cp -R $SRC_DIR/xmls $APP_DIR/usr/bin
cp -R $SRC_DIR/waveforms $APP_DIR/usr/bin
cp -R $SRC_DIR/filters $APP_DIR/usr/bin
cp -R $SRC_DIR/block_diagrams $APP_DIR/usr/bin
cp -R $SRC_DIR/build/glade $APP_DIR/usr/bin
cp $SRC_DIR/build/icons/* $APP_DIR/usr/bin/glade
cp -R $APP_DIR/usr/share/icons $APP_DIR/usr/bin
cp $SRC_DIR/build/styles.css $APP_DIR/usr/bin

cp /usr/local/lib/libad9361.so $APP_DIR/usr/lib
cp /usr/local/lib/libad9166.so $APP_DIR/usr/lib

popd
}

create_appimage(){
pushd $STAGING_AREA
$STAGING_AREA/linuxdeploy-plugin-appimage-x86_64.AppImage --appdir $APP_DIR
popd
}

move_appimage(){
mv $STAGING_AREA/ADI_IIO_Oscilloscope-x86_64.AppImage $SRC_DIR/
chmod +x $SRC_DIR/ADI_IIO_Oscilloscope-x86_64.AppImage
}

for arg in $@; do
$arg
done
8 changes: 8 additions & 0 deletions CI/appimage_x86_64/create_docker_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash -ex

SRC_SCRIPT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

docker build -t cristianbindea/osc-ubuntu20:testing -f docker/Dockerfile .

# # build the image using old backend
# DOCKER_BUILDKIT=0 docker build -t cristianbindea/osc-ubuntu20:testing -f docker/Dockerfile .
36 changes: 36 additions & 0 deletions CI/appimage_x86_64/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM ubuntu:20.04
SHELL ["/bin/bash", "-c"]

ARG USER=runner
ENV DEBIAN_FRONTEND=noninteractive
ENV CI_SCRIPT=ON

ENV TZ=Europe/Bucharest
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update && \
apt-get -y upgrade && \
apt-get install -y apt-utils sudo tzdata keyboard-configuration software-properties-common

RUN groupadd -g 1000 -r $USER && \
useradd -u 1000 -g 1000 --create-home -r $USER

#Change password
RUN echo "$USER:$USER" | chpasswd

#Make sudo passwordless
RUN echo "${USER} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-$USER && \
usermod -aG sudo $USER && \
usermod -aG plugdev $USER

USER $USER
WORKDIR /home/${USER}/scripts
COPY install_deps.sh .
RUN sudo chown -R $USER:$USER /home/${USER}/scripts
RUN ./install_deps.sh install_apt_pkgs install_gtkdatabox install_libserialport install_libiio install_libad9361 install_libad9166
WORKDIR /home/${USER}

# Clean image
RUN sudo rm -rf /home/${USER}/scripts
RUN sudo rm -rf /var/lib/apt/lists/*
FROM scratch
COPY --from=0 / /
113 changes: 113 additions & 0 deletions CI/appimage_x86_64/install_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/bin/bash
set -xe

SRC_DIR=$(git rev-parse --show-toplevel 2>/dev/null ) || \
SRC_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && cd ../../ && pwd )
SRC_SCRIPT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

STAGING_AREA=$SRC_SCRIPT/staging

LIBSERIALPORT_BRANCH="master"
LIBIIO_BRANCH="libiio-v0"
LIBAD9361_BRANCH="main"
LIBAD9166_BRANCH="main"

JOBS="-j14"

install_apt_pkgs() {
APT_PKGS="libglib2.0-dev \
libgtk-3-dev \
libmatio-dev \
libfftw3-dev \
libxml2 \
libxml2-dev\
bison \
flex \
libavahi-common-dev \
libavahi-client-dev \
libcurl4-openssl-dev \
libjansson-dev \
cmake \
libaio-dev \
libcdk5-dev \
libusb-1.0-0-dev \
autotools-dev \
autoconf \
wget \
git \
libtool \
libfuse2 \
dpkg-dev
"
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y $APT_PKGS
}

install_gtkdatabox() {
mkdir -p $STAGING_AREA
pushd $STAGING_AREA
if [ ! -d 'gtkdatabox-1.0.0' ]; then
wget https://downloads.sourceforge.net/project/gtkdatabox/gtkdatabox-1/gtkdatabox-1.0.0.tar.gz
tar xvf gtkdatabox-1.0.0.tar.gz
fi
cd gtkdatabox-1.0.0
./configure
sudo make $JOBS install
popd
}

install_libiio() {
mkdir -p $STAGING_AREA
pushd $STAGING_AREA
[ -d 'libiio' ] || git clone https://github.com/analogdevicesinc/libiio.git -b $LIBIIO_BRANCH libiio
cd libiio
mkdir -p build
cd build
cmake -DWITH_SERIAL_BACKEND=ON ../
make $JOBS
sudo make install
popd
}

install_libad9361() {
mkdir -p $STAGING_AREA
pushd $STAGING_AREA
[ -d 'libad9361-iio' ] || git clone https://github.com/analogdevicesinc/libad9361-iio.git -b $LIBAD9361_BRANCH libad9361-iio
cd libad9361-iio
mkdir -p build
cd build
cmake ../
make $JOBS
sudo make install
popd
}

install_libad9166 () {
mkdir -p $STAGING_AREA
pushd $STAGING_AREA
[ -d 'libad9166-iio' ] || git clone https://github.com/analogdevicesinc/libad9166-iio.git -b $LIBAD9166_BRANCH libad9166-iio
cd libad9166-iio
mkdir -p build
cd build
cmake ../
make $JOBS
sudo make install
popd
}

install_libserialport() {
mkdir -p $STAGING_AREA
pushd $STAGING_AREA
[ -d 'libserialport' ] || git clone https://github.com/sigrokproject/libserialport -b $LIBSERIALPORT_BRANCH libserialport
cd libserialport
./autogen.sh
./configure
make $JOBS
sudo make install
popd

}

for arg in $@; do
$arg
done
9 changes: 9 additions & 0 deletions CI/appimage_x86_64/osc.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Desktop Entry]
Version=1.0
Icon=osc
Exec=osc
Terminal=false
Type=Application
Categories=Science
Name=ADI IIO Oscilloscope
GenericName=ADI IIO Oscilloscope
Loading