You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

79 lines
2.3 KiB

  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'amd64'
  7. # apt-extracttemplates needs this
  8. insertinstalledpackage 'pkg-with-template' 'amd64' '1.0'
  9. # build a simple package that contains a config and a template
  10. mkdir -p DEBIAN
  11. CONFIG_STR="#!/bin/sh
  12. random shell stuff
  13. "
  14. echo "$CONFIG_STR" > DEBIAN/config
  15. chmod 755 DEBIAN/config
  16. testrun() {
  17. local TEMPLATE_STR='Template: foo/bar
  18. Type: string
  19. Description: Some bar var
  20. '
  21. echo "$TEMPLATE_STR" > DEBIAN/templates
  22. buildsimplenativepackage "$1" 'amd64' '0.8.15' 'stable' "$2" 'pkg with template' '' '' './DEBIAN'
  23. cp dpkg.status rootdir/var/lib/dpkg/status
  24. insertinstalledpackage 'debconf' 'amd64' '3'
  25. # ensure we get the right stuff out of the file
  26. rm -rf extracttemplates-out rootdir/var/cache/apt
  27. mkdir extracttemplates-out
  28. testsuccess aptextracttemplates -t ./extracttemplates-out incoming/${1}*.deb
  29. OUT='rootdir/tmp/testsuccess.output'
  30. testequal "$1" cut -f1 -d' ' $OUT
  31. if [ -n "$2" ]; then
  32. testequal '' cut -s -f2 -d' ' $OUT
  33. else
  34. testequal '1.0' cut -f2 -d' ' $OUT
  35. fi
  36. TEMPLATE=$(cut -f3 -d' ' $OUT)
  37. testfileequal "$TEMPLATE" "$TEMPLATE_STR"
  38. CONFIG=$(cut -f4 -d' ' $OUT)
  39. testfileequal "$CONFIG" "$CONFIG_STR"
  40. msgtest 'No extra files or directories in extraction directory'
  41. if [ "$(find ./extracttemplates-out | wc -l)" = '3' ]; then
  42. msgpass
  43. else
  44. msgfail
  45. ls -l ./extracttemplates-out
  46. fi
  47. # ensure that the format of the output string has the right number of dots
  48. for s in "$CONFIG" "$TEMPLATE"; do
  49. NR_DOTS=$(basename "$s" | tr -c -d '.')
  50. testequal '..' echo $NR_DOTS
  51. done
  52. if [ -n "$2" ]; then
  53. rm -rf extracttemplates-out rootdir/var/cache/apt
  54. mkdir extracttemplates-out
  55. cp dpkg.status rootdir/var/lib/dpkg/status
  56. insertinstalledpackage 'debconf' 'amd64' '1'
  57. testempty aptextracttemplates -t ./extracttemplates-out incoming/${1}*.deb
  58. fi
  59. }
  60. cp rootdir/var/lib/dpkg/status dpkg.status
  61. testrun 'pkg-with-template' ''
  62. testrun 'pkg-with-template-depends' 'Depends: debconf (>= 2)'
  63. testrun 'pkg-with-template-predepends' 'Pre-Depends: debconf (>= 2)'
  64. # test with no debconf installed
  65. cp dpkg.status rootdir/var/lib/dpkg/status
  66. testfailure aptextracttemplates -t ./extracttemplates-out incoming/pkg-with-template-depends*.deb
  67. testfileequal 'rootdir/tmp/testfailure.output' 'E: Cannot get debconf version. Is debconf installed?'