Yet more %config test-cases - shared configs have quirks of their own
[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
336
337 # Shared config file variants of the same cases
338 # ------------------------------
339 # (Build and) upgrade package with config file, no backup here
340 AT_SETUP([upgrade unchanged shared config])
341 AT_KEYWORDS([install])
342 AT_CHECK([
343 RPMDB_CLEAR
344 RPMDB_INIT
345 cf="${RPMTEST}"/etc/my.conf
346 rm -f "${cf}" "${cf}".rpm*
347 rm -rf "${TOPDIR}"
348
349 for s in "A" "B"; do
350     for v in "1.0" "2.0"; do
351         runroot rpmbuild --quiet -bb \
352             --define "sub $s" \
353             --define "ver $v" \
354             --define "filedata foo" \
355               /data/SPECS/configtest.spec
356     done
357 done
358
359 runroot rpm -U \
360     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
361     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
362 cat "${cf}"
363 runroot rpm -U \
364     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
365     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
366 cat "${cf}"
367 ],
368 [0],
369 [foo
370 foo
371 ],
372 [])
373
374 AT_CLEANUP
375 #
376 # ------------------------------
377 # Upgrade package with locally modified config file, unchanged in pkg
378 AT_SETUP([upgrade modified shared config])
379 AT_KEYWORDS([install])
380 AT_CHECK([
381 RPMDB_CLEAR
382 RPMDB_INIT
383 cf="${RPMTEST}"/etc/my.conf
384 rm -f "${cf}" "${cf}".rpm*
385 rm -rf "${TOPDIR}"
386
387 for s in "A" "B"; do
388     for v in "1.0" "2.0"; do
389         runroot rpmbuild --quiet -bb \
390             --define "sub $s" \
391             --define "ver $v" \
392             --define "filedata foo" \
393               /data/SPECS/configtest.spec
394     done
395 done
396
397 runroot rpm -U \
398     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
399     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
400 cat "${cf}"
401 echo "otherstuff" > "${cf}"
402 cat "${cf}"
403 runroot rpm -U \
404     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
405     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
406 cat "${cf}"
407 ],
408 [0],
409 [foo
410 otherstuff
411 otherstuff
412 ],
413 [])
414 AT_CLEANUP
415
416 # ------------------------------
417 # Upgrade package with unmodified config file, changed in pkg
418 AT_SETUP([upgrade changing shared config])
419 AT_KEYWORDS([install])
420 AT_CHECK([
421 RPMDB_CLEAR
422 RPMDB_INIT
423 cf="${RPMTEST}"/etc/my.conf
424 rm -f "${cf}" "${cf}".rpm*
425 rm -rf "${TOPDIR}"
426
427 for s in "A" "B"; do
428     for v in "1.0" "2.0"; do
429         runroot rpmbuild --quiet -bb \
430             --define "sub $s" \
431             --define "ver $v" \
432             --define "filedata foo-$v" \
433               /data/SPECS/configtest.spec
434     done
435 done
436
437 runroot rpm -U \
438     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
439     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
440 cat "${cf}"
441 runroot rpm -U \
442     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
443     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
444 cat "${cf}"
445 ],
446 [0],
447 [foo-1.0
448 foo-2.0
449 ],
450 [])
451 AT_CLEANUP
452
453 # ------------------------------
454 # Upgrade package with locally modified config file, changed in pkg
455 AT_SETUP([upgrade changing, modified shared config 1])
456 AT_KEYWORDS([install])
457 AT_CHECK([
458 RPMDB_CLEAR
459 RPMDB_INIT
460 cf="${RPMTEST}"/etc/my.conf
461 rm -f "${cf}" "${cf}".rpm*
462 rm -rf "${TOPDIR}"
463
464 for s in "A" "B"; do
465     for v in "1.0" "2.0"; do
466         runroot rpmbuild --quiet -bb \
467             --define "sub $s" \
468             --define "ver $v" \
469             --define "filedata foo-$v" \
470               /data/SPECS/configtest.spec
471     done
472 done
473
474 runroot rpm -U \
475     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
476     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
477 cat "${cf}"
478 echo "otherstuff" > "${RPMTEST}"/etc/my.conf
479 cat "${cf}"
480 runroot rpm -U \
481     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
482     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
483 cat "${cf}"
484 ],
485 [0],
486 [foo-1.0
487 otherstuff
488 foo-2.0
489 ],
490 [warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
491 )
492 AT_CLEANUP
493
494 # ------------------------------
495 # Modified config file matches the content from new package. Creating a 
496 # backup makes no sense in this case, but that's what currently happens.
497 AT_SETUP([upgrade changing, modified shared config 2])
498 AT_KEYWORDS([install])
499 AT_CHECK([
500 RPMDB_CLEAR
501 RPMDB_INIT
502 cf="${RPMTEST}"/etc/my.conf
503 rm -f "${cf}" "${cf}".rpm*
504 rm -rf "${TOPDIR}"
505
506 for s in "A" "B"; do
507     for v in "1.0" "2.0"; do
508         runroot rpmbuild --quiet -bb \
509             --define "sub $s" \
510             --define "ver $v" \
511             --define "filedata foo-$v" \
512               /data/SPECS/configtest.spec
513     done
514 done
515
516 runroot rpm -U \
517     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
518     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
519 cat "${cf}"
520 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
521 cat "${cf}"
522 runroot rpm -U \
523     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
524     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
525 cat "${cf}"
526 ],
527 [0],
528 [foo-1.0
529 foo-2.0
530 foo-2.0
531 ],
532 [warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
533 )
534 AT_CLEANUP
535
536 # Shared config(noreplace) variants of the more interesting cases
537 # ------------------------------
538 # Upgrade package with locally modified config file, changed in pkg.
539 # Creating *two* backups makes no sense, but that's what currently happens.
540 AT_SETUP([upgrade changing, modified shared config(noreplace) 1])
541 AT_KEYWORDS([install])
542 AT_CHECK([
543 RPMDB_CLEAR
544 RPMDB_INIT
545 cf="${RPMTEST}"/etc/my.conf
546 rm -f "${cf}" "${cf}".rpm*
547 rm -rf "${TOPDIR}"
548
549 for s in "A" "B"; do
550     for v in "1.0" "2.0"; do
551         runroot rpmbuild --quiet -bb \
552             --define "sub $s" \
553             --define "ver $v" \
554             --define "filedata foo-$v" \
555             --define "noreplace 1" \
556               /data/SPECS/configtest.spec
557     done
558 done
559
560 runroot rpm -U \
561     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
562     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
563 cat "${cf}"
564 echo "otherstuff" > "${RPMTEST}"/etc/my.conf
565 cat "${cf}"
566 runroot rpm -U \
567     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
568     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
569 cat "${cf}"
570 ],
571 [0],
572 [foo-1.0
573 otherstuff
574 otherstuff
575 ],
576 [warning: /etc/my.conf created as /etc/my.conf.rpmnew
577 warning: /etc/my.conf created as /etc/my.conf.rpmnew]
578 )
579 AT_CLEANUP
580
581 # ------------------------------
582 # Modified config file matches the content from new package. Creating a 
583 # backup makes no sense in this case, but that's what currently happens.
584 AT_SETUP([upgrade changing, modified shared config(noreplace) 2])
585 AT_KEYWORDS([install])
586 AT_CHECK([
587 RPMDB_CLEAR
588 RPMDB_INIT
589 cf="${RPMTEST}"/etc/my.conf
590 rm -f "${cf}" "${cf}".rpm*
591 rm -rf "${TOPDIR}"
592
593 for s in "A" "B"; do
594     for v in "1.0" "2.0"; do
595         runroot rpmbuild --quiet -bb \
596             --define "sub $s" \
597             --define "ver $v" \
598             --define "filedata foo-$v" \
599             --define "noreplace 1" \
600               /data/SPECS/configtest.spec
601     done
602 done
603
604 runroot rpm -U \
605     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
606     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
607 cat "${cf}"
608 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
609 cat "${cf}"
610 runroot rpm -U \
611     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
612     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
613 cat "${cf}"
614 ],
615 [0],
616 [foo-1.0
617 foo-2.0
618 foo-2.0
619 ],
620 [warning: /etc/my.conf created as /etc/my.conf.rpmnew]
621 )
622 AT_CLEANUP