Ignore:
Timestamp:
Sep 1, 2019, 6:16:11 PM (5 years ago)
Author:
Bruno Cornec
Message:

Improve install2pkg when repo already configured and use the new pb_distro_installpkgs function

File:
1 edited

Legend:

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

    r2426 r2427  
    3333 
    3434our @ISA = qw(Exporter);
    35 our @EXPORT = qw(pb_distro_init pb_distro_conffile pb_distro_sysconffile pb_distro_api pb_distro_get pb_distro_getlsb pb_distro_installdeps pb_distro_getdeps pb_distro_only_deps_needed pb_distro_setuprepo pb_distro_setuposrepo pb_distro_setuprepo_gen pb_distro_get_param pb_distro_get_context pb_distro_to_keylist pb_distro_conf_print pb_apply_conf_proxy);
     35our @EXPORT = qw(pb_distro_init pb_distro_conffile pb_distro_sysconffile pb_distro_api pb_distro_get pb_distro_getlsb pb_distro_installdeps pb_distro_installpkgs pb_distro_getdeps pb_distro_only_deps_needed pb_distro_setuprepo pb_distro_setuposrepo pb_distro_setuprepo_gen pb_distro_get_param pb_distro_get_context pb_distro_to_keylist pb_distro_conf_print pb_apply_conf_proxy);
    3636($VERSION,$REVISION,$PBCONFVER) = pb_version_init();
    3737
     
    370370}
    371371
     372=item B<pb_distro_installpkgs>
     373
     374This function install the packages passed as parameters on a distribution.
     375
     376=cut
     377
     378sub pb_distro_installpkgs {
     379
     380my $pbos = shift;
     381my $pkgs = shift;    # list of pkgs to install
     382my $local = shift;   # optional should we install local packages or remote (for deb command is different)
     383
     384# Protection
     385confess "Missing install command for $pbos->{name}-$pbos->{version}-$pbos->{arch}" unless (defined $pbos->{install} && $pbos->{install} =~ /\w/);
     386pb_apply_conf_proxy($pbos);
     387pb_log(1, "ftp_proxy=$ENV{'ftp_proxy'}\n") if (defined $ENV{'ftp_proxy'});
     388pb_log(1, "http_proxy=$ENV{'http_proxy'}\n")  if (defined $ENV{'http_proxy'});
     389pb_log(1, "https_proxy=$ENV{'https_proxy'}\n")  if (defined $ENV{'https_proxy'});
     390
     391# This may not be // proof. We should test for availability of repo and sleep if not
     392my $cmd = "$pbos->{'install'} $pkgs";
     393$cmd = "$pbos->{'localinstall'} $pkgs" if ((defined $local) && (defined $pbos->{'localinstall'}) && ($pbos->{'localinstall'} !~ /[ ]*/));
     394my $ret = pb_system($cmd, "Installing packages ($cmd)","mayfail");
     395# Try to accomodate deficient proxies
     396if ($ret != 0) {
     397    $ret = pb_system($cmd, "Re-trying installing packages ($cmd)");
     398}
     399confess "Some packages did not install" if (($ret != 0) && ($Global::pb_stop_on_error));
     400}
     401
     402
    372403=item B<pb_distro_installdeps>
    373404
     
    388419my $local = shift;   # optional should we install local packages or remote (for deb command is different)
    389420
    390 # Protection
    391 confess "Missing install command for $pbos->{name}-$pbos->{version}-$pbos->{arch}" unless (defined $pbos->{install} && $pbos->{install} =~ /\w/);
    392 pb_apply_conf_proxy($pbos);
    393 pb_log(1, "ftp_proxy=$ENV{'ftp_proxy'}\n") if (defined $ENV{'ftp_proxy'});
    394 pb_log(1, "http_proxy=$ENV{'http_proxy'}\n")  if (defined $ENV{'http_proxy'});
    395 pb_log(1, "https_proxy=$ENV{'https_proxy'}\n")  if (defined $ENV{'https_proxy'});
    396 
    397421# Get dependencies in the build file if not forced
    398422$deps = pb_distro_getdeps($f,$pbos, $forcerepo) if ((not defined $deps) || (defined $forcerepo));
     
    400424return if ((not defined $deps) || ($deps =~ /^\s*$/));
    401425
    402 # This may not be // proof. We should test for availability of repo and sleep if not
    403 my $cmd = "$pbos->{'install'} $deps";
    404 $cmd = "$pbos->{'localinstall'} $deps" if ((defined $local) && (defined $pbos->{'localinstall'}) && ($pbos->{'localinstall'} !~ /[ ]*/));
    405 my $ret = pb_system($cmd, "Installing dependencies ($cmd)","mayfail");
    406 # Try to accomodate deficient proxies
    407 if ($ret != 0) {
    408     pb_system($cmd, "Re-trying installing dependencies ($cmd)");
    409 }
     426pb_distro_installpkgs($pbos,$deps,$local);
    410427# Check that all deps have been installed correctly
    411428# This time we don't forcerepo to avoid getting a list as a return as we have
     
    637654    if ((not defined $addrepo) || (not defined $addrepo->{$ENV{'PBPROJ'}})) {
    638655        my ($pbrepo) = pb_conf_get_in_hash_if($h,"pbrepo");
    639         return undef if (not defined $pbrepo);
     656        return(undef) if (not defined $pbrepo);
    640657        my $url = "$pbrepo->{$ENV{'PBPROJ'}}";
    641658        my ($testver,$delivery) = pb_conf_get_in_hash_if($h,"testver","delivery");
     
    677694my $param = shift;
    678695
    679 return if (not defined $param);
     696return(undef) if (not defined $param);
    680697
    681698pb_apply_conf_proxy($pbos);
     
    721738            }
    722739            my $dest = "$dirdest/$bn";
    723             return undef if (pb_distro_compare_repo("$ENV{'PBTMP'}/$bn",$dest) == 1);
     740            return(undef) if (pb_distro_compare_repo("$ENV{'PBTMP'}/$bn",$dest) == 1);
    724741            if (! -d $dirdest) {
    725742                cluck "Missing directory $dirdest ($reponame)";
    726                 return undef;
     743                return(undef);
    727744            }
    728745            pb_system("sudo mv $ENV{'PBTMP'}/$bn $dest","Adding $reponame repository") if (not -f "$dest");
     
    748765        } elsif ($bn =~ /\.addmedia/) {
    749766            # URPMI repo
    750             # We should test that it's not already a urpmi repo
    751             pb_system("chmod 755 $ENV{'PBTMP'}/$bn ; sudo $ENV{'PBTMP'}/$bn 2>&1 > /dev/null","Adding urpmi repository");
     767            # We should test that it's not an already setup urpmi repo
     768            open(URPMI,"/etc/urpmi/urpmi.cfg") || cluck "Unable to open /etc/urpmi/urpmi.cfg" && next;
     769            my $found = 0;
     770            my $entry = $bn;
     771            $entry =~ s/.addmedia$//;
     772            while (<URPMI>) {
     773                $found = 1 if ($_ =~ /^$entry /);
     774            }
     775            pb_system("chmod 755 $ENV{'PBTMP'}/$bn ; sudo $ENV{'PBTMP'}/$bn 2>&1 > /dev/null","Adding urpmi repository") if ($found == 0);
     776            pb_log(0,"INFO urpmi $bn already set up\n") if ($found == 1);
    752777        } else {
    753778            pb_log(0,"ERROR: Unable to deal with repository file $i on rpm distro ! Please report to dev team\n");
     
    756781        if ($bn =~ /\.sources.list$/) {
    757782            my $dest = "/etc/apt/sources.list.d/$bn";
    758             return if (pb_distro_compare_repo("$ENV{'PBTMP'}/$bn",$dest) == 1);
     783            return(undef) if (pb_distro_compare_repo("$ENV{'PBTMP'}/$bn",$dest) == 1);
    759784            pb_system("sudo mv $ENV{'PBTMP'}/$bn $dest","Adding apt repository $dest");
    760785            # Check whether GPG keys for this repo are already known and if
     
    771796            }
    772797            close(REPO);
    773             return if (not defined $debrepo);
     798            return(undef) if (not defined $debrepo);
    774799
    775800            pb_system("wget -O $ENV{'PBTMP'}/Release $debrepo/Release","Downloading $debrepo/Release");
     
    792817            }
    793818            close(SIGN);
    794             return if (not defined $signature);
     819            return(undef) if (not defined $signature);
    795820
    796821            pb_log(3, "GnuPG repo verify returned: $signature\n");
Note: See TracChangeset for help on using the changeset viewer.