Need help in my attempt to package Black Box

So I recently found a terminal named BlackBox https://gitlab.gnome.org/raggesilver/blackbox and wanted to get it installed to my workstation but found it only has a flatpak and I couldn’t find a way to build it without pulling a lot of dev packages to my system. So I attempted to build it with snap, as follows

name: blackbox # you probably want to 'snapcraft register <name>'
base: core22 # the base snap is the execution environment for this snap
version: "0.13.2-git" # just for humans, typically '1.2+git' or '1.3.2'
summary: Single-line elevator pitch for your amazing snap # 79 char long summary
description: |
  This is my-snap's description. You have a paragraph or two to tell the
  most important story about your snap. Keep it under 100 words though,
  we live in tweetspace and your description wants to look good in the snap
  store.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

apps:
  blackbox:
    command: usr/bin/blackbox
    desktop: usr/share/applications/com.raggesilver.BlackBox.desktop
    environment:
      LD_LIBRARY_PATH: $SNAP/usr/lib64:$LD_LIBRARY_PATH
    extensions:
      - gnome
    plugs:
      - gsettings
    common-id: com.raggesilver.BlackBox

parts:
  vendor-marble-gtk:
    plugin: dump
    source: ./vendors/marble-gtk

  libicu71:
    source: http://mirrors.kernel.org/ubuntu/pool/main/i/icu/libicu71_71.1-3ubuntu1_amd64.deb
    source-type: deb
    plugin: dump

  libvte-2.91-gtk4-0:
    source: http://mirrors.kernel.org/ubuntu/pool/main/v/vte2.91/libvte-2.91-gtk4-0_0.70.0-1_amd64.deb
    source-type: deb
    plugin: dump

  libvte-2.91-gtk4-dev:
    source: http://mirrors.kernel.org/ubuntu/pool/main/v/vte2.91/libvte-2.91-gtk4-dev_0.70.0-1_amd64.deb
    source-type: deb
    plugin: dump

  libadwaita-1-0:
    source: http://mirrors.kernel.org/ubuntu/pool/main/liba/libadwaita-1/libadwaita-1-0_1.2.0-1ubuntu2_amd64.deb
    source-type: deb
    plugin: dump

  libadwaita-1-dev:
    source: http://mirrors.kernel.org/ubuntu/pool/main/liba/libadwaita-1/libadwaita-1-dev_1.2.0-1ubuntu2_amd64.deb
    source-type: deb
    plugin: dump

  librsvg2-2:
    source: http://mirrors.kernel.org/ubuntu/pool/main/libr/librsvg/librsvg2-2_2.54.4+dfsg-1ubuntu1_amd64.deb
    source-type: deb
    plugin: dump

  librsvg2-dev:
    source: http://mirrors.kernel.org/ubuntu/pool/main/libr/librsvg/librsvg2-dev_2.54.4+dfsg-1ubuntu1_amd64.deb
    source-type: deb
    plugin: dump

  blackbox:
    after:
      - vendor-marble-gtk
      - libicu71
      - libvte-2.91-gtk4-0
      - libvte-2.91-gtk4-dev
      - libadwaita-1-0
      - libadwaita-1-dev
      - librsvg2-2
      - librsvg2-dev
    source: https://gitlab.gnome.org/raggesilver/blackbox.git
    plugin: meson
    meson-parameters:
      - --prefix=/usr
      - --buildtype=release
    build-environment:
      - PKG_CONFIG_PATH: "$SNAPCRAFT_STAGE/usr/lib64/pkgconfig:$SNAPCRAFT_STAGE/usr/lib/x86_64-linux-gnu/pkgconfig"
      - VALAFLAGS: " --vapidir $SNAPCRAFT_STAGE/usr/share/vala/vapi"
      - LD_LIBRARY_PATH: "$SNAPCRAFT_STAGE/usr/lib64:$SNAPCRAFT_STAGE/usr/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu"
      - VALAC: "/usr/bin/valac"
    build-packages:
      - meson
      - ninja-build
      - valac
      - gettext
      - cmake
      - libgtk-4-dev
      #- libadwaita-1-dev
      #- libvte-2.91-gtk4-dev
      - libjson-glib-dev
      #- librsvg2-dev
      - libgee-0.8-dev
      - libxml2-dev
    override-stage: |
      craftctl default
      cp -r $CRAFT_PART_SRC/data $CRAFT_STAGE/data
    override-prime: |
      craftctl default
      cp -r $CRAFT_STAGE/data $CRAFT_PRIME/data
      sed -i 's|Icon=com.raggesilver.BlackBox|Icon=${SNAP}/data/icons/hicolor/scalable/apps/com.raggesilver.BlackBox.svg|' ${CRAFT_PRIME}/usr/share/applications/com.raggesilver.BlackBox.desktop
      sed -i 's|$(/usr/libexec/vte-urlencode-cwd)|$(${SNAP}/usr/libexec/vte-urlencode-cwd)|' ${CRAFT_PRIME}/etc/profile.d/vte-2.91.sh

    stage-packages:
      - libgtk-4-1
      - libgee-0.8-2
      - libjson-glib-1.0-0
      - libvte-2.91-common
    parse-info: [usr/share/metainfo/com.raggesilver.BlackBox.appdata.xml]

