sudo-give-me-coffee / flatpak2appdir

A proof of concept to demonstrate a viable way to turn a Flatpak into AppDir
MIT License
28 stars 2 forks source link

Try using appimagetool -s deploy #11

Closed probonopd closed 4 years ago

probonopd commented 4 years ago

appimagetool -s deploy rewrites rpaths and deploys any missing libraries into the AppDir. I'd like to try this out on flatpak2appdir. For that to work, it needs to be able to find the dependencies using ldd. Which means that appimagetool -s deploy appdir/usr/share/applications/*desktop needs to run inside the environment (here: chroot) while /app and the full Flatpak runtime/SDK are accessible from the "inside".

I tried putting it here

https://github.com/sudo-give-me-coffee/flatpak2appdir/blob/cab8ae0f588dbb805a9db283d508a1096a09a3fc/build-appimage.sh#L12-L13

but that doesn't work because it needs to run from inside the chroot. How to achieve this best?

sudo-give-me-coffee commented 4 years ago

Did you try export libunionpreload.so? chroot may be unnecessary

probonopd commented 4 years ago

I think that some AppDirs that are currently generated are missing some required libraries. Hence I want to run appimagetool -s deploy appdir/usr/share/applications/*desktop while it has a chance to copy additional stuff in from /app and from the full runtime/SDK.

How to do this?

probonopd commented 4 years ago

I have added the Bookworm application. When I am trying to run it, I get

me@host:~$ /home/me/Downloads/Bookworm-1.1.2-x86_64.AppImage
/tmp/.mount_BookwoQEg0kt/app/bin/com.github.babluboy.bookworm: error while loading shared libraries: libbsd.so.0: cannot open shared object file: No such file or directory

This shows that currently not all needed libraries get deployed into the AppDir yet. So I think this is a good test case.

sudo-give-me-coffee commented 4 years ago

Is possible run appimagetool -s deploy under the chroot?, eg:

mount_point=$(mktemp -d)
mkdir -p ${mount_point}/usr
mkdir -p ${mount_point}/appdir

ln -s usr/bin   ${mount_point}/bin
ln -s usr/lib   ${mount_point}/lib
ln -s usr/lib64 ${mount_point}/lib64
ln -s usr/etc   ${mount_point}/etc
ln -s usr/bin   ${mount_point}/sbin

mount --bind  /path/to/appdir  ${mount_point}/appdir
mount --bind /var/lib/flatpak/runtime/org.gnome.Platform/x86_64/3.36/active/files \
             ${mount_point}/usr

cd ${mount_point}
wget -c https://github.com/$(wget -q https://github.com/probonopd/go-appimage/releases -O - | grep "appimagetool-.*-x86_64.AppImage" | head -n 1 | cut -d '"' -f 2)
chmod +x appimagetool-.*-x86_64.AppImage

chroot /appimagetool-.*-x86_64.AppImage -s ...
probonopd commented 4 years ago

Sure, why not. That should be possible.

mount --bind  /path/to/appdir  ${mount_point}/appdir
mount --bind /var/lib/flatpak/runtime/org.gnome.Platform/x86_64/3.36/active/files \
             ${mount_point}/usr

Do you think this is gonna work? That would be brilliant...

sudo-give-me-coffee commented 4 years ago

I will close because i think that is not needed anymore please look this https://github.com/sudo-give-me-coffee/flatpak2appdir/commit/05833d3cd904075db655181d509bd874473a2f6d

probonopd commented 4 years ago

Very interesting approach

Will try it out immediately.