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.

test-apt-tagfile-fields-order 2.7 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. dpkg_field_ordered_list() {
  7. local FIELDS="$(perl -e "
  8. use Dpkg::Control;
  9. use Dpkg::Control::Fields;
  10. foreach \$f (field_ordered_list(${1})) {
  11. print \"\$f\\n\";
  12. }" | sort -u)"
  13. if [ -z "$FIELDS" ]; then
  14. msgfail 'Could not get fields via libdpkg-perl'
  15. fi
  16. echo "$FIELDS"
  17. }
  18. comparelsts() {
  19. local DIFFOUTPUT="$(diff -u apt.lst dpkg.lst || true)"
  20. if echo "$DIFFOUTPUT" | grep -q '^+[^+]'; then
  21. echo
  22. echo "$DIFFOUTPUT" | grep '^[+-][^+-]'
  23. msgfail
  24. else
  25. msgpass
  26. fi
  27. }
  28. msgtest 'Check that apt knows all fields dpkg orders in' 'Packages'
  29. dpkg_field_ordered_list 'CTRL_INDEX_PKG' > dpkg.lst
  30. sed -ne 's#^ "\(.*\)",.*$#\1#p' "${SOURCEDIRECTORY}/apt-pkg/tagfile-order.c" | sed -n '/^Package$/,/^Package$/ p' | head -n -1 | sort -u > apt.lst
  31. comparelsts
  32. msgtest 'Check that apt knows all fields dpkg orders in' 'status'
  33. dpkg_field_ordered_list 'CTRL_FILE_STATUS' > dpkg.lst
  34. comparelsts
  35. msgtest 'Check that apt knows all fields dpkg orders in' 'DEBIAN/control'
  36. dpkg_field_ordered_list 'CTRL_PKG_DEB' > dpkg.lst
  37. comparelsts
  38. msgtest 'Check that apt knows all fields dpkg orders in' 'Sources'
  39. dpkg_field_ordered_list 'CTRL_INDEX_SRC' > dpkg.lst
  40. echo 'Package' > apt.tmp
  41. sed -ne 's#^ "\(.*\)",.*$#\1#p' "${SOURCEDIRECTORY}/apt-pkg/tagfile-order.c" | sed '/^Package$/,/^Package$/ d' >> apt.tmp
  42. sort -u apt.tmp > apt.lst
  43. comparelsts
  44. msgtest 'Check that apt knows all fields dpkg orders in' 'dsc'
  45. dpkg_field_ordered_list 'CTRL_PKG_SRC' > dpkg.lst
  46. comparelsts
  47. # HACK, but there is no good way to acquire sources in tests and/or to remember to run this regular manually
  48. if [ "$USER" = 'david' ]; then
  49. msgtest 'Check if we have somewhere the sources of' 'dpkg'
  50. DPKGSOURCE="$(locate dpkg/lib/dpkg/parse.c | head -n 1 || true)"
  51. if [ -z "$DPKGSOURCE" ]; then
  52. msgskip 'Not found'
  53. else
  54. msgpass
  55. msgtest 'Check that apt knows about all fields' 'dpkg parses'
  56. sed -n 's#^.*FIELD("\(.*\)").*$#\1#p' "${DPKGSOURCE}" | sort -u > dpkg.lst
  57. sed -ne 's#^ "\(.*\)",.*$#\1#p' "${SOURCEDIRECTORY}/apt-pkg/tagfile-order.c" | sed -n '/^Package$/,/^Package$/ p' | head -n -1 | sort -u > apt.lst
  58. comparelsts
  59. fi
  60. msgtest 'Check if we have somewhere the sources of' 'dak'
  61. DAKSOURCE="$(locate dak/setup/core-init.d/080_metadatakeys | head -n 1 || true)"
  62. if [ -z "$DAKSOURCE" ]; then
  63. msgskip 'Not found'
  64. else
  65. msgpass
  66. msgtest 'Check that apt knows about all fields' 'dak knows'
  67. # dak mixes both, so we can only check with the mixed one as well
  68. sed -ne "s#^.* VALUES ('\(.*\)', \(.*\)).*\$#\1 \2#p" "${DAKSOURCE}" | cut -d ' ' -f 1 | sort -u > dpkg.lst
  69. sed -ne 's#^ "\(.*\)",.*$#\1#p' "${SOURCEDIRECTORY}/apt-pkg/tagfile-order.c" | sort -u > apt.lst
  70. comparelsts
  71. fi
  72. fi