]> git.saurik.com Git - apt.git/blame_incremental - test/integration/test-apt-tagfile-fields-order
test-apt-cdrom: Fix for gnupg 2.1.15
[apt.git] / test / integration / test-apt-tagfile-fields-order
... / ...
CommitLineData
1#!/bin/sh
2set -e
3
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
6setupenvironment
7
8dpkg_field_ordered_list() {
9 local FIELDS="$(perl -e "
10use Dpkg::Control;
11use Dpkg::Control::Fields;
12foreach \$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
21comparelsts() {
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
32msgtest 'Check that apt knows all fields dpkg orders in' 'Packages'
33dpkg_field_ordered_list 'CTRL_INDEX_PKG' > dpkg.lst
34sed -ne 's#^ "\(.*\)",.*$#\1#p' "${SOURCEDIRECTORY}/apt-pkg/tagfile-order.c" | sed -n '/^Package$/,/^Package$/ p' | head -n -1 | sort -u > apt.lst
35comparelsts
36
37msgtest 'Check that apt knows all fields dpkg orders in' 'status'
38dpkg_field_ordered_list 'CTRL_FILE_STATUS' > dpkg.lst
39comparelsts
40
41msgtest 'Check that apt knows all fields dpkg orders in' 'DEBIAN/control'
42dpkg_field_ordered_list 'CTRL_PKG_DEB' > dpkg.lst
43comparelsts
44
45msgtest 'Check that apt knows all fields dpkg orders in' 'Sources'
46dpkg_field_ordered_list 'CTRL_INDEX_SRC' > dpkg.lst
47echo 'Package' > apt.tmp
48sed -ne 's#^ "\(.*\)",.*$#\1#p' "${SOURCEDIRECTORY}/apt-pkg/tagfile-order.c" | sed '/^Package$/,/^Package$/ d' >> apt.tmp
49sort -u apt.tmp > apt.lst
50comparelsts
51
52msgtest 'Check that apt knows all fields dpkg orders in' 'dsc'
53dpkg_field_ordered_list 'CTRL_PKG_SRC' > dpkg.lst
54comparelsts
55
56# HACK, but there is no good way to acquire sources in tests and/or to remember to run this regular manually
57if [ "$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
82fi