Desktop file dropped at prime step

The attached yaml file creates a stage/meta/gui/engauge-digitizer.desktop file, but then only the prime/meta/gui/ directory is created. Does anybody know why the desktop file is not created? Thanks

name: engauge-digitizer
version: '10.8'
summary: Interactively convert a bitmap graph or map into numbers.
description: Software tool for extracting numbers from images of graphs and maps.
grade: stable
confinement: strict

parts:
  desktop-file:
    plugin: dump
    stage: [meta/gui/engauge-digitizer.desktop]
    prime: [meta/gui/engauge-digitizer.desktop]
    after: [engauge-digitizer]
  engauge-digitizer:
    plugin: qmake
    options: [CONFIG+=log4cpp_null, CONFIG+=pdf, QT+=printsupport, QT+=sql]
    qt-version: qt5
    build-packages: [qttools5-dev, libqt5gui5, libqt5sql5-sqlite, libfftw3-double3, libpoppler-dev, libpoppler-qt5-dev]
    stage-packages: [qttools5-dev, libqt5gui5, libqt5sql5-sqlite, libfftw3-double3, libpoppler-dev, libpoppler-qt5-dev]
    project-files: [engauge.pro]
    after: [help]
  help:
    plugin: dump
    stage: [documentation/engauge.qch, documentation/engauge.qhc]
    prime: [documentation/engauge.qch, documentation/engauge.qhc]
    after: [desktop-qt5]
apps:
  engauge-digitizer:
    command: desktop-launch $SNAP/engauge
    plugs: [home, cups-control, x11]
    desktop: meta/gui/engauge-digitizer.desktop

Please can you share a link to the complete snapcraft.yaml and associated assets? There should be no requirement to stage/prime the desktop file. Referencing it via the desktop: keyword using a path relative the install location should be sufficient, see the Atom snapcraft.yaml as a reference.

Alternatively, you can create a desktop file and icon as part of the snap, for example:

.
└── snap
    ├── gui
    │   ├── engauge-digitizer.desktop
    │   └── engauge-digitizer.png
    └── snapcraft.yaml

Doing the above does not require defining the desktop: keyword.

There is a build script that runs snapcraft, along with the yaml file, at https://github.com/markummitchell/engauge-digitizer/tree/master/dev/snapcraft

I tried with just the desktop: line several times but was unsuccessful.

Thanks for your help.

You shouldn’t create the meta/ tree on the stage and prime step as its content seems to be masked by snapcraft. Use the desktop keyword in /apps/_app_name_ to specify the desktop file in the prime tree (any underlying path will do, just NOT under meta/ ). Snapcraft will automatically create and populate the meta/ tree during the prime step.

1 Like

The engauge-dgitiizer.desktop file is not copied anywhere into the prime subdirectory. I understand that theoretically it should, but that does not happen. I build this by running build_snap at https://github.com/markummitchell/engauge-digitizer/tree/master/dev/snapcraft.

I misinterpreted your recipe, I suspect the problem is that you didn’t specify the source keyword in the desktop-file part, refer to the following for example:

apps:
  enguage-digitizer:
    command: enguage-digitizer
    desktop: enguage-digitizer.desktop
    plugs: [stripped]

parts:
  desktop-file:
    source: meta/gui/enguage-digitizer.desktop
    plugin: dump
    # No need for `stage` and `prime` keyword, by default snapcraft stage everything the part installs in $SNAPCRAFT_PART_INSTALL and $SNAPCRAFT_STAGE
    # The desktop file should be copied to $SNAPCRAFT_STAGE/enguage-digitizer.desktop and $SNAPCRAFT_PRIME/enguage-digitizer.desktop

Also stage, prime, and desktop keyword specifies the path relative to the $SNAPCRAFT_PRIME tree, NOT under the repo root source tree.

UPDATE: AFAICT the dump plugin copies all files under repo_root_directory to SNAPCRAFT_PART_INSTALL when source keyword is omitted. Then the problem cause is that Snapcraft doesn’t allow packager to install files under $SNAPCRAFT_PRIME/meta and will silently drop them if these files exist.

This might be a snapcraft bug though, at least the documentation didn’t note this behavior.

https://github.com/markummitchell/engauge-digitizer/tree/master/dev/snapcraft

Also, do note that build.snapcraft.io doesn’t support snapcraft recipe other than the following three paths:

  • /.snapcraft.yaml
  • /snapcraft.yaml
  • /snap/snapcraft.yaml

