Perl script (exiftool) as dependency for snap app

First I have to apologize for posting this question on multiple places (AskUbuntu and in rocket.ubuntu.com).

Since this is my first snap ever I’m struggling to package my tiny Python app (a single .py file) which depends on a Perl tool called exiftool (you can Google it. I can’t add more than 2 links to the topic because I’m a new user).

Exiftool is available in the repos as libimage-exiftool-perl and I’ve tried @popey’s suggestion to add it as stage-packages, but I receive the following error:

tar: ./usr/bin/pstruct: Cannot hard link to ‘./usr/bin/c2ph’: Operation not permitted
tar: ./usr/bin/perlthanks: Cannot hard link to ‘./usr/bin/perlbug’: Operation not permitted
tar: Exiting with failure status due to previous errors
dpkg-deb: error: subprocess tar returned error exit status 2
/home/vagrant/Code/phockup/parts/phockup/ubuntu/download/perl_5.22.1-9_amd64.deb

I saw the source of the exiftool does not require any compilation. It is possible to copy/paste the binary exiftool and lib/ directory to the required place and it will work, but I don’t know how to describe this in the snapcraft.yaml. It’s probably with a wrapper as @elopio suggests, but I don’t know how to organize this or where to place the wrapper file, etc.

I’ll appreciate any help.
I love how easy it is to use snap apps and I’d love to offer my tiny tool as snap.

Please, run the command
snap run --shell your-snap
and give me output
printenv | grep PERL
I think your need add perl into stage-packages.

I am unable to build the .span package and I cannot run snap run ...
Here is my current snapcraft.yaml
I am probably doing some pretty stupid things in there, but basically I’m kinda guessing the required settings.

Please, download https://yadi.sk/d/MRXT5xUw3KZNAQ
Extract this archive. File phockup/project-files/bin/run.sh - renamed desktop-launch
Main lines
export PERL5LIB="${PERL5LIB}:${SNAP}/usr/local/lib/x86_64-linux-gnu/perl/5.22.1:${SNAP}/usr/local/share/perl/5.22.1:${SNAP}/usr/lib/x86_64-linux-gnu/perl5/5.22:${SNAP}/usr/share/perl5:${SNAP}/usr/lib/x86_64-linux-gnu/perl/5.22:${SNAP}/usr/share/perl/5.22:${SNAP}/usr/local/lib/site_perl:${SNAP}/usr/lib/x86_64-linux-gnu/perl-base"
exec “$SNAP/usr/bin/python3” “$SNAP/bin/phockup” “$@”

Run the command and get the package
phockup/snap_make

phockup /home/vasilisc/Images/ /home/vasilisc/temp/phockup/
/home/vasilisc/Images/090420131565.jpg => /home/vasilisc/temp/phockup/2013/04/09/20130409-160715.jpg
/home/vasilisc/Images/ubuntu-nasa-1s.jpg => /home/vasilisc/temp/phockup/2014/08/06/20140806-12482324.jpg

It’s work!

I am unable to build the snap again.
This is what I get as output from running sudo ./snap_make
https://gist.github.com/ivandokov/fcfc09007c1d1cdbe183ce515261a9a8

A side note: I am using Ubuntu 14.04 and 16.04 on Vagrant on Mac to build the snap. I guess it does not matter, but still I have to mention it.

I am using Ubuntu 16.04 without Vagrant

It turns out the problem is in Vagrant. I ssh-ed to my home computer which is using elementaryOS (16.04 based) and I successfully created the snap.

I have a few questions.

  1. Why so many plugs? Do I need them all? plugs: [x11, home, unity7, gsettings]

  2. project-files and phockupgit looks complicated. Can we combine them together for a more simple flow?

  3. run.sh has quite a lot of code. Can I just leave the

... 
exec "$SNAP/usr/bin/python3" "$SNAP/bin/phockup" "$@"``` part?

4) When I am using a wrapper to execute my python script can I skip the part where I copy the `phockup.py` file to `bin` directory and just point the `exec` code to the current location of the `phockup.py` (which I don't know where it is in the snap)?

just turn them off, run your snap and watch syslog … if there are no denials you dont need the plugs…

2 Likes