Dont create %config backups on skipped files
[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. Creating a 
136 # backup makes no sense in this case, but that's what currently happens.
137 AT_SETUP([upgrade changing, modified config 2])
138 AT_KEYWORDS([install])
139 AT_CHECK([
140 RPMDB_CLEAR
141 RPMDB_INIT
142 cf="${RPMTEST}"/etc/my.conf
143 rm -f "${cf}" "${cf}".rpm*
144 rm -rf "${TOPDIR}"
145
146 for v in "1.0" "2.0"; do
147     runroot rpmbuild --quiet -bb \
148         --define "ver $v" \
149         --define "filedata foo-$v" \
150           /data/SPECS/configtest.spec
151 done
152
153 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
154 cat "${cf}"
155 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
156 cat "${cf}"
157 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
158 cat "${cf}"
159 ],
160 [0],
161 [foo-1.0
162 foo-2.0
163 foo-2.0
164 ],
165 [warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
166 )
167 AT_CLEANUP
168
169 # config(noreplace) variants of the same cases.
170 #
171 # ------------------------------
172 # (Build and) upgrade package with config file, no backup here
173 AT_SETUP([upgrade unchanged config(noreplace)])
174 AT_KEYWORDS([install])
175 AT_CHECK([
176 RPMDB_CLEAR
177 RPMDB_INIT
178 cf="${RPMTEST}"/etc/my.conf
179 rm -f "${cf}" "${cf}".rpm*
180 rm -rf "${TOPDIR}"
181
182 for v in "1.0" "2.0"; do
183     runroot rpmbuild --quiet -bb \
184         --define "ver $v" \
185         --define "filedata foo" \
186         --define "noreplace 1" \
187           /data/SPECS/configtest.spec
188 done
189
190 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
191 cat "${cf}"
192 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
193 cat "${cf}"
194 ],
195 [0],
196 [foo
197 foo
198 ],
199 [])
200 AT_CLEANUP
201
202 #
203 # ------------------------------
204 # Upgrade package with locally modified config file, unchanged in pkg
205 AT_SETUP([upgrade modified config(noreplace)])
206 AT_KEYWORDS([install])
207 AT_CHECK([
208 RPMDB_CLEAR
209 RPMDB_INIT
210 cf="${RPMTEST}"/etc/my.conf
211 rm -f "${cf}" "${cf}".rpm*
212 rm -rf "${TOPDIR}"
213
214 for v in "1.0" "2.0"; do
215     runroot rpmbuild --quiet -bb \
216         --define "ver $v" \
217         --define "filedata foo" \
218         --define "noreplace 1" \
219           /data/SPECS/configtest.spec
220 done
221
222 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
223 cat "${cf}"
224 echo "otherstuff" > "${cf}"
225 cat "${cf}"
226 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
227 cat "${cf}"
228 ],
229 [0],
230 [foo
231 otherstuff
232 otherstuff
233 ],
234 [])
235 AT_CLEANUP
236
237 # ------------------------------
238 # Upgrade package with unmodified config file, changed in pkg
239 AT_SETUP([upgrade changing config(noreplace)])
240 AT_KEYWORDS([install])
241 AT_CHECK([
242 RPMDB_CLEAR
243 RPMDB_INIT
244 cf="${RPMTEST}"/etc/my.conf
245 rm -f "${cf}" "${cf}".rpm*
246 rm -rf "${TOPDIR}"
247
248 for v in "1.0" "2.0"; do
249     runroot rpmbuild --quiet -bb \
250         --define "ver $v" \
251         --define "filedata foo-$v" \
252         --define "noreplace 1" \
253           /data/SPECS/configtest.spec
254 done
255
256 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
257 cat "${cf}"
258 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
259 cat "${cf}"
260 ],
261 [0],
262 [foo-1.0
263 foo-2.0
264 ],
265 [])
266 AT_CLEANUP
267
268 # ------------------------------
269 # Upgrade package with locally modified config file, changed in pkg
270 AT_SETUP([upgrade changing, modified config(noreplace) 1])
271 AT_KEYWORDS([install])
272 AT_CHECK([
273 RPMDB_CLEAR
274 RPMDB_INIT
275 cf="${RPMTEST}"/etc/my.conf
276 rm -f "${cf}" "${cf}".rpm*
277 rm -rf "${TOPDIR}"
278
279 for v in "1.0" "2.0"; do
280     runroot rpmbuild --quiet -bb \
281         --define "ver $v" \
282         --define "filedata foo-$v" \
283         --define "noreplace 1" \
284           /data/SPECS/configtest.spec
285 done
286
287 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
288 cat "${cf}"
289 echo "otherstuff" > "${RPMTEST}"/etc/my.conf
290 cat "${cf}"
291 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
292 cat "${cf}"
293 cat "${cf}.rpmnew"
294 ],
295 [0],
296 [foo-1.0
297 otherstuff
298 otherstuff
299 foo-2.0
300 ],
301 [warning: /etc/my.conf created as /etc/my.conf.rpmnew]
302 )
303 AT_CLEANUP
304
305 # ------------------------------
306 # Modified config file matches the content from new package. Creating a 
307 # backup makes no sense in this case, but that's what currently happens.
308 AT_SETUP([upgrade changing, modified config(noreplace) 2])
309 AT_KEYWORDS([install])
310 AT_CHECK([
311 RPMDB_CLEAR
312 RPMDB_INIT
313 cf="${RPMTEST}"/etc/my.conf
314 rm -f "${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         --define "noreplace 1" \
322           /data/SPECS/configtest.spec
323 done
324
325 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
326 cat "${cf}"
327 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
328 cat "${cf}"
329 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
330 cat "${cf}"
331 ],
332 [0],
333 [foo-1.0
334 foo-2.0
335 foo-2.0
336 ],
337 [warning: /etc/my.conf created as /etc/my.conf.rpmnew]
338 )
339 AT_CLEANUP
340
341 # Shared config file variants of the same cases
342 # ------------------------------
343 # (Build and) upgrade package with config file, no backup here
344 AT_SETUP([upgrade unchanged shared config])
345 AT_KEYWORDS([install])
346 AT_CHECK([
347 RPMDB_CLEAR
348 RPMDB_INIT
349 cf="${RPMTEST}"/etc/my.conf
350 rm -f "${cf}" "${cf}".rpm*
351 rm -rf "${TOPDIR}"
352
353 for s in "A" "B"; do
354     for v in "1.0" "2.0"; do
355         runroot rpmbuild --quiet -bb \
356             --define "sub $s" \
357             --define "ver $v" \
358             --define "filedata foo" \
359               /data/SPECS/configtest.spec
360     done
361 done
362
363 runroot rpm -U \
364     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
365     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
366 cat "${cf}"
367 runroot rpm -U \
368     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
369     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
370 cat "${cf}"
371 ],
372 [0],
373 [foo
374 foo
375 ],
376 [])
377
378 AT_CLEANUP
379 #
380 # ------------------------------
381 # Upgrade package with locally modified config file, unchanged in pkg
382 AT_SETUP([upgrade modified shared config])
383 AT_KEYWORDS([install])
384 AT_CHECK([
385 RPMDB_CLEAR
386 RPMDB_INIT
387 cf="${RPMTEST}"/etc/my.conf
388 rm -f "${cf}" "${cf}".rpm*
389 rm -rf "${TOPDIR}"
390
391 for s in "A" "B"; do
392     for v in "1.0" "2.0"; do
393         runroot rpmbuild --quiet -bb \
394             --define "sub $s" \
395             --define "ver $v" \
396             --define "filedata foo" \
397               /data/SPECS/configtest.spec
398     done
399 done
400
401 runroot rpm -U \
402     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
403     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
404 cat "${cf}"
405 echo "otherstuff" > "${cf}"
406 cat "${cf}"
407 runroot rpm -U \
408     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
409     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
410 cat "${cf}"
411 ],
412 [0],
413 [foo
414 otherstuff
415 otherstuff
416 ],
417 [])
418 AT_CLEANUP
419
420 # ------------------------------
421 # Upgrade package with unmodified config file, changed in pkg
422 AT_SETUP([upgrade changing shared config])
423 AT_KEYWORDS([install])
424 AT_CHECK([
425 RPMDB_CLEAR
426 RPMDB_INIT
427 cf="${RPMTEST}"/etc/my.conf
428 rm -f "${cf}" "${cf}".rpm*
429 rm -rf "${TOPDIR}"
430
431 for s in "A" "B"; do
432     for v in "1.0" "2.0"; do
433         runroot rpmbuild --quiet -bb \
434             --define "sub $s" \
435             --define "ver $v" \
436             --define "filedata foo-$v" \
437               /data/SPECS/configtest.spec
438     done
439 done
440
441 runroot rpm -U \
442     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
443     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
444 cat "${cf}"
445 runroot rpm -U \
446     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
447     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
448 cat "${cf}"
449 ],
450 [0],
451 [foo-1.0
452 foo-2.0
453 ],
454 [])
455 AT_CLEANUP
456
457 # ------------------------------
458 # Upgrade package with locally modified config file, changed in pkg
459 AT_SETUP([upgrade changing, modified shared config 1])
460 AT_KEYWORDS([install])
461 AT_CHECK([
462 RPMDB_CLEAR
463 RPMDB_INIT
464 cf="${RPMTEST}"/etc/my.conf
465 rm -f "${cf}" "${cf}".rpm*
466 rm -rf "${TOPDIR}"
467
468 for s in "A" "B"; do
469     for v in "1.0" "2.0"; do
470         runroot rpmbuild --quiet -bb \
471             --define "sub $s" \
472             --define "ver $v" \
473             --define "filedata foo-$v" \
474               /data/SPECS/configtest.spec
475     done
476 done
477
478 runroot rpm -U \
479     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
480     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
481 cat "${cf}"
482 echo "otherstuff" > "${RPMTEST}"/etc/my.conf
483 cat "${cf}"
484 runroot rpm -U \
485     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
486     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
487 cat "${cf}"
488 cat "${cf}.rpmsave"
489 ],
490 [0],
491 [foo-1.0
492 otherstuff
493 foo-2.0
494 otherstuff
495 ],
496 [warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
497 )
498 AT_CLEANUP
499
500 # ------------------------------
501 # Modified config file matches the content from new package. Creating a 
502 # backup makes no sense in this case, but that's what currently happens.
503 AT_SETUP([upgrade changing, modified shared config 2])
504 AT_KEYWORDS([install])
505 AT_CHECK([
506 RPMDB_CLEAR
507 RPMDB_INIT
508 cf="${RPMTEST}"/etc/my.conf
509 rm -f "${cf}" "${cf}".rpm*
510 rm -rf "${TOPDIR}"
511
512 for s in "A" "B"; do
513     for v in "1.0" "2.0"; do
514         runroot rpmbuild --quiet -bb \
515             --define "sub $s" \
516             --define "ver $v" \
517             --define "filedata foo-$v" \
518               /data/SPECS/configtest.spec
519     done
520 done
521
522 runroot rpm -U \
523     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
524     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
525 cat "${cf}"
526 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
527 cat "${cf}"
528 runroot rpm -U \
529     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
530     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
531 cat "${cf}"
532 ],
533 [0],
534 [foo-1.0
535 foo-2.0
536 foo-2.0
537 ],
538 [warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
539 )
540 AT_CLEANUP
541
542 # Shared config(noreplace) variants of the more interesting cases
543 # ------------------------------
544 # Upgrade package with locally modified config file, changed in pkg.
545 AT_SETUP([upgrade changing, modified shared config(noreplace) 1])
546 AT_KEYWORDS([install])
547 AT_CHECK([
548 RPMDB_CLEAR
549 RPMDB_INIT
550 cf="${RPMTEST}"/etc/my.conf
551 rm -f "${cf}" "${cf}".rpm*
552 rm -rf "${TOPDIR}"
553
554 for s in "A" "B"; do
555     for v in "1.0" "2.0"; do
556         runroot rpmbuild --quiet -bb \
557             --define "sub $s" \
558             --define "ver $v" \
559             --define "filedata foo-$v" \
560             --define "noreplace 1" \
561               /data/SPECS/configtest.spec
562     done
563 done
564
565 runroot rpm -U \
566     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
567     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
568 cat "${cf}"
569 echo "otherstuff" > "${RPMTEST}"/etc/my.conf
570 cat "${cf}"
571 runroot rpm -U \
572     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
573     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
574 cat "${cf}"
575 cat "${cf}.rpmnew"
576 ],
577 [0],
578 [foo-1.0
579 otherstuff
580 otherstuff
581 foo-2.0
582 ],
583 [warning: /etc/my.conf created as /etc/my.conf.rpmnew]
584 )
585 AT_CLEANUP
586
587 # ------------------------------
588 # Modified config file matches the content from new package. Creating a 
589 # backup makes no sense in this case, but that's what currently happens.
590 AT_SETUP([upgrade changing, modified shared config(noreplace) 2])
591 AT_KEYWORDS([install])
592 AT_CHECK([
593 RPMDB_CLEAR
594 RPMDB_INIT
595 cf="${RPMTEST}"/etc/my.conf
596 rm -f "${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             --define "noreplace 1" \
606               /data/SPECS/configtest.spec
607     done
608 done
609
610 runroot rpm -U \
611     "${TOPDIR}"/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \
612     "${TOPDIR}"/RPMS/noarch/configtest-B-1.0-1.noarch.rpm
613 cat "${cf}"
614 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
615 cat "${cf}"
616 runroot rpm -U \
617     "${TOPDIR}"/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \
618     "${TOPDIR}"/RPMS/noarch/configtest-B-2.0-1.noarch.rpm
619 cat "${cf}"
620 ],
621 [0],
622 [foo-1.0
623 foo-2.0
624 foo-2.0
625 ],
626 [warning: /etc/my.conf created as /etc/my.conf.rpmnew]
627 )
628 AT_CLEANUP