snap - Cannot get basic Content interface example working with Snapcraft - Ask Ubuntu


i have been trying content interface working trivial example.

consumer:

name: consumer # want 'snapcraft register <name>' version: '0.1' # humans, typically '1.2+git' or '1.3.2' summary: single-line elevator pitch amazing snap # 79 char long summary description: |  grade: devel # must 'stable' release candidate/stable channels confinement: devmode # use 'strict' once have right plugs , slots  apps:   consumer:     command: ls -lr /snap/consumer/current/  parts:   my-part:     # see 'snapcraft plugins'     plugin: nil  plugs:   shared-files:     content: shared-files     interface: content     target: shared     default-provider: provider:shared-files 

provider:

name: provider # want 'snapcraft register <name>' version: '0.1' # humans, typically '1.2+git' or '1.3.2' summary: single-line elevator pitch amazing snap # 79 char long summary description: |  grade: devel # must 'stable' release candidate/stable channels confinement: devmode # use 'strict' once have right plugs , slots  parts:   my-part:     plugin: dump     source: .  slots:   shared-files:     content: shared-files     interface: content     read:     - /src 

/src has random files placed in it. can see these in /snap/provider/current in /snap/consumer/current tree - believe should appear. snap interfaces shows plug , slot connected.

what doing wrong?

you're close!

the content sharing interface bind-mounts slot plug's target. end, target parameter must pointing existing directory (bind mounts need mount on top of other mount). in consumer, instead of using nil plugin, use dump plugin , dump empty shared directory root of snap. you'll see provider's $snap/src directory show in consumer's $snap/shared directory.

note won't see system perspective. if ls /snap/consumer/current/shared/ system, it'll empty directory packaged snap. however, when application fired up, context in run contains bind mount. let me prove it:

$ snap run --shell consumer run command administrator (user "root"), use "sudo <command>". see "man sudo_root" details.  $ ls $snap/shared/ file1  file2 

snap run --shell runs shell within exact environment used application in question. running snap run --shell consumer you're asking shell same confinement , environment consumer app have. that's why use $snap there. note file1 , file2 files contained within provider's src directory.

one last note: assuming want consumer app list contents of shared directory, change (no need use /snap/consumer/current):

apps:   consumer:     command: ls -lr $snap/shared/ 

Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User