Changeset 869 in ProjectBuilder
- Timestamp:
- Oct 21, 2009, 2:11:13 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/lib/ProjectBuilder/Distribution.pm
r867 r869 67 67 Mandriva, Open SuSE and Fedora have all the same "rpm" type of build system. Ubuntu ad Debian have the same "deb" type of build system. 68 68 And "fc" is the extension generated for all Fedora packages (Version will be added by pb). 69 All these information are stored in an external configuration file typically at /etc/pb/pb.conf 69 70 70 71 When passing the distribution name and version as parameters, the B<pb_distro_init> function returns the parameter of that distribution instead of the underlying one. … … 88 89 my $drmdot = "false"; 89 90 90 # If we don't know which distribution we're on, then guess it91 ($ddir,$dver) = pb_distro_get() if ((not defined $ddir) || (not defined $dver));92 93 # Initialize arch94 $darch=pb_get_arch() if (not defined $darch);95 96 91 # Adds conf file for distribution description 97 92 # the location of the conf file is finalyzed at install time 98 93 # depending whether we deal with package install or tar file install 99 94 pb_conf_add("CCCC/pb.conf"); 95 96 # If we don't know which distribution we're on, then guess it 97 ($ddir,$dver) = pb_distro_get() if ((not defined $ddir) || (not defined $dver)); 98 99 # Initialize arch 100 $darch=pb_get_arch() if (not defined $darch); 101 100 102 my ($osfamily,$ostype,$osupd,$ossuffix,$osnover,$osremovedotinver) = pb_conf_get("osfamily","ostype","osupd","ossuffix","osnover","osremovedotinver"); 101 103 … … 138 140 sub pb_distro_get { 139 141 140 my $base="/etc"; 141 142 # List of files that unambiguously indicates what distro we have 143 my %single_rel_files = ( 144 # Tested 145 'gentoo' => 'gentoo-release', # >= 1.6 146 'slackware' => 'slackware-version', # >= 10.2 147 'mandriva' => 'mandriva-release', # >=2006.0 148 'mandrakelinux' => 'mandrakelinux-release',# = 10.2 149 'fedora' => 'fedora-release', # >= 4 150 'vmware' => 'vmware-release', # >= 3 151 'sles' => 'sles-release', # Doesn't exist as of 10 152 'asianux' => 'asianux-release', # >= 2.2 153 # Untested 154 'knoppix' => 'knoppix_version', # 155 'yellowdog' => 'yellowdog-release', # 156 'esmith' => 'e-smith-release', # 157 'turbolinux' => 'turbolinux-release', # 158 'blackcat' => 'blackcat-release', # 159 'aurox' => 'aurox-release', # 160 'annvix' => 'annvix-release', # 161 'cobalt' => 'cobalt-release', # 162 'redflag' => 'redflag-release', # 163 'ark' => 'ark-release', # 164 'pld' => 'pld-release', # 165 'nld' => 'nld-release', # 166 'lfs' => 'lfs-release', # 167 'mk' => 'mk-release', # 168 'conectiva' => 'conectiva-release', # 169 'immunix' => 'immunix-release', # 170 'tinysofa' => 'tinysofa-release', # 171 'trustix' => 'trustix-release', # 172 'adamantix' => 'adamantix_version', # 173 'yoper' => 'yoper-release', # 174 'arch' => 'arch-release', # 175 'libranet' => 'libranet_version', # 176 'valinux' => 'va-release', # 177 'yellowdog' => 'yellowdog-release', # 178 'ultrapenguin' => 'ultrapenguin-release', # 179 ); 180 181 # List of files that ambiguously indicates what distro we have 182 my %ambiguous_rel_files = ( 183 'mandrake' => 'mandrake-release', # <= 10.1 184 'debian' => 'debian_version', # >= 3.1 185 'suse' => 'SuSE-release', # >= 10.0 186 'redhat' => 'redhat-release', # >= 7.3 187 'lsb' => 'lsb-release', # ??? 188 ); 189 190 # Should have the same keys as the previous one. 191 # If ambiguity, which other distributions should be checked 192 my %distro_similar = ( 193 'mandrake' => ['mandrake', 'mandrakelinux'], 194 'debian' => ['debian', 'ubuntu'], 195 'suse' => ['suse', 'sles', 'opensuse'], 196 'redhat' => ['redhat', 'rhel', 'centos', 'mandrake', 'vmware'], 197 'lsb' => ['ubuntu', 'lsb'], 198 ); 199 200 my %distro_match = ( 201 # Tested 202 'gentoo' => '.* version (.+)', 203 'slackware' => 'S[^ ]* (.+)$', 204 # There should be no ambiguity between potential ambiguous distro 205 'mandrakelinux' => 'Mandrakelinux release (.+) \(', 206 'mandrake' => 'Mandr[^ ]* release (.+) \(', 207 'mandriva' => 'Mandr[^ ]* [^ ]* release (.+) \(', 208 'fedora' => 'Fedora .*release (\d+) \(', 209 'vmware' => 'VMware ESX Server (\d+) \(', 210 'rhel' => 'Red Hat (?:Enterprise Linux|Linux Advanced Server) .*release ([0-9.]+).* \(', 211 'centos' => '.*CentOS .*release ([0-9]).* ', 212 'redhat' => 'Red Hat Linux release (.+) \(', 213 'sles' => 'SUSE .* Enterprise Server (\d+) \(', 214 'suse' => 'SUSE LINUX (\d.+) \(', 215 'opensuse' => 'openSUSE (\d.+) \(', 216 'asianux' => 'Asianux (?:Server|release) ([0-9]).* \(', 217 'lsb' => '.*[^Ubunt].*\nDISTRIB_RELEASE=(.+)', 218 # Ubuntu includes a /etc/debian_version file that creates an ambiguity with debian 219 # So we need to look at distros in reverse alphabetic order to treat ubuntu always first 220 'ubuntu' => '.*Ubuntu.*\nDISTRIB_RELEASE=(.+)', 221 'debian' => '(.+)', 222 # Not tested 223 'arch' => '.* ([0-9.]+) .*', 224 'redflag' => 'Red Flag (?:Desktop|Linux) (?:release |\()(.*?)(?: \(.+)?\)', 225 ); 142 # 1: List of files that unambiguously indicates what distro we have 143 # 2: List of files that ambiguously indicates what distro we have 144 # 3: Should have the same keys as the previous one. If ambiguity, which other distributions should be checked 145 # 4: Matching Rg. Expr to detect distribution and version 146 my ($single_rel_files, $ambiguous_rel_files,$distro_similar,$distro_match) = pb_conf_get("osrelfile","osrelambfile","osambiguous","osrelexpr"); 226 147 227 148 my $release; … … 231 152 # that way we reduce the choice 232 153 my ($d,$r); 233 while (($d,$r) = each % single_rel_files) {234 if (-f "$ base/$r" && ! -l "$base/$r") {235 my $tmp=pb_get_content("$ base/$r");154 while (($d,$r) = each %$single_rel_files) { 155 if (-f "$r" && ! -l "$r") { 156 my $tmp=pb_get_content("$r"); 236 157 # Found the only possibility. 237 158 # Try to get version and return 238 if (defined ($distro_match {$d})) {239 ($release) = $tmp =~ m/$distro_match {$d}/m;159 if (defined ($distro_match->{$d})) { 160 ($release) = $tmp =~ m/$distro_match->{$d}/m; 240 161 } else { 241 162 print STDERR "Unable to find $d version in $r\n"; … … 250 171 # Ubuntu includes a /etc/debian_version file that creates an ambiguity with debian 251 172 # So we need to look at distros in reverse alphabetic order to treat ubuntu always first via lsb 252 foreach $d (reverse keys % ambiguous_rel_files) {253 $r = $ambiguous_rel_files {$d};254 if (-f "$ base/$r" && !-l "$base/$r") {173 foreach $d (reverse keys %$ambiguous_rel_files) { 174 $r = $ambiguous_rel_files->{$d}; 175 if (-f "$r" && !-l "$r") { 255 176 # Found one possibility. 256 177 # Get all distros concerned by that file 257 my $tmp=pb_get_content("$ base/$r");178 my $tmp=pb_get_content("$r"); 258 179 my $found = 0; 259 my $ptr = $distro_similar {$d};180 my $ptr = $distro_similar->{$d}; 260 181 pb_log(2,"amb: ".Dumper($ptr)."\n"); 261 182 $release = "unknown"; 262 foreach my $dd ( @$ptr) {183 foreach my $dd (split(/,/,$ptr)) { 263 184 pb_log(2,"check $dd\n"); 264 185 # Try to check pattern 265 if (defined $distro_match {$dd}) {266 pb_log(2,"cmp: $distro_match {$dd} - vs - $tmp\n");267 ($release) = $tmp =~ m/$distro_match {$dd}/m;186 if (defined $distro_match->{$dd}) { 187 pb_log(2,"cmp: $distro_match->{$dd} - vs - $tmp\n"); 188 ($release) = $tmp =~ m/$distro_match->{$dd}/m; 268 189 if ((defined $release) && ($release ne "unknown")) { 269 190 $distro = $dd;
Note:
See TracChangeset
for help on using the changeset viewer.