1 # rpmvercmp.at: rpm config file behavior tests
3 AT_BANNER([RPM config file behavior])
5 # Install over existing config file
6 AT_SETUP([install config on existiting file])
11 cf="${RPMTEST}"/etc/my.conf
12 rm -rf "${cf}" "${cf}".rpm*
15 runroot rpmbuild --quiet -bb \
17 --define "filedata foo" \
18 /data/SPECS/configtest.spec
20 echo "otherstuff" > "${cf}"
21 runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm
23 runroot rpm -e configtest
30 [warning: /etc/my.conf saved as /etc/my.conf.rpmorig]
34 # Install over existing config file
35 AT_SETUP([install config(noreplace) on existing file])
36 AT_KEYWORDS([install])
40 cf="${RPMTEST}"/etc/my.conf
41 rm -rf "${cf}" "${cf}".rpm*
44 runroot rpmbuild --quiet -bb \
46 --define "filedata foo" \
47 --define "noreplace 1" \
48 /data/SPECS/configtest.spec
50 echo "otherstuff" > "${cf}"
51 runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm
54 runroot rpm -e configtest
64 [warning: /etc/my.conf created as /etc/my.conf.rpmnew
65 warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
69 # Install over existing identical config file, no backup needed
70 AT_SETUP([install config on existiting identical file])
71 AT_KEYWORDS([install])
75 cf="${RPMTEST}"/etc/my.conf
76 rm -rf "${cf}" "${cf}".rpm*
79 runroot rpmbuild --quiet -bb \
81 --define "filedata foo" \
82 /data/SPECS/configtest.spec
85 runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm
87 runroot rpm -e configtest
96 # Erase unmodified config file, no backup here
97 AT_SETUP([erase unchanged config])
98 AT_KEYWORDS([install])
102 cf="${RPMTEST}"/etc/my.conf
103 rm -rf "${cf}" "${cf}".rpm*
106 runroot rpmbuild --quiet -bb \
108 --define "filedata foo" \
109 /data/SPECS/configtest.spec
111 runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm
113 runroot rpm -e configtest
122 # Erase modified config file
123 AT_SETUP([erase changed config])
124 AT_KEYWORDS([install])
128 cf="${RPMTEST}"/etc/my.conf
129 rm -rf "${cf}" "${cf}".rpm*
132 runroot rpmbuild --quiet -bb \
134 --define "filedata foo" \
135 /data/SPECS/configtest.spec
137 runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm
139 echo "otherstuff" > "${cf}"
140 runroot rpm -e configtest
148 [warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
152 # Erase modified config(noreplace) file
153 AT_SETUP([erase changed config(noreplace)])
154 AT_KEYWORDS([install])
158 cf="${RPMTEST}"/etc/my.conf
159 rm -rf "${cf}" "${cf}".rpm*
162 runroot rpmbuild --quiet -bb \
164 --define "filedata foo" \
165 --define "noreplace 1" \
166 /data/SPECS/configtest.spec
168 runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm
170 echo "otherstuff" > "${cf}"
171 runroot rpm -e configtest
179 [warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
183 # ------------------------------
184 # (Build and) upgrade package with config file, no backup here
185 AT_SETUP([upgrade unchanged config])
186 AT_KEYWORDS([install])
190 cf="${RPMTEST}"/etc/my.conf
191 rm -rf "${cf}" "${cf}".rpm*
194 for v in "1.0" "2.0"; do
195 runroot rpmbuild --quiet -bb \
197 --define "filedata foo" \
198 /data/SPECS/configtest.spec
201 runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm
203 runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm
213 # ------------------------------
214 # (Build and) upgrade package with config file, no backup here
215 AT_SETUP([upgrade unchanged config - touching test])
216 AT_KEYWORDS([install])
220 cf="${RPMTEST}"/etc/my.conf
221 rm -rf "${cf}" "${cf}".rpm*
224 for v in "1.0" "2.0"; do
225 runroot rpmbuild --quiet -bb \
227 --define "filedata foo" \
228 /data/SPECS/configtest.spec
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
241 # ------------------------------
242 # Upgrade package with locally modified config file, unchanged in pkg
243 AT_SETUP([upgrade modified config])
244 AT_KEYWORDS([install])
248 cf="${RPMTEST}"/etc/my.conf
249 rm -rf "${cf}" "${cf}".rpm*
252 for v in "1.0" "2.0"; do
253 runroot rpmbuild --quiet -bb \
255 --define "filedata foo" \
256 /data/SPECS/configtest.spec
259 runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm
261 echo "otherstuff" > "${cf}"
263 runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm
274 # ------------------------------
275 # Upgrade package with unmodified config file, changed in pkg
276 AT_SETUP([upgrade changing config])
277 AT_KEYWORDS([install])
281 cf="${RPMTEST}"/etc/my.conf
282 rm -rf "${cf}" "${cf}".rpm*
285 for v in "1.0" "2.0"; do
286 runroot rpmbuild --quiet -bb \
288 --define "filedata foo-$v" \
289 /data/SPECS/configtest.spec
292 runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm
294 runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm
304 # ------------------------------
305 # Upgrade package with locally modified config file, changed in pkg
306 AT_SETUP([upgrade changing, modified config 1])
307 AT_KEYWORDS([install])
311 cf="${RPMTEST}"/etc/my.conf
312 rm -rf "${cf}" "${cf}".rpm*
315 for v in "1.0" "2.0"; do
316 runroot rpmbuild --quiet -bb \
318 --define "filedata foo-$v" \
319 /data/SPECS/configtest.spec
322 runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm
324 echo "otherstuff" > "${RPMTEST}"/etc/my.conf
326 runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm
336 [warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
340 # ------------------------------
341 # Modified config file matches the content from new package.
342 AT_SETUP([upgrade changing, modified config 2])
343 AT_KEYWORDS([install])
347 cf="${RPMTEST}"/etc/my.conf
348 rm -rf "${cf}" "${cf}".rpm*
351 for v in "1.0" "2.0"; do
352 runroot rpmbuild --quiet -bb \
354 --define "filedata foo-$v" \
355 /data/SPECS/configtest.spec
358 runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm
360 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
362 runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm
373 # config(noreplace) variants of the same cases.
375 # ------------------------------
376 # (Build and) upgrade package with config file, no backup here
377 AT_SETUP([upgrade unchanged config(noreplace)])
378 AT_KEYWORDS([install])
382 cf="${RPMTEST}"/etc/my.conf
383 rm -rf "${cf}" "${cf}".rpm*
386 for v in "1.0" "2.0"; do
387 runroot rpmbuild --quiet -bb \
389 --define "filedata foo" \
390 --define "noreplace 1" \
391 /data/SPECS/configtest.spec
394 runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm
396 runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm
407 # ------------------------------
408 # Upgrade package with locally modified config file, unchanged in pkg
409 AT_SETUP([upgrade modified config(noreplace)])
410 AT_KEYWORDS([install])
414 cf="${RPMTEST}"/etc/my.conf
415 rm -rf "${cf}" "${cf}".rpm*
418 for v in "1.0" "2.0"; do
419 runroot rpmbuild --quiet -bb \
421 --define "filedata foo" \
422 --define "noreplace 1" \
423 /data/SPECS/configtest.spec
426 runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm
428 echo "otherstuff" > "${cf}"
430 runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm
441 # ------------------------------
442 # Upgrade package with unmodified config file, changed in pkg
443 AT_SETUP([upgrade changing config(noreplace)])
444 AT_KEYWORDS([install])
448 cf="${RPMTEST}"/etc/my.conf
449 rm -rf "${cf}" "${cf}".rpm*
452 for v in "1.0" "2.0"; do
453 runroot rpmbuild --quiet -bb \
455 --define "filedata foo-$v" \
456 --define "noreplace 1" \
457 /data/SPECS/configtest.spec
460 runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm
462 runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm
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])
479 cf="${RPMTEST}"/etc/my.conf
480 rm -rf "${cf}" "${cf}".rpm*
483 for v in "1.0" "2.0"; do
484 runroot rpmbuild --quiet -bb \
486 --define "filedata foo-$v" \
487 --define "noreplace 1" \
488 /data/SPECS/configtest.spec
491 runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm
493 echo "otherstuff" > "${RPMTEST}"/etc/my.conf
495 runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm
505 [warning: /etc/my.conf created as /etc/my.conf.rpmnew]
509 # ------------------------------
510 # Modified config file matches the content from new package.
511 AT_SETUP([upgrade changing, modified config(noreplace) 2])
512 AT_KEYWORDS([install])
516 cf="${RPMTEST}"/etc/my.conf
517 rm -rf "${cf}" "${cf}".rpm*
520 for v in "1.0" "2.0"; do
521 runroot rpmbuild --quiet -bb \
523 --define "filedata foo-$v" \
524 --define "noreplace 1" \
525 /data/SPECS/configtest.spec
528 runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm
530 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
532 runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm
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])
551 cf="${RPMTEST}"/etc/my.conf
552 rm -rf "${cf}" "${cf}".rpm*
556 for v in "1.0" "2.0"; do
557 runroot rpmbuild --quiet -bb \
560 --define "filedata foo" \
561 /data/SPECS/configtest.spec
566 /build/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
567 /build/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
570 /build/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
571 /build/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
582 # ------------------------------
583 # Upgrade package with locally modified config file, unchanged in pkg
584 AT_SETUP([upgrade modified shared config])
585 AT_KEYWORDS([install])
589 cf="${RPMTEST}"/etc/my.conf
590 rm -rf "${cf}" "${cf}".rpm*
594 for v in "1.0" "2.0"; do
595 runroot rpmbuild --quiet -bb \
598 --define "filedata foo" \
599 /data/SPECS/configtest.spec
604 /build/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
605 /build/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
607 echo "otherstuff" > "${cf}"
610 /build/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
611 /build/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
622 # ------------------------------
623 # Upgrade package with unmodified config file, changed in pkg
624 AT_SETUP([upgrade changing shared config])
625 AT_KEYWORDS([install])
629 cf="${RPMTEST}"/etc/my.conf
630 rm -rf "${cf}" "${cf}".rpm*
634 for v in "1.0" "2.0"; do
635 runroot rpmbuild --quiet -bb \
638 --define "filedata foo-$v" \
639 /data/SPECS/configtest.spec
644 /build/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
645 /build/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
648 /build/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
649 /build/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
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])
666 cf="${RPMTEST}"/etc/my.conf
667 rm -rf "${cf}" "${cf}".rpm*
671 for v in "1.0" "2.0"; do
672 runroot rpmbuild --quiet -bb \
675 --define "filedata foo-$v" \
676 /data/SPECS/configtest.spec
681 /build/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
682 /build/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
684 echo "otherstuff" > "${RPMTEST}"/etc/my.conf
687 /build/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
688 /build/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
698 [warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
702 # ------------------------------
703 # Modified config file matches the content from new package.
704 AT_SETUP([upgrade changing, modified shared config 2])
705 AT_KEYWORDS([install])
709 cf="${RPMTEST}"/etc/my.conf
710 rm -rf "${cf}" "${cf}".rpm*
714 for v in "1.0" "2.0"; do
715 runroot rpmbuild --quiet -bb \
718 --define "filedata foo-$v" \
719 /data/SPECS/configtest.spec
724 /build/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
725 /build/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
727 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
730 /build/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
731 /build/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
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])
750 cf="${RPMTEST}"/etc/my.conf
751 rm -rf "${cf}" "${cf}".rpm*
755 for v in "1.0" "2.0"; do
756 runroot rpmbuild --quiet -bb \
759 --define "filedata foo-$v" \
760 --define "noreplace 1" \
761 /data/SPECS/configtest.spec
766 /build/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
767 /build/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
769 echo "otherstuff" > "${RPMTEST}"/etc/my.conf
772 /build/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
773 /build/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
783 [warning: /etc/my.conf created as /etc/my.conf.rpmnew]
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])
794 cf="${RPMTEST}"/etc/my.conf
795 rm -rf "${cf}" "${cf}".rpm*
799 for v in "1.0" "2.0"; do
800 runroot rpmbuild --quiet -bb \
803 --define "filedata foo-$v" \
804 --define "noreplace 1" \
805 /data/SPECS/configtest.spec
810 /build/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
811 /build/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
813 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
816 /build/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
817 /build/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
829 # Test pre-existing and post-install config ghost survival and erasure
830 AT_SETUP([install/upgrade/erase ghost config])
831 AT_KEYWORDS([install])
835 cf="${RPMTEST}"/etc/my.conf
836 rm -rf "${cf}" "${cf}".rpm*
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
848 # pre-existing config, install, erase
849 test ! -f "${cf}" && echo OK1
850 echo "keaton" > "${cf}"
852 runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm
854 runroot rpm -e configtest
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}"
863 runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm
865 runroot rpm -e configtest