Add similar set of %config(noreplace) tests
[platform/upstream/rpm.git] / tests / rpmconfig.at
1 #    rpmvercmp.at: rpm config file behavior tests
2
3 AT_BANNER([RPM config file behavior])
4
5 # ------------------------------
6 # (Build and) upgrade package with config file, no backup here
7 AT_SETUP([upgrade unchanged config])
8 AT_KEYWORDS([install])
9 AT_CHECK([
10 RPMDB_CLEAR
11 RPMDB_INIT
12 cf="${RPMTEST}"/etc/my.conf
13 rm -f "${cf}" "${cf}".rpm*
14 rm -rf "${TOPDIR}"
15
16 for v in "1.0" "2.0"; do
17     runroot rpmbuild --quiet -bb \
18         --define "ver $v" \
19         --define "filedata foo" \
20           /data/SPECS/configtest.spec
21 done
22
23 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
24 cat "${cf}"
25 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
26 cat "${cf}"
27 ],
28 [0],
29 [foo
30 foo
31 ],
32 [])
33 AT_CLEANUP
34 #
35 # ------------------------------
36 # Upgrade package with locally modified config file, unchanged in pkg
37 AT_SETUP([upgrade modified config])
38 AT_KEYWORDS([install])
39 AT_CHECK([
40 RPMDB_CLEAR
41 RPMDB_INIT
42 cf="${RPMTEST}"/etc/my.conf
43 rm -f "${cf}" "${cf}".rpm*
44 rm -rf "${TOPDIR}"
45
46 for v in "1.0" "2.0"; do
47     runroot rpmbuild --quiet -bb \
48         --define "ver $v" \
49         --define "filedata foo" \
50           /data/SPECS/configtest.spec
51 done
52
53 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
54 cat "${cf}"
55 echo "otherstuff" > "${cf}"
56 cat "${cf}"
57 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
58 cat "${cf}"
59 ],
60 [0],
61 [foo
62 otherstuff
63 otherstuff
64 ],
65 [])
66 AT_CLEANUP
67
68 # ------------------------------
69 # Upgrade package with unmodified config file, changed in pkg
70 AT_SETUP([upgrade changing config])
71 AT_KEYWORDS([install])
72 AT_CHECK([
73 RPMDB_CLEAR
74 RPMDB_INIT
75 cf="${RPMTEST}"/etc/my.conf
76 rm -f "${cf}" "${cf}".rpm*
77 rm -rf "${TOPDIR}"
78
79 for v in "1.0" "2.0"; do
80     runroot rpmbuild --quiet -bb \
81         --define "ver $v" \
82         --define "filedata foo-$v" \
83           /data/SPECS/configtest.spec
84 done
85
86 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
87 cat "${cf}"
88 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
89 cat "${cf}"
90 ],
91 [0],
92 [foo-1.0
93 foo-2.0
94 ],
95 [])
96 AT_CLEANUP
97
98 # ------------------------------
99 # Upgrade package with locally modified config file, changed in pkg
100 AT_SETUP([upgrade changing, modified config 1])
101 AT_KEYWORDS([install])
102 AT_CHECK([
103 RPMDB_CLEAR
104 RPMDB_INIT
105 cf="${RPMTEST}"/etc/my.conf
106 rm -f "${cf}" "${cf}".rpm*
107 rm -rf "${TOPDIR}"
108
109 for v in "1.0" "2.0"; do
110     runroot rpmbuild --quiet -bb \
111         --define "ver $v" \
112         --define "filedata foo-$v" \
113           /data/SPECS/configtest.spec
114 done
115
116 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
117 cat "${cf}"
118 echo "otherstuff" > "${RPMTEST}"/etc/my.conf
119 cat "${cf}"
120 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
121 cat "${cf}"
122 ],
123 [0],
124 [foo-1.0
125 otherstuff
126 foo-2.0
127 ],
128 [warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
129 )
130 AT_CLEANUP
131
132 # ------------------------------
133 # Modified config file matches the content from new package. Creating a 
134 # backup makes no sense in this case, but that's what currently happens.
135 AT_SETUP([upgrade changing, modified config 2])
136 AT_KEYWORDS([install])
137 AT_CHECK([
138 RPMDB_CLEAR
139 RPMDB_INIT
140 cf="${RPMTEST}"/etc/my.conf
141 rm -f "${cf}" "${cf}".rpm*
142 rm -rf "${TOPDIR}"
143
144 for v in "1.0" "2.0"; do
145     runroot rpmbuild --quiet -bb \
146         --define "ver $v" \
147         --define "filedata foo-$v" \
148           /data/SPECS/configtest.spec
149 done
150
151 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
152 cat "${cf}"
153 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
154 cat "${cf}"
155 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
156 cat "${cf}"
157 ],
158 [0],
159 [foo-1.0
160 foo-2.0
161 foo-2.0
162 ],
163 [warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
164 )
165 AT_CLEANUP
166
167 # config(noreplace) variants of the same cases.
168 #
169 # ------------------------------
170 # (Build and) upgrade package with config file, no backup here
171 AT_SETUP([upgrade unchanged config(noreplace)])
172 AT_KEYWORDS([install])
173 AT_CHECK([
174 RPMDB_CLEAR
175 RPMDB_INIT
176 cf="${RPMTEST}"/etc/my.conf
177 rm -f "${cf}" "${cf}".rpm*
178 rm -rf "${TOPDIR}"
179
180 for v in "1.0" "2.0"; do
181     runroot rpmbuild --quiet -bb \
182         --define "ver $v" \
183         --define "filedata foo" \
184         --define "noreplace 1" \
185           /data/SPECS/configtest.spec
186 done
187
188 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
189 cat "${cf}"
190 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
191 cat "${cf}"
192 ],
193 [0],
194 [foo
195 foo
196 ],
197 [])
198 AT_CLEANUP
199
200 #
201 # ------------------------------
202 # Upgrade package with locally modified config file, unchanged in pkg
203 AT_SETUP([upgrade modified config(noreplace)])
204 AT_KEYWORDS([install])
205 AT_CHECK([
206 RPMDB_CLEAR
207 RPMDB_INIT
208 cf="${RPMTEST}"/etc/my.conf
209 rm -f "${cf}" "${cf}".rpm*
210 rm -rf "${TOPDIR}"
211
212 for v in "1.0" "2.0"; do
213     runroot rpmbuild --quiet -bb \
214         --define "ver $v" \
215         --define "filedata foo" \
216         --define "noreplace 1" \
217           /data/SPECS/configtest.spec
218 done
219
220 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
221 cat "${cf}"
222 echo "otherstuff" > "${cf}"
223 cat "${cf}"
224 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
225 cat "${cf}"
226 ],
227 [0],
228 [foo
229 otherstuff
230 otherstuff
231 ],
232 [])
233 AT_CLEANUP
234
235 # ------------------------------
236 # Upgrade package with unmodified config file, changed in pkg
237 AT_SETUP([upgrade changing config(noreplace)])
238 AT_KEYWORDS([install])
239 AT_CHECK([
240 RPMDB_CLEAR
241 RPMDB_INIT
242 cf="${RPMTEST}"/etc/my.conf
243 rm -f "${cf}" "${cf}".rpm*
244 rm -rf "${TOPDIR}"
245
246 for v in "1.0" "2.0"; do
247     runroot rpmbuild --quiet -bb \
248         --define "ver $v" \
249         --define "filedata foo-$v" \
250         --define "noreplace 1" \
251           /data/SPECS/configtest.spec
252 done
253
254 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
255 cat "${cf}"
256 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
257 cat "${cf}"
258 ],
259 [0],
260 [foo-1.0
261 foo-2.0
262 ],
263 [])
264 AT_CLEANUP
265
266 # ------------------------------
267 # Upgrade package with locally modified config file, changed in pkg
268 AT_SETUP([upgrade changing, modified config(noreplace) 1])
269 AT_KEYWORDS([install])
270 AT_CHECK([
271 RPMDB_CLEAR
272 RPMDB_INIT
273 cf="${RPMTEST}"/etc/my.conf
274 rm -f "${cf}" "${cf}".rpm*
275 rm -rf "${TOPDIR}"
276
277 for v in "1.0" "2.0"; do
278     runroot rpmbuild --quiet -bb \
279         --define "ver $v" \
280         --define "filedata foo-$v" \
281         --define "noreplace 1" \
282           /data/SPECS/configtest.spec
283 done
284
285 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
286 cat "${cf}"
287 echo "otherstuff" > "${RPMTEST}"/etc/my.conf
288 cat "${cf}"
289 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
290 cat "${cf}"
291 ],
292 [0],
293 [foo-1.0
294 otherstuff
295 otherstuff
296 ],
297 [warning: /etc/my.conf created as /etc/my.conf.rpmnew]
298 )
299 AT_CLEANUP
300
301 # ------------------------------
302 # Modified config file matches the content from new package. Creating a 
303 # backup makes no sense in this case, but that's what currently happens.
304 AT_SETUP([upgrade changing, modified config(noreplace) 2])
305 AT_KEYWORDS([install])
306 AT_CHECK([
307 RPMDB_CLEAR
308 RPMDB_INIT
309 cf="${RPMTEST}"/etc/my.conf
310 rm -f "${cf}" "${cf}".rpm*
311 rm -rf "${TOPDIR}"
312
313 for v in "1.0" "2.0"; do
314     runroot rpmbuild --quiet -bb \
315         --define "ver $v" \
316         --define "filedata foo-$v" \
317         --define "noreplace 1" \
318           /data/SPECS/configtest.spec
319 done
320
321 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
322 cat "${cf}"
323 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
324 cat "${cf}"
325 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
326 cat "${cf}"
327 ],
328 [0],
329 [foo-1.0
330 foo-2.0
331 foo-2.0
332 ],
333 [warning: /etc/my.conf created as /etc/my.conf.rpmnew]
334 )
335 AT_CLEANUP