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