msm: consistency for equally ranked keys
[platform/upstream/rpm.git] / tests / rpmdb.at
1 #    rpmdb.at: test rpmdb access
2 #
3 #    Copyright (C) 2007  Ralf Corsépius <corsepiu@fedoraproject.org>
4 #
5 #    This program is free software; you can redistribute it and/or modify
6 #    it under the terms of the GNU General Public License as published by
7 #    the Free Software Foundation; either version 2 of the License, or
8 #    (at your option) any later version.
9 #
10 #    This program is distributed in the hope that it will be useful,
11 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #    GNU General Public License for more details.
14 #
15 #    You should have received a copy of the GNU General Public License
16 #    along with this program; if not, write to the Free Software
17 #    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18
19 AT_BANNER([RPM database access])
20
21 # ------------------------------
22 # Attempt to initialize a rpmdb
23 AT_SETUP([rpm --initdb])
24 AT_KEYWORDS([rpmdb])
25 AT_CHECK([
26 RPMDB_CLEAR
27 RPMDB_INIT
28 ],
29 [0],
30 [ignore],
31 [ignore])
32 AT_CLEANUP
33
34 # ------------------------------
35 # Run rpm -qa on an empty rpmdb
36 AT_SETUP([rpm -qa])
37 AT_KEYWORDS([rpmdb query])
38 AT_CHECK([
39 RPMDB_CLEAR
40 RPMDB_INIT
41 runroot rpm \
42   -qa
43 ],
44 [0])
45 AT_CLEANUP
46
47 # ------------------------------
48 # Run rpm -q <package> where <package> exists in the db.
49 AT_SETUP([rpm -q foo])
50 AT_KEYWORDS([rpmdb query])
51 AT_CHECK([
52 RPMDB_CLEAR
53 RPMDB_INIT
54
55 runroot rpm -i \
56   /data/RPMS/foo-1.0-1.noarch.rpm
57
58 runroot rpm -q foo
59
60 ],
61 [0],
62 [foo-1.0-1.noarch
63 ],
64 [])
65 AT_CLEANUP
66
67 # ------------------------------
68 # Run rpm -q <package>- where <package> exists in the db.
69 AT_SETUP([rpm -q foo-])
70 AT_KEYWORDS([rpmdb query])
71 AT_CHECK([
72 RPMDB_CLEAR
73 RPMDB_INIT
74
75 runroot rpm -i \
76   /data/RPMS/foo-1.0-1.noarch.rpm
77
78 runroot rpm -q foo-
79
80 ],
81 [1],
82 [package foo- is not installed
83 ],
84 [])
85 AT_CLEANUP
86
87 # ------------------------------
88 # install a noarch package into a local rpmdb without --relocate and --nodeps
89 # * Should always succeed
90 AT_SETUP([rpm -i *.noarch.rpm])
91 AT_KEYWORDS([rpmdb install])
92
93 AT_CHECK([
94 RPMDB_CLEAR
95 RPMDB_INIT
96
97 runroot rpm -i \
98   /data/RPMS/foo-1.0-1.noarch.rpm
99 ],
100 [0])
101
102 AT_CLEANUP
103
104 # ------------------------------
105 # reinstall a noarch package (with no files)
106 AT_SETUP([rpm -U --replacepkgs])
107 AT_KEYWORDS([rpmdb install])
108
109 AT_CHECK([
110 RPMDB_CLEAR
111 RPMDB_INIT
112
113 tpkg="/data/RPMS/foo-1.0-1.noarch.rpm"
114
115 runroot rpm -i "${tpkg}" && 
116   runroot rpm -U --replacepkgs "${tpkg}" &&
117   runroot rpm -qa
118 ],
119 [0],
120 [foo-1.0-1.noarch
121 ],
122 [])
123
124 AT_CLEANUP
125
126 # ------------------------------
127 # install a package into a local rpmdb
128 # * Shall only work with relocation
129 # * Use --ignorearch because we don't know the arch
130 AT_SETUP([rpm -i --relocate=.. *.i386.rpm])
131 AT_KEYWORDS([rpmdb install])
132 AT_CHECK([
133 RPMDB_CLEAR
134 RPMDB_INIT
135
136 runroot rpm -i \
137   --noscripts --nodeps --ignorearch --relocate=/usr=/check \
138   /data/RPMS/hello-1.0-1.i386.rpm
139 ],
140 [0])
141
142 AT_CLEANUP
143
144
145 # ------------------------------
146 # install a package into a local rpmdb
147 # * Shall only work with relocation
148 # * Use --ignorearch because we don't know the arch
149 AT_SETUP([rpm -i --relocate=.. *.ppc64.rpm])
150 AT_KEYWORDS([rpmdb install])
151 AT_CHECK([
152 RPMDB_CLEAR
153 RPMDB_INIT
154
155 runroot rpm -i \
156   --noscripts --nodeps --ignorearch --relocate=/usr=/check \
157   /data/RPMS/hello-1.0-1.ppc64.rpm
158 ],
159 [0],
160 [ignore],
161 [ignore])
162
163 AT_CLEANUP
164
165 # ------------------------------
166 # Install and verify status
167 AT_SETUP([rpm -U and verify status])
168 AT_KEYWORDS([install rpmdb query])
169 AT_CHECK([
170 RPMDB_CLEAR
171 RPMDB_INIT
172 rm -rf "${TOPDIR}"
173
174 runroot rpmbuild --quiet -bb \
175         --define "pkg status" \
176         --define "filedata same_stuff" \
177           /data/SPECS/conflicttest.spec
178
179 runroot rpm -U "${TOPDIR}"/RPMS/noarch/conflictstatus-1.0-1.noarch.rpm
180 runroot rpm -qls conflictstatus
181 ],
182 [0],
183 [normal        /usr/share/my.version
184 ],
185 [])
186 AT_CLEANUP
187
188 # ------------------------------
189 # Install and verify status
190 AT_SETUP([rpm -U with _install_lang and verify status])
191 AT_KEYWORDS([install rpmdb query])
192 AT_CHECK([
193 RPMDB_CLEAR
194 RPMDB_INIT
195 rm -rf "${TOPDIR}"
196
197 runroot rpmbuild --quiet -bb \
198           /data/SPECS/flangtest.spec
199
200 runroot rpm -U --define "_install_langs de:fi" "${TOPDIR}"/RPMS/noarch/flangtest-1.0-1.noarch.rpm
201 runroot rpm -qls flangtest
202 ],
203 [0],
204 [normal        /usr/share/flangtest/de.txt
205 not installed /usr/share/flangtest/en.txt
206 normal        /usr/share/flangtest/fi.txt
207 normal        /usr/share/flangtest/none.txt
208 not installed /usr/share/flangtest/pl.txt
209 ],
210 [])
211 AT_CLEANUP
212
213 # ------------------------------
214 # Install and verify files exist on disk
215 AT_SETUP([rpm -U and verify files on disk])
216 AT_KEYWORDS([install rpmdb])
217 AT_CHECK([
218 RPMDB_CLEAR
219 RPMDB_INIT
220 rm -rf "${TOPDIR}"
221 rm -rf "${RPMTEST}"/opt/*
222
223 runroot rpmbuild --quiet -bb /data/SPECS/selfconflict.spec
224 runroot rpm -U "${TOPDIR}"/RPMS/noarch/selfconflict-1.0-1.noarch.rpm
225 find "${RPMTEST}"/opt | wc -l
226 ],
227 [0],
228 [6
229 ],
230 [])
231 AT_CLEANUP
232
233 # ------------------------------
234 # Install, erase and oerify files removed from disk
235 # Note /opt is not owned by the pkg so it gets left behind
236 AT_SETUP([rpm -e and verify files removed])
237 AT_KEYWORDS([install rpmdb])
238 AT_CHECK([
239 RPMDB_CLEAR
240 RPMDB_INIT
241 rm -rf "${TOPDIR}"
242 rm -rf "${RPMTEST}"/opt/*
243
244 runroot rpmbuild --quiet -bb /data/SPECS/selfconflict.spec
245 runroot rpm -U "${TOPDIR}"/RPMS/noarch/selfconflict-1.0-1.noarch.rpm
246 runroot rpm -e selfconflict
247 find "${RPMTEST}"/opt | wc -l
248 ],
249 [0],
250 [1
251 ],
252 [])
253 AT_CLEANUP