Skip to content

Commit

Permalink
ci/x86_64: add workflow for linux x86_64 AppImage
Browse files Browse the repository at this point in the history
Signed-off-by: Bindea Cristian <[email protected]>
  • Loading branch information
bindea-cristian committed Jun 19, 2024
1 parent ad70eec commit 9aa5573
Show file tree
Hide file tree
Showing 9 changed files with 622 additions and 4 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/appimage-x86_64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Scopy x86_64 AppImage Build

on: [push, pull_request]

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

jobs:

build_scopy_x86-64_appimage:
runs-on: ubuntu-20.04

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

- name: Pull the Docker Image
run: docker pull cristianbindea/scopy2-x86_64-appimage:latest

- name: Create Scopy AppImage
shell: bash
run: |
export CI_SCRIPT=ON
cd $GITHUB_WORKSPACE
./ci/x86_64/x86-64_appimage_process.sh generate_ci_envs
docker run \
--mount type=bind,source="$GITHUB_WORKSPACE",target=/home/runner/scopy \
--env-file $GITHUB_WORKSPACE/ci/x86_64/gh-actions.envs \
cristianbindea/scopy2-x86_64-appimage:latest \
/bin/bash -c 'cd $HOME && \
sudo chown -R runner:runner scopy && \
cd $HOME/scopy && \
./ci/x86_64/x86-64_appimage_process.sh run_workflow
'
- name: Set short git commit SHA
shell: bash
run: echo "commit_sha=$(git rev-parse --short ${{ github.sha }})" >> "$GITHUB_ENV"

- uses: actions/upload-artifact@v4
with:
name: scopy-linux-x86_64-${{ env.commit_sha }}
path: ${{ github.workspace }}/Scopy-x86_64.AppImage
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ ci/armhf/scopy.AppDir
ci/armhf/staging
ci/armhf/scopy.AppDir
ci/armhf/scopy.squashfs
ci/x86_64/staging
ci/x86_64/scopy.AppDir
windows/*
core/include/scopy-core_config.h
core/include/scopy-core_export.h
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ if(ENABLE_TRANSLATION)
qt_add_resources(SCOPY_RESOURCES ${CMAKE_BINARY_DIR}/translations.qrc)
endif()

if(DEFINED ENV{APPIMAGE})
add_compile_definitions(__appimage__)
endif()

qt_add_resources(SCOPY_RESOURCES ${SCOPY_RESOURCE_FILES})

if(WIN32)
Expand Down
15 changes: 15 additions & 0 deletions ci/x86_64/AppRun
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -e
SELF=$(readlink -f "$0")
HERE=${SELF%/*}

export QT_PLUGIN_PATH=$HERE/usr/plugins
export QT_QPA_PLATFORM_PLUGIN_PATH=$HERE/usr/plugins/platforms
export LD_LIBRARY_PATH=$HERE/usr/lib

python_dir=$(find "$HERE/usr/lib/" -maxdepth 1 -type d -name "python3.*")
export PYTHONHOME=$python_dir
export PYTHONPATH=$python_dir:$python_dir/lib-dynload:$python_dir/site-packages:$python_dir/encodings
echo "Starting Scopy"
ldd $HERE/usr/bin/scopy
exec $HERE/usr/bin/scopy
35 changes: 35 additions & 0 deletions ci/x86_64/copy-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

set -e
SRC_DIR=$(git rev-parse --show-toplevel 2>/dev/null ) || \
SRC_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && cd ../../ && pwd )
source $SRC_DIR/ci/armhf/armhf_build_config.sh

BINARY=$1
LOCATION=$2
LIBS_ARRAY=()
BLACKLISTED=($(wget --quiet https://raw.githubusercontent.com/probonopd/AppImages/master/excludelist -O - | sort | uniq | cut -d '#' -f 1 | grep -v "^#.*" | grep "[^-\s]"))

export LD_LIBRARY_PATH="${APP_DIR}/usr/lib:${SYSROOT}/lib:${SYSROOT}/lib/arm-linux-gnueabihf:${SYSROOT}/usr/arm-linux-gnueabihf/lib:${SYSROOT}/usr/local/qt5.15/lib:${SYSROOT}/usr/local/lib:${SRC_DIR}/build"
run_ldd(){
for library in $(ldd "$1" | cut -d '>' -f 2 | awk '{print $1}')
do
# check if the library exists at that path and if it was processed already or blacklisted
if ! [[ "${BLACKLISTED[*]}" =~ "${library##*/}" ]]; then
if [ -f "${library}" ] && ! [[ "${LIBS_ARRAY[*]}" =~ "${library}" ]]; then
LIBS_ARRAY+=("${library}")
echo "---Added new lib: ${library}"
if [ ! -f "${LOCATION}"/"${library##*/}" ]; then
cp "${library}" "${LOCATION}"
[ -L "${library}" ] && cp "$(realpath "${library}")" "${LOCATION}"
strip --strip-unneeded "${LOCATION}"/"${library##*/}"
fi
run_ldd "${library}"
fi
fi
done
}

for arg in $BINARY; do
run_ldd "${arg}"
done
35 changes: 35 additions & 0 deletions ci/x86_64/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#docker build -t cristianbindea/scopy2-x86_64-appimage .
#DOCKER_BUILDKIT=0
FROM ubuntu:20.04
SHELL ["/bin/bash", "-c"]

ARG USER=runner
ARG DEBIAN_FRONTEND=noninteractive

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 git tzdata keyboard-configuration

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}
RUN git clone https://github.com/analogdevicesinc/scopy --branch dev
WORKDIR /home/${USER}/scopy

ENV CI_SCRIPT=ON
RUN ./ci/x86_64/x86-64_appimage_process.sh install_packages
RUN sudo pip3 install aqtinstall && sudo python3 -m aqt install-qt --outputdir /opt/Qt linux desktop 5.15.2
RUN ./ci/x86_64/x86-64_appimage_process.sh clone download_tools build_deps

WORKDIR /home/${USER}
# RUN rm -rf scopy
9 changes: 9 additions & 0 deletions ci/x86_64/scopy.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Desktop Entry]
Icon=scopy
Exec=scopy
Terminal=false
Type=Application
Categories=Science
Name=Scopy
GenericName=Oscilloscope
Comment=A software oscilloscope
Loading

0 comments on commit 9aa5573

Please sign in to comment.