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
|
#!/usr/bin/perl
use ExtUtils::testlib;
use rpm;
my $testfile = "foo.i386.rpm";
my $header = rpm::Header($testfile);
print "Test No. 1\n";
if ($header) {
my @foo_test = ();
my %foo_test = ();
my $key;
print "call to the header function SUCCEEDED\n";
@foo_test = $header->ItemByVal(1027);
print "values returned by ItemByVal(1027) ", join(' ',@foo_test), "\n\n\n";
@foo_test = $header->ItemByName("Filenames");
print "values returned by ItemByName(\"Filenames\") ", join(' ',@foo_test), "\n\n\n";
print "\n\nTest No. 2\n";
%foo_test = $header->List();
foreach $key (sort keys %foo_test) {
my $foo_it;
print "Item [$key] has [", scalar @{$foo_test{$key}}, "] values: ";
foreach $foo_it (@{$foo_test{$key}}) {
print "[$foo_it] ";
}
print "\n";
}
print "\n\nTest No. 3\n";
print "The number of header tags is: ", scalar $header->Tags(), "\n";
print "\n\nTest No. 4\n";
rpm::Debug();
my $db = rpm::dbOpen();
if ($db) {
my $rec = $db->First();
while ($rec != 0) {
my $hdr = $db->Record($rec);
print "Found header: Name=[", $hdr->ItemByName("Name"), "]\n";
$rec = $db->Next($rec);
}
$db->Close();
} else {
print "Could not open the RPM database! Error code: ", rpm::Error(), "\n";
}
} else {
print "call to the header function FAILED\n";
}
|