Command parameter => filename

Hello folk,

iam playing aournd with snap. My goal is to run a excecutable packt as snap on my Ubunut20.04 VM.

I can run my exectuable from actual location with “myApp -config config.yml” . an the config.yml is located in the same folder as my excutable.

Than i created a snap/snapcraft.yaml in the executable folder , and tried to pack my app to a snap with the following:

# define how apps & services are exposed to host system
apps:
  my-app:
    command: MyApp -config config.yml
    # interfaces to connect to https://snapcraft.io/docs/supported-interfaces
    plugs: ['network', 'network-bind']
    daemon: simple

#  describes how to import, and potentially build, each required part of the snap:
parts:
  my-app:
    #environment:
    #  LD_LIBRARY_PATH : /usr/lib/x86_64-linux-gnu
    plugin: dump
    source: .
    stage-packages:
      - libheimbase1-heimdal
      - libheimntlm0-heimdal
      - libhx509-5-heimdal
      - libkrb5-26-heimdal
      - libgssapi3-heimdal

No how can i add the “config.yml” to my snap data, and how do i have to create the command with filename?

=> command: MyApp -config config.yml ???

thank you

Since you are using the dump plugin with source: ., you can add config.yml to the root of your project directory. It will get included in the snap.

Many thanks to, you that was easy.

One other questions: My config file contains paths, can i use $SNAP as relaive path location inside the snap!?

Yes, that will work. You can expect $SNAP to resolve to /snap/<my-snap>/current/.

A relative path would work too - i.e. ./path/inside/snap/project.

1 Like