Skip to content

Commit

Permalink
[fix] The libarchive in the AppImage was not used
Browse files Browse the repository at this point in the history
  • Loading branch information
mxmlnkn committed Jun 2, 2024
1 parent be7ab14 commit ca817a5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
23 changes: 21 additions & 2 deletions AppImage/build-ratarmount-appimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
# E.g., run this script inside the manylinux2014 container and mount the whole ratarmount git root:
# docker run -v$PWD:/project -it quay.io/pypa/manylinux2014_x86_64 bash
# cd /project/AppImage && ./build-ratarmount-appimage.sh
# Should be built in the same manylinux container as used for the AppImage, or else the libarchive
# from the surrounding system is mixed with an incompatible liblzma from the Python AppImage, resulting in:
# OSError: /tmp/.mount_ratarmlSdCvH/usr/lib/liblzma.so.5: version `XZ_5.2' not found
# (required by /tmp/.mount_ratarmlSdCvH/usr/lib/libarchive.so.13)
# Then again, this error can be fixed by calling linxdeploy explicitly with liblzma.so.


function commandExists()
{
Expand All @@ -16,7 +22,8 @@ function installSystemRequirements()
yum -y install epel-release
# We need to isntall development dependencies to build Python packages from source and we also need
# to install libraries such as libarchive in order to copy them into the AppImage.
yum install -y fuse fakeroot patchelf fuse-libs libsqlite3x strace desktop-file-utils libzstd-devel libarchive lzop
yum install -y fuse fakeroot patchelf fuse-libs libsqlite3x strace desktop-file-utils libzstd-devel \
libarchive libarchive-devel lzop
}

function installAppImageTools()
Expand Down Expand Up @@ -88,16 +95,28 @@ function installAppImageSystemLibraries()
if commandExists repoquery; then
libraries+=( $( repoquery -l fuse-libs | 'grep' 'lib64.*[.]so' ) )
libraries+=( $( repoquery -l libarchive | 'grep' 'lib64.*[.]so' ) )
libraries+=( $( repoquery -l libarchive-devel | 'grep' 'lib64.*[.]so' ) )
libraries+=( $( repoquery -l xz-devel | 'grep' 'lib64.*[.]so' ) )
elif commandExists dnf; then
libraries+=( $( dnf repoquery -l fuse-libs | 'grep' 'lib64.*[.]so' ) )
libraries+=( $( dnf repoquery -l libarchive | 'grep' 'lib64.*[.]so' ) )
libraries+=( $( dnf repoquery -l libarchive-devel | 'grep' 'lib64.*[.]so' ) )
libraries+=( $( dnf repoquery -l xz-devel | 'grep' 'lib64.*[.]so' ) )
elif commandExists dpkg; then
libraries+=( $( dpkg -L libfuse2 | 'grep' '/lib.*[.]so' ) )
libraries+=( $( dpkg -L libarchive | 'grep' '/lib.*[.]so' ) )
libraries+=( $( dpkg -L libarchive13 | 'grep' '/lib.*[.]so' ) )
libraries+=( $( dpkg -L libarchive-dev | 'grep' '/lib.*[.]so' ) )
libraries+=( $( dpkg -L liblzma5 | 'grep' '/lib.*[.]so' ) )
else
echo -e "\e[31mCannot gather FUSE libs into AppImage without (dnf) repoquery.\e[0m"
fi

# For some reason, the simple libarchive.so file without any version suffix is only installed with the development
# packages! For yet another reason ctypes.util.find_library does not find libarchive.so.13 if libarchive.so
# does not # exist in the AppDir. However, when only libarchive.so.13 exists in the system location, it DOES
# find it even when libarchive.so does not exist -.-. It's really weird.
# https://github.com/Changaco/python-libarchive-c/issues/128

echo "Bundle libraries:"
printf ' %s\n' "${libraries[@]}"

Expand Down
5 changes: 5 additions & 0 deletions AppImage/ratarmount-metadata/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ export PATH="${APPDIR}/usr/bin/:$PATH"

# The fusepy module directly tries to read this environment variable and uses it.
export FUSE_LIBRARY_PATH="${APPDIR}/usr/lib/libfuse.so.2"
# Necessary because ctypes.util.find_library does not find the libarchive.so.13 if libarchive.so is missing.
# However, this only seems to be a problem with AppImage (LD_LIBRARY_PATH) not with system-installated versions.
if [[ -f "${APPDIR}/usr/lib/libarchive.so.13" ]]; then
export LIBARCHIVE="${APPDIR}/usr/lib/libarchive.so.13"
fi

# -u is important or else piping the output to other tools and therefore the tests might fail!
{{ python-executable }} -u -I -m ratarmount "$@"

0 comments on commit ca817a5

Please sign in to comment.