]> begriffs open source - repo-ui/blob - imprison
How to host gitweb
[repo-ui] / imprison
1 #!/bin/sh
2
3 if [ "$#" -ne 2 ]; then
4     echo "Usage: $0 <binary_path> <chroot_destination>"
5     exit 1
6 fi
7
8 BINARY_PATH="$1"
9 CHROOT_PATH="$2"
10
11 if [ ! -f "$BINARY_PATH" ]; then
12     echo "Error: Binary '$BINARY_PATH' does not exist."
13     exit 1
14 fi
15
16 if [ ! -d "$CHROOT_PATH" ]; then
17     echo "Error: Destination path '$CHROOT_PATH' does not exist."
18     exit 1
19 fi
20
21 DEPS=$(ldd "$BINARY_PATH" | grep '^[[:space:]]' | grep -o '/[^ ]*')
22
23 for DEP in $DEPS; do
24     if [ -f "$DEP" ]; then
25         DEP_DIR=$(dirname "$DEP")
26         mkdir -p "$CHROOT_PATH$DEP_DIR"
27         cp -f "$DEP" "$CHROOT_PATH$DEP"
28     else
29         echo "Warning: Dependency '$DEP' not found, skipping."
30     fi
31 done
32
33 echo "Binary and dependencies copied to '$CHROOT_PATH'."
34