Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
Expand All @@ -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 /
4 changes: 1 addition & 3 deletions appimagebuilder/modules/prime/appimage_primer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions appimagebuilder/modules/setup/apprun_2/executables_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import logging
import pathlib
import lief
import subprocess


class ExecutablesPatcherError(RuntimeError):
Expand Down Expand Up @@ -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:
Expand Down
52 changes: 40 additions & 12 deletions appimagebuilder/modules/setup/apprun_3/helpers/glibc_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import os
import pathlib
import shutil
import subprocess

import lief
import packaging
Expand All @@ -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)

Expand All @@ -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"""
Expand All @@ -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": {
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down