aboutsummaryrefslogtreecommitdiffstats
path: root/genhdlist
blob: 0521947a10c738f56fde08c1bab255bc7bdd1bc3 (plain)
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
#!/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);