msm: consistency for equally ranked keys
[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 # Install over existing config file
6 AT_SETUP([install config on existiting file])
7 AT_KEYWORDS([install])
8 AT_CHECK([
9 RPMDB_CLEAR
10 RPMDB_INIT
11 cf="${RPMTEST}"/etc/my.conf
12 rm -rf "${cf}" "${cf}".rpm*
13 rm -rf "${TOPDIR}"
14
15 runroot rpmbuild --quiet -bb \
16         --define "ver 1.0" \
17         --define "filedata foo" \
18           /data/SPECS/configtest.spec
19
20 echo "otherstuff" > "${cf}"
21 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
22 cat "${cf}"
23 runroot rpm -e configtest
24 cat "${cf}.rpmorig"
25 ],
26 [0],
27 [foo
28 otherstuff
29 ],
30 [warning: /etc/my.conf saved as /etc/my.conf.rpmorig]
31 )
32 AT_CLEANUP
33
34 # Install over existing config file
35 AT_SETUP([install config(noreplace) on existiting file])
36 AT_KEYWORDS([install])
37 AT_CHECK([
38 RPMDB_CLEAR
39 RPMDB_INIT
40 cf="${RPMTEST}"/etc/my.conf
41 rm -rf "${cf}" "${cf}".rpm*
42 rm -rf "${TOPDIR}"
43
44 runroot rpmbuild --quiet -bb \
45         --define "ver 1.0" \
46         --define "filedata foo" \
47           /data/SPECS/configtest.spec
48
49 echo "otherstuff" > "${cf}"
50 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
51 cat "${cf}"
52 runroot rpm -e configtest
53 cat "${cf}.rpmorig"
54 ],
55 [0],
56 [foo
57 otherstuff
58 ],
59 [warning: /etc/my.conf saved as /etc/my.conf.rpmorig]
60 )
61 AT_CLEANUP
62
63 # Install over existing identical config file, no backup needed
64 AT_SETUP([install config on existiting identical file])
65 AT_KEYWORDS([install])
66 AT_CHECK([
67 RPMDB_CLEAR
68 RPMDB_INIT
69 cf="${RPMTEST}"/etc/my.conf
70 rm -rf "${cf}" "${cf}".rpm*
71 rm -rf "${TOPDIR}"
72
73 runroot rpmbuild --quiet -bb \
74         --define "ver 1.0" \
75         --define "filedata foo" \
76           /data/SPECS/configtest.spec
77
78 echo "foo" > "${cf}"
79 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
80 cat "${cf}"
81 runroot rpm -e configtest
82 test ! -f "${cf}"
83 ],
84 [0],
85 [foo
86 ],
87 [])
88 AT_CLEANUP
89
90 # Erase unmodified config file, no backup here
91 AT_SETUP([erase unchanged config])
92 AT_KEYWORDS([install])
93 AT_CHECK([
94 RPMDB_CLEAR
95 RPMDB_INIT
96 cf="${RPMTEST}"/etc/my.conf
97 rm -rf "${cf}" "${cf}".rpm*
98 rm -rf "${TOPDIR}"
99
100 runroot rpmbuild --quiet -bb \
101         --define "ver 1.0" \
102         --define "filedata foo" \
103           /data/SPECS/configtest.spec
104
105 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
106 cat "${cf}"
107 runroot rpm -e configtest
108 test ! -f "${cf}"
109 ],
110 [0],
111 [foo
112 ],
113 [])
114 AT_CLEANUP
115
116 # Erase modified config file
117 AT_SETUP([erase changed config])
118 AT_KEYWORDS([install])
119 AT_CHECK([
120 RPMDB_CLEAR
121 RPMDB_INIT
122 cf="${RPMTEST}"/etc/my.conf
123 rm -rf "${cf}" "${cf}".rpm*
124 rm -rf "${TOPDIR}"
125
126 runroot rpmbuild --quiet -bb \
127         --define "ver 1.0" \
128         --define "filedata foo" \
129           /data/SPECS/configtest.spec
130
131 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
132 cat "${cf}"
133 echo "otherstuff" > "${cf}"
134 runroot rpm -e configtest
135 cat "${cf}.rpmsave"
136 test ! -f "${cf}"
137 ],
138 [0],
139 [foo
140 otherstuff
141 ],
142 [warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
143 )
144 AT_CLEANUP
145
146 # Erase modified config(noreplace) file
147 AT_SETUP([erase changed config(noreplace)])
148 AT_KEYWORDS([install])
149 AT_CHECK([
150 RPMDB_CLEAR
151 RPMDB_INIT
152 cf="${RPMTEST}"/etc/my.conf
153 rm -rf "${cf}" "${cf}".rpm*
154 rm -rf "${TOPDIR}"
155
156 runroot rpmbuild --quiet -bb \
157         --define "ver 1.0" \
158         --define "filedata foo" \
159         --define "noreplace 1" \
160           /data/SPECS/configtest.spec
161
162 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
163 cat "${cf}"
164 echo "otherstuff" > "${cf}"
165 runroot rpm -e configtest
166 cat "${cf}.rpmsave"
167 test ! -f "${cf}"
168 ],
169 [0],
170 [foo
171 otherstuff
172 ],
173 [warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
174 )
175 AT_CLEANUP
176
177 # ------------------------------
178 # (Build and) upgrade package with config file, no backup here
179 AT_SETUP([upgrade unchanged config])
180 AT_KEYWORDS([install])
181 AT_CHECK([
182 RPMDB_CLEAR
183 RPMDB_INIT
184 cf="${RPMTEST}"/etc/my.conf
185 rm -rf "${cf}" "${cf}".rpm*
186 rm -rf "${TOPDIR}"
187
188 for v in "1.0" "2.0"; do
189     runroot rpmbuild --quiet -bb \
190         --define "ver $v" \
191         --define "filedata foo" \
192           /data/SPECS/configtest.spec
193 done
194
195 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
196 cat "${cf}"
197 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
198 cat "${cf}"
199 ],
200 [0],
201 [foo
202 foo
203 ],
204 [])
205 AT_CLEANUP
206 #
207 # ------------------------------
208 # Upgrade package with locally modified config file, unchanged in pkg
209 AT_SETUP([upgrade modified config])
210 AT_KEYWORDS([install])
211 AT_CHECK([
212 RPMDB_CLEAR
213 RPMDB_INIT
214 cf="${RPMTEST}"/etc/my.conf
215 rm -rf "${cf}" "${cf}".rpm*
216 rm -rf "${TOPDIR}"
217
218 for v in "1.0" "2.0"; do
219     runroot rpmbuild --quiet -bb \
220         --define "ver $v" \
221         --define "filedata foo" \
222           /data/SPECS/configtest.spec
223 done
224
225 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
226 cat "${cf}"
227 echo "otherstuff" > "${cf}"
228 cat "${cf}"
229 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
230 cat "${cf}"
231 ],
232 [0],
233 [foo
234 otherstuff
235 otherstuff
236 ],
237 [])
238 AT_CLEANUP
239
240 # ------------------------------
241 # Upgrade package with unmodified config file, changed in pkg
242 AT_SETUP([upgrade changing config])
243 AT_KEYWORDS([install])
244 AT_CHECK([
245 RPMDB_CLEAR
246 RPMDB_INIT
247 cf="${RPMTEST}"/etc/my.conf
248 rm -rf "${cf}" "${cf}".rpm*
249 rm -rf "${TOPDIR}"
250
251 for v in "1.0" "2.0"; do
252     runroot rpmbuild --quiet -bb \
253         --define "ver $v" \
254         --define "filedata foo-$v" \
255           /data/SPECS/configtest.spec
256 done
257
258 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
259 cat "${cf}"
260 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
261 cat "${cf}"
262 ],
263 [0],
264 [foo-1.0
265 foo-2.0
266 ],
267 [])
268 AT_CLEANUP
269
270 # ------------------------------
271 # Upgrade package with locally modified config file, changed in pkg
272 AT_SETUP([upgrade changing, modified config 1])
273 AT_KEYWORDS([install])
274 AT_CHECK([
275 RPMDB_CLEAR
276 RPMDB_INIT
277 cf="${RPMTEST}"/etc/my.conf
278 rm -rf "${cf}" "${cf}".rpm*
279 rm -rf "${TOPDIR}"
280
281 for v in "1.0" "2.0"; do
282     runroot rpmbuild --quiet -bb \
283         --define "ver $v" \
284         --define "filedata foo-$v" \
285           /data/SPECS/configtest.spec
286 done
287
288 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
289 cat "${cf}"
290 echo "otherstuff" > "${RPMTEST}"/etc/my.conf
291 cat "${cf}"
292 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
293 cat "${cf}"
294 cat "${cf}.rpmsave"
295 ],
296 [0],
297 [foo-1.0
298 otherstuff
299 foo-2.0
300 otherstuff
301 ],
302 [warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
303 )
304 AT_CLEANUP
305
306 # ------------------------------
307 # Modified config file matches the content from new package.
308 AT_SETUP([upgrade changing, modified config 2])
309 AT_KEYWORDS([install])
310 AT_CHECK([
311 RPMDB_CLEAR
312 RPMDB_INIT
313 cf="${RPMTEST}"/etc/my.conf
314 rm -rf "${cf}" "${cf}".rpm*
315 rm -rf "${TOPDIR}"
316
317 for v in "1.0" "2.0"; do
318     runroot rpmbuild --quiet -bb \
319         --define "ver $v" \
320         --define "filedata foo-$v" \
321           /data/SPECS/configtest.spec
322 done
323
324 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
325 cat "${cf}"
326 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
327 cat "${cf}"
328 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
329 cat "${cf}"
330 ],
331 [0],
332 [foo-1.0
333 foo-2.0
334 foo-2.0
335 ],
336 [])
337 AT_CLEANUP
338
339 # config(noreplace) variants of the same cases.
340 #
341 # ------------------------------
342 # (Build and) upgrade package with config file, no backup here
343 AT_SETUP([upgrade unchanged config(noreplace)])
344 AT_KEYWORDS([install])
345 AT_CHECK([
346 RPMDB_CLEAR
347 RPMDB_INIT
348 cf="${RPMTEST}"/etc/my.conf
349 rm -rf "${cf}" "${cf}".rpm*
350 rm -rf "${TOPDIR}"
351
352 for v in "1.0" "2.0"; do
353     runroot rpmbuild --quiet -bb \
354         --define "ver $v" \
355         --define "filedata foo" \
356         --define "noreplace 1" \
357           /data/SPECS/configtest.spec
358 done
359
360 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
361 cat "${cf}"
362 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
363 cat "${cf}"
364 ],
365 [0],
366 [foo
367 foo
368 ],
369 [])
370 AT_CLEANUP
371
372 #
373 # ------------------------------
374 # Upgrade package with locally modified config file, unchanged in pkg
375 AT_SETUP([upgrade modified config(noreplace)])
376 AT_KEYWORDS([install])
377 AT_CHECK([
378 RPMDB_CLEAR
379 RPMDB_INIT
380 cf="${RPMTEST}"/etc/my.conf
381 rm -rf "${cf}" "${cf}".rpm*
382 rm -rf "${TOPDIR}"
383
384 for v in "1.0" "2.0"; do
385     runroot rpmbuild --quiet -bb \
386         --define "ver $v" \
387         --define "filedata foo" \
388         --define "noreplace 1" \
389           /data/SPECS/configtest.spec
390 done
391
392 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
393 cat "${cf}"
394 echo "otherstuff" > "${cf}"
395 cat "${cf}"
396 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
397 cat "${cf}"
398 ],
399 [0],
400 [foo
401 otherstuff
402 otherstuff
403 ],
404 [])
405 AT_CLEANUP
406
407 # ------------------------------
408 # Upgrade package with unmodified config file, changed in pkg
409 AT_SETUP([upgrade changing config(noreplace)])
410 AT_KEYWORDS([install])
411 AT_CHECK([
412 RPMDB_CLEAR
413 RPMDB_INIT
414 cf="${RPMTEST}"/etc/my.conf
415 rm -rf "${cf}" "${cf}".rpm*
416 rm -rf "${TOPDIR}"
417
418 for v in "1.0" "2.0"; do
419     runroot rpmbuild --quiet -bb \
420         --define "ver $v" \
421         --define "filedata foo-$v" \
422         --define "noreplace 1" \
423           /data/SPECS/configtest.spec
424 done
425
426 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
427 cat "${cf}"
428 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
429 cat "${cf}"
430 ],
431 [0],
432 [foo-1.0
433 foo-2.0
434 ],
435 [])
436 AT_CLEANUP
437
438 # ------------------------------
439 # Upgrade package with locally modified config file, changed in pkg
440 AT_SETUP([upgrade changing, modified config(noreplace) 1])
441 AT_KEYWORDS([install])
442 AT_CHECK([
443 RPMDB_CLEAR
444 RPMDB_INIT
445 cf="${RPMTEST}"/etc/my.conf
446 rm -rf "${cf}" "${cf}".rpm*
447 rm -rf "${TOPDIR}"
448
449 for v in "1.0" "2.0"; do
450     runroot rpmbuild --quiet -bb \
451         --define "ver $v" \
452         --define "filedata foo-$v" \
453         --define "noreplace 1" \
454           /data/SPECS/configtest.spec
455 done
456
457 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
458 cat "${cf}"
459 echo "otherstuff" > "${RPMTEST}"/etc/my.conf
460 cat "${cf}"
461 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
462 cat "${cf}"
463 cat "${cf}.rpmnew"
464 ],
465 [0],
466 [foo-1.0
467 otherstuff
468 otherstuff
469 foo-2.0
470 ],
471 [warning: /etc/my.conf created as /etc/my.conf.rpmnew]
472 )
473 AT_CLEANUP
474
475 # ------------------------------
476 # Modified config file matches the content from new package.
477 AT_SETUP([upgrade changing, modified config(noreplace) 2])
478 AT_KEYWORDS([install])
479 AT_CHECK([
480 RPMDB_CLEAR
481 RPMDB_INIT
482 cf="${RPMTEST}"/etc/my.conf
483 rm -rf "${cf}" "${cf}".rpm*
484 rm -rf "${TOPDIR}"
485
486 for v in "1.0" "2.0"; do
487     runroot rpmbuild --quiet -bb \
488         --define "ver $v" \
489         --define "filedata foo-$v" \
490         --define "noreplace 1" \
491           /data/SPECS/configtest.spec
492 done
493
494 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
495 cat "${cf}"
496 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
497 cat "${cf}"
498 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
499 cat "${cf}"
500 ],
501 [0],
502 [foo-1.0
503 foo-2.0
504 foo-2.0
505 ],
506 [])
507 AT_CLEANUP
508
509 # Shared config file variants of the same cases
510 # ------------------------------
511 # (Build and) upgrade package with config file, no backup here
512 AT_SETUP([upgrade unchanged shared config])
513 AT_KEYWORDS([install])
514 AT_CHECK([
515 RPMDB_CLEAR
516 RPMDB_INIT
517 cf="${RPMTEST}"/etc/my.conf
518 rm -rf "${cf}" "${cf}".rpm*
519 rm -rf "${TOPDIR}"
520
521 for s in "A" "B"; do
522     for v in "1.0" "2.0"; do
523         runroot rpmbuild --quiet -bb \
524             --define "sub $s" \
525             --define "ver $v" \
526             --define "filedata foo" \
527               /data/SPECS/configtest.spec
528     done
529 done
530
531 runroot rpm -U \
532     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
533     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
534 cat "${cf}"
535 runroot rpm -U \
536     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
537     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
538 cat "${cf}"
539 ],
540 [0],
541 [foo
542 foo
543 ],
544 [])
545
546 AT_CLEANUP
547 #
548 # ------------------------------
549 # Upgrade package with locally modified config file, unchanged in pkg
550 AT_SETUP([upgrade modified shared config])
551 AT_KEYWORDS([install])
552 AT_CHECK([
553 RPMDB_CLEAR
554 RPMDB_INIT
555 cf="${RPMTEST}"/etc/my.conf
556 rm -rf "${cf}" "${cf}".rpm*
557 rm -rf "${TOPDIR}"
558
559 for s in "A" "B"; do
560     for v in "1.0" "2.0"; do
561         runroot rpmbuild --quiet -bb \
562             --define "sub $s" \
563             --define "ver $v" \
564             --define "filedata foo" \
565               /data/SPECS/configtest.spec
566     done
567 done
568
569 runroot rpm -U \
570     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
571     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
572 cat "${cf}"
573 echo "otherstuff" > "${cf}"
574 cat "${cf}"
575 runroot rpm -U \
576     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
577     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
578 cat "${cf}"
579 ],
580 [0],
581 [foo
582 otherstuff
583 otherstuff
584 ],
585 [])
586 AT_CLEANUP
587
588 # ------------------------------
589 # Upgrade package with unmodified config file, changed in pkg
590 AT_SETUP([upgrade changing shared config])
591 AT_KEYWORDS([install])
592 AT_CHECK([
593 RPMDB_CLEAR
594 RPMDB_INIT
595 cf="${RPMTEST}"/etc/my.conf
596 rm -rf "${cf}" "${cf}".rpm*
597 rm -rf "${TOPDIR}"
598
599 for s in "A" "B"; do
600     for v in "1.0" "2.0"; do
601         runroot rpmbuild --quiet -bb \
602             --define "sub $s" \
603             --define "ver $v" \
604             --define "filedata foo-$v" \
605               /data/SPECS/configtest.spec
606     done
607 done
608
609 runroot rpm -U \
610     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
611     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
612 cat "${cf}"
613 runroot rpm -U \
614     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
615     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
616 cat "${cf}"
617 ],
618 [0],
619 [foo-1.0
620 foo-2.0
621 ],
622 [])
623 AT_CLEANUP
624
625 # ------------------------------
626 # Upgrade package with locally modified config file, changed in pkg
627 AT_SETUP([upgrade changing, modified shared config 1])
628 AT_KEYWORDS([install])
629 AT_CHECK([
630 RPMDB_CLEAR
631 RPMDB_INIT
632 cf="${RPMTEST}"/etc/my.conf
633 rm -rf "${cf}" "${cf}".rpm*
634 rm -rf "${TOPDIR}"
635
636 for s in "A" "B"; do
637     for v in "1.0" "2.0"; do
638         runroot rpmbuild --quiet -bb \
639             --define "sub $s" \
640             --define "ver $v" \
641             --define "filedata foo-$v" \
642               /data/SPECS/configtest.spec
643     done
644 done
645
646 runroot rpm -U \
647     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
648     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
649 cat "${cf}"
650 echo "otherstuff" > "${RPMTEST}"/etc/my.conf
651 cat "${cf}"
652 runroot rpm -U \
653     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
654     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
655 cat "${cf}"
656 cat "${cf}.rpmsave"
657 ],
658 [0],
659 [foo-1.0
660 otherstuff
661 foo-2.0
662 otherstuff
663 ],
664 [warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
665 )
666 AT_CLEANUP
667
668 # ------------------------------
669 # Modified config file matches the content from new package.
670 AT_SETUP([upgrade changing, modified shared config 2])
671 AT_KEYWORDS([install])
672 AT_CHECK([
673 RPMDB_CLEAR
674 RPMDB_INIT
675 cf="${RPMTEST}"/etc/my.conf
676 rm -rf "${cf}" "${cf}".rpm*
677 rm -rf "${TOPDIR}"
678
679 for s in "A" "B"; do
680     for v in "1.0" "2.0"; do
681         runroot rpmbuild --quiet -bb \
682             --define "sub $s" \
683             --define "ver $v" \
684             --define "filedata foo-$v" \
685               /data/SPECS/configtest.spec
686     done
687 done
688
689 runroot rpm -U \
690     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
691     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
692 cat "${cf}"
693 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
694 cat "${cf}"
695 runroot rpm -U \
696     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
697     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
698 cat "${cf}"
699 ],
700 [0],
701 [foo-1.0
702 foo-2.0
703 foo-2.0
704 ],
705 [])
706 AT_CLEANUP
707
708 # Shared config(noreplace) variants of the more interesting cases
709 # ------------------------------
710 # Upgrade package with locally modified config file, changed in pkg.
711 AT_SETUP([upgrade changing, modified shared config(noreplace) 1])
712 AT_KEYWORDS([install])
713 AT_CHECK([
714 RPMDB_CLEAR
715 RPMDB_INIT
716 cf="${RPMTEST}"/etc/my.conf
717 rm -rf "${cf}" "${cf}".rpm*
718 rm -rf "${TOPDIR}"
719
720 for s in "A" "B"; do
721     for v in "1.0" "2.0"; do
722         runroot rpmbuild --quiet -bb \
723             --define "sub $s" \
724             --define "ver $v" \
725             --define "filedata foo-$v" \
726             --define "noreplace 1" \
727               /data/SPECS/configtest.spec
728     done
729 done
730
731 runroot rpm -U \
732     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
733     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
734 cat "${cf}"
735 echo "otherstuff" > "${RPMTEST}"/etc/my.conf
736 cat "${cf}"
737 runroot rpm -U \
738     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
739     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
740 cat "${cf}"
741 cat "${cf}.rpmnew"
742 ],
743 [0],
744 [foo-1.0
745 otherstuff
746 otherstuff
747 foo-2.0
748 ],
749 [warning: /etc/my.conf created as /etc/my.conf.rpmnew]
750 )
751 AT_CLEANUP
752
753 # ------------------------------
754 # Modified config file matches the content from new package.
755 AT_SETUP([upgrade changing, modified shared config(noreplace) 2])
756 AT_KEYWORDS([install])
757 AT_CHECK([
758 RPMDB_CLEAR
759 RPMDB_INIT
760 cf="${RPMTEST}"/etc/my.conf
761 rm -rf "${cf}" "${cf}".rpm*
762 rm -rf "${TOPDIR}"
763
764 for s in "A" "B"; do
765     for v in "1.0" "2.0"; do
766         runroot rpmbuild --quiet -bb \
767             --define "sub $s" \
768             --define "ver $v" \
769             --define "filedata foo-$v" \
770             --define "noreplace 1" \
771               /data/SPECS/configtest.spec
772     done
773 done
774
775 runroot rpm -U \
776     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
777     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
778 cat "${cf}"
779 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
780 cat "${cf}"
781 runroot rpm -U \
782     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
783     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
784 cat "${cf}"
785 ],
786 [0],
787 [foo-1.0
788 foo-2.0
789 foo-2.0
790 ],
791 [])
792 AT_CLEANUP
793
794 ---------
795 # Test pre-existing and post-install config ghost survival and erasure
796 AT_SETUP([install/upgrade/erase ghost config])
797 AT_KEYWORDS([install])
798 AT_CHECK([
799 RPMDB_CLEAR
800 RPMDB_INIT
801 cf="${RPMTEST}"/etc/my.conf
802 rm -rf "${cf}" "${cf}".rpm*
803 rm -rf "${TOPDIR}"
804
805 for v in 1.0 2.0; do
806     runroot rpmbuild --quiet -bb \
807         --define "ver ${v}" \
808         --define "filetype file" \
809         --define "filedata buster" \
810         --define "fileattr %ghost" \
811           /data/SPECS/configtest.spec
812 done
813
814 # pre-existing config, install, erase
815 test ! -f "${cf}" && echo OK1
816 echo "keaton" > "${cf}"
817 cat "${cf}"
818 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
819 cat "${cf}"
820 runroot rpm -e configtest
821 cat "${cf}"
822 rm -f "${cf}"
823
824 # post-install config, upgrade, erase
825 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
826 test ! -f "${cf}" && echo OK2
827 echo "buster" > "${cf}"
828 cat "${cf}"
829 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
830 cat "${cf}"
831 runroot rpm -e configtest
832 cat "${cf}"
833 ],
834 [],
835 [OK1
836 keaton
837 keaton
838 keaton
839 OK2
840 buster
841 buster
842 buster
843 ],
844 [])
845 AT_CLEANUP