diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/package.py | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/scripts/package.py b/scripts/package.py index a10cdcb..f2841b8 100755 --- a/scripts/package.py +++ b/scripts/package.py @@ -15,8 +15,7 @@ set -e script_path=`readlink -f $0` script_dir=`dirname $script_path` -cd "$script_dir" -"./$SO_LOADER" --library-path libs "./$PROGRAM_NAME" "$@" +"$script_dir/$SO_LOADER" --library-path "$script_dir/libs" "$script_dir/$PROGRAM_NAME" "$@" """ def get_executable_dynamic_libraries(filepath): @@ -38,6 +37,14 @@ def make_executable(filepath): mode = os.stat(filepath).st_mode os.chmod(filepath, mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) +def get_libnss_files(): + libnss_pattern = re.compile("libnss.*\\.so.*") + files = [] + for filepath in os.listdir("/usr/lib"): + if libnss_pattern.match(filepath): + files.append(os.path.join("/usr/lib", filepath)) + return files + def main(): if len(sys.argv) <= 2: print("usage: %s executable_path destination_path" % sys.argv[0]) @@ -60,6 +67,17 @@ def main(): exit(5) so_loader = os.path.join("libs", so_loader) + + libnss_files = get_libnss_files() + for idx, libnss_file in enumerate(libnss_files): + new_file_path = os.path.join(sys.argv[2], os.path.basename(libnss_file)) + libnss_files[idx] = new_file_path + if os.path.islink(libnss_file): + target_name = os.path.basename(os.readlink(libnss_file)) + os.symlink(target_name, new_file_path) + else: + shutil.copyfile(libnss_file, new_file_path) + executable_filename = os.path.basename(sys.argv[1]) new_executable_path = os.path.join(sys.argv[2], executable_filename) shutil.copyfile(sys.argv[1], new_executable_path) @@ -89,6 +107,12 @@ def main(): for lib in libs: print("Adding shared library %s to package" % lib[0]) tar.add(lib[0], arcname=os.path.join("libs", lib[1])) + + for libnss_file in libnss_files: + print("Adding libnss shared library %s to package" % libnss_file) + libnss_name = os.path.basename(libnss_file) + tar.add(libnss_file, arcname=os.path.join("libs", libnss_name)) + print("Adding executable %s to package" % sys.argv[1]) tar.add(new_executable_path, arcname="program") print("Adding run script %s to package" % run_script_path) @@ -97,6 +121,8 @@ def main(): print("Removing temporary files") os.remove(new_executable_path) os.remove(run_script_path) + for libnss_file in libnss_files: + os.remove(libnss_file) print("Package has been created at %s" % package_name) if __name__ == "__main__": |