nurupo / vlc-pause-click-plugin

Plugin for VLC that pauses/plays video on mouse click
GNU Lesser General Public License v2.1
945 stars 64 forks source link

Can't install on snap #33

Closed giuseppe-dandrea closed 6 years ago

giuseppe-dandrea commented 6 years ago

Is there a way to install the plugin if I installed vlc 3 through snap? I'm using a debian-based distro of linux but the debian instruction doesn't work, maybe because snap installs the applications in a read-only partition in the root directory. Tried to copy the .so file in /snap/vlc/usr/lib etc.. but can't write in the directory. Is there another way to install the plugin or to copy the file in that directory? (Tried to change the permissions but without success)

nurupo commented 6 years ago

Sorry, don't know anything about snaps. Also, the build instructions build the plugin for your system's VLC, if the version of the VLC from your package repository differs from the one in the snap, e.g. VLC 2.2 vs VLC 3.0, then the plugin won't work. You can't use a plugin built for VLC 2.2 in VLC 3.0 (same with any other combination of 2.1, 2.2 and 3.0).

nurupo commented 6 years ago

It sounds like snaps can't be modified, so you can't add the plugin file in there. The next best thing would be to copy over all the VLC plugins from the snap somewhere into your home directory and then run vlc with VLC_PLUGIN_PATH env variable set pointing to where you copied all the plugins, including the vlc-pause-click-plugin. But then you'd need to copy over the plugins every time you update the VLC snap, as well as to figure out how to build the plugin against the VLC snap, which might not be possible if the snap doesn't provide SDK.

Can you run the tree command inside the root directory of VLC snap and paste-bin somewhere the output? Want to see if it includes the SDK. If it doesn't include it, then there is no way you are building the plugin for that VLC.

giuseppe-dandrea commented 6 years ago

Here is the output https://github.com/giuseppe-dandrea/tree-snap-vlc-output/blob/master/output.txt Was too big for pastebin

nurupo commented 6 years ago

Alright, it does include the SDK, so it's possible to build the plugin against it, it just won't be pretty. Can you tell where is the snap located at? I seecurrent/usr/lib/libvlccore.so file exists, but I need an absolute path to it, starting with root directory. With that information I could try writing a bash script for building the plugin for you.

giuseppe-dandrea commented 6 years ago

The path of the snap directory is simply /snap, in the root, in this folder there is the list of all snap applications, so the full path is /snap/vlc and you can see from the output that in this folder there are the folders for the versions (just the 158 in that case) and the symlink to the current version (current). Thanks a lot for the help

giuseppe-dandrea commented 6 years ago

Tried to ask in the snap forum too for more info, but seems that there isn't a way without recompiling the snap... https://forum.snapcraft.io/t/call-for-testing-vlc-3-0-0-rc1/3202/44

nurupo commented 6 years ago

Right, it's a security feature.

Anyway, I'm convinced that we can make it work.

Try this to build the plugin binary against the VLC SDK from the snap:

