summaryrefslogtreecommitdiff
path: root/tests/rpmdb.at
blob: 961025273841466db4ebd6fe51bb9e448abf9613 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
#    rpmdb.at: test rpmdb access
#
#    Copyright (C) 2007  Ralf Corsépius <corsepiu@fedoraproject.org>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

AT_BANNER([RPM database access])

# ------------------------------
# Attempt to initialize a rpmdb
AT_SETUP([rpm --initdb])
AT_KEYWORDS([rpmdb])
AT_CHECK([
RPMDB_CLEAR
RPMDB_INIT
],
[0],
[ignore],
[ignore])
AT_CLEANUP

# ------------------------------
# Run rpm -qa on an empty rpmdb
AT_SETUP([rpm -qa])
AT_KEYWORDS([rpmdb query])
AT_CHECK([
RPMDB_CLEAR
RPMDB_INIT
runroot rpm \
  -qa
],
[0])
AT_CLEANUP

# ------------------------------
# Run rpm -q <package> where <package> exists in the db.
AT_SETUP([rpm -q foo])
AT_KEYWORDS([rpmdb query])
AT_CHECK([
RPMDB_CLEAR
RPMDB_INIT

runroot rpm -i \
  /data/RPMS/foo-1.0-1.noarch.rpm

runroot rpm -q foo

],
[0],
[foo-1.0-1.noarch
],
[])
AT_CLEANUP

# ------------------------------
# Run rpm -q <package>- where <package> exists in the db.
AT_SETUP([rpm -q foo-])
AT_KEYWORDS([rpmdb query])
AT_CHECK([
RPMDB_CLEAR
RPMDB_INIT

runroot rpm -i \
  /data/RPMS/foo-1.0-1.noarch.rpm

runroot rpm -q foo-

],
[1],
[package foo- is not installed
],
[])
AT_CLEANUP

# ------------------------------
# install a noarch package into a local rpmdb without --relocate and --nodeps
# * Should always succeed
AT_SETUP([rpm -i *.noarch.rpm])
AT_KEYWORDS([rpmdb install])

AT_CHECK([
RPMDB_CLEAR
RPMDB_INIT

runroot rpm -i \
  /data/RPMS/foo-1.0-1.noarch.rpm
],
[0])

AT_CLEANUP

# ------------------------------
# reinstall a noarch package (with no files)
AT_SETUP([rpm -U --replacepkgs])
AT_KEYWORDS([rpmdb install])

AT_CHECK([
RPMDB_CLEAR
RPMDB_INIT

tpkg="/data/RPMS/foo-1.0-1.noarch.rpm"

runroot rpm -i "${tpkg}" && 
  runroot rpm -U --replacepkgs "${tpkg}" &&
  runroot rpm -qa
],
[0],
[foo-1.0-1.noarch
],
[])

AT_CLEANUP

# ------------------------------
# install a package into a local rpmdb
# * Shall only work with relocation
# * Use --ignorearch because we don't know the arch
AT_SETUP([rpm -i --relocate=.. *.i386.rpm])
AT_KEYWORDS([rpmdb install])
AT_CHECK([
RPMDB_CLEAR
RPMDB_INIT

runroot rpm -i \
  --noscripts --nodeps --ignorearch --relocate=/usr=/check \
  /data/RPMS/hello-1.0-1.i386.rpm
],
[0])

AT_CLEANUP


# ------------------------------
# install a package into a local rpmdb
# * Shall only work with relocation
# * Use --ignorearch because we don't know the arch
AT_SETUP([rpm -i --relocate=.. *.ppc64.rpm])
AT_KEYWORDS([rpmdb install])
AT_CHECK([
RPMDB_CLEAR
RPMDB_INIT

runroot rpm -i \
  --noscripts --nodeps --ignorearch --relocate=/usr=/check \
  /data/RPMS/hello-1.0-1.ppc64.rpm
],
[0],
[ignore],
[ignore])

AT_CLEANUP

AT_SETUP([rpmdb --rebuilddb])
AT_KEYWORDS([rpmdb])
AT_CHECK([
RPMDB_CLEAR
RPMDB_INIT

runroot rpm -U --noscripts --nodeps --ignorearch \
  /data/RPMS/hello-1.0-1.i386.rpm
runroot rpm -qa --qf "%{nevra} %{dbinstance}\n"
runroot rpm -U --noscripts --nodeps --ignorearch \
  /data/RPMS/hello-2.0-1.i686.rpm
runroot rpm -qa --qf "%{nevra} %{dbinstance}\n"
runroot rpmdb --rebuilddb
runroot rpm -qa --qf "%{nevra} %{dbinstance}\n"
],
[],
[hello-1.0-1.i386 1
hello-2.0-1.i686 2
hello-2.0-1.i686 1
],
[])
AT_CLEANUP


# ------------------------------
# Install and verify status
AT_SETUP([rpm -U and verify status])
AT_KEYWORDS([install rpmdb query])
AT_CHECK([
RPMDB_CLEAR
RPMDB_INIT
rm -rf "${TOPDIR}"

runroot rpmbuild --quiet -bb \
        --define "pkg status" \
	--define "filedata same_stuff" \
          /data/SPECS/conflicttest.spec

runroot rpm -U "${TOPDIR}"/RPMS/noarch/conflictstatus-1.0-1.noarch.rpm
runroot rpm -qls conflictstatus
],
[0],
[normal        /usr/share/my.version
],
[])
AT_CLEANUP

# ------------------------------
# Install and verify status
AT_SETUP([rpm -U with _install_lang and verify status])
AT_KEYWORDS([install rpmdb query])
AT_CHECK([
RPMDB_CLEAR
RPMDB_INIT
rm -rf "${TOPDIR}"

runroot rpmbuild --quiet -bb \
          /data/SPECS/flangtest.spec

runroot rpm -U --define "_install_langs de:fi" "${TOPDIR}"/RPMS/noarch/flangtest-1.0-1.noarch.rpm
runroot rpm -qls flangtest
],
[0],
[normal        /usr/share/flangtest/de.txt
not installed /usr/share/flangtest/en.txt
normal        /usr/share/flangtest/fi.txt
normal        /usr/share/flangtest/none.txt
not installed /usr/share/flangtest/pl.txt
],
[])
AT_CLEANUP

# ------------------------------
# Install and verify files exist on disk
AT_SETUP([rpm -U and verify files on disk])
AT_KEYWORDS([install rpmdb])
AT_CHECK([
RPMDB_CLEAR
RPMDB_INIT
rm -rf "${TOPDIR}"
rm -rf "${RPMTEST}"/opt/*

runroot rpmbuild --quiet -bb /data/SPECS/selfconflict.spec
runroot rpm -U "${TOPDIR}"/RPMS/noarch/selfconflict-1.0-1.noarch.rpm
find "${RPMTEST}"/opt | wc -l
],
[0],
[6
],
[])
AT_CLEANUP

# ------------------------------
# Install, erase and oerify files removed from disk
# Note /opt is not owned by the pkg so it gets left behind
AT_SETUP([rpm -e and verify files removed])
AT_KEYWORDS([install rpmdb])
AT_CHECK([
RPMDB_CLEAR
RPMDB_INIT
rm -rf "${TOPDIR}"
rm -rf "${RPMTEST}"/opt/*

runroot rpmbuild --quiet -bb /data/SPECS/selfconflict.spec
runroot rpm -U "${TOPDIR}"/RPMS/noarch/selfconflict-1.0-1.noarch.rpm
runroot rpm -e selfconflict
find "${RPMTEST}"/opt | wc -l
],
[0],
[1
],
[])
AT_CLEANUP