Taisei Project (game) - help needed to build

I try to make a snap for this freegame game, it is a shoot’em up (website), mainly made with C (90%) then Python.

I’m stuck with the following error: Environment validation failed for part ‘gamemode’: ‘meson’ failed with error code 1. My snap is based on the Steam’s snap. It is easy to test (no local files), just put the snap then run snapcraft.

The snap:

name: taisei
base: core22
version: '1.4.1'
summary: Shoot ’em up game with lots of bullets (genre called bullet hell).
description: |
  It doesn’t aim to rebuild a particular installment of the Tōhō games, but 
  is rather an original game set in the world of Tōhō. Enjoy dodging through
  6 stages full of new bullet patterns on four difficulty levels! 
compression: lzo
assumes:
  - snapd2.62
  
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

# :: + sed -i 's%^#!/usr/bin/python3$%#!/usr/bin/env python3%g' /usr/local/bin/meson                                                             
# :: sed: can't read /usr/local/bin/meson: No such file or directory                                                                             
# 'override-build' in part 'meson-deps' failed with code 2.
# Review the scriptlet and make sure it's correct.                                     
# Failed to execute pack in instance.         
#
# => Meson must be installed locally.


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

lint:
  # Snapcraft's `ldd` lint can't handle 32-bit things,
  # So just make it quiet and also make builds a surprising amount faster
  ignore:
    - library:
        - lib/i386-linux-gnu/**
        - usr/lib/i386-linux-gnu/**
        - lib32/**
        - usr/lib32/**

layout:
  /usr/lib/taisei:
    bind: $SNAP/usr/lib/taisei
  /usr/share/zenity:
    bind: $SNAP/usr/share/zenity
  # https://discourse.ubuntu.com/t/the-graphics-core20-snap-interface/23000
  /usr/share/drirc.d:
    bind: $SNAP/graphics/usr/share/drirc.d
  /usr/share/glvnd/egl_vendor.d:
    bind: $SNAP/graphics/usr/share/glvnd/egl_vendor.d
  /usr/lib/x86_64-linux-gnu/alsa-lib:
    bind: $SNAP/usr/lib/x86_64-linux-gnu/alsa-lib
  /usr/share/alsa:
    bind: $SNAP/usr/share/alsa
  /usr/share/X11/xkb:
    bind: $SNAP/usr/share/X11/xkb
  /usr/lib/x86_64-linux-gnu/libvulkan_intel.so:
    symlink: $SNAP/graphics/usr/lib/x86_64-linux-gnu/libvulkan_intel.so
  /usr/lib/i386-linux-gnu/libvulkan_intel.so:
    symlink: $SNAP/graphics/usr/lib/i386-linux-gnu/libvulkan_intel.so
  /usr/lib/x86_64-linux-gnu/libvulkan_lvp.so:
    symlink: $SNAP/graphics/usr/lib/x86_64-linux-gnu/libvulkan_lvp.so
  /usr/lib/i386-linux-gnu/libvulkan_lvp.so:
    symlink: $SNAP/graphics/usr/lib/i386-linux-gnu/libvulkan_lvp.so
  /usr/lib/x86_64-linux-gnu/libvulkan_radeon.so:
    symlink: $SNAP/graphics/usr/lib/x86_64-linux-gnu/libvulkan_radeon.so
  /usr/lib/i386-linux-gnu/libvulkan_radeon.so:
    symlink: $SNAP/graphics/usr/lib/i386-linux-gnu/libvulkan_radeon.so
  /usr/lib/x86_64-linux-gnu/libxcb-dri3.so.0.0.0:
    symlink: $SNAP/graphics/usr/lib/x86_64-linux-gnu/libxcb-dri3.so.0.0.0
  /usr/lib/x86_64-linux-gnu/libxcb-dri3.so.0:
    symlink: $SNAP/graphics/usr/lib/x86_64-linux-gnu/libxcb-dri3.so.0.0.0
  /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0:
    symlink: $SNAP/graphics/usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
  /usr/lib/x86_64-linux-gnu/libxcb.so:
    symlink: $SNAP/graphics/usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
  /usr/lib/x86_64-linux-gnu/libxcb.so.1:
    symlink: $SNAP/graphics/usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
  /etc/ld.so.cache:
    bind-file: $SNAP_DATA/etc/ld.so.cache
  /etc/fonts:
    bind: $SNAP/etc/fonts

plugs:
  gaming-mesa:
    interface: content
    target: $SNAP/graphics
    default-provider: gaming-graphics-core22
  gtk-3-themes:
    interface: content
    target: $SNAP/share/themes
    default-provider: gtk-common-themes
  icon-themes:
    interface: content
    target: $SNAP/share/icons
    default-provider: gtk-common-themes
  sound-themes:
    interface: content
    target: $SNAP/share/sounds
    default-provider: gtk-common-themes
  dot-local-share-taisei:
    interface: personal-files
    write:
      - $HOME/.local/share/taisei
      - $HOME/taisei
  dot-local-share-applications:
    interface: personal-files
    write:
      - $HOME/.local/share/applications
  dot-local-share-icons:
    interface: personal-files
    write:
      - $HOME/.local/share/icons
  desktop:
    mount-host-font-cache: false
  shmem:
    interface: shared-memory
    private: true

hooks:
  configure:
    plugs:
      - opengl

environment:
  LD_LIBRARY_PATH: $SNAP/graphics/lib/i386-linux-gnu:$SNAP/graphics/usr/lib:$SNAP/usr/lib/i386-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$SNAP/lib/i386-linux-gnu:$SNAP/usr/lib/i386-linux-gnu/pulseaudio${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
  LIBGL_DRIVERS_PATH: $SNAP/graphics/usr/lib/i386-linux-gnu/dri:$SNAP/graphics/usr/lib/x86_64-linux-gnu/dri:${LIBGL_DRIVERS_PATH:+:$LIBGL_DRIVERS_PATH} 

parts:
  ninja:
    plugin: nil
    source: https://github.com/ninja-build/ninja.git
    source-tag: "v1.12.1"
    override-build: |
      rm -rf build
      rm -f ninja
      rm -f ninja_bootstrap
      sed -i 's_^#!/usr/bin/env python$_#!/usr/bin/env python3_g' configure.py
      ./configure.py --bootstrap
      mv ninja ninja_bootstrap
      rm -rf build
      ./ninja_bootstrap
      rm -f ninja_bootstrap
      mkdir -p $CRAFT_PART_INSTALL/usr/bin
      mv ninja $CRAFT_PART_INSTALL/usr/bin/
    build-packages:
      - python3
    prime:
      - -*

  meson-deps:
    after: [ninja]
    plugin: nil
    source: https://github.com/mesonbuild/meson.git
    source-tag: "1.5.1"
    override-build: |
      python3 -m pip install .
      mkdir -p $CRAFT_PART_INSTALL/usr/lib/python3/dist-packages
      rm -rf $CRAFT_PART_INSTALL/usr/lib/python3/dist-packages/meson*
      python3 -m pip install --target=$CRAFT_PART_INSTALL/usr .
      mv $CRAFT_PART_INSTALL/usr/meson* $CRAFT_PART_INSTALL/usr/lib/python3/dist-packages/
      sed -i "s%^#!/usr/bin/python3$%#!/usr/bin/env python3%g" /usr/local/bin/meson
      sed -i "s%^#!/usr/bin/python3$%#!/usr/bin/env python3%g" $CRAFT_PART_INSTALL/usr/bin/meson
    build-packages:
      - python3-pip
    prime:
      - -*


  gamemode:
    after: [meson-deps]
    source: https://github.com/ashuntu/gamemode.git
    source-branch: "add-snap-support"
    plugin: meson
    organize:
      snap/taisei/current/usr: usr      #  To adapt with your app name
    meson-parameters:
      - --prefix=/usr
    build-packages:
      - libsystemd-dev
      - pkg-config
      - libdbus-1-dev
    prime:
      - usr/bin/gamemoderun
      - usr/lib/*/libgamemode*.so.*
      
  taisei:
    plugin: python
    source: https://github.com/taisei-project/taisei.git
    stage-packages:
       - python3-usb
       - libzip-dev

