Created
February 25, 2020 05:26
-
-
Save gryf/ff2ade6a2c15a97817a7b6b7071a7810 to your computer and use it in GitHub Desktop.
Copy dependencies (libs) for certain binaries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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