test-apt-extracttemplates 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 'debconf' 'amd64' '1.5'
  9. insertinstalledpackage 'pkg-with-template' 'amd64' '1.0'
  10. # build a simple package that contains a config and a tempalte
  11. mkdir -p DEBIAN
  12. TEMPLATE_STR="Template: foo/bar
  13. Type: string
  14. Description: Some bar var
  15. "
  16. echo "$TEMPLATE_STR" > DEBIAN/templates
  17. CONFIG_STR="#!/bin/sh
  18. random shell stuff
  19. "
  20. echo "$CONFIG_STR" > DEBIAN/config
  21. buildsimplenativepackage 'pkg-with-template' 'amd64' '0.8.15' 'stable' '' 'pkg with template' '' '' './DEBIAN'
  22. # ensure we get the right stuff out of the file
  23. mkdir extracttemplates-out
  24. OUT="$(aptextracttemplates -t ./extracttemplates-out incoming/pkg-with-template*.deb)"
  25. PKG=$(printf "$OUT" | cut -f1 -d' ')
  26. INSTALLED_VER=$(printf "$OUT" | cut -f2 -d' ')
  27. TEMPLATE=$(printf "$OUT" | cut -f3 -d' ')
  28. CONFIG=$(printf "$OUT" | cut -f4 -d' ')
  29. testequal "$CONFIG_STR" cat $CONFIG
  30. testequal "$TEMPLATE_STR" cat $TEMPLATE
  31. # ensure that the format of the output string has the right number of dots
  32. for s in "$CONFIG" "$TEMPLATE"; do
  33. NR_DOTS=$(basename "$s" | tr -c -d .)
  34. testequal ".." echo $NR_DOTS
  35. done