I tried a few years ago to create a Snap and gave up. Instead I built and published a Flatpak. I’ve since discovered ChatGPT and thought I might succeed in creating a Snap if I used it to convert the Flatpak manifest to a snapcraft.yaml.
The build starts working then fails with a mysterious message.:
chris@UNKNOWN:~/snap$ snapcraft
'override-build' in part 'myapp' 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/chris/.local/state/snapcraft/log/snapcraft-20250130-163007.810377.log'
I don’t think that “- -debug to shell into the environment” would help as I wouldn’t know what to look for in the shell. “introspect this failure” to me this means “examine myself this failure” so means nothing to me :). Any ideas what might have gone wrong?
Comments on the manifest would be helpful in case ChatGPT was hallucinating. It is written with Python and GTK4 and has dependencies on python3, python3-pil, python3-numpy and python3-opencv.
I want to avoid setup.py etc and have used Meson to avoid them, however I would prefer to use Bash to install the files instead of Meson, if it would be possible here “override-build: |”.
snapcraft.yaml
name: myapp
base: core22
version: "0.0.0"
summary: An application
description: |
An application to do something.
grade: stable
confinement: strict
adopt-info: myapp
apps:
myapp:
command: bin/myapp
extensions: [gnome]
environment:
EGL_PLATFORM: wayland
plugs:
- home
- wayland
- opengl
parts:
myapp:
plugin: meson
source: local
source-type: local
build-packages:
- python3-pip
- python3-setuptools
- python3-wheel
- meson
- ninja-build
stage-packages:
- python3
- python3-pil
- python3-numpy
- python3-opencv
override-build: |
pip install --prefix=$SNAPCRAFT_PART_INSTALL meson meson-python
meson setup builddir --prefix=$SNAPCRAFT_PART_INSTALL
meson install -C builddir
plugs:
wayland:
interface: wayland
opengl:
interface: opengl
meson.build
project(
'myapp',
version: '1.0.0',
meson_version: '>= 0.46.0'
)
bindir = get_option('bindir')
datadir = get_option('datadir')
pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), 'myapp')
conf = configuration_data()
conf.set('pkgdatadir', pkgdatadir)
configure_file(
input: 'myapp.py',
output: 'myapp',
configuration: conf,
install_dir: bindir
)
data_files = [
'com.github.myapps.myapp.png',
'dummy.png'
]
foreach file : data_files
install_data(file, install_dir: pkgdatadir)
endforeach
install_data(
'com.github.myapps.myapp.appdata.xml',
install_dir: join_paths(datadir, 'metainfo')
)
install_data(
'com.github.myapps.myapp.desktop',
install_dir: join_paths(datadir, 'applications')
)
install_data(
'com.github.myapps.myapp.png',
install_dir: join_paths(datadir, 'icons', 'hicolor', '128x128', 'apps')
)
install_data(
'com.github.myapps.myapp64x64.png', rename : 'com.github.myapps.myapp.png',
install_dir: join_paths(datadir, 'icons', 'hicolor', '64x64', 'apps')
)
install_data(
'myapp_de_DE.mo', rename : 'myapp.mo',
install_dir: join_paths(get_option('prefix'), get_option('localedir'), 'de_DE', 'LC_MESSAGES')
)