Changeset 622 in ProjectBuilder for devel/pb-modules
- Timestamp:
- Nov 30, 2008, 12:32:47 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/lib/ProjectBuilder/Distribution.pm
r621 r622 20 20 21 21 our @ISA = qw(Exporter); 22 our @EXPORT = qw(pb_distro_init pb_ get_distro pb_distro_installdeps);22 our @EXPORT = qw(pb_distro_init pb_distro_get pb_distro_installdeps pb_distro_getdeps pb_distro_only_deps_needed); 23 23 24 24 =pod … … 49 49 # Return information on the running distro 50 50 # 51 my ($ddir,$dver) = pb_ get_distro();51 my ($ddir,$dver) = pb_distro_get(); 52 52 my ($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd) = pb_distro_init($ddir,$dver); 53 53 print "distro tuple: ".Dumper($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd)."\n"; … … 58 58 59 59 60 =item B<pb_ get_distro>60 =item B<pb_distro_get> 61 61 62 62 This function returns a list of 2 parameters indicating the distribution name and version of the underlying Linux distribution. The value of those 2 fields may be "unknown" in case the function was unable to recognize on which distribution it is running. … … 76 76 77 77 # If we don't know which distribution we're on, then guess it 78 ($ddir,$dver) = pb_ get_distro() if ((not defined $ddir) || (not defined $dver));78 ($ddir,$dver) = pb_distro_get() if ((not defined $ddir) || (not defined $dver)); 79 79 80 80 # There should be unicity of names between ddir dfam and dtype … … 85 85 $dtype="deb"; 86 86 $dsuf=".$ddir$dver"; 87 $dupd="apt-get -y install "; 87 # Chaining the commands allow to only test for what is able o be installed, 88 # not the update of the repo which may well be unaccessible if too old 89 $dupd="sudo apt-get update ; sudo apt-get -y install "; 88 90 } elsif ($ddir =~ /gentoo/) { 89 91 $dfam="gen"; … … 91 93 $dver="nover"; 92 94 $dsuf=".$ddir"; 93 $dupd=" emerge ";95 $dupd="sudo emerge "; 94 96 } elsif ($ddir =~ /slackware/) { 95 97 $dfam="slack"; … … 104 106 $dtype="rpm"; 105 107 $dsuf=".$ddir$dver"; 106 $dupd=" yast2 -y ";108 $dupd="export TERM=linux ; sudo yast2 -y "; 107 109 } elsif (($ddir =~ /redhat/) || 108 110 ($ddir =~ /rhel/) || … … 122 124 $opt="--exclude=*.i?86"; 123 125 } 124 $dupd=" yum -y $opt install ";126 $dupd="sudo yum clean all; sudo yum update ; sudo yum -y $opt install "; 125 127 if ($ddir =~ /fedora/) { 126 128 $dsuf=".fc$dver1"; … … 134 136 # older versions of rhel and centos ran up2date 135 137 if (($dver eq "2.1") || ($dver eq "3") || ($dver eq "4")) { 136 $dupd=" up2date -y ";138 $dupd="sudo up2date -y "; 137 139 } 138 140 $dsuf=".$ddir$dver1"; … … 153 155 $dsuf=".mdv$dver"; 154 156 } 155 $dupd="urpmi --auto "; 157 # Chaining the commands allow to only test for what is able o be installed, 158 # not the update of the repo which may well be unaccessible if too old 159 $dupd="sudo urpmi.update -a ; sudo urpmi --auto "; 156 160 } elsif ($ddir =~ /freebsd/) { 157 161 $dfam="bsd"; … … 164 168 } 165 169 166 # Update command needs to be run by root167 $dupd = "sudo ".$dupd;168 169 170 return($ddir, $dver, $dfam, $dtype, $dsuf, $dupd); 170 171 } … … 185 186 =cut 186 187 187 sub pb_ get_distro{188 sub pb_distro_get { 188 189 189 190 my $base="/etc"; … … 381 382 pb_log(3,"entering pb_distro_getdeps: $dtype - $f\n"); 382 383 # Protection 383 return if (not defined $dtype);384 return("") if (not defined $dtype); 384 385 if ($dtype eq "rpm") { 385 386 # In RPM this could include files, but we do not handle them atm. … … 392 393 } else { 393 394 # No idea 394 return ;395 return(""); 395 396 } 396 397 pb_log(2,"regexp: $regexp\n"); … … 398 399 399 400 # Protection 400 return if (not defined $f);401 return("") if (not defined $f); 401 402 402 403 # Preserve separator before using the one we need … … 423 424 $/ = $oldsep; 424 425 pb_log(2,"now deps: $deps\n"); 426 my $deps2 = pb_distro_only_deps_needed($dtype,$deps); 427 return($deps2); 428 } 429 430 431 =over 4 432 433 =item B<pb_distro_only_deps_needed> 434 435 This function returns only the dependencies not yet installed 436 437 =cut 438 439 sub pb_distro_only_deps_needed { 440 441 my $deps = shift || undef; 442 my $dtype = shift || undef; 443 425 444 my $deps2 = ""; 426 427 445 # Avoid to install what is already there 428 446 foreach my $p (split(/ /,$deps)) {
Note:
See TracChangeset
for help on using the changeset viewer.