github.com/ncdc/docker@v0.10.1-0.20160129113957-6c6729ef5b74/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  	for dir in contrib/builder/deb/*/; do
    16  		local from="$(awk 'toupper($1) == "FROM" { print $2; exit }' "$dir/Dockerfile")"
    17  		local dir=$(basename "$dir")
    18  
    19  		if [[ ! -d "${DEB_DIR}/${dir}" ]]; then
    20  			echo "No deb found for ${dir}"
    21  			exit 1
    22  		fi
    23  
    24  		local script=$(mktemp /tmp/install-XXXXXXXXXX.sh)
    25  		cat <<-EOF > "${script}"
    26  		#!/bin/bash
    27  		set -e
    28  		set -x
    29  
    30  		apt-get update && apt-get install -y apparmor
    31  
    32  		dpkg -i /root/debs/*.deb || true
    33  
    34  		apt-get install -yf
    35  
    36  		/etc/init.d/apparmor start
    37  
    38  		# this will do everything _except_ load the profile into the kernel
    39  		(
    40  		cd /etc/apparmor.d
    41  		/sbin/apparmor_parser --skip-kernel-load docker-engine
    42  		)
    43  		EOF
    44  
    45  		chmod +x "${script}"
    46  
    47  		echo "testing deb install for ${from}"
    48  		docker run --rm -i --privileged \
    49  			-v ${DEB_DIR}/${dir}:/root/debs \
    50  			-v ${script}:/install.sh \
    51  			${from} /install.sh
    52  
    53  		rm -f ${script}
    54  	done
    55  }
    56  
    57  test_deb_install