]> git.saurik.com Git - apt.git/blob - test/integration/test-bug-661537-build-profiles-support
Use _apt as our unprivileged user name
[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] <!profile.stage1 !profile.cross>, bar'
15
16 # table from https://wiki.debian.org/BuildProfileSpec
17 insertsource 'unstable' 'spec-1' 'any' '1' 'Build-Depends: foo <!profile.stage1>'
18 insertsource 'unstable' 'spec-2' 'any' '1' 'Build-Depends: foo <profile.stage1>'
19 insertsource 'unstable' 'spec-3' 'any' '1' 'Build-Depends: foo <!profile.stage1 !profile.notest>'
20 insertsource 'unstable' 'spec-4' 'any' '1' 'Build-Depends: foo <profile.stage1 profile.notest>'
21 insertsource 'unstable' 'spec-5' 'any' '1' 'Build-Depends: foo <!profile.stage1 profile.notest>'
22 insertsource 'unstable' 'spec-6' 'any' '1' 'Build-Depends: foo <profile.stage1 !profile.notest>'
23 # multiple stanzas not supported: error out
24 insertsource 'unstable' 'spec-7' 'any' '1' 'Build-Depends: foo <profile.stage1><!profile.notest>'
25 insertsource 'unstable' 'spec-8' 'any' '1' 'Build-Depends: foo <profile.stage1> <!profile.notest>'
26
27 setupaptarchive
28
29 testequal 'Reading package lists...
30 Building dependency tree...
31 The following NEW packages will be installed:
32 bar
33 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
34 Inst bar (1.0 unstable [all])
35 Conf bar (1.0 unstable [all])' aptget build-dep buildprofiles -s
36
37 testequal 'Reading package lists...
38 Building dependency tree...
39 The following NEW packages will be installed:
40 bar foo
41 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
42 Inst bar (1.0 unstable [all])
43 Inst foo (1.0 unstable [all])
44 Conf bar (1.0 unstable [all])
45 Conf foo (1.0 unstable [all])' aptget build-dep buildprofiles -s -o APT::Architecture=i386
46
47 testequal 'Reading package lists...
48 Building dependency tree...
49 The following NEW packages will be installed:
50 bar
51 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
52 Inst bar (1.0 unstable [all])
53 Conf bar (1.0 unstable [all])' aptget build-dep buildprofiles -s -o APT::Architecture=armel
54
55 testequal 'Reading package lists...
56 Building dependency tree...
57 The following NEW packages will be installed:
58 bar
59 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
60 Inst bar (1.0 unstable [all])
61 Conf bar (1.0 unstable [all])' aptget build-dep buildprofiles -s -o APT::Architecture=i386 -P stage1
62
63 KEEP='Reading package lists...
64 Building dependency tree...
65 The following NEW packages will be installed:
66 foo
67 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
68 Inst foo (1.0 unstable [all])
69 Conf foo (1.0 unstable [all])'
70 DROP='Reading package lists...
71 Building dependency tree...
72 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.'
73
74 msgtest 'Check if version of installed dpkg is high enough for' 'build profiles support'
75 if 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 }
96 else
97 msgskip
98 testwithdpkg() {
99 msgtest "Test with" "dpkg-checkbuilddeps -d '$1' -P '$2'"
100 msgskip
101 }
102 fi
103
104 testprofile() {
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
116 testprofile 'spec-1' 'foo <!profile.stage1>' '' "$KEEP"
117 testprofile 'spec-1' 'foo <!profile.stage1>' 'stage1' "$DROP"
118 testprofile 'spec-1' 'foo <!profile.stage1>' 'notest' "$KEEP"
119 testprofile 'spec-1' 'foo <!profile.stage1>' 'stage1,notest' "$DROP"
120
121 testprofile 'spec-2' 'foo <profile.stage1>' '' "$DROP"
122 testprofile 'spec-2' 'foo <profile.stage1>' 'stage1' "$KEEP"
123 testprofile 'spec-2' 'foo <profile.stage1>' 'notest' "$DROP"
124 testprofile 'spec-2' 'foo <profile.stage1>' 'stage1,notest' "$KEEP"
125
126 testprofile 'spec-3' 'foo <!profile.stage1 !profile.notest>' '' "$KEEP"
127 testprofile 'spec-3' 'foo <!profile.stage1 !profile.notest>' 'stage1' "$DROP"
128 testprofile 'spec-3' 'foo <!profile.stage1 !profile.notest>' 'notest' "$DROP"
129 testprofile 'spec-3' 'foo <!profile.stage1 !profile.notest>' 'stage1,notest' "$DROP"
130
131 testprofile 'spec-4' 'foo <profile.stage1 profile.notest>' '' "$DROP"
132 testprofile 'spec-4' 'foo <profile.stage1 profile.notest>' 'stage1' "$KEEP"
133 testprofile 'spec-4' 'foo <profile.stage1 profile.notest>' 'notest' "$KEEP"
134 testprofile 'spec-4' 'foo <profile.stage1 profile.notest>' 'stage1,notest' "$KEEP"
135
136 testprofile 'spec-5' 'foo <!profile.stage1 profile.notest>' '' "$KEEP"
137 testprofile 'spec-5' 'foo <!profile.stage1 profile.notest>' 'stage1' "$DROP"
138 testprofile 'spec-5' 'foo <!profile.stage1 profile.notest>' 'notest' "$KEEP"
139 testprofile 'spec-5' 'foo <!profile.stage1 profile.notest>' 'stage1,notest' "$DROP"
140
141 testprofile 'spec-6' 'foo <profile.stage1 !profile.notest>' '' "$KEEP"
142 testprofile 'spec-6' 'foo <profile.stage1 !profile.notest>' 'stage1' "$KEEP"
143 testprofile 'spec-6' 'foo <profile.stage1 !profile.notest>' 'notest' "$DROP"
144 testprofile 'spec-6' 'foo <profile.stage1 !profile.notest>' 'stage1,notest' "$KEEP"
145
146 testfailure aptget build-dep spec-7 -s
147 testfailure aptget build-dep spec-8 -s