Add a test-case for another %config file special case
[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([rpm -U to package with unchanged config file])
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([rpm -U to package with locally modified config file])
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([rpm -U to package with unchanged config file])
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([rpm -U to package with modified config file 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 ],
123 [0],
124 [foo-1.0
125 otherstuff
126 foo-2.0
127 ],
128 [warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
129 )
130 AT_CLEANUP
131
132 # ------------------------------
133 # Modified config file matches the content from new package. Creating a 
134 # backup makes no sense in this case, but that's what currently happens.
135 AT_SETUP([rpm -U to package with modified config file 2])
136 AT_KEYWORDS([install])
137 AT_CHECK([
138 RPMDB_CLEAR
139 RPMDB_INIT
140 cf="${RPMTEST}"/etc/my.conf
141 rm -f "${cf}" "${cf}".rpm*
142 rm -rf "${TOPDIR}"
143
144 for v in "1.0" "2.0"; do
145     runroot rpmbuild --quiet -bb \
146         --define "ver $v" \
147         --define "filedata foo-$v" \
148           /data/SPECS/configtest.spec
149 done
150
151 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-1.0-1.noarch.rpm
152 cat "${cf}"
153 echo "foo-2.0" > "${RPMTEST}"/etc/my.conf
154 cat "${cf}"
155 runroot rpm -U "${TOPDIR}"/RPMS/noarch/configtest-2.0-1.noarch.rpm
156 cat "${cf}"
157 ],
158 [0],
159 [foo-1.0
160 foo-2.0
161 foo-2.0
162 ],
163 [warning: /etc/my.conf saved as /etc/my.conf.rpmsave]
164 )
165 AT_CLEANUP