Changeset 24 in ProjectBuilder
- Timestamp:
- Jul 31, 2007, 8:00:18 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/lib/distro.pm
r23 r24 138 138 # If ambiguity, which other distributions should be checked 139 139 my %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 ); 145 145 146 146 my %distro_match = ( … … 148 148 'gentoo' => '.* version (.+)', 149 149 'debian' => '([^/]+)[/]*.*', 150 'slackware' => ' [^ ]* (.+) [^ ]*',150 'slackware' => 'S[^ ]* (.+)$', 151 151 # 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 (.+) \(', 158 158 'sles' => '.* Enterprise .*\nVERSION = (.+)', 159 159 'suse' => '.* [^Enterpis] .*\nVERSION = (.+)', … … 170 170 # Begin to test presence of non-amiguous files 171 171 # 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"); 172 my ($d,$r); 173 while (($d,$r) = each %single_rel_files) { 174 if (-f "$base/$r" && !-l "$base/$r") { 175 my $tmp=get_content("$base/$r"); 175 176 # Found the only possibility. 176 177 # 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; 179 180 } else { 180 print STDERR "Unable to find $d 'sversion in $r\n";181 print STDERR "Unable to find $d version in $r\n"; 181 182 print STDERR "Please report to the maintainer bruno_at_project-builder.org\n"; 182 183 $release = "unknown"; … … 186 187 } 187 188 188 while ( my ($d,$r)each %ambiguous_rel_files) {189 while (($d,$r) = each %ambiguous_rel_files) { 189 190 if (-f "$base/$r" && !-l "$base/$r"){ 190 191 # Found one possibility. 191 192 # 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); 195 200 # 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 } 200 209 } 201 210 } 202 211 if ($found == 0) { 203 print STDERR "Unable to find $d 'sversion in $r\n";212 print STDERR "Unable to find $d version in $r\n"; 204 213 print STDERR "Please report to the maintainer bruno_at_project-builder.org\n"; 205 214 $release = "unknown"; … … 210 219 } 211 220 return("unknown","unknown"); 221 } 212 222 213 223 sub get_content { … … 220 230 my $content=<R>; 221 231 close(R); 232 chomp($content); 222 233 $/ = $bkp; 223 234 return($content);
Note:
See TracChangeset
for help on using the changeset viewer.