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