Dont create redundant %config backups when on-disk content is same as new
[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 cat "${cf}.rpmsave"
123 ],
124 [0],
125 [foo-1.0
126 otherstuff
127 foo-2.0
128 otherstuff
129 ],
130 [warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
131 )
132 AT_CLEANUP
133
134 # ------------------------------
135 # Modified config file matches the content from new package.
136 AT_SETUP([upgrade changing, modified config 2])
137 AT_KEYWORDS([install])
138 AT_CHECK([
139 RPMDB_CLEAR
140 RPMDB_INIT
141 cf="${RPMTEST}"/etc/my.conf
142 rm -f "${cf}" "${cf}".rpm*
143 rm -rf "${TOPDIR}"
144
145 for v in "1.0" "2.0"; do
146     runroot rpmbuild --quiet -bb \
147         --define "ver $v" \
148         --define "filedata foo-$v" \
149           /data/SPECS/configtest.spec
150 done
151
152 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
153 cat "${cf}"
154 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
155 cat "${cf}"
156 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
157 cat "${cf}"
158 ],
159 [0],
160 [foo-1.0
161 foo-2.0
162 foo-2.0
163 ],
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 cat "${cf}.rpmnew"
292 ],
293 [0],
294 [foo-1.0
295 otherstuff
296 otherstuff
297 foo-2.0
298 ],
299 [warning: /etc/my.conf created as /etc/my.conf.rpmnew]
300 )
301 AT_CLEANUP
302
303 # ------------------------------
304 # Modified config file matches the content from new package.
305 AT_SETUP([upgrade changing, modified config(noreplace) 2])
306 AT_KEYWORDS([install])
307 AT_CHECK([
308 RPMDB_CLEAR
309 RPMDB_INIT
310 cf="${RPMTEST}"/etc/my.conf
311 rm -f "${cf}" "${cf}".rpm*
312 rm -rf "${TOPDIR}"
313
314 for v in "1.0" "2.0"; do
315     runroot rpmbuild --quiet -bb \
316         --define "ver $v" \
317         --define "filedata foo-$v" \
318         --define "noreplace 1" \
319           /data/SPECS/configtest.spec
320 done
321
322 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
323 cat "${cf}"
324 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
325 cat "${cf}"
326 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
327 cat "${cf}"
328 ],
329 [0],
330 [foo-1.0
331 foo-2.0
332 foo-2.0
333 ],
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 cat "${cf}.rpmsave"
485 ],
486 [0],
487 [foo-1.0
488 otherstuff
489 foo-2.0
490 otherstuff
491 ],
492 [warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
493 )
494 AT_CLEANUP
495
496 # ------------------------------
497 # Modified config file matches the content from new package.
498 AT_SETUP([upgrade changing, modified shared config 2])
499 AT_KEYWORDS([install])
500 AT_CHECK([
501 RPMDB_CLEAR
502 RPMDB_INIT
503 cf="${RPMTEST}"/etc/my.conf
504 rm -f "${cf}" "${cf}".rpm*
505 rm -rf "${TOPDIR}"
506
507 for s in "A" "B"; do
508     for v in "1.0" "2.0"; do
509         runroot rpmbuild --quiet -bb \
510             --define "sub $s" \
511             --define "ver $v" \
512             --define "filedata foo-$v" \
513               /data/SPECS/configtest.spec
514     done
515 done
516
517 runroot rpm -U \
518     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
519     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
520 cat "${cf}"
521 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
522 cat "${cf}"
523 runroot rpm -U \
524     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
525     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
526 cat "${cf}"
527 ],
528 [0],
529 [foo-1.0
530 foo-2.0
531 foo-2.0
532 ],
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 AT_SETUP([upgrade changing, modified shared config(noreplace) 1])
540 AT_KEYWORDS([install])
541 AT_CHECK([
542 RPMDB_CLEAR
543 RPMDB_INIT
544 cf="${RPMTEST}"/etc/my.conf
545 rm -f "${cf}" "${cf}".rpm*
546 rm -rf "${TOPDIR}"
547
548 for s in "A" "B"; do
549     for v in "1.0" "2.0"; do
550         runroot rpmbuild --quiet -bb \
551             --define "sub $s" \
552             --define "ver $v" \
553             --define "filedata foo-$v" \
554             --define "noreplace 1" \
555               /data/SPECS/configtest.spec
556     done
557 done
558
559 runroot rpm -U \
560     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
561     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
562 cat "${cf}"
563 echo "otherstuff" > "${RPMTEST}"/etc/my.conf
564 cat "${cf}"
565 runroot rpm -U \
566     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
567     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
568 cat "${cf}"
569 cat "${cf}.rpmnew"
570 ],
571 [0],
572 [foo-1.0
573 otherstuff
574 otherstuff
575 foo-2.0
576 ],
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.
583 AT_SETUP([upgrade changing, modified shared config(noreplace) 2])
584 AT_KEYWORDS([install])
585 AT_CHECK([
586 RPMDB_CLEAR
587 RPMDB_INIT
588 cf="${RPMTEST}"/etc/my.conf
589 rm -f "${cf}" "${cf}".rpm*
590 rm -rf "${TOPDIR}"
591
592 for s in "A" "B"; do
593     for v in "1.0" "2.0"; do
594         runroot rpmbuild --quiet -bb \
595             --define "sub $s" \
596             --define "ver $v" \
597             --define "filedata foo-$v" \
598             --define "noreplace 1" \
599               /data/SPECS/configtest.spec
600     done
601 done
602
603 runroot rpm -U \
604     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
605     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
606 cat "${cf}"
607 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
608 cat "${cf}"
609 runroot rpm -U \
610     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
611     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
612 cat "${cf}"
613 ],
614 [0],
615 [foo-1.0
616 foo-2.0
617 foo-2.0
618 ],
619 [])
620 AT_CLEANUP