How to install and stage external debian package in SNAP?

Hello, I want to build a QT6 Lazarus/Free Pascal app under the base ‘core24’ which needs two additional packages (libqt6pas6-dev_6.2.10-1 for building and libqt6pas6_6.2.10-1 as a dependency for the final program).

However, the libraries can’t be found during the building process. If I move the two parts instructions into the cantara building part, the building succeeds but the library libqt6pas won’t be found during the execution of the snap.

What am I missing here?

This is my current snapcraft.yml:

name: cantara
version: '2.7.0'  # bump this when you release a new version
summary: A Song Presentation Software.
description: |
  A simple, lightweight but powerful program for song presentation in churches,
  small groups or at karaoke parties.

confinement: strict
base: core24
grade: stable

platforms:
  amd64:
    build-on: [amd64]
    build-for: [amd64]

icon: app.cantara.Cantara.png

slots:
  cantara-dbus:
    interface: dbus
    bus: session
    name: app.cantara.Cantara

apps:
  cantara:
    command: cantara       # binary lives at $SNAP/bin/cantara
    desktop: cantara.desktop
    extensions: [ "kde-neon-6" ]
    plugs:
      - home
      - desktop
      - desktop-legacy
      - opengl
      - x11
      - wayland
      - audio-playback
      - gsettings

parts:
  libqt6pas_dev:
    plugin: nil
    source: .
    source-type: local
    build-packages:
      - wget
    override-build: |
      wget https://github.com/davidbannon/libqt6pas/releases/download/v6.2.10/libqt6pas6-dev_6.2.10-1_amd64.deb
      apt install -y ./libqt6pas6-dev_6.2.10-1_amd64.deb
  libqt6pas:
    plugin: nil
    source: .
    source-type: local
    override-pull: |
      wget https://github.com/davidbannon/libqt6pas/releases/download/v6.2.10/libqt6pas6_6.2.10-1_amd64.deb
      apt install -y ./libqt6pas6_6.2.10-1_amd64.deb
    prime:
      - usr/lib/*/libQt6Pas.so*

  cantara:
    plugin: nil
    after:
      - libqt6pas_dev
      - libqt6pas
    source: https://github.com/reckel-jm/cantara.git
    source-type: git
    build-packages:
      - build-essential
      - git
      - lcl
      - lcl-utils
      - lazarus          # Pulls in Lazarus IDE and LCL
      - fpc              # Pulls in Free Pascal Compiler
      #- libqt5pas-dev    # Headers for compiling against Qt6 Pascal bindings
      - wget
    stage-packages:
      # - libqt5pas1       # Runtime library bundled into the final
      - libxinerama1
      - libqt6dbus6t64
      - libqt6core6t64
      - libqt6gui6t64
      - libqt6widgets6t64
      - libqt6printsupport6t64
      - libb2-1
      - libdouble-conversion3
      - libmd4c0
    stage:
      - cantara
      - languages
      - cantara.desktop
      - Cantara.ico
      - app.cantara.Cantara.png
    override-pull: |
      craftctl default
      git submodule update --init --recursive
    override-build: |
      set -eux

      cd src

      # Build required library packages with Qt6 widgetset
      lazbuild --ws=qt6 bgrabitmap/bgrabitmap/bgrabitmappack.lpk
      lazbuild --ws=qt6 metadarkstyle/metadarkstyle.lpk

      # Build Cantara with the ReleaseConfined mode (stripped, optimised, Qt6)
      lazbuild -B --bm="ReleaseConfined" --ws=qt6 Cantara.lpi

      # ── Install binary ───────────────────────────────────────────────────
      mkdir -p "$SNAPCRAFT_PART_INSTALL/"
      install -m 755 cantara "$SNAPCRAFT_PART_INSTALL/cantara"

      # ── Install data dirs (both live inside src/, not the project root) ──
      cp -r languages   "$SNAPCRAFT_PART_INSTALL/"
      cp -r backgrounds "$SNAPCRAFT_PART_INSTALL/"

      # Copy everything needed for runtime
      mkdir -p "$SNAPCRAFT_PART_INSTALL/lib/x86_64-linux-gnu"
      cp -a "$SNAPCRAFT_PART_BUILD/usr/lib/x86_64-linux-gnu/libqt6pas.so"* \
         "$SNAPCRAFT_PART_INSTALL/lib/x86_64-linux-gnu/"

      # ── Install icon (src/Cantara.ico) ───────────────────────────────────
      install -Dm644 Cantara.ico \
        "$SNAPCRAFT_PART_INSTALL/Cantara.ico"

      # ── Install PNG icon into standard hicolor theme path ────────────────
      # ../  from src/ = project root = $SNAPCRAFT_PART_SRC
      install -Dm644 ../app.cantara.Cantara.png \
        "$SNAPCRAFT_PART_INSTALL/app.cantara.Cantara.png"

      # ── Install desktop file ─────────────────────────────────────────────
      install -Dm644 ../cantara.desktop \
        "$SNAPCRAFT_PART_INSTALL/cantara.desktop"

  # ── Strip documentation from the prime directory ─────────────────
  cleanup:
    after: [cantara]
    plugin: nil
    override-prime: |
      set -eux
      rm -rf "$SNAPCRAFT_PRIME/usr/share/doc"
      rm -rf "$SNAPCRAFT_PRIME/usr/share/man"
      find "$SNAPCRAFT_PRIME/usr/share" -type d -empty -delete 2>/dev/null || true

Thank you very much in advance!

Just a pointer: Did the libraries end up in the snap? Try running your snap with –shelland have a look/search.

1 Like

For the libqt6pas_dev: Change override-build to override-pull.

For the libqt6pas part:

  • Drop the override-pull stanza.
  • Set source to the download URL of the Debian package.
  • Use the dump plugin instead with source-type: deb.
1 Like