github.com/sijibomii/docker@v0.0.0-20231230191044-5cf6ca554647/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=( $(echo ${DOCKER_BUILD_PKGS[@]/#/$builderDir\/}) )
    20  	fi
    21  	for dir in "${pkgs[@]}"; do
    22  		[ -d "$dir" ] || { echo >&2 "skipping nonexistent $dir"; continue; }
    23  		local from="$(awk 'toupper($1) == "FROM" { print $2; exit }' "$dir/Dockerfile")"
    24  		local dir=$(basename "$dir")
    25  
    26  		if [[ ! -d "${DEB_DIR}/${dir}" ]]; then
    27  			echo "No deb found for ${dir}"
    28  			exit 1
    29  		fi
    30  
    31  		local script=$(mktemp /tmp/install-XXXXXXXXXX.sh)
    32  		cat <<-EOF > "${script}"
    33  		#!/bin/bash
    34  		set -e
    35  		set -x
    36  
    37  		apt-get update && apt-get install -y apparmor
    38  
    39  		dpkg -i /root/debs/*.deb || true
    40  
    41  		apt-get install -yf
    42  
    43  		/etc/init.d/apparmor start
    44  
    45  		# this will do everything _except_ load the profile into the kernel
    46  		(
    47  		cd /etc/apparmor.d
    48  		/sbin/apparmor_parser --skip-kernel-load docker-engine
    49  		)
    50  		EOF
    51  
    52  		chmod +x "${script}"
    53  
    54  		echo "testing deb install for ${from}"
    55  		docker run --rm -i --privileged \
    56  			-v ${DEB_DIR}/${dir}:/root/debs \
    57  			-v ${script}:/install.sh \
    58  			${from} /install.sh
    59  
    60  		rm -f ${script}
    61  	done
    62  }
    63  
    64  (
    65  	bundle .integration-daemon-start
    66  	test_deb_install
    67  	bundle .integration-daemon-stop
    68  ) 2>&1 | tee -a "$DEST/test.log"