apps:
  taisei:
    command: bin/taisei
    environment:
      HOME: $SNAP_USER_COMMON
      #LIBGL_DEBUG: verbose
      TMPDIR: $XDG_RUNTIME_DIR
      ALWAYS_USE_PULSEAUDIO: 1
      DISABLE_WAYLAND: 1
      PKG_CONFIG_PATH: $SNAP/usr/lib/i386-linux-gnu/pkgconfig:$SNAP/usr/lib/x86_64-linux-gnu/pkgconfig:$SNAP/usr/lib/pkgconfig
      PYTHONPATH: $SNAP/usr/lib/python3/dist-packages
      GI_TYPELIB_PATH: $SNAP/usr/lib/x86_64-linux-gnu/girepository-1.0 
    plugs:
      - audio-playback
      - desktop
      - desktop-legacy
#      - network
#      - network-bind
      - opengl
      - process-control
      - pulseaudio
      - wayland
      - x11
#      - screen-inhibit-controlparts:

Debug output :

$ snapcraft --verbose
Starting snapcraft, version 8.3.2                                                                                                  
Logging execution to '/home/dadu042/.local/state/snapcraft/log/snapcraft-20240827-142230.622996.log'                             
Running on amd64 for amd64                                                                                                         
Launching 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                                                                                                             
Environment validation failed for part 'gamemode': 'meson' failed with error code 1.                                               
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. 

