test-deb-install 1.6 KB

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