Changeset 1506


Ignore:
Timestamp:
05/09/12 02:46:34 (13 months ago)
Author:
bruno
Message:
  • Base.pm: add pb_path_expand to do the path expansion for config values. Print out all sudo'd commands if we haven't already so people know what they're typing their passwords in for. (Eric Anderson from aaf4d2337ab1554ba0c1f894108b3edc90996f69)
  • Env.pm: use pb_path_expand instead of inline expansion. (Eric Anderson from aaf4d2337ab1554ba0c1f894108b3edc90996f69)
  • VE.pm: Error out if vetype isn't defined; improve variable name, and verify that we don't try to launch a mips ve on x86_64 (previous check only prevented x86_64 on ix86). Use pb_path_expand to expand out the vepath also. Make sure to create the path to the VE before we try to bootstrap it. (Eric Anderson from aaf4d2337ab1554ba0c1f894108b3edc90996f69)
Location:
devel/pb-modules/lib/ProjectBuilder
Files:
3 edited

Legend:

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

    r1505 r1506  
    4141 
    4242our @ISA = qw(Exporter); 
    43 our @EXPORT = qw(pb_mkdir_p pb_system pb_rm_rf pb_get_date pb_log pb_log_init pb_get_uri pb_get_content pb_set_content pb_display_file pb_syntax_init pb_syntax pb_temp_init pb_get_arch pb_get_osrelease pb_check_requirements pb_check_req $pbdebug $pbLOG $pbdisplaytype $pblocale); 
     43our @EXPORT = qw(pb_mkdir_p pb_system pb_rm_rf pb_get_date pb_log pb_log_init pb_get_uri pb_get_content pb_set_content pb_display_file pb_syntax_init pb_syntax pb_temp_init pb_get_arch pb_get_osrelease pb_check_requirements pb_check_req pb_path_expand $pbdebug $pbLOG $pbdisplaytype $pblocale); 
    4444($VERSION,$REVISION) = pb_version_init(); 
    4545 
     
    153153unlink("$ENV{'PBTMP'}/system.$$.log") if (-f "$ENV{'PBTMP'}/system.$$.log"); 
    154154$redir = "2>> $ENV{'PBTMP'}/system.$$.log 1>> $ENV{'PBTMP'}/system.$$.log" if ((! defined $verbose) || ($verbose ne "noredir")); 
     155 
     156# If sudo used, then be more verbose 
     157pb_log(0,"Executing $cmd\n") if (($pbdebug < 1) && ($cmd =~ /^\s*\S*sudo/o)); 
     158 
    155159system("$cmd $redir"); 
    156160my $res = $?; 
     
    494498} 
    495499 
     500=item B<pb_path_expand> 
     501 
     502Expand out a path by environment variables as ($ENV{XXX}) and ~ 
     503 
     504=cut 
     505 
     506sub pb_path_expand { 
     507 
     508my $path = shift; 
     509 
     510eval { $path =~ s/(\$ENV.+\})/$1/eeg; }; 
     511$path =~ s/^\~/$ENV{HOME}/; 
     512 
     513return($path); 
     514} 
     515 
    496516=back  
    497517 
  • devel/pb-modules/lib/ProjectBuilder/Env.pm

    r1495 r1506  
    249249} 
    250250# Expand potential env variable in it 
    251 eval { $ENV{'PBDEFDIR'} =~ s/(\$ENV.+\})/$1/eeg }; 
    252  
     251$ENV{PBDEFDIR} = pb_path_expand($ENV{PBDEFDIR}); 
    253252pb_log(2,"PBDEFDIR: $ENV{'PBDEFDIR'}\n"); 
    254253 
  • devel/pb-modules/lib/ProjectBuilder/VE.pm

    r1352 r1506  
    1010use strict; 
    1111use Data::Dumper; 
     12use Carp 'confess'; 
    1213use English; 
    1314use ProjectBuilder::Version; 
     
    7273my $vetype = $ptr->{$ENV{'PBPROJ'}}; 
    7374 
     75confess "No vetype defined for $ENV{PBPROJ}" unless (defined $vetype); 
     76pb_log(1, "Using vetype $vetype for $ENV{PBPROJ}\n"); 
     77 
    7478if (($vetype eq "chroot") || ($vetype eq "schroot")) { 
    7579 
     
    8387    my $arch = pb_get_arch(); 
    8488    if ($arch ne $pbos->{'arch'}) { 
    85         die "Unable to launch a VE of architecture $pbos->{'arch'} on a $arch platform" if (($pbos->{'arch'} eq "x86_64") && ($arch =~ /i?86/)); 
     89        die "Unable to launch a VE of architecture $pbos->{'arch'} on a $arch platform" unless (($pbos->{'arch'} =~ /i?86/o) && ($arch eq "x86_64")); 
    8690    } 
    8791 
     
    9094    $sudocmd ="sudo " if ($EFFECTIVE_USER_ID != 0); 
    9195 
     96    my $root = pb_path_expand($vepath->{$ENV{PBPROJ}}); 
    9297    if (((defined $verebuild) && ($verebuild->{$ENV{'PBPROJ'}} =~ /true/i)) || ($pbforce == 1)) { 
    9398        my ($verpmtype,$vedebtype) = pb_conf_get("verpmtype","vedebtype"); 
     
    144149     
    145150                my $command = pb_check_req("rinse",0); 
    146                 pb_system("$sudocmd $command --directory \"$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}\" --arch \"$pbos->{'arch'}\" --distribution \"$pbos->{'name'}-$pbos->{'version'}\" --config \"$rbsconf->{$ENV{'PBPROJ'}}\" $b4post $postinstall $rbsopt $addpkgs $rinseverb","Creating the rinse VE for $pbos->{'name'}-$pbos->{'version'} ($pbos->{'arch'})", "verbose"); 
     151                pb_system("$sudocmd $command --directory \"$root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}\" --arch \"$pbos->{'arch'}\" --distribution \"$pbos->{'name'}-$pbos->{'version'}\" --config \"$rbsconf->{$ENV{'PBPROJ'}}\" $b4post $postinstall $rbsopt $addpkgs $rinseverb","Creating the rinse VE for $pbos->{'name'}-$pbos->{'version'} ($pbos->{'arch'})", "verbose"); 
    147152            } elsif ($verpmstyle eq "rpmbootstrap") { 
    148153                my $rbsverb = ""; 
     
    206211                $rbsopt .= " --components=main,universe" if ($pbos->{'name'} eq "ubuntu"); 
    207212         
    208                 pb_system("$sudocmd /usr/sbin/debootstrap $dbsverb $rbsopt --arch=$debarch $addpkgs $codename \"$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}\" $debmir","Creating the debootstrap VE for $pbos->{'name'}-$pbos->{'version'} ($pbos->{'arch'})", "verbose"); 
     213                pb_system("$sudocmd mkdir -p $root/$pbos->{name}/$pbos->{version}/$pbos->{arch} ; $sudocmd /usr/sbin/debootstrap $dbsverb $rbsopt --arch=$debarch $addpkgs $codename \"$root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}\" $debmir","Creating the debootstrap VE for $pbos->{'name'}-$pbos->{'version'} ($pbos->{'arch'})", "verbose"); 
    209214                # debootstrap doesn't create an /etc/hosts file 
    210                 if (! -f "$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/etc/hosts" ) { 
    211                     pb_system("$sudocmd cp /etc/hosts $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/etc/hosts"); 
     215                if (! -f "$root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/etc/hosts" ) { 
     216                    pb_system("$sudocmd cp /etc/hosts $root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/etc/hosts"); 
    212217                } 
    213218            } else { 
     
    222227     
    223228    # Fix modes to allow access to the VE for pb user 
    224     pb_system("$sudocmd chmod 755 $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'} $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'} $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}","Fixing permissions"); 
     229    pb_system("$sudocmd chmod 755 $root/$pbos->{'name'} $root/$pbos->{'name'}/$pbos->{'version'} $root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}","Fixing permissions"); 
    225230 
    226231    # Test if an existing snapshot exists and use it if appropriate 
    227232    # And also use it of no local extracted VE is present 
    228     if ((-f "$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz") && 
     233    if ((-f "$root/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz") && 
    229234    (((defined $vesnap->{$v}) && ($vesnap->{$v} =~ /true/i)) || 
    230235        ((defined $vesnap->{$ENV{'PBPROJ'}}) && ($vesnap->{$ENV{'PBPROJ'}} =~ /true/i)) || 
    231236        ($pbsnap eq 1) || 
    232         (! -d "$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}"))) { 
    233             pb_system("$sudocmd rm -rf $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'} ; $sudocmd mkdir -p $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'} ; $sudocmd tar xz  -C $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'} -f $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz","Extracting snapshot of $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz under $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}"); 
     237        (! -d "$root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}"))) { 
     238            pb_system("$sudocmd rm -rf $root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'} ; $sudocmd mkdir -p $root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'} ; $sudocmd tar xz  -C $root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'} -f $root/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz","Extracting snapshot of $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz under $root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}"); 
    234239    } 
    235240    # Nothing more to do for VE. No real launch 
Note: See TracChangeset for help on using the changeset viewer.