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
|
#include "system.h"
#include "intl.h"
#include "rpmlib.h"
int main(int argc, char ** argv)
{
Header h;
int offset;
int dspBlockNum = 0; /* default to all */
int blockNum = 0;
rpmdb db;
rpmReadConfigFiles(NULL, NULL, NULL, 0, NULL);
if (argc == 2) {
dspBlockNum = atoi(argv[1]);
} else if (argc != 1) {
fprintf(stderr, _("dumpdb <block num>\n"));
exit(1);
}
if (rpmdbOpen("", &db, O_RDONLY, 0644)) {
fprintf(stderr, _("cannot open /var/lib/rpm/packages.rpm\n"));
exit(1);
}
offset = rpmdbFirstRecNum(db);
while (offset) {
blockNum++;
if (!dspBlockNum || dspBlockNum == blockNum) {
h = rpmdbGetRecord(db, offset);
if (!h) {
fprintf(stderr, _("headerRead failed\n"));
exit(1);
}
headerDump(h, stdout, 1, rpmTagTable);
fprintf(stdout, "Offset: %d\n", offset);
headerFree(h);
}
if (dspBlockNum && blockNum > dspBlockNum) exit(0);
offset = rpmdbNextRecNum(db, offset);
}
rpmdbClose(db);
return 0;
}
|