Created
September 2, 2022 19:09
-
-
Save allenh1/a6a0039a3caf6fce681223f23cef6d64 to your computer and use it in GitHub Desktop.
Bundle so files for an exe
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
| #!/bin/bash | |
| if [[ -z $1 ]]; then | |
| echo "error: please provide an executable" | |
| exit 1 | |
| fi | |
| out_dir="$(basename ${1}).bundled" | |
| mkdir -p "${out_dir}" | |
| # ldd gives the SO files the exe links with | |
| so_list=( $(ldd $1 | awk '{print $3}') ) | |
| next_so_list=so_list | |
| while (( ${#so_list[@]} > 0 )); do | |
| next_so_list=() | |
| for f in ${so_list[@]}; do | |
| [ -f "${out_dir}/$(basename ${f})" ] || { | |
| cp -L $f "${out_dir}" && echo "Copying $(basename $f)"; | |
| next_so_list+=( $(ldd $1 | awk '{print $3}') ); | |
| } | |
| done | |
| so_list=( ${next_so_list[@]} ) | |
| done | |
| cp -L "${1}" "${out_dir}/$(basename ${1}).exe" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment