aboutsummaryrefslogtreecommitdiffstats
path: root/genbasefiles
blob: 03411a90b7eef6e532e30e80c7b1350751e52e98 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/perl

#- Copyright (C) 1999 MandrakeSoft (fpons@mandrakesoft.com)
#-
#- This program is free software; you can redistribute it and/or modify
#- it under the terms of the GNU General Public License as published by
#- the Free Software Foundation; either version 2, or (at your option)
#- any later version.
#-
#- This program is distributed in the hope that it will be useful,
#- but WITHOUT ANY WARRANTY; without even the implied warranty of
#- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#- GNU General Public License for more details.
#-
#- You should have received a copy of the GNU General Public License
#- along with this program; if not, write to the Free Software
#- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

use strict qw(subs vars refs);
use rpmtools;

sub main {
    my ($output_dir, @files) = @_;
    my $params = new rpmtools;

    -d $output_dir or die "usage: gendepslist <output_dir> <hdlist files|rpm files>\n";

    #- this version try to use an existing profiles file to reduce
    #- number of pass of parsing hdlist.
    if (-r "$output_dir/provides") {
	print STDERR "using existing $output_dir/provides file\n";
	open F, "$output_dir/provides";
	$params->read_provides_files(\*F);
	close F;
    }

    #- now, try to build dependancy, but incrementally only.
    foreach (@files) {
	print STDERR "reading $_\n";
	/\.rpm$/ ? $params->read_rpms($_) : $params->read_hdlists($_);
	$params->compute_depslist();
    }

    my @unresolved = $params->get_unresolved_provides_files();
    if (@unresolved > 0) {
	foreach (@unresolved) {
	    print STDERR "found requires on file not yet found [$_], forcing two other linked pass\n";
	}

	#- cleaning.
	$params->keep_only_cleaned_provides_files();

	#- much more severe cleaning here, so we are sure with 2 pass.
	#- else it may happen that a package need an inexistant file,
	#- which will be in the provides forever, event after fixing the
	#- package.
	$params->{provides} = {};

	#- compute (avoiding depslist computation on first one.
	foreach (@files) {
	    print STDERR "reading (second pass) $_\n";
	    /\.rpm$/ ? $params->read_rpms($_) : $params->read_hdlists($_);
	}
	$params->keep_only_cleaned_provides_files();
	foreach (@files) {
	    print STDERR "reading (third pass) $_\n";
	    /\.rpm$/ ? $params->read_rpms($_) : $params->read_hdlists($_);
	    $params->compute_depslist();
	}
    }

    #- work finished, so write results:
    #-   $output_dir/depslist.ordered
    #-   $output_dir/provides
    #-   $output_dir/compss
    print STDERR "writing $output_dir/depslist.ordered\n";
    open F, ">$output_dir/depslist.ordered" or die "unable to write depslist file $output_dir/depslist.ordered\n";
    $params->write_depslist(\*F);
    close F;
    print STDERR "writing $output_dir/provides\n";
    open F, ">$output_dir/provides" or die "unable to write provides file $output_dir/provides\n";
    $params->write_provides(\*F);
    close F;
    print STDERR "writing $output_dir/compss\n";
    open F, ">$output_dir/compss" or die "unable to write compss file $output_dir/compss";
    $params->write_compss(\*F);
    close F;
}

main(@ARGV);