#!/usr/bin/perl
use strict;
use rpmtools;
use File::Find;
use File::Path;
my $params = new rpmtools;
my $tmpdir = "/tmp/genhdlist";
my $index="hdlist.cz";
my $synthesis="synthesis.$index";
my $list="list";
my $dir = @ARGV[0] or die "usage: genhdlist
";
chdir $dir or die "can't chdir in directory $dir";
# get rpm list
my @rpms;
File::Find::find({wanted => \&wanted}, ".");
sub wanted {
if (-f $_ && $_ =~ /^.*\.rpm$/ ) {
print "$File::Find::name\n";
push(@rpms, $File::Find::name);
}
}
if (!@rpms) {
print "no rpms found, aborting\n";
exit(0);
}
# create index file
mkpath($tmpdir);
$params->build_hdlist('noclean', 9, $tmpdir, $index, @rpms);
rmtree($tmpdir);
# create synthesis file
system "parsehdlist --synthesis $index | gzip -9 > $synthesis";
# create list file
open(LIST, "> $list") or die "can't create list file $list: $!";
foreach my $rpm (@rpms) { print LIST "$rpm\n" };
close(LIST);