Open rrenomeron opened 4 years ago
The layout is required due to the way ilibgphoto2 looks up camera drivers. Without the layout, it can't find the libraries it expects to find in subdirectories of /usr/lib when unconfined, and then it can't find a connected camera.
These libraries should all be in $LD_LIBRARY_PATH
, does that not suffice?
Apparently it doesn't. I just followed what was done for the gPhoto2 snap:
https://github.com/gphoto/gphoto2/blob/master/snap/snapcraft.yaml
Unfortunately, it's been too long since I added the layout, so I don't remember what error messages I was seeing that indicated that gPhoto-in-the-darktable-snap wasn't finding the camera driver libraries.
I found some info on why the layout is necessary: https://forum.snapcraft.io/t/gphoto-snap-cannot-detect-any-cameras/10518
It looks like libgphoto2 does its own thing when loading the camera drivers; rather than searching LD_LIBRARY_PATH for a specific list of libraries (e.g. canon6d.so, fujixt20.so), it looks in a specific directory and loads all the files it finds: https://github.com/gphoto/libgphoto2/blob/libgphoto2-2_5_9-release/libgphoto2/gphoto2-abilities-list.c#L156
I suspect the directory it looks in is set at compile time. Since the snap uses libgphoto2 from a package, my guess that it's been hardcoded to look in /usr/lib/$ARCH/libgphoto2/ rather than in the snap. Do you have an issue with having the layout in there? One way we could get around that would be to build libgphoto2 from source, I think.
TL;DR: re-request of #32, but without commingling a darktable version update. This should fix both #27 and #4.
This adds support for the gPhoto2 library and the interfaces it expects, since darktable uses gPhoto2 for both camera tethering and import from removable memory cards. This should make the darktable snap usable for photographers who use the "import from camera" feature, which I suspect is a significant portion of the userbase.
The layout is required due to the way ilibgphoto2 looks up camera drivers. Without the layout, it can't find the libraries it expects to find in subdirectories of /usr/lib when unconfined, and then it can't find a connected camera.
One caveat: memory cards mounted as removable storage show up twice; once as /media/$USER/card and once as /var/lib/snapd/hostfs/media/$USER/card, and apparmor denies any access to the latter.
I have done some preliminary testing with this patch, and other than the caveat mentioned above, it seems to work well.