Make the copied library writable.

We need to make sure the library is writable before trying to patchelf
it.
This commit is contained in:
Ivor Wanders 2022-12-06 10:54:21 +01:00 committed by Félix Baylac Jacqué
parent 29f82cbd52
commit 95456b5ed1
1 changed files with 3 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import os
import re import re
import shutil import shutil
import subprocess import subprocess
import stat
import sys import sys
import time import time
from glob import glob 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) newpath = os.path.join(libs_dir, basename)
log_info(f"Copying and patching {dso} to {newpath}") log_info(f"Copying and patching {dso} to {newpath}")
shutil.copyfile(dso.fullpath, 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) patch_dso(newpath, rpath)