Skip to content

Instantly share code, notes, and snippets.

@toshke
Created May 6, 2020 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toshke/186b6d50c0b437007b383d9f390a8bf5 to your computer and use it in GitHub Desktop.
Save toshke/186b6d50c0b437007b383d9f390a8bf5 to your computer and use it in GitHub Desktop.
Isolate binary using chroot
function isolate_binary() {
binary=$(which $1)
libs=$(ldd -v $binary | grep -o '/.*[[:space:]]')
libs=($libs)
mkdir -p ${2}$(dirname $binary)
cp -vn ${binary} ${2}${binary}
for l in "${libs[@]}"; do mkdir -p ${2}$(dirname $l) && cp -vn ${l} ${2}${l}; done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment