Skip to content

Commit

Permalink
ci/flatpak: update scripts to work with current location
Browse files Browse the repository at this point in the history
Signed-off-by: Bindea Cristian <[email protected]>
  • Loading branch information
bindea-cristian committed Aug 14, 2024
1 parent 8919443 commit da27e3c
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 109 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/linuxflatpakbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,22 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Pull the Docker Image
run: docker pull cristianbindea/scopy2-flatpak
run: docker pull cristianbindea/scopy2-flatpak:testing

- name: Setup upterm session
uses: lhotari/action-upterm@v1
with:
wait-timeout-minutes: 5

- name: Run Docker Image
run: |
$GITHUB_WORKSPACE/ci/general/gen_ci_envs.sh > $GITHUB_WORKSPACE/ci/general/gh-actions.envs
docker run --privileged \
-v `pwd`:$GITHUB_WORKSPACE:rw \
-e CI_SCRIPT='ON' \
--mount type=bind,source="$GITHUB_WORKSPACE",target=$GITHUB_WORKSPACE \
--env-file $GITHUB_WORKSPACE/ci/general/gh-actions.envs \
cristianbindea/scopy2-flatpak /bin/bash -xe $GITHUB_WORKSPACE/ci/flatpak/inside_flatpak_docker.sh
cristianbindea/scopy2-flatpak:testing
/bin/bash -c '$GITHUB_WORKSPACE/ci/flatpak/flatpak_build_process.sh'
- name: Set short git commit SHA
shell: bash
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ doc/*
.cache/*
build/*
.vscode/*
ci/general/gh-actions.envs
ci/ubuntu/staging
ci/macOS/staging
ci/armhf/staging
Expand Down
3 changes: 2 additions & 1 deletion ci/flatpak/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Scopy.flatpak
.flatpak-builder
build
repo
org.adi.Scopy.json
org.adi.Scopy.json
tmp.json
24 changes: 24 additions & 0 deletions ci/flatpak/create_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash -xe

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

build_docker(){
pushd $SRC_DIR/ci/flatpak
docker build -t cristianbindea/scopy2-flatpak:testing -f docker/Dockerfile .
CONTAINER_NAME=builder-flatpak
docker run \
--name $CONTAINER_NAME \
--privileged \
--mount type=bind,source="$SRC_DIR/ci/flatpak/build_flatpak_deps.sh",target=/home/runner/config/build_flatpak_deps.sh,readonly \
--mount type=bind,source="$SRC_DIR/ci/flatpak/defined_variables.h",target=/home/runner/config/defined_variables.h,readonly \
--mount type=bind,source="$SRC_DIR/ci/flatpak/org.adi.Scopy.json.c",target=/home/runner/config/org.adi.Scopy.json.c,readonly \
--mount type=bind,source="$SRC_DIR/ci/flatpak/Makefile",target=/home/runner/config/Makefile,readonly \
cristianbindea/scopy2-flatpak:testing /bin/bash -c /home/runner/config/build_flatpak_deps.sh

docker commit $CONTAINER_NAME cristianbindea/scopy2-flatpak:testing
echo "Docker container $CONTAINER_NAME commited as cristianbindea/scopy2-flatpak:testing image"
popd
}

build_docker
2 changes: 1 addition & 1 deletion ci/flatpak/defined_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define _ENABLE_VOLK OFF

#elif __X86__
#define RUNTIME_VERSION 5.15-22.08
#define RUNTIME_VERSION 5.15-23.08
#define CFLAGS --disable-assembly
#define CMAKE_C_FLAGS -DCMAKE_C_FLAGS= -fno-asynchronous-unwind-tables -fPIC
#define CMAKE_ASM_FLAGS -DCMAKE_ASM_FLAGS=
Expand Down
48 changes: 27 additions & 21 deletions ci/flatpak/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
FROM ubuntu:20.04
CMD ["/bin/bash"]
ARG USER=runner
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Bucharest
ENV CI_SCRIPT=ON
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update -y
# Install starting packages
RUN apt update && apt -y upgrade && \
apt install -y apt-utils software-properties-common sudo

# Install base dependencies
RUN apt-get install -y software-properties-common build-essential git sudo apt-utils subversion mm-common
# Create user
RUN groupadd -g 1000 -r $USER && \
useradd -u 1000 -g 1000 --create-home -r $USER

# Install flatpak
RUN add-apt-repository ppa:alexlarsson/flatpak -y
RUN apt-get update -y
RUN apt install flatpak flatpak-builder -y
# Change password
RUN echo "$USER:$USER" | chpasswd

# Install remote
RUN flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
RUN flatpak install flathub org.kde.Platform//5.15-22.08 -y
RUN flatpak install flathub org.kde.Sdk//5.15-22.08 -y
# Make sudo passwordless
RUN echo "${USER} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-$USER && \
usermod -aG sudo $USER && \
usermod -aG plugdev $USER

# Clean
RUN apt-get clean -y && apt-get autoclean -y
USER $USER

RUN echo Cloning scopy-flatpak
ARG REPO_LINK=https://github.com/analogdevicesinc/scopy-flatpak
ARG REPO_LOCAL=/home/docker/scopy-flatpak
ARG REPO_BRANCH=ci-for-scopy2
# Install base dependencies
# Install flatpak
# Clean apt
RUN sudo apt install -y git wget vim build-essential subversion mm-common && \
sudo apt install flatpak jq flatpak-builder -y && \
sudo apt clean -y && sudo apt autoclean -y

RUN git clone --recurse-submodules "$REPO_LINK" -b "$REPO_BRANCH" "$REPO_LOCAL" 2> /dev/null || (cd "$REPO_LOCAL"; git pull)
# Install remote
RUN sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
RUN sudo flatpak install flathub org.kde.Platform//5.15-23.08 -y && sudo flatpak install flathub org.kde.Sdk//5.15-23.08 -y

#RUN cd /home/docker/scopy-flatpak && make -j4
#RUN rm -rf Scopy.flatpak
CMD ["/bin/bash"]
WORKDIR /home/$USER
11 changes: 0 additions & 11 deletions ci/flatpak/docker/README

This file was deleted.

60 changes: 60 additions & 0 deletions ci/flatpak/flatpak_build_process.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash -xe

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

SCOPY_JSON=$SCOPY_DIR/ci/flatpak/org.adi.Scopy.json

if [ "$CI_SCRIPT" == "ON" ];
then
SOURCE_DIR=$GITHUB_WORKSPACE
# this is needed in order to be used by flatpak caching system
# the docker image already contains the built dependencies so we just have to move them
cp -r /home/runner/flatpak_tools/.flatpak-builder $SOURCE_DIR/ci/flatpak
cp -r /home/runner/flatpak_tools/build $SOURCE_DIR/ci/flatpak
else
SOURCE_DIR=$SCOPY_DIR
fi

pushd $SCOPY_DIR/ci/flatpak

git submodule update --init

# Run the preprocess step to generate org.adi.Scopy.json
make preprocess

# Disable the preprocess step; The Json file will now be modified and
# we don't want to re-generate it at the build step
export EN_PREPROCESS=false

# check the number of elements in the json file in order to get the last element, which is Scopy
cnt=$( echo $(jq '.modules | length' $SCOPY_JSON) )
cnt=$(($cnt-1))

# We are building in Github Actions and we use the current directory folder on a CLEAN Docker image
cat $SCOPY_JSON | jq --tab '.modules['$cnt'].sources[0].type = "dir"' > tmp.json
cp tmp.json $SCOPY_JSON
cat $SCOPY_JSON | jq --tab '.modules['$cnt'].sources[0].path = "'$SOURCE_DIR'"' > tmp.json
cp tmp.json $SCOPY_JSON
cat $SCOPY_JSON | jq --tab 'del(.modules['$cnt'].sources[0].url)' > tmp.json
cp tmp.json $SCOPY_JSON
cat $SCOPY_JSON | jq --tab 'del(.modules['$cnt'].sources[0].branch)' > tmp.json
cp tmp.json $SCOPY_JSON
rm tmp.json

# Generate build status info for the about page
echo "Details about the versions of dependencies can be found <a href="https://github.com/analogdevicesinc/scopy-flatpak/blob/master/org.adi.Scopy.json.c">here</a>" > build-status
cp build-status $SOURCE_DIR/build-status

# Insert env vars in the sandboxed flatpak build
# $SOURCE_DIR/ci/general/gen_ci_envs.sh > $SOURCE_DIR/ci/general/gh-actions.envs
# CI_ENVS=$(jq -R -n -c '[inputs|split("=")|{(.[0]):.[1]}] | add' $SOURCE_DIR/ci/general/gh-actions.envs)
# echo "CI_ENVS= $CI_ENVS"
# cat $SCOPY_JSON | jq --tab '."build-options".env += ('$CI_ENVS')' > tmp.json
# cp tmp.json $SCOPY_JSON

make

# Copy the Scopy.flatpak file in $SOURCE_DIR (which is the external location, mount when docker starts)
[ -z $CI_SCRIPT ] || cp Scopy.flatpak $SOURCE_DIR/
popd
68 changes: 0 additions & 68 deletions ci/flatpak/inside_flatpak_docker.sh

This file was deleted.

6 changes: 3 additions & 3 deletions ci/flatpak/org.adi.Scopy.json.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@
"-DCMAKE_INSTALL_PREFIX:PATH=/app",
"-DENABLE_PYTHON=OFF",
"-DENABLE_CSHARP=OFF",
"-DENABLE_LOG=ON",
"-DENABLE_TOOLS=ON",
"-DENABLE_TOOLS=OFF",
"-DBUILD_EXAMPLES=OFF",
"-DINSTALL_UDEV_RULES=OFF"
],
"sources": [
Expand Down Expand Up @@ -495,7 +495,7 @@
{
"type": "git",
"url": "https://github.com/analogdevicesinc/iio-emu",
"commit": "b8208485f50573a38263031ab05e9cd30712bf0c"
"branch": "master"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion ci/flatpak/shared-modules
Submodule shared-modules updated 65 files
+7 −1 CODEOWNERS
+23 −3 README.md
+3 −0 SDL/README.md
+6 −0 SDL/SDL_image-1.2.12.json
+5 −0 SDL/SDL_mixer-1.2.12.json
+6 −0 SDL/SDL_ttf-2.0.11.json
+17 −0 SDL/sdl12-compat.json
+15 −0 SDL2/README.md
+22 −0 SDL2/SDL2-no-libdecor.json
+23 −0 SDL2/SDL2-with-libdecor.json
+18 −0 clutter/clutter.json
+3 −3 glu/glu-9.json
+59 −22 gtk2/gtk2-common-themes.json
+30 −0 gtk2/gtk2-fix-crash-in-show-uri.patch
+4 −0 gtk2/gtk2.json
+10 −0 gtk2/readme.md
+2 −2 gudev/gudev.json
+20 −0 gzdoom/game-music-emu.json
+23 −19 gzdoom/gzdoom.json
+20 −0 gzdoom/zmusic.json
+8 −1 libcanberra/libcanberra.json
+6 −0 libdecor/README.md
+18 −0 libdecor/libdecor.json
+0 −34 libmad/Provide-Thumb-2-alternative-code-for-MAD_F_MLN.diff
+0 −12 libmad/libmad-0.15.1b-cflags-O2.patch
+0 −146 libmad/libmad-0.15.1b-cflags.patch
+0 −37 libmad/libmad-0.15.1b-multiarch.patch
+0 −13 libmad/libmad-0.15.1b-ppc.patch
+9 −42 libmad/libmad.json
+0 −12 libmad/libmad.thumb.diff
+0 −11 libmad/mad.pc
+2 −2 libsecret/libsecret.json
+14 −0 libsoup/libsoup-2.4.json
+4 −4 libusb/libusb.json
+1 −0 linux-audio/fftw3f.json
+6 −4 linux-audio/fluidsynth2-static.json
+3 −5 linux-audio/fluidsynth2.json
+0 −23 linux-audio/jack2.json
+3 −0 linux-audio/ladspa.json
+5 −0 linux-audio/lash.json
+3 −1 linux-audio/libinstpatch.json
+1 −1 linux-audio/liblo-static.json
+3 −0 linux-audio/liblo.json
+94 −0 linux-audio/lilv-static.json
+18 −36 linux-audio/lilv.json
+12 −5 linux-audio/lrdf.json
+4 −9 linux-audio/lv2.json
+31 −0 linux-audio/patches/raptor-libxml.patch
+1 −1 lua5.3/lua-5.3.5.json
+6 −6 lua5.4/lua-5.4.json
+30 −0 luajit/luajit.json
+27 −0 lzo/lzo.json
+3 −7 mac/mac.json
+18 −0 physfs/physfs.json
+34 −0 pygame/cython-fixes.patch
+25 −0 pygame/glib.patch
+47 −1 pygame/pygame-1.9.6.json
+0 −54 qt4/disable-sslv3.patch
+0 −11 qt4/fixgcc11.patch
+0 −31 qt4/fixgcc9.patch
+0 −118 qt4/qt4-4.8.7-minimal.json
+0 −514 qt4/qt4-aarch64.patch
+0 −409 qt4/qt4-openssl-1.1.patch
+6 −1 smpeg/smpeg-0.4.5.json
+22 −0 squashfs-tools/squashfs-tools.json

0 comments on commit da27e3c

Please sign in to comment.