Does the game need gamemode? If not, remove that entire part.

I’d go even a step further than Popey here, the steam snap is designed to be able to run each and every game shipped in steam, it will have hacks for each and every corner case you find out there… I’d not base a single game snap on it even remotely and rather start the packaging from scratch…

Good point. I’d use whatever was used to publish other games that have similar requirements. Here’s the yaml for ROTA which is the last game I published.

1 Like

I have try a lot of things with this game. Since this game is very nice, I would not mind if a expert does snap it. I could also try to make a snap with the game pre-compiled, but since development is not dead, I would prefer the compile-latest-version way.

When removing ‘gamemode’ i get:

$ snapcraft 
Generated snap metadata                                                                                                               
Lint warnings:                                                                                                                        
- library: libcrypt.so.1: unused library 'lib/x86_64-linux-gnu/libcrypt.so.1'. (https://snapcraft.io/docs/linters-library)            
- library: libtirpc.so.3: unused library 'lib/x86_64-linux-gnu/libtirpc.so.3.0.0'. (https://snapcraft.io/docs/linters-library)        
- library: libz.so.1: unused library 'lib/x86_64-linux-gnu/libz.so.1.2.11'. (https://snapcraft.io/docs/linters-library)               
- library: libgamemode.so.0: unused library 'usr/lib/x86_64-linux-gnu/libgamemode.so.0.0.0'. (https://snapcraft.io/docs/linters-library)                                                                                                                                     
- library: libgamemodeauto.so.0: unused library 'usr/lib/x86_64-linux-gnu/libgamemodeauto.so.0.0.0'. (https://snapcraft.io/docs/linters-library)                                                                                                                             
- library: libusb-1.0.so.0: unused library 'usr/lib/x86_64-linux-gnu/libusb-1.0.so.0.3.0'. (https://snapcraft.io/docs/linters-library)
- library: libzip.so.4: unused library 'usr/lib/x86_64-linux-gnu/libzip.so.4.0'. (https://snapcraft.io/docs/linters-library)          
Command '['snap', 'pack', '--filename', 'taisei_1.4.1_amd64.snap', '--compression', 'lzo', PosixPath('/root/prime'), PosixPath('/root/project')]' returned non-zero exit status 1.                                                                                           
Failed to execute pack in instance.