Changeset 24


Ignore:
Timestamp:
Jul 31, 2007, 8:00:18 PM (12 years ago)
Author:
bruno
Message:

get_distro begins to work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/lib/distro.pm

    r23 r24  
    138138# If ambiguity, which other distributions should be checked
    139139my %distro_similar = (
    140     'mandrake'          => ('mandrake'),
    141     'suse'              => ('suse', 'sles'),
    142     'redhat'            => ('redhat', 'rhel', 'centos', 'mandrake'),
    143     'lsb'               => ('ubuntu', 'debian', 'lsb')
    144     )
     140    'mandrake'          => ['mandrake'],
     141    'suse'              => ['suse', 'sles'],
     142    'redhat'            => ['redhat', 'rhel', 'centos', 'mandrake'],
     143    'lsb'               => ['ubuntu', 'debian', 'lsb'],
     144    );
    145145
    146146my %distro_match = (
     
    148148    'gentoo'                => '.* version (.+)',
    149149    'debian'                => '([^/]+)[/]*.*',
    150     'slackware'             => '[^ ]* (.+) [^ ]*',
     150    'slackware'             => 'S[^ ]* (.+)$',
    151151# There should be no ambiguity between potential ambiguous distro
    152     'mandrake'              => 'Mandr[^ ]* release (.+) .*',
    153     'mandriva'              => 'Mandr[^ ]* [^ ]* release (.+) .*',
    154     'fedora'                => 'Fedora .*release (\d+) .*',
    155     'rhel'                  => '.* Enterprise .*release (.+) \(',
    156     'centos'                => '.*CentOS .*release (.+) .*',
    157     'redhat'                => 'Red Hat Linux release (.+) .*',
     152    'mandrake'              => 'Mandr[^ ]* release (.+) \(',
     153    'mandriva'              => 'Mandr[^ ]* [^ ]* release (.+) \(',
     154    'fedora'                => 'Fedora .*release (\d+) \(',
     155    'rhel'                  => 'Red Hat Enterprise Linux .*release (.+) \(',
     156    'centos'                => '.*CentOS .*release (.+) ',
     157    'redhat'                => 'Red Hat Linux release (.+) \(',
    158158    'sles'                  => '.* Enterprise .*\nVERSION = (.+)',
    159159    'suse'                  => '.* [^Enterpis] .*\nVERSION = (.+)',
     
    170170# Begin to test presence of non-amiguous files
    171171# that way we reduce the choice
    172 while (my ($d,$r) each %single_rel_files) {
    173     if (-f "$base/$r" && !-l "$base/$r"){
    174         $release=get_content("$base/$r");
     172my ($d,$r);
     173while (($d,$r) = each %single_rel_files) {
     174    if (-f "$base/$r" && !-l "$base/$r") {
     175        my $tmp=get_content("$base/$r");
    175176        # Found the only possibility.
    176177        # Try to get version and return
    177         if (defined ($distro_match{$d}) {
    178             $release =~ m/$distro_match{$d}/m;
     178        if (defined ($distro_match{$d})) {
     179            ($release) = $tmp =~ m/$distro_match{$d}/m;
    179180        } else {
    180             print STDERR "Unable to find $d's version in $r\n";
     181            print STDERR "Unable to find $d version in $r\n";
    181182            print STDERR "Please report to the maintainer bruno_at_project-builder.org\n";
    182183            $release = "unknown";
     
    186187}
    187188
    188 while (my ($d,$r) each %ambiguous_rel_files) {
     189while (($d,$r) = each %ambiguous_rel_files) {
    189190    if (-f "$base/$r" && !-l "$base/$r"){
    190191        # Found one possibility.
    191192        # Get all distros concerned by that file
    192         $release=get_content("$base/$r");
    193         $found = 0;
    194         foreach $dd (@$distro_similar{$d}) {
     193        my $tmp=get_content("$base/$r");
     194        my $found = 0;
     195        my $ptr = $distro_similar{$d};
     196        print $LOG "amb: ".Dumper($ptr)."\n" if ($debug >= 1);
     197        $release = "unknown";
     198        foreach my $dd (@$ptr) {
     199            print $LOG "check $dd\n" if ($debug >= 1);
    195200            # Try to check pattern
    196             if ((defined ($distro_match{$dd}) && ($release =~ /$distro_match{$dd}/m) {
    197                 $release =~ m/$distro_match{$dd}/m;
    198                 $distro = $dd;
    199                 $found = 1;
     201            if (defined $distro_match{$dd}) {
     202                print $LOG "cmp: $distro_match{$dd} - vs - $tmp\n" if ($debug >= 1);
     203                ($release) = $tmp =~ m/$distro_match{$dd}/m;
     204                if ((defined $release) && ($release ne "unknown")) {
     205                    $distro = $dd;
     206                    $found = 1;
     207                    last;
     208                }
    200209            }
    201210        }
    202211        if ($found == 0) {
    203             print STDERR "Unable to find $d's version in $r\n";
     212            print STDERR "Unable to find $d version in $r\n";
    204213            print STDERR "Please report to the maintainer bruno_at_project-builder.org\n";
    205214            $release = "unknown";
     
    210219}
    211220return("unknown","unknown");
     221}
    212222
    213223sub get_content {
     
    220230my $content=<R>;
    221231close(R);
     232chomp($content);
    222233$/ = $bkp;
    223234return($content);
Note: See TracChangeset for help on using the changeset viewer.