Changeset 1111 in ProjectBuilder for devel/pb/bin/pb


Ignore:
Timestamp:
Nov 18, 2010, 2:06:01 AM (13 years ago)
Author:
Bruno Cornec
Message:
  • Rename previous option osupd into the more correct osins, and add a real osupd param to support distribution update commands
  • Adds 2 new commands to update distributions in VM|VE with updatevm|ve (Fix #70)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r1109 r1111  
    257257
    258258Snapshot a virtual environment for pb usage
     259
     260=item B<updatevm>
     261
     262Update the distribution in the virtual machine
     263
     264=item B<updateve>
     265
     266Update the distribution in the virtual environment
    259267
    260268=item B<test2pkg>
     
    530538} elsif ($action =~ /^setupvm$/) {
    531539    pb_setup2v("vm");
     540} elsif ($action =~ /^updateve$/) {
     541    pb_update2v("ve");
     542} elsif ($action =~ /^updatevm$/) {
     543    pb_update2v("vm");
    532544} elsif ($action =~ /^snapve$/) {
    533545    pb_snap2v("ve");
     
    670682        my %build;
    671683        # We want to at least build for the underlying distro
    672         my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $arch) = pb_distro_init();
     684        my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $arch) = pb_distro_init();
    673685        my $tmpl = "$ddir-$dver-$arch,";
    674686        my %patches;
     
    929941sub pb_test2pkg {
    930942    # Get the running distro to test on
    931     my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $arch) = pb_distro_init();
    932     pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $arch))."\n");
     943    my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $arch) = pb_distro_init();
     944    pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $pbins, $arch))."\n");
    933945
    934946    # Get list of packages to test
     
    941953    foreach my $pbpkg (@pkgs) {
    942954        # We need to install the package to test, and deps brought with it
    943         pb_distro_installdeps(undef,$dtype,$pbupd,$pbpkg);
     955        pb_distro_installdeps(undef,$dtype,$pbins,$pbpkg);
    944956        pb_system("$ENV{'PBDESTDIR'}/pbtest","Launching test for $pbpkg","verbose");
    945957    }
     
    949961
    950962    # Get the running distro to build on
    951     my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $arch) = pb_distro_init();
    952     pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $arch))."\n");
     963    my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $arch) = pb_distro_init();
     964    pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $pbins, $arch))."\n");
    953965
    954966    # Get list of packages to build
     
    10021014            foreach my $f (@specfile) {
    10031015                if ($f =~ /\.spec$/) {
    1004                     pb_distro_installdeps($f,$dtype,$pbupd);
     1016                    pb_distro_installdeps($f,$dtype,$pbins);
    10051017                    pb_system("rpmbuild $specialdef --define \"packager $ENV{'PBPACKAGER'}\" --define \"_topdir $ENV{'PBBUILDDIR'}\" -ba $f","Building package with $f under $ENV{'PBBUILDDIR'}","verbose");
    10061018                    last;
     
    10281040
    10291041            pb_distro_setuprepo($ddir,$dver,$arch,$dtype);
    1030             pb_distro_installdeps("debian/control",$dtype,$pbupd);
     1042            pb_distro_installdeps("debian/control",$dtype,$pbins);
    10311043            pb_system("dpkg-buildpackage -us -uc -rfakeroot","Building package","verbose");
    10321044            # Get the name of the generated packages
     
    10811093            foreach my $f (@ebuildfile) {
    10821094                if ($f =~ /\.ebuild$/) {
    1083                     pb_distro_installdeps($f,$dtype,$pbupd);
     1095                    pb_distro_installdeps($f,$dtype,$pbins);
    10841096                    move($f,"$tmpd/$pbpkg-$pbver.ebuild");
    10851097                    pb_system("cd $tmpd ; ebuild $pbpkg-$pbver.ebuild clean ; ebuild $pbpkg-$pbver.ebuild digest ; ebuild $pbpkg-$pbver.ebuild package","verbose");
     
    11011113            symlink "pbconf/$ddir-$dver-$arch","install" || die "Unable to symlink to pbconf/$ddir-$dver-$arch";
    11021114            if (-x "install/pbslack") {
    1103                 pb_distro_installdeps("./install/pbslack",$dtype,$pbupd);
     1115                pb_distro_installdeps("./install/pbslack",$dtype,$pbins);
    11041116                pb_system("./install/pbslack","Building software");
    11051117                pb_system("sudo /sbin/makepkg -p -l y -c y $pbpkg","Packaging $pbpkg","verbose");
     
    12571269    my $src = "";
    12581270    my ($odir,$over,$oarch) = (undef, undef, undef);
    1259     my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $darch);
     1271    my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $darch);
    12601272
    12611273    if ($cmt ne "Announce") {
     
    12681280            ($odir,$over,$oarch) = split(/-/,$v);
    12691281        }
    1270         ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $darch) = pb_distro_init($odir,$over,$oarch);
    1271         pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf, $darch))."\n");
     1282        ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $darch) = pb_distro_init($odir,$over,$oarch);
     1283        pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $pbins, $darch))."\n");
    12721284
    12731285        # Get list of packages to build
     
    23152327    my ($name,$ver,$darch) = split(/-/,$v);
    23162328    chomp($darch);
    2317     my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd) = pb_distro_init($name,$ver,$darch);
     2329    my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins) = pb_distro_init($name,$ver,$darch);
    23182330   
    23192331    # Name of the account to deal with for VM/VE
     
    25142526# And we now need the conf file required for this to work created above
    25152527
    2516 my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $darch) = pb_distro_init();
    2517 print "distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf, $darch))."\n";
     2528my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $darch) = pb_distro_init();
     2529print "distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $pbins, $darch))."\n";
    25182530
    25192531# Adapt sudoers
     
    25752587   
    25762588my $pkgdep = pb_distro_get_param($ddir,$dver,$darch,$ospkgdep,$dfam,$dtype,$dos);
    2577 pb_distro_installdeps(undef,$dtype,$pbupd,pb_distro_only_deps_needed($dtype,join(' ',split(/,/,$pkgdep))));
     2589pb_distro_installdeps(undef,$dtype,$pbins,pb_distro_only_deps_needed($dtype,join(' ',split(/,/,$pkgdep))));
    25782590
    25792591EOF
     
    26022614my $pkgforpb = pb_distro_get_param($ddir,$dver,$darch,$pbpkg,$dfam,$dtype,$depdos);
    26032615pb_distro_setuprepo($ddir,$dver,$darch,$dtype);
    2604 pb_distro_installdeps(undef,$dtype,$pbupd,pb_distro_only_deps_needed($dtype,join(' ',split(/,/,$pkgforpb))));
     2616pb_distro_installdeps(undef,$dtype,$pbins,pb_distro_only_deps_needed($dtype,join(' ',split(/,/,$pkgforpb))));
    26052617EOF
    26062618    } else {
     
    26532665    $pbaccount = "root";
    26542666
    2655     # Force shutdown of VM exept if it was already launched
     2667    # Force shutdown of VM except if it was already launched
    26562668    my $pbforce = 0;
    26572669    if ((! $vmexist) && ($vtype eq "vm")) {
     
    26882700            pb_system("sudo rm -f $vepath->{$ENV{'PBPROJ'}}/$ddir-$dver-$darch.tar.gz","Removing previous snapshot $ddir-$dver-$darch.tar.gz");
    26892701    }
    2690 
    2691     # Name of the account to deal with for VM/VE
    2692     # Do not use the one passed potentially with -a
    2693     my ($vmexist,$vmpid);
    26942702
    26952703    # Prepare the script to be executed on the VM/VE
     
    27072715    # Force snapshot of VM/VE
    27082716    pb_script2v($pbscript,$vtype,1,$v,1);
     2717}
     2718return;
     2719}
     2720
     2721# Function to update a VMs or VEs with the latest distribution content
     2722sub pb_update2v {
     2723
     2724my $vtype = shift;
     2725
     2726my ($vm,$all) = pb_get2v($vtype);
     2727
     2728# Script generated
     2729my $pbscript = "$ENV{'PBDESTDIR'}/updatev";
     2730
     2731my ($pbac) = pb_conf_get($vtype."login");
     2732
     2733foreach my $v (@$vm) {
     2734    # Get distro context
     2735    my ($name,$ver,$darch) = split(/-/,$v);
     2736    chomp($darch);
     2737    my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins) = pb_distro_init($name,$ver,$darch);
     2738
     2739    # Prepare the script to be executed on the VM/VE
     2740    # in $ENV{'PBDESTDIR'}/updatev
     2741    open(SCRIPT,"> $pbscript") || die "Unable to create $pbscript";
     2742   
     2743    print SCRIPT << 'EOF';
     2744    #!/bin/bash
     2745    sleep 2
     2746EOF
     2747    # VE needs a good /proc
     2748    if ($vtype eq "ve") {
     2749        print SCRIPT "sudo mount -t proc /proc /proc\n";
     2750    }
     2751    print SCRIPT "$pbupd\n";
     2752    if ($vtype eq "ve") {
     2753        print SCRIPT "sudo umount /proc\n";
     2754    }
     2755    close(SCRIPT);
     2756    chmod 0755,"$pbscript";
     2757
     2758    # Force shutdown of VM except
     2759    pb_script2v($pbscript,$vtype,1,$v);
    27092760}
    27102761return;
Note: See TracChangeset for help on using the changeset viewer.