From 143012f18ab6319300db08d7cf083b92b1e49aa8 Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Mon, 30 Oct 2023 19:16:17 +0100
Subject: [PATCH] BUILD: Fixing once again the docker files...

---
 Dockerfile.appimage                           |  5 ++-
 Dockerfile.windows                            |  4 +-
 .../docker/{touch_files.bash => build.bash}   | 16 ++++++-
 utils/scripts/docker/package_appimages.bash   | 42 +++++++++++--------
 4 files changed, 44 insertions(+), 23 deletions(-)
 rename utils/scripts/docker/{touch_files.bash => build.bash} (51%)

diff --git a/Dockerfile.appimage b/Dockerfile.appimage
index d768628f..e42cb92c 100644
--- a/Dockerfile.appimage
+++ b/Dockerfile.appimage
@@ -23,7 +23,8 @@ RUN     STAGE=2 ./prepare
 
 FROM        linux-cache
 WORKDIR     /usr/src
+ENV         CXX=clang++
 COPY        --chmod=0755 utils/scripts/docker/package_appimages.bash package
-COPY        --chmod=0755 utils/scripts/docker/touch_files.bash       touch
-ENTRYPOINT  ./touch && CXX=clang++ cargo test --release && CXX=clang++ cargo build --release && ./package
+COPY        --chmod=0755 utils/scripts/docker/build.bash             build
+ENTRYPOINT  [ "./build" ]
 
diff --git a/Dockerfile.windows b/Dockerfile.windows
index e3d2f588..a72d28e0 100644
--- a/Dockerfile.windows
+++ b/Dockerfile.windows
@@ -34,7 +34,7 @@ ENV         MAKE=x86_64-w64-mingw32-make
 ENV         CMAKE=x86_64-w64-mingw32-cmake
 ENV         CXX=x86_64-w64-mingw32-g++
 WORKDIR     /home/devel
-COPY        --chmod=0755 utils/scripts/docker/touch_files.bash touch
+COPY        --chmod=0755 utils/scripts/docker/build.bash       build
 COPY        --chmod=0755 utils/scripts/docker/package_zip.bash package
-ENTRYPOINT  ./touch && cargo test --release --target x86_64-pc-windows-gnu && cargo build --release --target x86_64-pc-windows-gnu && ./package
+ENTRYPOINT  [ "./build", "--target", "x86_64-pc-windows-gnu " ]
 