Refer the following issue for more info: build.snapcraft.io doesn’t allow custom snapcraft.yaml location · Issue #1094 · canonical-websites/build.snapcraft.io

The script creates a directory called ‘build’ and the snapcraft.yaml file is copied into that directory before the snapcraft command is run.

The text you provided also does not specify the source command. Is it ‘source: meta/gui/engauge-digitizer.desktop’ or ‘source: engauge-digitizer.desktop’?

Every attempt takes 30 minutes. It has taken many attempts. To be honest, I really do not have much more time and may put this off until a future release.

I copied engauge-digitizer.desktop to both build/stage and build/prime. I then tried one time with ‘source: engauge-digitizer.desktop’ and then one time with ‘source: meta/gui/engauge-digitizer.desktop’. Both cases failed with 'Failed to pull source: unable to determine source type of engauge-digitizer.desktop. Check that the URL is correct…"

Set source-type: local should fix this error.

The source keyword requires the relative path from the directory snapcraft is run as the value. According to your script the line should be source: enguage-digitizer.desktop

Setup ccache might help, refer https://github.com/Lin-Buo-Ren/guvcview-snap/blob/6d9d8fd4810de2d94e2e41a98bf1a862f63027e9/snap/snapcraft.yaml#L129 for an implementation.

Here’s the recipe thst should work:

apps:
  enguage-digitizer:
    command: [stripped]
    desktop: enguage-digitizer.desktop
    plugs: [stripped]

parts:
  desktop-file:
    source: enguage-digitizer.desktop
    source-type: local
    plugin: dump

Thanks for the help, but I am still getting error "NotADirectoryError: /home/mark/engauge-digitizer/dev/snapcraft/build/engauge-digitizer.desktop is not a directory’

I am thinking because this is a qt5 build that yaml steps that would work without qt5 will require some extra changes to work with qt5.

Wrapper script and yaml file are at https://github.com/markummitchell/engauge-digitizer/tree/master/dev/snapcraft. For convenience the yaml file is:

name: engauge-digitizer
version: '10.8'
summary: Interactively convert a bitmap graph or map into numbers.
description: Software tool for extracting numbers from images of graphs and maps.
grade: stable
confinement: strict

parts:
  engauge-digitizer:
    plugin: qmake
    options: [CONFIG+=log4cpp_null, CONFIG+=pdf, QT+=printsupport, QT+=sql]
    qt-version: qt5
    build-packages: [qttools5-dev, libqt5gui5, libqt5sql5-sqlite, libfftw3-double3, libpoppler-dev, libpoppler-qt5-dev]
    stage-packages: [qttools5-dev, libqt5gui5, libqt5sql5-sqlite, libfftw3-double3, libpoppler-dev, libpoppler-qt5-dev]
    project-files: [engauge.pro]
    after: [help]
  help:
    plugin: dump
    stage: [documentation/engauge.qch, documentation/engauge.qhc]
    prime: [documentation/engauge.qch, documentation/engauge.qhc]
    after: [desktop-file]
  desktop-file:
    source: engauge-digitizer.desktop
    source-type: local
    plugin: dump
    after: [desktop-qt5]    
apps:
  engauge-digitizer:
    command: desktop-launch $SNAP/engauge
    plugs: [home, cups-control, x11]
    desktop: engauge-digitizer.desktop

That’s probably due to the local source-type doesn’t allow file path as URL, apologies for the invalid example. Here’s the official documentation in snapcraft help sources:

  - source: url-or-path

    A URL or path to some source tree to build. It can be local
    ('./src/foo') or remote ('https://foo.org/...'), and can refer to a
    directory tree or a tarball or a revision control repository
    ('git:...').

I would suggest creating a desktop-file sub-directory, copy the desktop entry file in and use the following recipe:

apps:
  engauge-digitizer:
    command: desktop-launch $SNAP/engauge
    plugs: [home, cups-control, x11]
    desktop: engauge-digitizer.desktop

parts:
  desktop-file:
    source: desktop-file
    source-type: local
    plugin: dump

That does not work. I have tried your version and other attempts with slight changes. In every case I get ‘NotADirectoryError …/engauge-digitizer.desktop is not a directory’, even though the file exists.

I think we are past the stage where this can be thought of as a ‘read-the-manual’ problem. There is something wrong here.

The error is, in fact, pretty clear, source keyword only allows a directory path instead of a file path with source-type: local. You have to specify . or create a new directory to contain the desktop entry file and specify the directory path as the value.

Strange. I tried your input before and it did not work. In any event it works fine now. Thanks