Build snap for QGIS - ask for help

Hello, I would like to install QGIS (https://www.qgis.org) but this software is shipped with Python itself which is conflicting with my environment.

So I wanted to use snap for this. There is no snap for qgis, so I wanted to make one of my own. After long hours I’m able to compile the qgis as snap - but it is not starting because it doesn’t have QT and xcb backend for running.

I tried everything what I found on the Internet, I asked many times ChatGPT I looked long hours in google. I’m not able to setup this snapcraft for compiling.

The current version of my snapcraft.yaml is here:

name: qgis
version: '3.38.2'
summary: A snap package for QGIS
description: A snap package to avoid python version conflicts when using QGIS.
base: core22
confinement: strict
grade: stable

parts:
  qgis:
    source-type: git
    source: https://github.com/qgis/QGIS.git
    source-tag: final-3_38_2
    plugin: cmake
    build-packages:
      - bison
      - build-essential
      - ca-certificates
      - ccache
      - cmake
      - cmake-curses-gui
      - dh-python
      - doxygen
      - expect
      - flex
      - flip
      - gdal-bin
      - git
      - graphviz
      - grass-dev
      - libdraco-dev
      - libexiv2-dev
      - libexpat1-dev
      - libfcgi-dev
      - libgdal-dev
      - libgeos-dev
      - libgsl-dev
      - libpdal-dev
      - libpq-dev
      - libproj-dev
      - libprotobuf-dev
      - libqca-qt5-2-dev
      - libqca-qt5-2-plugins
      - libqscintilla2-qt5-dev
      - libqt5opengl5-dev
      - libqt5serialport5-dev
      - libqt5sql5-sqlite
      - libqt5svg5-dev
      - libqt5webkit5-dev
      - libqt5xmlpatterns5-dev
      - libqwt-qt5-dev
      - libspatialindex-dev
      - libspatialite-dev
      - libsqlite3-dev
      - libsqlite3-mod-spatialite
      - libyaml-tiny-perl
      - libzip-dev
      - libzstd-dev
      - lighttpd
      - locales
      - ninja-build
      - ocl-icd-opencl-dev
      - opencl-headers
      - pandoc
      - pdal
      - pkg-config
      - poppler-utils
      - protobuf-compiler
      - pyqt5-dev
      - pyqt5-dev-tools
      - pyqt5.qsci-dev
      - python3-all-dev
      - python3-autopep8
      - python3-dev
      - python3-gdal
      - python3-jinja2
      - python3-lxml
      - python3-mock
      - python3-nose2
      - python3-owslib
      - python3-plotly
      - python3-psycopg2
      - python3-pygments
      - python3-pyproj
      - python3-pyqt5
      - python3-pyqt5.qsci
      - python3-pyqt5.qtmultimedia
      - python3-pyqt5.qtpositioning
      - python3-pyqt5.qtserialport
      - python3-pyqt5.qtsql
      - python3-pyqt5.qtsvg
      - python3-pyqt5.qtwebkit
      - python3-pyqtbuild
      - python3-sip
      - python3-termcolor
      - python3-yaml
      - qt3d-assimpsceneimport-plugin
      - qt3d-defaultgeometryloader-plugin
      - qt3d-gltfsceneio-plugin
      - qt3d-scene2d-plugin
      - qt3d5-dev
      - qtbase5-dev
      - qtbase5-private-dev
      - qtkeychain-qt5-dev
      - qtmultimedia5-dev
      - qtpositioning5-dev
      - qttools5-dev
      - qttools5-dev-tools
      - sip-tools
      - spawn-fcgi
      - xauth
      - xfonts-100dpi
      - xfonts-75dpi
      - xfonts-base
      - xfonts-scalable
      - xvfb
      - libatlas3-base
      - liblapack3
      - libatlas-base-dev
      - libxcb-cursor0
      - qml-module-qt3d
      - qt3d5-dev-tools
    stage-packages:
      - qgis
      - grass

    override-build: |
      cmake ../src
      make -j$(nproc)
      make install

#      cmake ../src
#      set -eux
#      mkdir -p "$CRAFT_PART_BUILD"
#      cp -r "$CRAFT_PART_SRC_WORK/*" "$CRAFT_PART_BUILD"
#      cd "$CRAFT_PART_BUILD"
#      cmake -DCMAKE_CXX_FLAGS="-std=c++17" .
#      cmake ../src
#      make -j$(nproc)
#      make install
#  desktop-helpers:
#    source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
#    source-subdir: gtk
#    plugin: make
#    build-packages:
#     - build-essential
#     - libgtk-3-dev
#     - libgdk-pixbuf2.0-dev
#     - libglib2.0-dev

#    build-environment:
#      - Qt53DCore_DIR: ../../../usr/lib/$SNAPCRAFT_ARCH_TRIPLET/cmake/Qt53DCore
#      - CMAKE_PREFIX_PATH: $CMAKE_PREFIX_PATH:$SNAPCRAFT_STAGE/usr/lib/x86_64-linux-gnu/cmake


environment:
  LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/usr/lib:$SNAP/usr/lib/x86_64-linux-gnu/blas/:$SNAP/usr/lib/x86_64-linux-gnu/lapack:$SNAP/usr/lib/x86_64-linux-gnu
#  "LD_LIBRARY_PATH": ":$SNAP/usr/lib/x86_64-linux-gnu:$SNAPCRAFT_ARCH_TRIPLET/blas:$SNAPCRAFT_ARCH_TRIPLET/lapack"

apps:
  qgis:
    command: /usr/bin/qgis
#    command: desktop-launch qgis
#    command: $SNAP/usr/bin/qgis
    plugs: [home, network, network-bind, opengl, pulseaudio, desktop, x11]
#    environment:
#      LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/qgis/x1/usr/lib/x86_64-linux-gnu/blas/

And the error is always the same:

Starting snapcraft, version 8.3.2                                                                                                                                                           
Logging execution to '/home/gregor/.local/state/snapcraft/log/snapcraft-20240829-184212.047946.log'                                                                                         
Running on amd64 for amd64                                                                                                                                                                  
Launching instance...                                                                                                                                                                       
Starting instance                                                                                                                                                                           
Starting snapcraft, version 8.3.2                                                                                                                                                           
Logging execution to '/tmp/snapcraft.log'                                                                                                                                                   
Running on amd64 for amd64                                                                                                                                                                  
Initializing parts lifecycle                                                                                                                                                                
Installing build-packages                                                                                                                                                                   
Installing build-snaps                                                                                                                                                                      
Skipping pull for qgis (already ran)                                                                                                                                                        
Building qgis                                                                                                                                                                               
Removing suid/guid from /root/parts/qgis/install/usr/lib/x86_64-linux-gnu/utempter/utempter                                                                                                 
:: + cmake ../src                                                                                                                                                                           
:: -- QGIS version: 3.38.2 Grenoble (33802)                                                                                                                                                 
:: -- Found OpenCL C++ headers: /usr/include                                                                                                                                                
:: -- ccache found                                                                                                                                                                          
:: -- Found GRASS 7: /usr/lib/grass78 (7.8.7, off_t size = 8)                                                                                                                               
:: -- Could not find GRASS 8                                                                                                                                                                
:: -- Could NOT find PROJ (missing: PROJ_DIR)                                                                                                                                               
:: -- Found Proj: /usr/lib/x86_64-linux-gnu/libproj.so version 8 (8.2.1)                                                                                                                    
:: -- Found Proj:  PROJ_DIR-NOTFOUND                                                                                                                                                        
:: -- Found Geos: 3.10.2 /usr/lib/x86_64-linux-gnu/cmake/GEOS                                                                                                                               
:: -- Could NOT find GDAL (missing: GDAL_DIR)                                                                                                                                               
:: -- Found GDAL: /usr/lib/libgdal.so (3.4.1)                                                                                                                                               
:: -- Found GDAL:  GDAL_DIR-NOTFOUND                                                                                                                                                        
:: -- Found Spatialindex: /usr/lib/x86_64-linux-gnu/libspatialindex.so                                                                                                                      
:: -- Found libzip: /usr/lib/x86_64-linux-gnu/libzip.so                                                                                                                                     
:: -- Found Sqlite3: /usr/lib/x86_64-linux-gnu/libsqlite3.so                                                                                                                                
:: -- Could NOT find Protobuf (missing: Protobuf_DIR)                                                                                                                                       
:: -- Found Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so                                                                                                                              
:: -- Found zlib: /usr/lib/x86_64-linux-gnu/libz.so                                                                                                                                         
:: -- Found exiv2: /usr/lib/x86_64-linux-gnu/libexiv2.so                                                                                                                                    
:: -- Qt WebKit support enabled                                                                                                                                                             
:: -- Using embedded laz-perf                                                                                                                                                               
:: -- Found ZSTD: /usr/lib/x86_64-linux-gnu/libzstd.so                                                                                                                                      
:: -- Found PDAL: pdal_base;pdal_util (2.3.0)                                                                                                                                               
:: -- Found Draco: /usr/lib/x86_64-linux-gnu/libdraco.so (1.5.2)                                                                                                                            
:: -- PDF4Qt disabled                                                                                                                                                                       
:: CMake Error at /snap/kf5-5-113-qt-5-15-11-core22-sdk/current/usr/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake:28 (find_package):                                                       
::   Could not find a package configuration file provided by "Qt53DCore" with                                                                                                               
::   any of the following names:                                                                                                                                                            
::                                                                                                                                                                                          
::     Qt53DCoreConfig.cmake                                                                                                                                                                
::     qt53dcore-config.cmake                                                                                                                                                               
::                                                                                                                                                                                          
::   Add the installation prefix of "Qt53DCore" to CMAKE_PREFIX_PATH or set                                                                                                                 
::   "Qt53DCore_DIR" to a directory containing one of the above files.  If                                                                                                                  
::   "Qt53DCore" provides a separate development package or SDK, be sure it has                                                                                                             
::   been installed.                                                                                                                                                                        
:: Call Stack (most recent call first):                                                                                                                                                     
::   CMakeLists.txt:524 (find_package)                                                                                                                                                      
::                                                                                                                                                                                          
::                                                                                                                                                                                          
:: -- Configuring incomplete, errors occurred!                                                                                                                                              
:: See also "/root/parts/qgis/build/CMakeFiles/CMakeOutput.log".                                                                                                                            
'override-build' in part 'qgis' failed with code 1.
Review the scriptlet and make sure it's correct.                                                                                        
Failed to execute pack in instance.                                                                                                                                                         
Recommended resolution: Run the same command again with --debug to shell into the environment if you wish to introspect this failure.                                                       
Full execution log: '/home/gregor/.local/state/snapcraft/log/snapcraft-20240829-184212.047946.log' 

I’m giving up. Or maybe somebody gives some advices how it should be done? I wanted to use kde-neon because as I understand this is the current method for include Qt into snap.

Anyway, I will be grateful for any advice what I can try for making this snap. Regards, Grzegorz