sudo apt-get install build-essential pkg-config git
cd ~
git clone https://github.com/nurupo/vlc-pause-click-plugin
cd vlc-pause-click-plugin
git checkout 1.0.0 
cp -a /snap/vlc/current/usr/lib/pkgconfig .
sed -i "s|^prefix=.*|prefix=/snap/vlc/current/usr|g" pkgconfig/*.pc
export PKG_CONFIG_PATH="${PWD}/pkgconfig"
make

Now place the plugin whenever you want on your system, for this example I will just use ~/.config/vlc/plugins:

mkdir -p ~/.config/vlc/plugins
cp libpause_click_plugin.so ~/.config/vlc/plugins

Now start VLC, telling it to check ~/.config/vlc/plugins for extra plugins. You'd do usually do it like this:

VLC_PLUGIN_PATH=/home/giuseppe-dandrea/.config/vlc/plugins /snap/vlc/current/bin/vlc

changing the username in the path yours, but there is a little complication here, as it seems that you don't start the snap VLC by directly running /snap/vlc/current/bin/vlc but rather /snap/vlc/current/bin/vlc-snap-wrapper.sh or something else, which might override VLC_PLUGIN_PATH, throwing away whatever we have set it to . Could tell what exactly do you run to start the snap VLC? If it's a desktop icon, open it in a text editor and see what program it calls. I think it calls vlc-snap-wrapper.sh, but I don't have snap installed to be check if it is so. If it's so, pastebin the contents of vlc-snap-wrapper.sh somewhere.

giuseppe-dandrea commented 6 years ago

All the commands worked but the last, wich said that /snap/vlc/current/bin/vlc doesn't exist. In fact in that folder there are only two files, but if I try to run them these are the output:

[giuseppe]: ./desktop-launch
Can't save user-dirs.dirs
mkdir: cannot create directory '/.config/dconf': Permission denied
ln: failed to create symbolic link '/.config/dconf': Permission denied
./desktop-launch: riga 335: /flavor-select: File o directory non esistente
[giuseppe]: ./vlc-snap-wrapper.sh
Unsupported architecture for this app build

https://github.com/giuseppe-dandrea/tree-snap-vlc-output here i pushed the content of the folder.

I usually start vlc by typing vlc in the terminal or I have a script that exec vlc with the media argument, anyway don't have a desktop icon or start it by double-click on the media.

nurupo commented 6 years ago

I usually start vlc by typing vlc in the terminal

Does typing vlc in the terminal start the snap VLC or the VLC packaged by your distribution?

giuseppe-dandrea commented 6 years ago

@nurupo the snap vlc, wich is the only version installed

nurupo commented 6 years ago

Oh, then just do

VLC_PLUGIN_PATH=/home/giuseppe-dandrea/.config/vlc/plugins vlc

assuming you have the libpause_click_plugin.so plugin binary in /home/giuseppe-dandrea/.config/vlc/plugins. If everything works, you should see the plugin options appear in the preferences (here are screenshots).

giuseppe-dandrea commented 6 years ago

No it doesn't work, the command starts vlc but in the preferences there aren't new checkboxes, tried with --reset-plugins-cache too but no luck

nurupo commented 6 years ago

Try it a bit differently then

export VLC_PLUGIN_PATH=/home/giuseppe-dandrea/.config/vlc/plugins
vlc
nurupo commented 6 years ago

If that doesn't work there are a few possibilities here

  1. VLC can't access the VLC_PLUGIN_PATH for some reason
    • Incorrect VLC_PLUGIN_PATH was specified
    • File permission issue
    • Snap apps are sandboxed?
  2. Snap VLC was made to ignore VLC_PLUGIN_PATH by whoever made the snap
  3. Plugin is not compatible with the snap VLC (e.g. it was build against system libvlccore instead)

You could look into 1 on your own, check that the path, file permissions, etc. are correct there.

I have no idea how to check 2.

For 3, repeat the build process from scratch and pastebin output of the make and ldd commands

sudo apt-get install build-essential pkg-config git
cd ~
git clone https://github.com/nurupo/vlc-pause-click-plugin
cd vlc-pause-click-plugin
git checkout 1.0.0 
cp -a /snap/vlc/current/usr/lib/pkgconfig .
sed -i "s|^prefix=.*|prefix=/snap/vlc/current/usr|g" pkgconfig/*.pc
export PKG_CONFIG_PATH="${PWD}/pkgconfig"
make
sudo apt-get install build-essential pkg-config git
cd ~
git clone https://github.com/nurupo/vlc-pause-click-plugin
cd vlc-pause-click-plugin
git checkout 1.0.0 
cp -a /snap/vlc/current/usr/lib/pkgconfig .
sed -i "s|^prefix=.*|prefix=/snap/vlc/current/usr|g" pkgconfig/*.pc
export PKG_CONFIG_PATH="${PWD}/pkgconfig"
make
ldd libpause_click_plugin.so
giuseppe-dandrea commented 6 years ago

Ok then, 1- Double checked the path and set all the permissions in the plugin folder to 777. 2- Don't know that 3- Here is the output:

make output:
cc -std=gnu11 -g0 -O3 -Wall -Wextra -fPIC -D__PLUGIN__ -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D_THREAD_SAFE -I/snap/vlc/current/usr/include -I/snap/vlc/current/usr/include/vlc/plugins -DPIC -I. -Isrc -DMODULE_STRING=\"pause_click\"  -c -o pause_click.o pause_click.c
cc -std=gnu11 -shared -o libpause_click_plugin.so pause_click.o  -L/snap/vlc/current/usr/lib -lvlccore
ldd output:
    linux-vdso.so.1 (0x00007ffd863ad000)
    libvlccore.so.9 => not found
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fae5e065000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fae5e607000)
nurupo commented 6 years ago

make and ldd outputs look good.

Can you run:

VLC_PLUGIN_PATH=/home/giuseppe-dandrea/.config/vlc/plugins vlc --verbose 2

(replace /home/giuseppe-dandrea/.config/vlc/plugins with the path to whatever directory you put the plugin .so file into)

then close VLC and and pastebin the output?

giuseppe-dandrea commented 6 years ago

Ok this helped, it show that vlc is exploring the folder with the plugin (ps. tried to copy the plugin also in a folder called video_filters in the plugin folder), but tried with or without the plugin file and it loads 508 modules. Here is the output: https://github.com/giuseppe-dandrea/tree-snap-vlc-output/blob/master/vlc_output

nurupo commented 6 years ago

So, since the number of plugins doesn't change, then VLC simply doesn't/can't load it. Can you provide output of ldd on one of the plugins VLC comes with?

Something like

ldd /snap/vlc/current/usr/lib/vlc/plugins/video_filter/libpuzzle_plugin.so

Not sure if that's the correct path to the plugin though, fix it if it's not.

nurupo commented 6 years ago

Actually, do ldd -v both on libpause_click_plugin.so and then on /snap/vlc/current/usr/lib/vlc/plugins/video_filter/libpuzzle_plugin.so.

Also, what is your distribution release version?

My current guess is that VLC is not loading the plugin due to libc incompatibilities or due to some missing shared library dependencies (i.e. the dlopen() call on libpause_click_plugin.so within VLC fails).

giuseppe-dandrea commented 6 years ago

Also, what is your distribution release version?

I'm using Deepin 15.5 based on Debian with i3wm

Here is the output

ldd -v libpuzzle_plugin.so
linux-vdso.so.1 (0x00007ffc9bf75000)
    libvlccore.so.9 => not found
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f864175b000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f8641d0f000)

    Version information:
    /snap/vlc/current/usr/lib/vlc/plugins/video_filter/libpuzzle_plugin.so:
        libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
    /lib/x86_64-linux-gnu/libc.so.6:
        ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
        ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
ldd -v libpause_click_plugin.so
linux-vdso.so.1 (0x00007ffc61703000)
    libvlccore.so.9 => not found
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9a2eb2f000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f9a2f0d1000)

    Version information:
    /home/giuseppe/Desktop/Temp_Downloads/vlc-pause-click-plugin/libpause_click_plugin.so:
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
    /lib/x86_64-linux-gnu/libc.so.6:
        ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
        ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
nurupo commented 6 years ago

Alright, it appears like the snap VLC is built on Ubuntu Xenial using gcc 5.4.0. We build the plugin using you system's gcc and linking it against your system's libc version, which are newer than the ones in Ubuntu Xenial. Meaning the the plugin might not be binary compatible with what VLC expects when it loads a plugin. This is just an educated guess though, I'm not 100% sure. The plugin is more likely to work if we build it on Ubuntu Xenial.

How willing are you to install Docker on your system so that we could try building the plugin using the Ubuntu Xenial container to see if it makes VLC load the plugin? I can guide you through the entire thing, it's actually easy, pretty much the build instructions you have used to build the plugin plus a couple of docker commands.

giuseppe-dandrea commented 6 years ago

Ok no problem, but never used Docker before, let me know how to do.

nurupo commented 6 years ago

Well, first install it. Not sure if your distribution packages it, but I'm using Debian and it doesn't, so I have to add Docker's package repository to get it https://docs.docker.com/install/linux/docker-ce/debian/. Deepin 15.5 looks to be based on Debian Stretch, so installing Docker sums up to

sudo apt-get install \
     apt-transport-https \
     ca-certificates \
     curl \
     gnupg2 \
     software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
sudo echo "deb [arch=amd64] https://download.docker.com/linux/debian stretch stable" >> /etc/apt/sources.list
sudo apt-get update
sudo apt-get install docker-ce

To build the plugin in a Ubuntu Xenial container do

mkdir result
# This will create a temporary ubuntu 16.04 container with your system's $PWD/result
# being mounted in container's /result and your system's /snap in container's /snap
# and will start bash inside of the container
sudo docker run --rm -it -v $PWD/result:/result -v /snap:/snap ubuntu:16.04 /bin/bash
# Now you are in a bash session inside the container, which you can see by the changed
# command prompt, which would be something like root@11212a8998fc, so whatever
# you do here won't affect your system
apt-get update
# Now we follow the instructions on building the plugin
apt-get install build-essential pkg-config git
# Make sure the GCC version is 5.4.0
gcc --version
cd /result
git clone https://github.com/nurupo/vlc-pause-click-plugin
cd vlc-pause-click-plugin
git checkout 1.0.0 
cp -a /snap/vlc/current/usr/lib/pkgconfig .
sed -i "s|^prefix=.*|prefix=/snap/vlc/current/usr|g" pkgconfig/*.pc
export PKG_CONFIG_PATH="${PWD}/pkgconfig"
make
# Now that we have built the plugin, let's exit the container, which will also destroy it
logout
# Free disk space by deleting the downloaded Ubuntu 16.04 base image
sudo docker rmi ubuntu:16.04
# You should have the plugin in result/vlc-pause-click-plugin directory
# Change the ownership to your user, as it is owned by root because we
# were running as root inside the container
sudo chown giuseppe:giuseppe -R result

Now try making VLC use the plugin you got in result/vlc-pause-click-plugin, e.g. put it in /home/giuseppe/.config/vlc/plugins/ and try the VLC_PLUGIN_PATH=/home/giuseppe/.config/vlc/plugins vlc, it might work now that the plugin is built using the same versions of the compiler and libc.

giuseppe-dandrea commented 6 years ago

Followed all the steps, no error message, gcc version 5.4.0... Only 508 plugins and no new checkboxes in the preferences.. I think that there's no way to install new plugins in snap vlc without recompile it. Thanks a lot for the help, if you have new ideas I'm happy to try, otherwise I could close the issue.

nurupo commented 6 years ago

Do you keep the plugin name the same, i.e. libpause_click_plugin.so? I'm going though VLC source code for loading plugins and it searches specifically for lib*_plugin.so pattern when loading a module, so renaming it to anything else would prevent VLC from loading it https://github.com/videolan/vlc/blob/3.0.0-git/src/modules/bank.c#L367

giuseppe-dandrea commented 6 years ago

Yes the name is the same

giuseppe@giuseppe-PC:~$ ls .config/vlc/plugins/
libpause_click_plugin.so
nurupo commented 6 years ago

What does

LD_BIND_NOW=1 VLC_PLUGIN_PATH=/home/giuseppe/.config/vlc/plugins vlc --verbose 2

output?

giuseppe-dandrea commented 6 years ago

Here is the output https://github.com/giuseppe-dandrea/tree-snap-vlc-output/blob/master/vlc_output2

nurupo commented 6 years ago

Was hoping to see this message pop up but it didn't. Yeah, it's hard to say why it's not working. You can close the issue now. Don't forget to uninstall Docker, it always runs in the background, which you probably don't want if you are not going to use it:

sudo service docker stop
sudo apt-get purge docker-ce
sudo sed -i '/docker/d' /etc/apt/sources.list
sudo apt-key del 0EBFCD88

should do it.

giuseppe-dandrea commented 6 years ago

Ok, thanks again for the help.