github.com/duglin/docker@v1.13.1/hack/make/test-deb-install (about)

     1  #!/bin/bash
     2  # This script is used for testing install.sh and that it works for
     3  # each of component of our apt and yum repos
     4  set -e
     5  
     6  : ${DEB_DIR:="$(pwd)/bundles/$(cat VERSION)/build-deb"}
     7  
     8  if [[ ! -d "${DEB_DIR}" ]]; then
     9  	echo "you must first run `make deb` or hack/make/build-deb"
    10  	exit 1
    11  fi
    12  
    13  test_deb_install(){
    14  	# test for each Dockerfile in contrib/builder
    15  
    16  	builderDir="contrib/builder/deb/${PACKAGE_ARCH}"
    17  	pkgs=( $(find "${builderDir}/"*/ -type d) )
    18  	if [ ! -z "$DOCKER_BUILD_PKGS" ]; then
    19  		pkgs=()
    20  		for p in $DOCKER_BUILD_PKGS; do
    21  			pkgs+=( "$builderDir/$p" )
    22  		done
    23  	fi
    24  	for dir in "${pkgs[@]}"; do
    25  		[ -d "$dir" ] || { echo >&2 "skipping nonexistent $dir"; continue; }
    26  		local from="$(awk 'toupper($1) == "FROM" { print $2; exit }' "$dir/Dockerfile")"
    27  		local dir=$(basename "$dir")
    28  
    29  		if [[ ! -d "${DEB_DIR}/${dir}" ]]; then
    30  			echo "No deb found for ${dir}"
    31  			exit 1
    32  		fi
    33  
    34  		local script=$(mktemp /tmp/install-XXXXXXXXXX.sh)
    35  		cat <<-EOF > "${script}"
    36  		#!/bin/bash
    37  		set -e
    38  		set -x
    39  
    40  		apt-get update && apt-get install -y apparmor
    41  
    42  		dpkg -i /root/debs/*.deb || true
    43  
    44  		apt-get install -yf
    45  
    46  		/etc/init.d/apparmor start
    47  
    48  		# this will do everything _except_ load the profile into the kernel
    49  		(
    50  		cd /etc/apparmor.d
    51  		/sbin/apparmor_parser --skip-kernel-load docker-engine
    52  		)
    53  		EOF
    54  
    55  		chmod +x "${script}"
    56  
    57  		echo "testing deb install for ${from}"
    58  		docker run --rm -i --privileged \
    59  			-v ${DEB_DIR}/${dir}:/root/debs \
    60  			-v ${script}:/install.sh \
    61  			${from} /install.sh
    62  
    63  		rm -f ${script}
    64  	done
    65  }
    66  
    67  (
    68  	bundle .integration-daemon-start
    69  	test_deb_install
    70  	bundle .integration-daemon-stop
    71  ) 2>&1 | tee -a "$DEST/test.log"