From d9e1861aff327bbda78477eed44ac6392f6c03ad Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 9 May 2014 19:29:18 +0800 Subject: [PATCH] linux: Ship system dynamic libraries, closes #278. --- script/create-dist.py | 26 ++++++++++++++++++++++++++ script/lib/util.py | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/script/create-dist.py b/script/create-dist.py index 069a86c..270be34 100755 --- a/script/create-dist.py +++ b/script/create-dist.py @@ -2,6 +2,7 @@ import argparse import os +import re import shutil import subprocess import sys @@ -64,6 +65,11 @@ TARGET_DIRECTORIES = { ], } +SYSTEM_LIBRARIES = [ + 'libudev.so', + 'libgcrypt.so', +] + HEADERS_SUFFIX = [ '.h', '.gypi', @@ -94,6 +100,10 @@ def main(): copy_binaries() copy_headers() copy_license() + + if TARGET_PLATFORM == 'linux': + copy_system_libraries() + create_version() create_dist_zip() create_symbols_zip() @@ -157,6 +167,20 @@ def copy_license(): shutil.copy2(os.path.join(SOURCE_ROOT, 'LICENSE'), DIST_DIR) +def copy_system_libraries(): + ldd = execute(['ldd', os.path.join(OUT_DIR, 'atom')]) + lib_re = re.compile('\t(.*) => (.+) \(.*\)$') + for line in ldd.splitlines(): + m = lib_re.match(line) + if not m: + continue + for i, library in enumerate(SYSTEM_LIBRARIES): + real_library = m.group(1) + if real_library.startswith(library): + shutil.copy2(m.group(2), os.path.join(DIST_DIR, real_library)) + SYSTEM_LIBRARIES[i] = real_library + + def create_version(): version_path = os.path.join(SOURCE_ROOT, 'dist', 'version') with open(version_path, 'w') as version_file: @@ -194,6 +218,8 @@ def create_dist_zip(): with scoped_cwd(DIST_DIR): files = TARGET_BINARIES[TARGET_PLATFORM] + ['LICENSE', 'version'] + if TARGET_PLATFORM == 'linux': + files += SYSTEM_LIBRARIES dirs = TARGET_DIRECTORIES[TARGET_PLATFORM] make_zip(zip_file, files, dirs) diff --git a/script/lib/util.py b/script/lib/util.py index c5194d0..c66dca8 100644 --- a/script/lib/util.py +++ b/script/lib/util.py @@ -112,7 +112,7 @@ def safe_mkdir(path): def execute(argv): try: - subprocess.check_output(argv, stderr=subprocess.STDOUT) + return subprocess.check_output(argv, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: print e.output raise e -- 2.7.4