diff --git a/utils/scripts/docker/touch_files.bash b/utils/scripts/docker/build.bash
similarity index 51%
rename from utils/scripts/docker/touch_files.bash
rename to utils/scripts/docker/build.bash
index a93c3262..2b4c9001 100755
--- a/utils/scripts/docker/touch_files.bash
+++ b/utils/scripts/docker/build.bash
@@ -13,5 +13,19 @@ for SOURCE in /src/**; do
         && [[ ! ${SOURCE} == "/src/build"* ]] \
         && [[ ! ${SOURCE} == "/src/utils"* ]] \
         && [[ ! ${SOURCE} == "/src/compile_commands.json" ]] \
-        && install -CD ${SOURCE} $(realpath --relative-base=/src/ ${SOURCE})
+        && {
+            echo "copy source file ${SOURCE}"
+            install -CD ${SOURCE} $(realpath --relative-base=/src/ ${SOURCE})
+        }
 done
+
+cargo test  --release $@
+cargo build --release $@
+
+[ -x ./package ] && {
+    echo "calling the package script"
+    ./package
+} || {
+    echo "no package script to package the produced executables"
+    exit 1
+}
diff --git a/utils/scripts/docker/package_appimages.bash b/utils/scripts/docker/package_appimages.bash
index d950d791..b807068a 100755
--- a/utils/scripts/docker/package_appimages.bash
+++ b/utils/scripts/docker/package_appimages.bash
@@ -1,5 +1,5 @@
 #!/usr/bin/env bash
-set -e
+set -xe
 [ ! -f /build/.gitignore ] && {
     echo "The appimage folder is not mounted in the docker"
     exit 1
@@ -23,19 +23,20 @@ function join_by() {
 
 function get_additional_libs() {
     case $* in
-        *qt*) for LIB in /usr/lib/x86_64-linux-gnu/libQt6WaylandEglCompositorHwIntegration.so   \
-                         /usr/lib/x86_64-linux-gnu/libQt6WaylandEglClientHwIntegration.so       \
-                         /usr/lib/x86_64-linux-gnu/libQt6WaylandCompositor.so                   \
-                         /usr/lib/x86_64-linux-gnu/libQt6OpenGLWidgets.so                       \
-                         /usr/lib/x86_64-linux-gnu/libQt6OpenGL.so                              \
-                         /usr/lib/x86_64-linux-gnu/libQt6MultimediaWidgets.so                   \
-                         /usr/lib/x86_64-linux-gnu/libQt6Multimedia.so                          \
-                         /usr/lib/x86_64-linux-gnu/libQt6Concurrent.so                          \
-                         /usr/lib/x86_64-linux-gnu/libQt6WaylandClient.so                       \
-                         /usr/lib/x86_64-linux-gnu/libQt6XcbQpa.so                              \
-                         /usr/lib/x86_64-linux-gnu/libQt6EglFSDeviceIntegration.so              \
-                         /usr/lib/x86_64-linux-gnu/libQt6EglFsKmsGbmSupport.so                  \
-                         /usr/lib/x86_64-linux-gnu/libQt6EglFsKmsSupport.so                     ;
+        *qt*)
+        for LIB in /usr/lib/x86_64-linux-gnu/libQt6WaylandEglCompositorHwIntegration.so   \
+                   /usr/lib/x86_64-linux-gnu/libQt6WaylandEglClientHwIntegration.so       \
+                   /usr/lib/x86_64-linux-gnu/libQt6WaylandCompositor.so                   \
+                   /usr/lib/x86_64-linux-gnu/libQt6OpenGLWidgets.so                       \
+                   /usr/lib/x86_64-linux-gnu/libQt6OpenGL.so                              \
+                   /usr/lib/x86_64-linux-gnu/libQt6MultimediaWidgets.so                   \
+                   /usr/lib/x86_64-linux-gnu/libQt6Multimedia.so                          \
+                   /usr/lib/x86_64-linux-gnu/libQt6Concurrent.so                          \
+                   /usr/lib/x86_64-linux-gnu/libQt6WaylandClient.so                       \
+                   /usr/lib/x86_64-linux-gnu/libQt6XcbQpa.so                              \
+                   /usr/lib/x86_64-linux-gnu/libQt6EglFSDeviceIntegration.so              \
+                   /usr/lib/x86_64-linux-gnu/libQt6EglFsKmsGbmSupport.so                  \
+                   /usr/lib/x86_64-linux-gnu/libQt6EglFsKmsSupport.so                     ;
         do
             for FILE in ${LIB}*; do
                 echo -n " -l${FILE} "
@@ -73,15 +74,20 @@ function deploy() {
         *qt*)
         for PLUGIN in ${QT_SRC}/*; do
             local PLUGIN=$(basename ${PLUGIN})
-            if [ ! -d ${QT_DST}/${PLUGIN} ]; then
-                cp -rf ${QT_SRC}/${PLUGIN} ${QT_DST}/${PLUGIN}
-            fi
-        done;;
+            mkdir -p ${QT_DST}/${PLUGIN}
+            cp -rf ${QT_SRC}/${PLUGIN}/* ${QT_DST}/${PLUGIN}/
+        done
+        for PRL_FILE in /usr/lib/x86_64-linux-gnu/libQt6Wayland*.prl; do
+            cp ${PRL_FILE} ${EXEC^}/usr/lib/$(basename ${PRL_FILE})
+        done
+        ;;
         *);;
     esac
     find ${EXEC^}/usr/lib/ -type f -and \( ${EXCLUDE_LIBS} \) -delete
     cp LICENSE CHANGELOG.md CONTRIBUTING.md ${EXEC^}/
     install -Dm644 ${EXEC}/${EXEC}.appdata.xml ${EXEC^}/usr/share/metainfo/${EXEC}.appdata.xml
+
+    # Custom AppRun script!
     unlink ${EXEC^}/AppRun \
         && touch ${EXEC^}/AppRun \
         && chmod +x ${EXEC^}/AppRun
-- 
GitLab