aboutsummaryrefslogtreecommitdiffstats
path: root/genhdlist
diff options
context:
space:
mode:
Diffstat (limited to 'genhdlist')
-rw-r--r--genhdlist51
1 files changed, 51 insertions, 0 deletions
diff --git a/genhdlist b/genhdlist
new file mode 100644
index 0000000..0521947
--- /dev/null
+++ b/genhdlist
@@ -0,0 +1,51 @@
+#!/usr/bin/perl
+
+use strict;
+use URPM;
+use URPM::Build;
+use File::Find;
+use File::Path;
+
+my $urpm = new URPM;
+my $tmpdir = "/tmp/genhdlist";
+my $index="hdlist.cz";
+my $synthesis="synthesis.$index";
+my $dir = @ARGV[0] or die "usage: genhdlist <dir>";
+
+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);
+$urpm->parse_rpms_build_headers(dir => $tmpdir,
+ rpms => \@rpms);
+@{$urpm->{depslist}} > 0 or die "nothing read";
+$urpm->build_hdlist(start => 0,
+ end => $#{$urpm->{depslist}},
+ dir => $tmpdir,
+ hdlist => $index,
+ ratio => 9);
+rmtree($tmpdir);
+
+# create synthesis file
+$urpm->build_synthesis(start => 0,
+ end => $#{$urpm->{depslist}},
+ synthesis => $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);