9 This script converts an RPM package into what we call a "tags file",
10 which is simply an associative array listing all the tags and their
16 For our rpm helper tests we need an RPM file. But we also want the tests
17 to be able to run on systems where the rpm binary isn't installed. The
18 solution: our tests work on "tags files" instead of real RPM files.
25 \$ perl $0 /path/to/some/package.rpm > test.input
27 You can run this script only on systems where 'rpm' is installed.
32 After all was done the author of this script discovered something not
33 mentioned in rpm's manpage: one can do "rpm -qp --xml pkg.rpm" to
34 serialize the metadata and get the same effect. But this would just move
35 the complexity to the test (in handling XML).
38 # Tag variations we're interested in and wish to record as well.
39 my @formatted_tags = qw(
45 OBSOLETEFLAGS:depflags
46 CONFLICTFLAGS:depflags
49 # Big tags we want to omit to save space.
50 my %skip = map {$_ => 1} qw(
54 # Make 'rpm' print dates in the format our helper expects.
55 $ENV{'LC_TIME'} = 'C';
63 chomp(my @all_tags = `rpm --querytags`);
64 @all_tags = grep {!$skip{$_}} @all_tags;
66 foreach my $tag (@all_tags, @formatted_tags) {
67 $tags{$tag} = `rpm -qp --qf "%{$tag}" "$rpm_pkg"`;
71 $tags{'_INFO'} = `rpm -qip "$rpm_pkg"`;
78 my $cmdline = join(' ', 'perl', $0, @ARGV);
83 # This "tags file" was created by running the following command:
87 # This file is used in our tests instead of the corresponding RPM file.
88 # This lets us run the tests on systems where 'rpm' is not installed.
94 if (!$ARGV[0] || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") {
98 my %tags = rpm2tags
($ARGV[0]);
99 $Data::Dumper
::Terse
= 1;
100 print(prolog
(), "\n", '$tags = ', Dumper
(\
%tags), ";\n");