This dvswitch videomixer snap is/was a former Debian/Ubuntu cmake deb package:
https://code.launchpad.net/~walterav/+snap/dvswitch
It natively builds/installs/runs successful on Ubuntu 16.04 xenial amd64&i686&powerpc(slow) using the following source and instructions:
https://github.com/walterav1984/dvswitch
When crafting a snapcraft.yaml for building the snap on this Ubuntu 16.04 amd64 host I set it up to use the cmake plugin (which build process was already there/complete for Debian) and it builds snaps both local and on launchpad
.
https://github.com/walterav1984/dvswitch/blob/ubuntu-16.04-master/snap/snapcraft.yaml
However some shared files *.png are in the stage/prime folders and final snap build are not available when running the dvswitch snap giving the following error on Ubuntu mate 17.10:
$dvswitch -p 1234 -h 127.0.0.1
(process:31968): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.
Gtk-Message: Failed to load module "unity-gtk-module"
Gtk-Message: Failed to load module "gail"
Gtk-Message: Failed to load module "atk-bridge"
Gtk-Message: Failed to load module "canberra-gtk-module"
ERROR: Failed to open file '/usr/local/share/dvswitch/pri-video-source.png': No such file or directory
The snap however contains “binaries” that do work but not intended as a snap, I mean when installing the snap on ubuntu mate 17.10 “sudo snap install dvswitch_0.9.5_amd64.snap --devmode” and quick and dirty manually linking the libs via /etc/ld.so.conf.d/dvswitch.conf containing “/snap/dvswitch/x1/usr/lib/x86_64-linux-gnu” completed with sudo ldconfig and copying the snap folder “/snap/dvswitch/x1/usr/local/share/dvswitch” to the system natives /usr/local/share/ than the binary “/snap/dvswitch/x1/usr/local/bin/dvswitch” runs fine and works even with firewire camera’s and local storage reading and saving video files :-). But than conflicts arise since older libs from the snap are hardlinked with ones already on the system and vlc or other native apps won’t run anymore.
Off course this is not the way a snap should work but it shows that its functionality is almost there.
Is it possible/needed to address the /usr/local/share in the snap yaml ifso how?
PS: the *.png icons that are not found are no desktop icons for a snap shortcut but assets of the dvswitch binary itself
It’s worth checking whether the application is portable once compiled. Some applications hard-code paths at compile-time, but others allow overriding locations via environment variables.
If the app is one of the former, that hard-code the paths, you could in the short term set the compile to build with a target directory of /snap/dvswitch/current/usr/local
and then use organize
to move the final files into the correct location (remove the prefix leaving it to /usr/local
) within the final snap:
...
parts:
dvswitch-part:
plugin: cmake
configflags:
- '-DCMAKE_INSTALL_PREFIX=/snap/dvswitch/current/usr/local'
organize:
snap/dvswitch/current/usr/local: usr/local
...
...
The longer term solution is to work with the project maintainers to add support into the project to provide overriding support to the currently-hard-coded paths.
If the project already includes the ability to override the paths then you just need to ensure the requisite environment variables are added to the apps
section of your snapcraft.yaml
. The names of these variables are arbitrary and vary between projects that have this concept implemented.
Thanks for responding.
Blockquote
It’s worth checking whether the application is portable once compiled.
It is portable, it can be run from any folder even the snap binaries from the installed snap as long as the right libs are in place and the /usr/local/share/dvswitch/ folder contains the png’s.
Blockquote
Some applications hard-code paths at compile-time, but others allow overriding locations via environment variables.
There is a partly hardcoded path $sharedir/dvswitch/pri-video-source.png" in the “src/dv_selector_widget.cpp” probably set by DSHAREDIR flag during compile some-where/how. For the fun I changed it to “/snap/dvswitch/current/usr/local/share/dvswitch/pri-video-source.png” and now running dvswitch from the snap gets a little bit further :-). But stopping on a real hard to fix snap issue since “gdk-pixbuf-query-loaders” is not run to create a cache inside the snap?
dvswitch -p 1234 -h 127.0.0.1
(process:2295): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.
Gtk-Message: Failed to load module "unity-gtk-module"
Gtk-Message: Failed to load module "gail"
Gtk-Message: Failed to load module "atk-bridge"
Gtk-Message: Failed to load module "canberra-gtk-module"
(dvswitch:2295): GdkPixbuf-WARNING **: Cannot open pixbuf loader module file '/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders.cache': No such file or directory
This likely means that your installation is broken.
Try running the command
gdk-pixbuf-query-loaders > /usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders.cache
to make things work again for the time being.
ERROR: Couldn't recognize the image file format for file '/snap/dvswitch/current/usr/local/share/dvswitch/pri-video-source.png'
According to the info from the following pixbuf related links:
https://bugs.launchpad.net/snapcraft/+bug/1576289
https://github.com/ubuntu/snapcraft-desktop-helpers/issues/42
It seems that when adding a desktop icon launcher to snap, which is possible for dvswitch since it is the GUI part of the app that might/will trigger the pixbuf cache generating for *.png formats in the snap. Well I hope so.
Do you happen to know more about this pixbuf cache generating or will be using a new snapcraft version wil fix this, since that is also somehow asserted in one of the threads?
Blockquote
The longer term solution is to work with the project maintainers to add support into the project to provide overriding support to the currently-hard-coded paths.
The dvswitch project is sadly denounced dead a couple of years ago, so setting new snap focused hard coded paths is possible, but maybe not needed.
gdk-pixbuf is handled by the desktop-helpers. You can set your part to require the desktop-gtk2
or desktop-gtk3
or desktop-glib-only
to pull-in a script and some supporting stage-packages
. Then you will need to edit the command:
for the graphical utilities to prefix them with desktop-launch
. You will also want to ensure that you plug the desktop-related interfaces for the graphical utilities:
parts:
dvswitch-part:
after: [desktop-gtk2]
plugin: cmake
...
apps:
dvswitch:
command: desktop-launch $SNAP/usr/local/bin/dvswitch
plugs:
- desktop
- desktop-legacy
- wayland
- x11
...
Again thanks with your suggestions for gdk-pixbuf on the yaml the dvswitch gui app finally starts
, but will crash "Gtk::IconThemeError "as soon as DV video is sent into the application either from file or firewire. Other options/menu items are click-able.
I think this might be because the png’s talked earlier about are than actually rendered/visible first time.
dvswitch -p 1234 -h 127.0.0.1
Gtk-Message: Failed to load module “gail”
Gtk-Message: Failed to load module “atk-bridge”
Gtk-Message: Failed to load module “canberra-gtk-module”
terminate called after throwing an instance of ‘Gtk::IconThemeError’
Aborted (core dumped)
Hardcoding out the png’s might be my first noop attempt to see if it fixes it, unless you have more valuable advice?
PS: pixbuf loader.cache is still missing from the snap (unsquashing/squashing and adding it manually didn’t help).
You possibly need to add the default icon theme as a stage package so that your application can use the icons expected to be present on a system:
parts:
dvswitch:
...
stage-packages:
...
- hicolor-icon-theme
Adding “hicolor-icon-theme” gives the same 'Gtk::IconThemeError’ like before, I do have to say that with or without hicolor-icon-theme normal/regular gnome2 icons like scissors and green apply/checkbox mark already appear.
I have only ran dvswitch on machines on which I also build it, I will try and see if it errors on a default ubuntu 16.04 install with a already compiled package.
The documentation of the GTK::IconThemeError class says that there are two potential error codes:
- The icon theme cannot be found
- Other unspecified error that shouldn’t occur
So I would surmise that your app is unable to find the icon theme. I see that you’re installing dvswitch into $SNAP/usr/local
. This might be the cause of the problem in that the desktop-launch
script is not tooled-up to tell the app about paths in usr/local
. You could try using:
parts:
dvswitch:
...
configflags:
- '-DCMAKE_INSTALL_PREFIX=/usr'
This will enforce being specifically not including the local
part of the path, and will therefore be within the paths that desktop-launch
sets up.
Almost there I think, but I’m having some mixed results using different snapcraft.yaml and hardcodec png location settings. There is still a difference with my local snapcraft and the one on launchpad I think because they create different output files. Sorry for the messy information.
I got rid of the /usr/local prefix by editing CMakelists.txt and changed /usr/local > /usr. Still using hardcoded png locations for dv_selector.cpp.
Played around with adding dcmake list configflag and organize flag, but still not sure what does what.
The dvswitch snap build has seen working (although with still a few unknown hacks/steps) on ubuntu 16.04 ubuntu 17.10 and even ubuntu 18.04 daily(all use mate theme/desktop).
Ugly hack by copying the "home/user/snap/* folder from the ubuntu 17.10 install to ubuntu 18.04 made the app running on 18.04 (including successful firewire camera test). I didn’t do any ugly LD lib linking or copying png files. I didn’t realize this ~/snap/ folder was created until the output on ubuntu 18.04.
dvswitch -p 1234 -h 127.0.0.1
g_module_open() failed for /snap/dvswitch/x1/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-png.so: libpng12.so.0: cannot open shared object file: No such file or directory
/snap/dvswitch/x1/usr/sbin/update-icon-caches: 16: /snap/dvswitch/x1/usr/sbin/update-icon-caches: gtk-update-icon-cache-3.0: not found
WARNING: icon cache generation failed for /home/ua/snap/dvswitch/x1/.local/share/icons/Adwaita
/snap/dvswitch/x1/usr/sbin/update-icon-caches: 16: /snap/dvswitch/x1/usr/sbin/update-icon-caches: gtk-update-icon-cache-3.0: not found
WARNING: icon cache generation failed for /home/ua/snap/dvswitch/x1/.local/share/icons/DMZ-Black
/snap/dvswitch/x1/usr/sbin/update-icon-caches: 16: /snap/dvswitch/x1/usr/sbin/update-icon-caches: gtk-update-icon-cache-3.0: not found
WARNING: icon cache generation failed for /home/ua/snap/dvswitch/x1/.local/share/icons/DMZ-White
/snap/dvswitch/x1/usr/sbin/update-icon-caches: 16: /snap/dvswitch/x1/usr/sbin/update-icon-caches: gtk-update-icon-cache-3.0: not found
WARNING: icon cache generation failed for /home/ua/snap/dvswitch/x1/.local/share/icons/hicolor
/snap/dvswitch/x1/usr/sbin/update-icon-caches: 16: /snap/dvswitch/x1/usr/sbin/update-icon-caches: gtk-update-icon-cache-3.0: not found
WARNING: icon cache generation failed for /home/ua/snap/dvswitch/x1/.local/share/icons/Humanity
/snap/dvswitch/x1/usr/sbin/update-icon-caches: 16: /snap/dvswitch/x1/usr/sbin/update-icon-caches: gtk-update-icon-cache-3.0: not found
WARNING: icon cache generation failed for /home/ua/snap/dvswitch/x1/.local/share/icons/Humanity-Dark
/snap/dvswitch/x1/usr/sbin/update-icon-caches: 16: /snap/dvswitch/x1/usr/sbin/update-icon-caches: gtk-update-icon-cache-3.0: not found
WARNING: icon cache generation failed for /home/ua/snap/dvswitch/x1/.local/share/icons/LoginIcons
/snap/dvswitch/x1/usr/sbin/update-icon-caches: 16: /snap/dvswitch/x1/usr/sbin/update-icon-caches: gtk-update-icon-cache-3.0: not found
WARNING: icon cache generation failed for /home/ua/snap/dvswitch/x1/.local/share/icons/ubuntu-mono-dark
/snap/dvswitch/x1/usr/sbin/update-icon-caches: 16: /snap/dvswitch/x1/usr/sbin/update-icon-caches: gtk-update-icon-cache-3.0: not found
WARNING: icon cache generation failed for /home/ua/snap/dvswitch/x1/.local/share/icons/ubuntu-mono-light
/snap/dvswitch/x1/usr/sbin/update-icon-caches: 16: /snap/dvswitch/x1/usr/sbin/update-icon-caches: gtk-update-icon-cache-3.0: not found
WARNING: icon cache generation failed for /home/ua/snap/dvswitch/x1/.local/share/icons/default
ERROR: Couldn't recognize the image file format for file '/snap/dvswitch/current/usr/share/dvswitch/pri-video-source.png'
I may have run manually sudo gtk-update-icon-cache somewhere in the process?
This error indicates you’re missing at least one library. You will need to add a stage-package
for libpng12-0
to satisfy that specific dependency.
Strange thing is that “libpng12-0” is already part of the stage packages, however I’ve changed and played with the confinement from “devmode” to “classic” / " and other way around" and read on a shotcut snap thread that classic confinement makes the snap bins skip for looking for the libs inside the snap but outside in the host system. Since newer ubuntu versions won’t ship with version 12 of libpng its a stopper. Also read somewhere that classic confinement has undergone some changes on higher ubuntu versions and behaves differently than on 16.04.
I’ve also noticed that dvgrab which I ship with dvswitch cannot find libquicktime2 but that file is also in the snap (not in stages) but that may still missing because its a classic instead of devmode confinement.
I think I need a default ubuntu 16.04 desktop instead of a more gtk2 focused mate desktop to really pinpoint all the dependencies. I’m still amazed that with your input I have seen dvswitch running on higher ubuntu versions than 16.04 without the need to change ffmpeg and boost changes to the source code
.
After Ubuntu 18.04 bionic is released I will do more attempts, but it looks very promising already thanks @lucyllewy for the input sofar.