github.com/nf/docker@v1.8.1/contrib/mkimage/busybox-static (about)

     1  #!/usr/bin/env bash
     2  set -e
     3  
     4  rootfsDir="$1"
     5  shift
     6  
     7  busybox="$(which busybox 2>/dev/null || true)"
     8  if [ -z "$busybox" ]; then
     9  	echo >&2 'error: busybox: not found'
    10  	echo >&2 '  install it with your distribution "busybox-static" package'
    11  	exit 1
    12  fi
    13  if ! ldd "$busybox" 2>&1 | grep -q 'not a dynamic executable'; then
    14  	echo >&2 "error: '$busybox' appears to be a dynamic executable"
    15  	echo >&2 '  you should install your distribution "busybox-static" package instead'
    16  	exit 1
    17  fi
    18  
    19  mkdir -p "$rootfsDir/bin"
    20  rm -f "$rootfsDir/bin/busybox" # just in case
    21  cp "$busybox" "$rootfsDir/bin/busybox"
    22  
    23  (
    24  	cd "$rootfsDir"
    25  
    26  	IFS=$'\n'
    27  	modules=( $(bin/busybox --list-modules) )
    28  	unset IFS
    29  
    30  	for module in "${modules[@]}"; do
    31  		mkdir -p "$(dirname "$module")"
    32  		ln -sf /bin/busybox "$module"
    33  	done
    34  )