summaryrefslogtreecommitdiffstats
path: root/tools/closurepkgs
blob: f060d1b29dbc33d7ab048214768ecbba58d2fe2b (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
91
92
#!/usr/bin/perl

use strict;

sub chop_version($) {
    ($_[0] =~ /(.*)-[^-]+-[^-]+/)[0] || $_[0];
}

sub read_depslist {
    my ($file) = @_;
    my $depslist = { 'ordered' => [], 'packages' => {} };

    local *F;
    open F, $file or die "closurepkgs: unable to open ordered dependencies list file $file\n";
    foreach (<F>) {
	my ($name, $size, @deps) = split;
	push @{$depslist->{ordered}}, { name => $name, size => $size, deps => \@deps };
    }
    close F;

    foreach (@{$depslist->{ordered}}) {
	$depslist->{packages}{chop_version($_->{name})} = $_;
    }

    print STDERR "closurepkgs: read " . scalar(@{$depslist->{ordered}}) . " package dependancies\n";

    $depslist;
}

sub read_compsslist {
    my ($file) = @_;
    my %compsslist;

    local *F;
    open F, $file or die "closurepkgs: unable to open compsslist file $file\n";
    foreach (<F>) {
	my ($name, $level) = /^\s*(\S+)\s+(\d+)/;
	$compsslist{$name} = $level;
    }
    close F;

    \%compsslist;
}

sub main {
    my ($depslist_file, $compsslist_file) = @_;
    my $depslist = read_depslist($depslist_file);
    my $compsslist = read_compsslist($compsslist_file);

    my @pkgs = qw(XFree86 XFree86-server XFree86-glide-module Device3Dfx Glide_V3-DRI Glide_V5 Mesa dhcpcd pump dhcpxd dhcp-client isdn4net isdn4k-utils dev pptp-adsl-fr rp-pppoe ppp ypbind rhs-printfilters lpr cups cups-drivers samba ncpfs);
    push @pkgs, "XFree86-$_" foreach qw(3DLabs 3dfx 8514 AGX FBDev I128 Mach8 Mach32 Mach64 Mono P9000 Rage128 S3 S3V SVGA VGA16 W32);

    #- closure the list of package to be kept for oem.
    my %closure;
    foreach (@pkgs) {
	$closure{$_} = 1;
	map { $closure{chop_version($_->{name})} = 1 } map { $depslist->{ordered}[$_] } map { split /\|/ } @{$depslist->{packages}{$_}{deps}};
    }

    #- closure the list of package to always install for oem. (level >= 50)...
    my %install;
    foreach (grep { $compsslist->{$_} >= 70 } keys %{$depslist->{packages}}) {
	$install{$_} = 1;
	map { $install{chop_version($_->{name})} = 1 } map { $depslist->{ordered}[$_] } map { split /\|/ } @{$depslist->{packages}{$_}{deps}};
    }

    #- remove base packages, which have to be installed, according to basesystem.
    delete $closure{'basesystem'};
    $install{'basesystem'} = 1;
    map { delete $closure{chop_version($_->{name})};
	  $install{chop_version($_->{name})} = 1 } map { $depslist->{ordered}[$_] } map { split /\|/ } @{$depslist->{packages}{'basesystem'}{deps}};

    #- special packages that are to be move to closure always ...
    foreach (qw(kernel-smp kernel-linus kernel-secure hackkernel-smp hackkernel-linus hackkernel-secure)) {
	$depslist->{packages}{$_} or next;
	$closure{$_} = 1;
	delete $install{$_};
    }

    #- dump out the list of package according to the 2 lists defined above.
    my $total_install = 0;
    map { $total_install += $depslist->{packages}{$_}{size};
	  delete $closure{$_};
	  print "I:", $depslist->{packages}{$_}{name}, "\n" } grep { $depslist->{packages}{$_} } keys %install;
    my $total_closure = 0;
    map { $total_closure += $depslist->{packages}{$_}{size};
	  print "C:", $depslist->{packages}{$_}{name}, "\n" } grep { $depslist->{packages}{$_} } keys %closure;
    print "\n\ntotal_install=$total_install\n";
    print "total_closure=$total_closure\n";
}

main(@ARGV);