Commit 1e4a291e authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Allow collect-binaries to accept a file list on stdin

If no files are specified in the command line arguments then stdin will
be read, expecting a line-feed (newline) terminated list of file names.
parent 2f11b412
Loading
Loading
Loading
Loading
Loading
+27 −12
Original line number Diff line number Diff line
@@ -58,6 +58,20 @@ copy() {
	fi
}

copy_bin() {
	local bin=$1
	ldd "$bin" | while read dep; do
		local dep=${dep% (*}
		case $dep in
			*'=>'*) dep=${dep#*=> } ;;
			/*) ;;
			*) continue ;;
		esac
		copy $dep
	done || true
	copy $bin
}

trap missing EXIT

declare -a TARGETS=()
@@ -72,15 +86,16 @@ until [[ $# -eq 0 ]]; do
	shift
done

if [[ ${#TARGETS[*]} -gt 0 ]]; then
	for bin in "${TARGETS[@]}"; do
	ldd "$bin" | while read dep; do
		dep=${dep% (*}
		case $dep in
			*'=>'*) dep=${dep#*=> } ;;
			/*) ;;
			*) continue ;;
		esac
		copy $dep
	done || true
	copy $bin
		copy_bin "$bin"
	done
else
	[[ -t 0 ]] && cat <<-END_TXT >&2
		No files specified in arguments; are you sure you meant to do that?
		Reading files list from terminal input:
	END_TXT
	while read bin; do
		copy_bin "$bin"
	done
fi