Changeset 622


Ignore:
Timestamp:
Nov 30, 2008, 12:32:47 PM (11 years ago)
Author:
Bruno Cornec
Message:
  • pb now uses pb_distro_installdeps in VM/VE setup
  • pb_get_distro => pb_distro_get for homogeneity
  • before installing packages, call the update of the pkg db before (may create issues, but is generally better)
  • Adds pb_distro_only_deps_needed to compute the packages in a list whose installation is really needed
Location:
devel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/lib/ProjectBuilder/Distribution.pm

    r621 r622  
    2020 
    2121our @ISA = qw(Exporter);
    22 our @EXPORT = qw(pb_distro_init pb_get_distro pb_distro_installdeps);
     22our @EXPORT = qw(pb_distro_init pb_distro_get pb_distro_installdeps pb_distro_getdeps pb_distro_only_deps_needed);
    2323
    2424=pod
     
    4949  # Return information on the running distro
    5050  #
    51   my ($ddir,$dver) = pb_get_distro();
     51  my ($ddir,$dver) = pb_distro_get();
    5252  my ($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd) = pb_distro_init($ddir,$dver);
    5353  print "distro tuple: ".Dumper($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd)."\n";
     
    5858
    5959
    60 =item B<pb_get_distro>
     60=item B<pb_distro_get>
    6161
    6262This 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.
     
    7676
    7777# 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));
    7979
    8080# There should be unicity of names between ddir dfam and dtype
     
    8585    $dtype="deb";
    8686    $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 ";
    8890} elsif ($ddir =~ /gentoo/) {
    8991    $dfam="gen";
     
    9193    $dver="nover";
    9294    $dsuf=".$ddir";
    93     $dupd="emerge ";
     95    $dupd="sudo emerge ";
    9496} elsif ($ddir =~ /slackware/) {
    9597    $dfam="slack";
     
    104106    $dtype="rpm";
    105107    $dsuf=".$ddir$dver";
    106     $dupd="yast2 -y ";
     108    $dupd="export TERM=linux ; sudo yast2 -y ";
    107109} elsif (($ddir =~ /redhat/) ||
    108110        ($ddir =~ /rhel/) ||
     
    122124        $opt="--exclude=*.i?86";
    123125    }
    124     $dupd="yum -y $opt install ";
     126    $dupd="sudo yum clean all; sudo yum update ; sudo yum -y $opt install ";
    125127    if ($ddir =~ /fedora/) {
    126128        $dsuf=".fc$dver1";
     
    134136        # older versions of rhel and centos ran up2date
    135137        if (($dver eq "2.1") || ($dver eq "3") || ($dver eq "4")) {
    136             $dupd="up2date -y ";
     138            $dupd="sudo up2date -y ";
    137139        }
    138140        $dsuf=".$ddir$dver1";
     
    153155        $dsuf=".mdv$dver";
    154156    }
    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 ";
    156160} elsif ($ddir =~ /freebsd/) {
    157161    $dfam="bsd";
     
    164168}
    165169
    166 # Update command needs to be run by root
    167 $dupd = "sudo ".$dupd;
    168 
    169170return($ddir, $dver, $dfam, $dtype, $dsuf, $dupd);
    170171}
     
    185186=cut
    186187
    187 sub pb_get_distro {
     188sub pb_distro_get {
    188189
    189190my $base="/etc";
     
    381382pb_log(3,"entering pb_distro_getdeps: $dtype - $f\n");
    382383# Protection
    383 return if (not defined $dtype);
     384return("") if (not defined $dtype);
    384385if ($dtype eq  "rpm") {
    385386    # In RPM this could include files, but we do not handle them atm.
     
    392393} else {
    393394    # No idea
    394     return;
     395    return("");
    395396}
    396397pb_log(2,"regexp: $regexp\n");
     
    398399
    399400# Protection
    400 return if (not defined $f);
     401return("") if (not defined $f);
    401402
    402403# Preserve separator before using the one we need
     
    423424$/ = $oldsep;
    424425pb_log(2,"now deps: $deps\n");
     426my $deps2 = pb_distro_only_deps_needed($dtype,$deps);
     427return($deps2);
     428}
     429
     430
     431=over 4
     432
     433=item B<pb_distro_only_deps_needed>
     434
     435This function returns only the dependencies not yet installed
     436
     437=cut
     438
     439sub pb_distro_only_deps_needed {
     440
     441my $deps = shift || undef;
     442my $dtype = shift || undef;
     443
    425444my $deps2 = "";
    426 
    427445# Avoid to install what is already there
    428446foreach my $p (split(/ /,$deps)) {
  • devel/pb/bin/pb

    r621 r622  
    19441944    pb_system("yum clean all","Cleaning yum env");
    19451945    if ($dver == 4) {
    1946         pb_system("$pbupd rpm-build wget patch ntp sudo perl-DateManip perl-ExtUtils-MakeMaker",$cmtall);
     1946        pb_distro_installdeps(undef,$dtype,$pbupd,pb_distro_only_deps_needed($dtype,"rpm-build wget patch ntp sudo perl-DateManip perl-ExtUtils-MakeMaker"));
    19471947        pb_system("$insmb","$cmtmb");
    19481948        pb_system("$insfm","$cmtfm");
     
    19511951        pb_system("$inslg","$cmtlg");
    19521952    } else {
    1953         pb_system("$pbupd rpm-build wget patch ntp sudo perl-DateManip perl-ExtUtils-MakeMaker perl-File-MimeInfo perl-Mail-Sendmail",$cmtall);
     1953        my $addp = "";
    19541954        if ($dver > 9) {
    1955             pb_system("$pbupd perl-gettext",$cmtall);
     1955            $addp = "perl-gettext";
    19561956        } else {
    19571957            pb_system("$inslg","$cmtlg");
    19581958        }
     1959        pb_distro_installdeps(undef,$dtype,$pbupd,pb_distro_only_deps_needed($dtype,"rpm-build wget patch ntp sudo perl-DateManip perl-ExtUtils-MakeMaker perl-File-MimeInfo perl-Mail-Sendmail $addp"));
    19591960    }
    19601961} elsif (( $dfam eq "rh" ) || ($ddir eq "sles") || (($ddir eq "suse") && (($dver eq "10.1") || ($dver eq "10.0"))) || ($ddir eq "slackware")) {
     
    19731974    pb_system("$insfb","$cmtfb");
    19741975    pb_system("$insms","$cmtms");
    1975     pb_system("export TERM=linux ; liste=\"\" ; for i in make wget patch sudo perl-DateManip perl-File-HomeDir perl-Mail-Sendmail ntp; do rpm -q \$i 1> /dev/null 2> /dev/null ; if [ \$\? != 0 ]; then liste=\"\$liste \$i\"; fi; done; echo \"Liste: \$liste\" ; if [ \"\$liste\" != \"\" ]; then $pbupd \$liste ; fi","$cmtall");
     1976    pb_distro_installdeps(undef,$dtype,$pbupd,pb_distro_only_deps_needed($dtype,"make wget patch sudo perl-DateManip perl-File-HomeDir perl-Mail-Sendmail ntp"));
    19761977} elsif ( $dfam eq "md" ) {
    1977         pb_system("urpmi.update -a ; $pbupd rpm-build wget sudo patch ntp-client perl-File-MimeInfo perl-Mail-Sendmail perl-Locale-gettext","$cmtall");
     1978        my $addp = "";
    19781979        if (($ddir eq "mandrake") && ($dver eq "10.1")) {
    19791980            pb_system("$insdm","$cmtdm");
    19801981            pb_system("$inslg","$cmtlg");
    19811982        } else {
    1982             pb_system("$pbupd perl-DateManip","$cmtdm");
    1983             pb_system("$pbupd perl-Locale-gettext","$cmtdm");
    1984         }
     1983            $addp ="perl-DateManip perl-Locale-gettext";
     1984        }
     1985        pb_distro_installdeps(undef,$dtype,$pbupd,pb_distro_only_deps_needed($dtype,"rpm-build wget sudo patch ntp-client perl-File-MimeInfo perl-Mail-Sendmail perl-Locale-gettext $addp"));
    19851986} elsif ( $dfam eq "du" ) {
    19861987    if (( $dver eq "3.1" ) && ($ddir eq "debian")) {
    1987         #system "apt-get update";
    19881988        pb_system("$insfb","$cmtfb");
    19891989        pb_system("$insfm","$cmtfm");
    1990         pb_system("apt-get -y install wget patch ssh sudo debian-builder dh-make fakeroot ntpdate libmodule-build-perl libdate-manip-perl libmail-sendmail-perl liblocale-gettext-perl","$cmtall");
     1990        pb_distro_installdeps(undef,$dtype,$pbupd,pb_distro_only_deps_needed($dtype,"wget patch ssh sudo debian-builder dh-make fakeroot ntpdate libmodule-build-perl libdate-manip-perl libmail-sendmail-perl liblocale-gettext-perl"));
    19911991    } else  {
    1992         pb_system("apt-get update; $pbupd wget patch openssh-server dpkg-dev sudo debian-builder dh-make fakeroot ntpdate libfile-mimeinfo-perl libmodule-build-perl libdate-manip-perl libmail-sendmail-perl liblocale-gettext-perl","$cmtall");
     1992        pb_distro_installdeps(undef,$dtype,$pbupd,pb_distro_only_deps_needed($dtype,"wget patch openssh-server dpkg-dev sudo debian-builder dh-make fakeroot ntpdate libfile-mimeinfo-perl libmodule-build-perl libdate-manip-perl libmail-sendmail-perl liblocale-gettext-perl"));
    19931993    }
    19941994} elsif ( $dfam eq "gen" ) {
    19951995        #system "emerge -u system";
    1996         pb_system("$pbupd wget sudo ntp DateManip File-MimeInfo Mail-Sendmail Locale-gettext","$cmtall");
     1996        pb_distro_installdeps(undef,$dtype,$pbupd,pb_distro_only_deps_needed($dtype,"wget sudo ntp DateManip File-MimeInfo Mail-Sendmail Locale-gettext"));
    19971997} else {
    19981998    pb_log(0,"No pkg to install\n");
Note: See TracChangeset for help on using the changeset viewer.