#!/bin/sh if [ "$#" -ne 2 ]; then echo "Usage: $0 " exit 1 fi BINARY_PATH="$1" CHROOT_PATH="$2" if [ ! -f "$BINARY_PATH" ]; then echo "Error: Binary '$BINARY_PATH' does not exist." exit 1 fi if [ ! -d "$CHROOT_PATH" ]; then echo "Error: Destination path '$CHROOT_PATH' does not exist." exit 1 fi DEPS=$(ldd "$BINARY_PATH" | grep '^[[:space:]]' | grep -o '/[^ ]*') for DEP in $DEPS; do if [ -f "$DEP" ]; then DEP_DIR=$(dirname "$DEP") mkdir -p "$CHROOT_PATH$DEP_DIR" cp -f "$DEP" "$CHROOT_PATH$DEP" else echo "Warning: Dependency '$DEP' not found, skipping." fi done echo "Binary and dependencies copied to '$CHROOT_PATH'."