slots:
  gnome-text-editor:
    interface: dbus
    bus: session
    name: com.raggesilver.BlackBox

It also requires a rpm package I downloaded and extracted from https://fedora.pkgs.org/37/terra/marble-gtk-0:42.alpha0-1.fc37.x86_64.rpm.html

Overall it was a frustrating journey throughout the attempt (a lot of things didn’t work properly when I use core22), and I am still not sure if the resulting application is working as intended (it keeps saying /usr/libexec/vte-urlencode-cwd is not found for instance, and it will not access files outside my home directory), but it is now running at least. I am sure there are a lot of things that could be done better though (for instance, I probably shouldn’t have to cheat by pulling deb for kinetic).

Some of the references I found useful:

  • /docs/parts-environment-variables
  • /blog/zero-to-snap-rev-up-your-packaging
  • /docs/gtk4-applications
  • forum/t/micro-howto-migrate-from-core20-to-core22/30188 (only realized i need to manually define meson and ninja-build in build-packages)
  • /docs/parts-lifecycle (keep checking if things are done properly in every stage)
2 Likes

Please Rename your Title Its BlackBox not BlackBoard, regarding Building Snaps of LibAdwaita i think you should consult snapcraft yaml of video-downloader by Unrud, Snapcrafters Community, LibAdwaita apps in my perception is not yet fully integrated in Snaps since existing LibAdwaita apps are very poor in regards of theming,interfaces etc.

ah I mistyped the name, and I am not given the option to edit the title ):

Leave the name any success with the snap ?? , check out this post --> Issue while packaging snap

were you asking if there’s any success with the snap?

the snap builds, and it is kind of usable, though it is having some issues after installing

  • it keeps complaining about /usr/libexec/vte-urlencode-cwd not found (patched the path in /etc/profile.d/vte-2.91.sh but seems not enough)
  • some terminal themes not found
  • i can’t access files outside my home directory

You guessed right, the perfect solution for your snap is to build it in Classic mode (With Classic mode it can almost work like native apps…)

nope, it says

Extension 'gnome' does not support confinement 'classic'                                                                                                                                                                                                                       
Full execution log: '/home/jeffrey04/.cache/snapcraft/log/snapcraft-20230227-164205.843563.log'                                                                                                                                                                                

and the log

2023-02-27 16:42:05.844 Starting Snapcraft 7.2.9
2023-02-27 16:42:05.845 lifecycle command: 'pack', arguments: Namespace(bind_ssh=False, build_for=None, debug=True, destructive_mode=False, directory=None, enable_developer_debug=False, enable_experimental_extensions=False, enable_experimental_target_arch=False, enable_experimental_ua_services=False, enable_manifest=False, http_proxy=None, https_proxy=None, manifest_image_information=None, output=None, provider=None, target_arch=None, ua_token=None, use_lxd=False)
2023-02-27 16:42:05.845 command: pack, arguments: Namespace(bind_ssh=False, build_for=None, debug=True, destructive_mode=False, directory=None, enable_developer_debug=False, enable_experimental_extensions=False, enable_experimental_target_arch=False, enable_experimental_ua_services=False, enable_manifest=False, http_proxy=None, https_proxy=None, manifest_image_information=None, output=None, provider=None, target_arch=None, ua_token=None, use_lxd=False)
2023-02-27 16:42:05.867 CPU count (from process affinity): 8
2023-02-27 16:42:05.867 Invalid SNAPCRAFT_MAX_PARALLEL_BUILD_COUNT value
2023-02-27 16:42:05.867 Running on amd64 for amd64
2023-02-27 16:42:05.868 Extension 'gnome' does not support confinement 'classic'
2023-02-27 16:42:05.868 Full execution log: '/home/jeffrey04/.cache/snapcraft/log/snapcraft-20230227-164205.843563.log'

Is there a specific reason to declare those as separate parts instead of listing the runtime packages as stage-packages and the development packages as build-packages?

the version required does not match the one provided by stage-packages provided by core22

Don’t pull them, they are in the gnome extension

Just be careful using binary packages built for a different version, you may run into compatibility problems related to sonames or other changes. The safest (and slowest) solution would be to rebuild those libraries on top of the base you want to use. Also you can filter out the development components from the final payload since these won’t be needed at runtime.

I suppose they are, but didnt really test without them as I included the gnome extension until very later in my attempt

yes, am aware of the version mismatch, was experimenting and it worked so I just left them there

am also aware of the best practice to just build the dependencies if not found, just that it would be another round of headache trying to resolve the dependencies ):

hence i “cheated” by pulling later versions directly from the repository