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