aboutsummaryrefslogtreecommitdiff
path: root/scripts/package.py
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-10-03 01:47:45 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:39:33 +0200
commit4f64673d835fd0efd51cef78d2935b7628a6abfe (patch)
treee50145a0f469a7f033fd45012af3b74d23a9438c /scripts/package.py
parent5b25b99e2eed7eaf82bf73b8e8021b314fc3cbdb (diff)
Bundle libnss libraries when packaging...
Diffstat (limited to 'scripts/package.py')
-rwxr-xr-xscripts/package.py30
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__":