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
|
# 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
# ------------------------------
# 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}"
],
[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=.. *.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
# ------------------------------
# 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}"
run rpmbuild --quiet -bb \
--define "pkg status" \
--define "filedata same_stuff" \
${RPMDATA}/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}"
run rpmbuild --quiet -bb \
${RPMDATA}/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 -f "${RPMTEST}"/usr/share/my.version
run rpmbuild --quiet -bb \
--define "pkg status" \
--define "filedata same_stuff" \
${RPMDATA}/SPECS/conflicttest.spec
runroot rpm -U "${TOPDIR}"/RPMS/noarch/conflictstatus-1.0-1.noarch.rpm
test -f "${RPMTEST}"/usr/share/my.version
],
[0],
[],
[])
AT_CLEANUP
# ------------------------------
# Install, erase and verify files removed from disk
AT_SETUP([rpm -e and verify files removed])
AT_KEYWORDS([install rpmdb])
AT_CHECK([
RPMDB_CLEAR
RPMDB_INIT
rm -rf "${TOPDIR}"
rm -f "${RPMTEST}"/usr/share/my.version
run rpmbuild --quiet -bb \
--define "pkg status" \
--define "filedata same_stuff" \
${RPMDATA}/SPECS/conflicttest.spec
runroot rpm -U "${TOPDIR}"/RPMS/noarch/conflictstatus-1.0-1.noarch.rpm
runroot rpm -e conflictstatus
test -f "${RPMTEST}"/usr/share/my.version
],
[1],
[],
[])
AT_CLEANUP
|