Skip to content

Instantly share code, notes, and snippets.

@gryf
Created February 25, 2020 05:26
Show Gist options
  • Select an option

  • Save gryf/ff2ade6a2c15a97817a7b6b7071a7810 to your computer and use it in GitHub Desktop.

Select an option

Save gryf/ff2ade6a2c15a97817a7b6b7071a7810 to your computer and use it in GitHub Desktop.
Copy dependencies (libs) for certain binaries
DEPS=(/bin/foo /sbin/bar /usr/bin/baz)
# copy libs of foo/bar/baz to lib in current directory
for bin in ${DEPS[*]}; do
cp $bin ./bin/
ldd $bin >/dev/null || continue
for lib in $(ldd $bin | sed -nre 's,.* (/.*lib.*/.*.so.*) .*,\\1,p' \\
-e 's,.*(/lib.*/ld.*.so.*) .*,\\1,p')
do
mkdir -p .${lib%/*} && cp {,.}$lib
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment