From 95456b5ed190cb737a4c0cda3975b7c515381184 Mon Sep 17 00:00:00 2001 From: Ivor Wanders Date: Tue, 6 Dec 2022 10:54:21 +0100 Subject: [PATCH] Make the copied library writable. We need to make sure the library is writable before trying to patchelf it. --- src/nixglhost_wrapper.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/nixglhost_wrapper.py b/src/nixglhost_wrapper.py index 09b7006..4431a73 100755 --- a/src/nixglhost_wrapper.py +++ b/src/nixglhost_wrapper.py @@ -7,6 +7,7 @@ import os import re import shutil import subprocess +import stat import sys import time from glob import glob @@ -254,7 +255,8 @@ def copy_and_patch_libs(dsos: List[ResolvedLib], libs_dir: str, rpath=None) -> N newpath = os.path.join(libs_dir, basename) log_info(f"Copying and patching {dso} to {newpath}") shutil.copyfile(dso.fullpath, newpath) - shutil.copymode(dso.fullpath, newpath) + # Provide write permissions to ensure we can patch this binary. + os.chmod(newpath, os.stat(dso.fullpath).st_mode | stat.S_IWUSR) patch_dso(newpath, rpath)