Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t1509/prepare-chroot.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t1509 / prepare-chroot.sh` 58 lines ยท 1650 bytes Raw Blame History 1 #!/bin/sh 2 3 die() { 4 echo >&2 "$@" 5 exit 1 6 } 7 8 xmkdir() { 9 while [ -n "$1" ]; do 10 [ -d "$1" ] || mkdir "$1" || die "Unable to mkdir $1" 11 shift 12 done 13 } 14 15 R="$1" 16 17 [ "$(id -u)" -eq 0 ] && die "This script should not be run as root, what if it does rm -rf /?" 18 [ -n "$R" ] || die "usage: prepare-chroot.sh " 19 [ -x git ] || die "This script needs to be executed at git source code's top directory" 20 if [ -x /bin/busybox ]; then 21 BB=/bin/busybox 22 elif [ -x /usr/bin/busybox ]; then 23 BB=/usr/bin/busybox 24 else 25 die "You need busybox" 26 fi 27 28 xmkdir "$R" "$R/bin" "$R/etc" "$R/lib" "$R/dev" 29 touch "$R/dev/null" 30 echo "root:x:0:0:root:/:/bin/sh" > "$R/etc/passwd" 31 echo "$(id -nu):x:$(id -u):$(id -g)::$(pwd)/t:/bin/sh" >> "$R/etc/passwd" 32 echo "root::0:root" > "$R/etc/group" 33 echo "$(id -ng)::$(id -g):$(id -nu)" >> "$R/etc/group" 34 35 [ -x "$R$BB" ] || cp $BB "$R/bin/busybox" 36 for cmd in sh su ls expr tr basename rm mkdir mv id uname dirname cat true sed diff; do 37 ln -f -s /bin/busybox "$R/bin/$cmd" 38 done 39 40 mkdir -p "$R$(pwd)" 41 rsync --exclude-from t/t1509/excludes -Ha . "$R$(pwd)" 42 # Fake perl to reduce dependency, t1509 does not use perl, but some 43 # env might slip through, see test-lib.sh, unset.*PERL_PATH 44 sed 's|^PERL_PATH=.*|PERL_PATH=/bin/true|' GIT-BUILD-OPTIONS > "$R$(pwd)/GIT-BUILD-OPTIONS" 45 for cmd in git $BB;do 46 ldd $cmd | sed -n '/\//s,.*\s\(/[^ ]*\).*,\1,p' | while read i; do 47 mkdir -p "$R$(dirname $i)" 48 cp "$i" "$R/$i" 49 done 50 done 51 cat <