prepare 1.0.4 upload
[ntk/apt.git] / test / integration / test-bug-661537-build-profiles-support
CommitLineData
ce7f128c
DK
1#!/bin/sh
2set -e
3
4TESTDIR=$(readlink -f $(dirname $0))
5. $TESTDIR/framework
6setupenvironment
7configarchitecture 'amd64' 'i386' 'armel'
8
9insertinstalledpackage 'build-essential' 'all' '0' 'Multi-Arch: foreign'
10
11insertpackage 'unstable' 'foo' 'all' '1.0'
12insertpackage 'unstable' 'bar' 'all' '1.0'
13
14insertsource 'unstable' 'buildprofiles' 'any' '1' 'Build-Depends: foo (>= 1.0) [i386 arm] <!profile.stage1 !profile.cross>, bar'
15
16# table from https://wiki.debian.org/BuildProfileSpec
17insertsource 'unstable' 'spec-1' 'any' '1' 'Build-Depends: foo <!profile.stage1>'
18insertsource 'unstable' 'spec-2' 'any' '1' 'Build-Depends: foo <profile.stage1>'
19insertsource 'unstable' 'spec-3' 'any' '1' 'Build-Depends: foo <!profile.stage1 !profile.notest>'
20insertsource 'unstable' 'spec-4' 'any' '1' 'Build-Depends: foo <profile.stage1 profile.notest>'
21insertsource 'unstable' 'spec-5' 'any' '1' 'Build-Depends: foo <!profile.stage1 profile.notest>'
22insertsource 'unstable' 'spec-6' 'any' '1' 'Build-Depends: foo <profile.stage1 !profile.notest>'
23# multiple stanzas not supported: error out
24insertsource 'unstable' 'spec-7' 'any' '1' 'Build-Depends: foo <profile.stage1><!profile.notest>'
25insertsource 'unstable' 'spec-8' 'any' '1' 'Build-Depends: foo <profile.stage1> <!profile.notest>'
26
27setupaptarchive
28
29testequal 'Reading package lists...
30Building dependency tree...
31The following NEW packages will be installed:
32 bar
330 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
34Inst bar (1.0 unstable [all])
35Conf bar (1.0 unstable [all])' aptget build-dep buildprofiles -s
36
37testequal 'Reading package lists...
38Building dependency tree...
39The following NEW packages will be installed:
40 bar foo
410 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
42Inst bar (1.0 unstable [all])
43Inst foo (1.0 unstable [all])
44Conf bar (1.0 unstable [all])
45Conf foo (1.0 unstable [all])' aptget build-dep buildprofiles -s -o APT::Architecture=i386
46
47testequal 'Reading package lists...
48Building dependency tree...
49The following NEW packages will be installed:
50 bar
510 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
52Inst bar (1.0 unstable [all])
53Conf bar (1.0 unstable [all])' aptget build-dep buildprofiles -s -o APT::Architecture=armel
54
55testequal 'Reading package lists...
56Building dependency tree...
57The following NEW packages will be installed:
58 bar
590 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
60Inst bar (1.0 unstable [all])
61Conf bar (1.0 unstable [all])' aptget build-dep buildprofiles -s -o APT::Architecture=i386 -P stage1
62
63KEEP='Reading package lists...
64Building dependency tree...
65The following NEW packages will be installed:
66 foo
670 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
68Inst foo (1.0 unstable [all])
69Conf foo (1.0 unstable [all])'
70DROP='Reading package lists...
71Building dependency tree...
720 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.'
73
74msgtest 'Check if version of installed dpkg is high enough for' 'build profiles support'
75if dpkg --compare-versions "$(command dpkg-query --showformat='${Version}' --show dpkg)" 'ge' '1.17.2'; then
76 msgpass
77 testwithdpkg() {
78 msgtest "Test with" "dpkg-checkbuilddeps -d '$1' -P '$2'"
79 local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testwithdpkg.output"
80 if dpkgcheckbuilddeps -d "$1" -P "$2" /dev/null >$OUTPUT 2>&1; then
81 if [ "$3" = "$DROP" ]; then
82 msgpass
83 else
84 cat $OUTPUT
85 msgfail
86 fi
87 else
88 if [ "$3" = "$KEEP" ]; then
89 msgpass
90 else
91 cat $OUTPUT
92 msgfail
93 fi
94 fi
95 }
96else
97 msgskip
98 testwithdpkg() {
99 msgtest "Test with" "dpkg-checkbuilddeps -d '$1' -P '$2'"
100 msgskip
101 }
102fi
103
104testprofile() {
105 if [ -n "$3" ]; then
106 testequal "$4" aptget build-dep "$1" -s -P "$3"
107 export DEB_BUILD_PROFILES="$(echo "$3" | tr ',' ' ')"
108 testequal "$4" aptget build-dep "$1" -s -o with::environment=1
109 unset DEB_BUILD_PROFILES
110 else
111 testequal "$4" aptget build-dep "$1" -s
112 fi
113 testwithdpkg "$2" "$3" "$4"
114}
115
116testprofile 'spec-1' 'foo <!profile.stage1>' '' "$KEEP"
117testprofile 'spec-1' 'foo <!profile.stage1>' 'stage1' "$DROP"
118testprofile 'spec-1' 'foo <!profile.stage1>' 'notest' "$KEEP"
119testprofile 'spec-1' 'foo <!profile.stage1>' 'stage1,notest' "$DROP"
120
121testprofile 'spec-2' 'foo <profile.stage1>' '' "$DROP"
122testprofile 'spec-2' 'foo <profile.stage1>' 'stage1' "$KEEP"
123testprofile 'spec-2' 'foo <profile.stage1>' 'notest' "$DROP"
124testprofile 'spec-2' 'foo <profile.stage1>' 'stage1,notest' "$KEEP"
125
126testprofile 'spec-3' 'foo <!profile.stage1 !profile.notest>' '' "$KEEP"
127testprofile 'spec-3' 'foo <!profile.stage1 !profile.notest>' 'stage1' "$DROP"
128testprofile 'spec-3' 'foo <!profile.stage1 !profile.notest>' 'notest' "$DROP"
129testprofile 'spec-3' 'foo <!profile.stage1 !profile.notest>' 'stage1,notest' "$DROP"
130
131testprofile 'spec-4' 'foo <profile.stage1 profile.notest>' '' "$DROP"
132testprofile 'spec-4' 'foo <profile.stage1 profile.notest>' 'stage1' "$KEEP"
133testprofile 'spec-4' 'foo <profile.stage1 profile.notest>' 'notest' "$KEEP"
134testprofile 'spec-4' 'foo <profile.stage1 profile.notest>' 'stage1,notest' "$KEEP"
135
136testprofile 'spec-5' 'foo <!profile.stage1 profile.notest>' '' "$KEEP"
137testprofile 'spec-5' 'foo <!profile.stage1 profile.notest>' 'stage1' "$DROP"
138testprofile 'spec-5' 'foo <!profile.stage1 profile.notest>' 'notest' "$KEEP"
139testprofile 'spec-5' 'foo <!profile.stage1 profile.notest>' 'stage1,notest' "$DROP"
140
141testprofile 'spec-6' 'foo <profile.stage1 !profile.notest>' '' "$KEEP"
142testprofile 'spec-6' 'foo <profile.stage1 !profile.notest>' 'stage1' "$KEEP"
143testprofile 'spec-6' 'foo <profile.stage1 !profile.notest>' 'notest' "$DROP"
144testprofile 'spec-6' 'foo <profile.stage1 !profile.notest>' 'stage1,notest' "$KEEP"
145
146testfailure aptget build-dep spec-7 -s
147testfailure aptget build-dep spec-8 -s