setup 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # -*- mode: sh -*-
  2. #
  3. # © 2017-2018 Ansgar Burchardt <ansgar@debian.org>
  4. # License: GPL-2+
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. if [[ ! -v DAK_INTEGRATION_TEST || ! -v DAK_ROOT ]]; then
  19. exit 1
  20. fi
  21. test-setup() {
  22. local setupdir="${DAK_ROOT}/setup"
  23. . ${DAK_ROOT:?}/integration-tests/common
  24. section_start "setup_dak_installation[collapsed=true]" "Prepare DAK"
  25. export DAKBASE=$(mktemp -d --tmpdir dak-integration-test.XXXXXXXXXX)
  26. export HOME="${DAKBASE}/home"
  27. export DAKHOST=dak-master
  28. export PGDATABASE=projectb
  29. mkdir "$HOME" || exit $?
  30. mkdir "$DAKBASE/outgoing-mail" || exit $?
  31. ${setupdir}/dak-setup.sh
  32. export PATH="${DAKBASE}/bin:${PATH}"
  33. export DAK_CONFIG="${DAKBASE}/etc/dak.conf"
  34. export GNUPGHOME="${DAKBASE}/gpg"
  35. cp -a "${DAK_ROOT}/tests/fixtures/packages/gpg" "${GNUPGHOME}"
  36. chmod 0700 "${GNUPGHOME}"
  37. echo "Dinstall::SigningHomedir \"${GNUPGHOME}\";" >> "${DAK_CONFIG}"
  38. echo "Dir::Mail \"${DAKBASE}/outgoing-mail\";" >> "${DAK_CONFIG}"
  39. echo "Dinstall::BXANotify 1;" >> "${DAK_CONFIG}"
  40. echo "Dinstall::Mail-Signature-Key \"589E8FA542378066E944B6222F7C63E8F3A2C549\";" >> "${DAK_CONFIG}"
  41. section_end setup_dak_installation
  42. }
  43. test-cleanup() {
  44. if [[ -v DAKBASE ]]; then
  45. # Ensure we stop the gpg-agent to avoid leaving processes running
  46. gpg-connect-agent --homedir "${GNUPGHOME}" KILLAGENT /bye
  47. rm -rf -- "${DAKBASE}"
  48. fi
  49. }
  50. if [[ ! -v DAK_INTERACTIVE_SHELL ]]; then
  51. trap test-cleanup EXIT
  52. test-setup
  53. fi
  54. if [ "$0" = "${BASH_SOURCE}" ] ; then
  55. echo "============= STARTING interactive dak integration test shell ==========="
  56. echo
  57. echo "Run psql for accessing projectb"
  58. echo "Run dak commands via \"dak <cmd>\""
  59. echo "Note that some data (e.g. postgres and dak.conf) will be discarded at"
  60. echo "the end of the run"
  61. echo
  62. echo "You may want to run \"make -C tests/fixtures/packages\" and"
  63. echo "\"integration-tests/tests/0001-basic\" test to import some basic data"
  64. echo
  65. DAK_INTERACTIVE_SHELL=1 "${SHELL}" -s
  66. echo "============= STOPPING interactive dak integration test shell ==========="
  67. fi