pkg2appimage icon indicating copy to clipboard operation
pkg2appimage copied to clipboard

Investigate rtldi and PatchELF for AppImages that bundle "everything"

Open probonopd opened this issue 7 years ago • 8 comments

Although not generally recommended, there might be some edge cases in which it might be desirable to bundle all dependencies, not just the ones that cannot be expected to be part of the base system(s).

For these cases, we should investigate to use http://bitwagon.com/rtldi/rtldi.html although it can be done in some cases without it, too.

Also see http://joeyh.name/blog/entry/completely_linux_distribution-independent_packaging/ for an example.

probonopd avatar Sep 03 '16 14:09 probonopd

Also, check patchelf --set-interpreter. http://nixos.org/patchelf.html May be even more elegant.

probonopd avatar Sep 04 '16 11:09 probonopd

http://www.trigger.im/fix-spotify-incompatible-libc-after-update-on-debian-gnulinux/

probonopd avatar Oct 29 '16 21:10 probonopd

We need to prevent the loader from loading stuff outside of the bundle.

The loader has hardcoded instructions to load libraries from /lib!

when I patch /lib to ./li, then

Inconsistency detected by ld.so: dl-load.c: 719: _dl_init_paths: Assertion `pelem->dirname[0] == '/'' failed!

Hence we patch these paths to other (empty) absolute paths

sed -i -e 's|/lib|/xib|g' lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
sed -i -e 's|/etc|/xtc|g' lib/x86_64-linux-gnu/ld-linux-x86-64.so.2

Now it no longer loads something from somewhere. I can now actually run a bleeding-edge VLC on a much older base system like this:

QT_PLUGIN_PATH=./lib/x86_64-linux-gnu/qt5/plugins/ ../lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 --library-path '../lib/x86_64-linux-gnu/:./lib/x86_64-linux-gnu/:./lib/'  ./bin/vlc

probonopd avatar Oct 30 '16 11:10 probonopd

Some experimentation in this regard, using the glibc deb package from, e.g., debian sid:

# This does not work
[me@host ~]$  LD_LIBRARY_PATH=/mnt/usr/lib64/ /mnt/usr/bin/gnome-font-viewer /mnt/usr/bin/gnome-font-viewer: relocation error: /mnt/usr/lib64/libc.so.6: symbol _dl_find_dso_for_object, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference

# This doesn't cut it
[me@host ~]$ LD_LIBRARY_PATH=/mnt/usr/lib64/ '/home/me/Downloads/libc6_2.21-3_amd64/lib/x86_64-linux-gnu/ld-2.21.so' /mnt/usr/bin/gnome-font-viewer /mnt/usr/bin/gnome-font-viewer: relocation error: /mnt/usr/lib64/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference

# This doesn't cut it either
[me@host ~]$ LD_LIBRARY_PATH='/home/me/Downloads/libc6_2.21-3_amd64/lib/x86_64-linux-gnu':/mnt/usr/lib64/  /mnt/usr/bin/gnome-font-viewer 
/mnt/usr/bin/gnome-font-viewer: relocation error: /home/me/Downloads/libc6_2.21-3_amd64/lib/x86_64-linux-gnu/libc.so.6: symbol _dl_find_dso_for_object, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference

# This works!!! 
# On CentOS 7 I can run gnome-font-viewer from Fedora 23
[me@host ~]$ LD_LIBRARY_PATH='/home/me/Downloads/libc6_2.21-3_amd64/lib/x86_64-linux-gnu':/mnt/usr/lib64/ '/home/me/Downloads/libc6_2.21-3_amd64/lib/x86_64-linux-gnu/ld-2.21.so' /mnt/usr/bin/gnome-font-viewer 

probonopd avatar Dec 01 '16 22:12 probonopd

https://github.com/matthewbauer/nix-bundle/ creates AppImages that bundle everything, down to ld-linux.so - but are broken in other ways https://github.com/matthewbauer/nix-bundle/issues/8

probonopd avatar Feb 07 '17 17:02 probonopd

Also check https://github.com/lvml/makeaoi, a tool that bundles "everything"

probonopd avatar Jul 23 '17 23:07 probonopd

Another option that automates this:

https://github.com/Intoli/exodus#how-it-works

probonopd avatar Feb 02 '18 17:02 probonopd

Hi, Please see my comment at:

https://github.com/probonopd/go-appimage/issues/49

Juuliuus avatar Oct 19 '20 12:10 Juuliuus