setup 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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)
  26. export HOME="${DAKBASE}/home"
  27. export DAKHOST=dak-master
  28. export PGDATABASE=projectb
  29. mkdir "$HOME" || exit $?
  30. ${setupdir}/dak-setup.sh
  31. export PATH="${DAKBASE}/bin:${PATH}"
  32. export DAK_CONFIG="${DAKBASE}/etc/dak.conf"
  33. export GNUPGHOME="${DAKBASE}/gpg"
  34. cp -a "${DAK_ROOT}/tests/fixtures/packages/gpg" "${GNUPGHOME}"
  35. chmod 0700 "${GNUPGHOME}"
  36. echo "Dinstall::SigningHomedir \"${GNUPGHOME}\";" >> "${DAK_CONFIG}"
  37. section_end setup_dak_installation
  38. }
  39. test-cleanup() {
  40. if [[ -v DAKBASE ]]; then
  41. # Ensure we stop the gpg-agent to avoid leaving processes running
  42. gpg-connect-agent --homedir "${GNUPGHOME}" KILLAGENT /bye
  43. rm -rf -- "${DAKBASE}"
  44. fi
  45. }
  46. if [[ ! -v DAK_INTERACTIVE_SHELL ]]; then
  47. trap test-cleanup EXIT
  48. test-setup
  49. fi
  50. if [ "$0" = "${BASH_SOURCE}" ] ; then
  51. echo "============= STARTING interactive dak integration test shell ==========="
  52. echo
  53. echo "Run psql for accessing projectb"
  54. echo "Run dak commands via \"dak <cmd>\""
  55. echo "Note that some data (e.g. postgres and dak.conf) will be discarded at"
  56. echo "the end of the run"
  57. echo
  58. echo "You may want to run \"make -C tests/fixtures/packages\" and"
  59. echo "\"integration-tests/tests/0001-basic\" test to import some basic data"
  60. echo
  61. DAK_INTERACTIVE_SHELL=1 "${SHELL}" -s
  62. echo "============= STOPPING interactive dak integration test shell ==========="
  63. fi