diff --git a/Dockerfile b/Dockerfile index 2d37abd1..184f46aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,26 +3,25 @@ ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && \ apt-get -yq install \ - breeze-icon-theme \ - desktop-file-utils \ - elfutils \ - fakeroot \ - file \ - git \ - gnupg2 \ - gtk-update-icon-cache \ - libgdk-pixbuf2.0-dev \ - libglib2.0-bin \ - librsvg2-dev \ - libyaml-dev \ - python3 \ - python3-pip \ - python3-setuptools \ - strace \ - wget \ - squashfs-tools \ - zsync && \ - apt-get -yq autoclean + breeze-icon-theme \ + desktop-file-utils \ + elfutils \ + fakeroot \ + file \ + git \ + gnupg2 \ + gtk-update-icon-cache \ + libgdk-pixbuf2.0-dev \ + libglib2.0-bin \ + librsvg2-dev \ + libyaml-dev \ + python3 \ + python3-pip \ + squashfs-tools \ + strace \ + wget \ + zsync && \ + rm -rf /var/lib/apt/lists/* WORKDIR /tmp RUN wget https://github.com/NixOS/patchelf/releases/download/0.12/patchelf-0.12.tar.bz2; \ @@ -31,8 +30,9 @@ RUN wget https://github.com/NixOS/patchelf/releases/download/0.12/patchelf-0.12. ./configure && make && make install; \ rm -rf patchelf-* -ADD . /opt/appimage-builder -RUN python3 -m pip install /opt/appimage-builder -RUN rm -rf /opt/appimage-builder +COPY . /opt/appimage-builder +RUN python3 -m pip install setuptools==75.3.0 && \ + python3 -m pip install /opt/appimage-builder && \ + rm -rf /opt/appimage-builder WORKDIR / diff --git a/appimagebuilder/modules/prime/appimage_primer.py b/appimagebuilder/modules/prime/appimage_primer.py index 245d3ecb..dab3c443 100644 --- a/appimagebuilder/modules/prime/appimage_primer.py +++ b/appimagebuilder/modules/prime/appimage_primer.py @@ -89,8 +89,6 @@ def _make_squashfs(self, appdir: pathlib.Path): # we wouldn't need to update the code and release a new version just for a new compression method if self.config.comp() != "None": command += [ "-comp", self.config.comp()] - else: - command += ["-no-compression"] self.logger.info("Creating squashfs from AppDir") self.logger.debug(" ".join(command)) @@ -99,7 +97,7 @@ def _make_squashfs(self, appdir: pathlib.Path): def _get_appimage_kit_runtime(self): url = ( - "https://github.com/AppImage/AppImageKit/releases/download/continuous/runtime-%s" + "https://github.com/AppImage/AppImageKit/releases/download/continuous/obsolete-runtime-%s" % self.bundle_main_arch ) logging.info("Downloading: %s" % url) diff --git a/appimagebuilder/modules/setup/apprun_2/executables_patcher.py b/appimagebuilder/modules/setup/apprun_2/executables_patcher.py index af0ecac7..eb017bf4 100644 --- a/appimagebuilder/modules/setup/apprun_2/executables_patcher.py +++ b/appimagebuilder/modules/setup/apprun_2/executables_patcher.py @@ -12,6 +12,7 @@ import logging import pathlib import lief +import subprocess class ExecutablesPatcherError(RuntimeError): @@ -64,8 +65,15 @@ def patch_binary_executable(self, path: pathlib.Path): interpreter_path = binary.interpreter if interpreter_path: patched_interpreter_path = interpreter_path.lstrip("/") - binary.interpreter = patched_interpreter_path - binary.write(path.__str__()) + subprocess.run( + [ + "patchelf", + "--set-interpreter", + patched_interpreter_path, + path.__str__(), + ], + check=True, + ) self.binary_interpreters_paths[path] = patched_interpreter_path except Exception as e: diff --git a/appimagebuilder/modules/setup/apprun_3/helpers/glibc_module.py b/appimagebuilder/modules/setup/apprun_3/helpers/glibc_module.py index 167c3c40..1c827569 100644 --- a/appimagebuilder/modules/setup/apprun_3/helpers/glibc_module.py +++ b/appimagebuilder/modules/setup/apprun_3/helpers/glibc_module.py @@ -14,6 +14,7 @@ import os import pathlib import shutil +import subprocess import lief import packaging @@ -38,7 +39,9 @@ def run(self): """Configures glibc for AppRun 3""" # extract glibc module files - self._glibc_module_files = self.context.app_dir.find(file_matching_patterns.glibc) + self._glibc_module_files = self.context.app_dir.find( + file_matching_patterns.glibc + ) if self._glibc_module_files: self._module_dir.mkdir(parents=True, exist_ok=True) @@ -58,18 +61,29 @@ def _patch_binaries_interpreter_path(self): """Patches the binaries interpreter path on the AppDir""" for file in self.context.app_dir.files.values(): - if file.interpreter and not self._is_file_in_a_module(file) and not file.path.is_symlink(): + if ( + file.interpreter + and not self._is_file_in_a_module(file) + and not file.path.is_symlink() + ): binary = lief.parse(file.path.__str__()) - self._patch_binary_interpreter_path(binary) + self._patch_binary_interpreter_path(binary, file.path) - def _patch_binary_interpreter_path(self, binary): + def _patch_binary_interpreter_path(self, binary, path: pathlib.Path): """Patch the interpreter of a binary making it relative""" interpreter = binary.interpreter new_interpreter = interpreter.lstrip("/") - binary.interpreter = new_interpreter - binary.write(binary.name) + subprocess.run( + [ + "patchelf", + "--set-interpreter", + new_interpreter, + path.__str__(), + ], + check=True, + ) def _extract_library_paths_from_glibc_module_files(self): """Extracts library paths from glibc module files""" @@ -82,8 +96,14 @@ def _extract_library_paths_from_glibc_module_files(self): return library_paths def _generate_glibc_module_config(self, library_paths): - library_paths = [replace_app_dir_in_path(self.context.app_dir.path, path) for path in library_paths] - runtime_dir = "$APPDIR/" + self._module_dir.relative_to(self.context.app_dir.path).__str__() + library_paths = [ + replace_app_dir_in_path(self.context.app_dir.path, path) + for path in library_paths + ] + runtime_dir = ( + "$APPDIR/" + + self._module_dir.relative_to(self.context.app_dir.path).__str__() + ) config = { "version": "1.0", "check": { @@ -144,9 +164,11 @@ def _find_bundled_glibc_version(self): def _link_binary_interpreter_to_their_default_path(self): """Links the binary interpreter to their default path""" - sys_root = pathlib.Path('/') + sys_root = pathlib.Path("/") for binary_interpreter in self.context.app_dir.binary_interpreters: - binary_interpreter_path = self.context.app_dir.path / binary_interpreter.__str__().strip("/") + binary_interpreter_path = ( + self.context.app_dir.path / binary_interpreter.__str__().strip("/") + ) # ensure the binary interpreter dir exists binary_interpreter_path.parent.mkdir(parents=True, exist_ok=True) @@ -167,12 +189,18 @@ def _link_script_interpreters_to_their_path(self): logging.info("Linking script interpreter: %s", interpreter_path) mirror_path.symlink_to(rel_mirror_path) else: - logging.warning("Script interpreter not found in AppDir: %s", interpreter_path) + logging.warning( + "Script interpreter not found in AppDir: %s", interpreter_path + ) def _deploy_check_glibc_binary(self): """Deploys the glibc check binary""" - glibc_check_binary_path = self.context.binaries_resolver.resolve_check_glibc_binary(self.context.main_arch) + glibc_check_binary_path = ( + self.context.binaries_resolver.resolve_check_glibc_binary( + self.context.main_arch + ) + ) glibc_check_binary_target_path = self._module_dir / "check" # ensure the target directory exists diff --git a/requirements.txt b/requirements.txt index d70d29a5..d63bac62 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,7 @@ filelock==3.12.4 idna==3.4 jsonpath-rw==1.4.0 libconf==2.0.1 -lief==0.12.2 +lief==0.16.4 packaging==23.2 PGPy==0.6.0 pipenv==2023.10.3