diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-10-04 02:43:30 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-06 07:39:33 +0200 |
commit | 7cfe40b987bf08053487f4a72fafe11de219b583 (patch) | |
tree | 7ad327ae75818a98cae2bbb617d075353ae69882 /scripts | |
parent | 3d7802afb6fcd2a8e80a48067f0c94cebeedbc9f (diff) |
Add package lib blacklist, remove patchelf dependency
Some libraries such as gpu driver libraries cant be distributed because
even though the program is run on the same cpu arch, gpu can differ.
Removed dependency on patchelf, as it's not needed when executing ld-so
directly with --library-path
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/package.py | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/scripts/package.py b/scripts/package.py index 61f12c7..ce7eb71 100755 --- a/scripts/package.py +++ b/scripts/package.py @@ -22,6 +22,8 @@ $DOWNLOAD_DEPENDENCIES_COMMAND "$script_dir/$SO_LOADER" --library-path "$script_dir/libs":$HOME/.local/lib/sibs/"$program_full_name":/usr/lib/sibs/"$program_full_name" "$script_dir/$PROGRAM_NAME" "$@" """ +blacklisted_libs = [ "libGL\\.so.*", "libGLX.*", "libGLdispatch.*" ] + def get_executable_dynamic_libraries(filepath): libs = [] process = subprocess.Popen(["ldd", filepath], stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -76,6 +78,18 @@ def fetch_checksums(url): return checksums +def remove_blacklisted_libs(libs): + new_libs = [] + for lib in libs: + is_blacklisted = False + for blacklisted_lib in blacklisted_libs: + if re.match(blacklisted_lib, os.path.basename(lib[0])): + is_blacklisted = True + break + if not is_blacklisted: + new_libs.append(lib) + return new_libs + def main(): if len(sys.argv) <= 4: usage() @@ -92,6 +106,10 @@ def main(): os.makedirs(destination_path, exist_ok=True) libs = get_executable_dynamic_libraries(executable_path) + # Some libraries can't be distributed because different hardware. Since we are operating on a specific architecture, the types of libraries + # that can't be distributed are commonly gpu driver libraries + libs = remove_blacklisted_libs(libs) + so_loader_pattern = re.compile("ld-linux-x86-64\\.so.*") so_loader = None for lib in libs: @@ -147,19 +165,6 @@ def main(): shutil.copyfile(executable_path, new_executable_path) make_executable(new_executable_path) - print("Patching executable") - process = subprocess.Popen(["patchelf", "--set-interpreter", so_loader, new_executable_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (stdout, stderr) = process.communicate() - if process.returncode != 0: - print("Failed to execute patchelf --set-interpreter on executable %s, error: %s" % (new_executable_path, stderr)) - exit(3) - - #process = subprocess.Popen(["patchelf", "--set-rpath", "libs", new_executable_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - #(stdout, stderr) = process.communicate() - #if process.returncode != 0: - # print("Failed to execute patchelf --set-rpath on executable %s, error: %s" % (new_executable_path, stderr)) - # exit(4) - run_script_path = os.path.join(destination_path, "run.sh") with open(run_script_path, "wb") as run_script: run_script.write(run_script_linux.replace("$SO_LOADER", so_loader)\ |