Whipper snap - cdparanoia apparmor issues

I’ve been experimenting a bit lately with creating a snap of whipper, a command line tool to rip audio cds to flac.

So far, I have managed to get something together that seems to mostly function okay (in devmode).

However, I am hitting an issue with sox, specifically the following error.

exception Exception at /snap/whipper/x1/lib/python2.7/site-packages/whipper/common/config.py:116: getDefeatsCache(): soxi failed: soxi FAIL formats: no handler for detected file type `flac'

Weird thing is, when I run sox from within the snap, it reports that flac files are supported.

duncan@duncan-desktop:/snap/whipper/x1/usr/bin$ ./sox --help
...
AUDIO FILE FORMATS: 8svx aif aifc aiff aiffc al amb amr-nb amr-wb anb au avr awb caf cdda cdr cvs cvsd cvu dat dvms f32 f4 f64 f8 fap flac fssd gsm gsrt hcom htk ima ircam la lpc lpc10 lu mat mat4 mat5 maud mp2 mp3 nist ogg paf prc pvf raw s1 s16 s2 s24 s3 s32 s4 s8 sb sd2 sds sf sl sln smp snd sndfile sndr sndt sou sox sph sw txw u1 u16 u2 u24 u3 u32 u4 u8 ub ul uw vms voc vorbis vox w64 wav wavpcm wv wve xa xi

So I’m really a bit stumped as to what the issue could be. I’m not sure whether it’s my snapcraft file, a bug in the program, or something else entirely.

For reference, my snapcraft.yaml looks as follows.

name: whipper
version: '0.5.1+git'
summary: Python CD-DA ripper preferring accuracy over speed (FORKED from morituri)
description: |
  Whipper is a Python 2.7 CD-DA ripper, fork of the morituri project (CDDA ripper for *nix systems aiming for accuracy over speed). It improves morituri which development seems to have halted merging old ignored pull requests, improving it with bugfixes and new features.

grade: devel
confinement: devmode

apps:
  whipper:
    command: bin/whipper

parts:
  whipper:
    source: https://github.com/JoeLametta/whipper.git
    plugin: python
    python-version: python2
    build-packages:
      - libiso9660-dev
      - python-pip
      - swig
#      - cdparanoia
#      - cdrdao
      - flac
      - libcdio-dev
      - libsndfile1-dev
      - python-cddb
      - python-gobject
      - python-musicbrainzngs
      - python-mutagen
      - python-setuptools
      - sox
      
    stage-packages:
      - cdparanoia
      - cdrdao
      - flac
      - libcdio13
      - libsndfile1
      - python-cddb
      - python-gobject
      - python-musicbrainzngs
      - python-mutagen
      - python-setuptools
      - sox
      
    python-packages:
      - pycdio
    prepare: |
      cd src
      make
    install: |
      cd src
      cp accuraterip-checksum $SNAPCRAFT_PART_INSTALL/usr/bin

The command used to rip cds (and produce the error) are as follows

snap run whipper offset find
snap run whipper cd rip

I had a bit more time to work on this and managed to resolve this issue by including SOX as a part in my snap. I’m not entirely sure why this works where throwing it in the stage-packages doesn’t.

My updated yaml now looks as follows

name: whipper
version: '0.5.1'
summary: Python CD-DA ripper preferring accuracy over speed (FORKED from morituri)
description: |
  Whipper is a Python 2.7 CD-DA ripper, fork of the morituri project (CDDA ripper for *nix systems aiming for accuracy over speed). It improves morituri which development seems to have halted merging old ignored pull requests, improving it with bugfixes and new features.

grade: devel
confinement: strict

apps:
  whipper:
    command: bin/whipper
    plugs:
      - optical-drive
      - network
      - home
      - mount-observe
parts:
  whipper:
    source: https://github.com/JoeLametta/whipper/archive/v0.5.1.tar.gz
    plugin: python
    python-version: python2
    build-packages:
      - libiso9660-dev
      - python-pip
      - swig
#      - cdparanoia
#      - cdrdao
      - flac
      - libcdio-dev
      - libsndfile1-dev
      - python-cddb
      - python-gobject
      - python-musicbrainzngs
      - python-mutagen
      - python-setuptools      
    stage-packages:
      - cdparanoia
      - cdrdao
      - flac
      - libcdio13
      - libsndfile1
      - python-cddb
      - python-gobject
      - python-musicbrainzngs
      - python-mutagen
      - python-setuptools
    python-packages:
      - pycdio
    prepare: |
      cd src
      make
    install: |
      cd src
      cp accuraterip-checksum $SNAPCRAFT_PART_INSTALL/usr/bin
  
  sox:
    source: http://downloads.sourceforge.net/sox/sox-14.4.2.tar.gz
    plugin: autotools

I am now working on removing devmode and am encountering what looks like an apparmour issue with cdparanoia. So far I have run the following commands

sudo snap install whipper_0.5.1_amd64.snap --dangerous
sudo snap connect whipper:mount-observe
snap run whipper offset find

At this point, whipper stalls and dmesg produces the following errors

[ 9461.983456] audit: type=1400 audit(1507541224.485:2010): apparmor="DENIED" operation="create" profile="snap.whipper.whipper" pid=9198 comm="snap-exec" family="inet" sock_type="stream" protocol=6 requested_mask="create" denied_mask="create"
[ 9461.983458] audit: type=1400 audit(1507541224.485:2011): apparmor="DENIED" operation="create" profile="snap.whipper.whipper" pid=9198 comm="snap-exec" family="inet6" sock_type="stream" protocol=6 requested_mask="create" denied_mask="create"
[ 9461.983459] audit: type=1400 audit(1507541224.485:2012): apparmor="DENIED" operation="create" profile="snap.whipper.whipper" pid=9198 comm="snap-exec" family="inet6" sock_type="stream" protocol=6 requested_mask="create" denied_mask="create"
[ 9462.988000] audit: type=1400 audit(1507541225.489:2013): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/dev/sr0" pid=9198 comm="python2" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
[ 9462.988002] audit: type=1400 audit(1507541225.489:2014): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/dev/sr0" pid=9198 comm="python2" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
[ 9462.988002] audit: type=1400 audit(1507541225.489:2015): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/proc/9198/mounts" pid=9198 comm="python2" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
[ 9462.988003] audit: type=1400 audit(1507541225.489:2016): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/etc/fstab" pid=9198 comm="python2" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
[ 9462.988364] audit: type=1400 audit(1507541225.489:2017): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/dev/sr0" pid=9198 comm="python2" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
[ 9820.720615] audit: type=1400 audit(1507541583.224:2110): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/proc/20177/mounts" pid=20177 comm="python2" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
[ 9820.720617] audit: type=1400 audit(1507541583.224:2111): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/etc/fstab" pid=20177 comm="python2" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
[ 9820.725119] audit: type=1400 audit(1507541583.228:2112): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/proc/20177/mounts" pid=20177 comm="python2" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
[10005.201498] audit: type=1400 audit(1507541767.704:2208): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/proc/31076/mounts" pid=31076 comm="python2" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
[10005.201499] audit: type=1400 audit(1507541767.704:2209): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/etc/fstab" pid=31076 comm="python2" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
[10005.206294] audit: type=1400 audit(1507541767.708:2210): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/proc/31076/mounts" pid=31076 comm="python2" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
[10161.802365] audit: type=1400 audit(1507541924.303:2218): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/proc/31283/mounts" pid=31283 comm="python2" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
[10161.802367] audit: type=1400 audit(1507541924.303:2219): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/etc/fstab" pid=31283 comm="python2" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
[10161.807938] audit: type=1400 audit(1507541924.311:2220): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/proc/31283/mounts" pid=31283 comm="python2" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
[10185.685982] audit: type=1400 audit(1507541948.187:2225): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/etc/libao.conf" pid=31351 comm="cdrdao" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
[10185.686140] audit: type=1400 audit(1507541948.187:2226): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/dev/sr0" pid=31351 comm="cdrdao" requested_mask="w" denied_mask="w" fsuid=1000 ouid=0
[10194.559085] audit: type=1400 audit(1507541957.064:2227): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/dev/sr0" pid=31352 comm="cdparanoia" requested_mask="w" denied_mask="w" fsuid=1000 ouid=0
[10257.592628] audit: type=1400 audit(1507542020.097:2228): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/dev/sg3" pid=31352 comm="cdparanoia" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
[10258.616561] audit: type=1400 audit(1507542021.125:2229): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/dev/sg3" pid=31352 comm="cdparanoia" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
[10259.713715] audit: type=1400 audit(1507542022.217:2230): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/dev/sg3" pid=31352 comm="cdparanoia" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
[10260.804031] audit: type=1400 audit(1507542023.309:2231): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/dev/sg3" pid=31352 comm="cdparanoia" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
[10261.889229] audit: type=1400 audit(1507542024.397:2232): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/dev/sg3" pid=31352 comm="cdparanoia" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
[10262.916000] audit: type=1400 audit(1507542025.421:2233): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/dev/sg3" pid=31352 comm="cdparanoia" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
[10263.970071] audit: type=1400 audit(1507542026.473:2234): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/dev/sg3" pid=31352 comm="cdparanoia" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
[10265.007724] audit: type=1400 audit(1507542027.513:2235): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/dev/sg3" pid=31352 comm="cdparanoia" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
[10266.083848] audit: type=1400 audit(1507542028.589:2236): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/dev/sg3" pid=31352 comm="cdparanoia" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
[10267.135194] audit: type=1400 audit(1507542029.641:2237): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/dev/sg3" pid=31352 comm="cdparanoia" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
[10268.202033] audit: type=1400 audit(1507542030.709:2238): apparmor="DENIED" operation="open" profile="snap.whipper.whipper" name="/dev/sg3" pid=31352 comm="cdparanoia" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0

Any tips on how I might resolve this? Is it possible that these errors are related to this bug?