Which stage-package is `od` command part of?

On ubuntu 16.04: od is part of coreutils.
$ dpkg -S /usr/bin/od
coreutils: /usr/bin/od
When I include stage-packages: [coreutils] as a stage package the bin folder doesn’t include od binary.

I am using od command in my application can you please help on how to include it?

The binary od is already a part of the core snap so you don’t need to ship it in your snap. The package coreutils is correct, you can verify that by running dpkg -S coreutils. Whatever is causing your program not to find it is another problem.

Thanks for responding @zyga-snapd. The error thrown by apparmor when using od is /usr/bin/od permission denied. I am running snap on ubuntu16.04, why is it trying to use host os binaries? Shouldn’t it use binaries from snap/core/bin? Also the snap core bin directory also doesn’t contain od binary.

Apologies if some of my interpretation is wrong I am new to snaps.

Looks like /usr/bin/od is missing from the default apparmor template. Since od seems relatively harmless, perhaps @jdstrand could add it to the default apparmor template as part of the updates for 2.39 or 2.40?

2 Likes

It is. In the snap runtime the core snap’s directory hierarchy is mapped as the root file system, however there’s a white list in snapd on which binaries are accessible.

@ijohnson yeah, seems like something we should add for 2.39

1 Like

@zyga-snapd meanwhile can you please guide if is there any way to use od binary in my application? As I mentioned earlier I tried including stage-packages: [coreutils] in my yaml but didn’t work.

Added a quick PR to allow snaps to run /usr/bin/od https://github.com/snapcore/snapd/pull/6768

2 Likes

@prasha stage-packages: [coreutils] should leave od in usr/bin/. I notice you say

did you check usr/bin?

1 Like

@chipaca yes snaps bin dir doesn’t contain od binary even after using core-utils in stage-packages

did you check usr/bin? Not bin/; usr/bin/.
If I put stage-packages: [coreutils], I get usr/bin/od in the snap. Why wouldn’t you get the same? Please check that directory.

1 Like

Just for everyone’s sake:

name: od
base: core18
version: current
summary: od in a snap
description: |
  A PoC for https://forum.snapcraft.io/t/which-stage-package-is-od-command-part-of/11067

grade: stable
confinement: strict

parts:
  od:
    plugin: nil
    stage-packages:
    - coreutils
    stage:
    - usr/bin/od

apps:
  od:
    command: od

root@snapcraft-od:~# tree stage
stage
└── usr
    └── bin
        └── od
$ snap run od --version
od (GNU coreutils) 8.28
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jim Meyering.
2 Likes