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


Ignore:
Timestamp:
Sep 30, 2014, 10:08:03 AM (10 years ago)
Author:
Bruno Cornec
Message:
  • Add support for docker phase 1: newve working
  • Add separate pb_ve_snap function
  • Add separate pb_ve_docker functions to interact with the registry and the repository
  • Add a dockerregistry conf parameter
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r1886 r1900  
    6262my $pbport;                 # Port to use to connect to the VM/RM
    6363my $newver;                 # New version to create
    64 my $iso = undef;            # ISO image for the VM to create
     64my $pbimage = undef;            # ISO image for the VM to create or docker image for the VE
     65my $vetype = undef;         # Type of Virtual environment to deal with
    6566
    6667my @date = pb_get_date();
     
    8586=head1 SYNOPSIS
    8687
    87 pb [-vhSq][-r pbroot][-p project][[-s script -a account -P port][-t [os-ver-arch]][-m os-ver-arch[,...]]][-g][-i iso] <action> [<pkg1> ...]
    88 
    89 pb [--verbose][--help][--man][--quiet][--snapshot][--revision pbroot][--project project][[--script script --account account --port port][--target [os-ver-arch]][--machine os-ver-arch[,...]]][--nographic][--iso iso][--rebuild] <action> [<pkg1> ...]
     88pb [-vhSq][-r pbroot][-p project][[-s script -a account -P port][-T VEtype][-t [os-ver-arch]][-m os-ver-arch[,...]]][-g][-i image] <action> [<pkg1> ...]
     89
     90pb [--verbose][--help][--man][--quiet][--snapshot][--revision pbroot][--project project][[--script script --account account --port port][-T VEtype][--target [os-ver-arch]][--machine os-ver-arch[,...]]][--nographic][--image image][--rebuild] <action> [<pkg1> ...]
    9091
    9192=head1 OPTIONS
     
    124125All if none precised (or use the env variable PBV).
    125126
     127=item B<-T|--vetype VEtype]>
     128
     129Type of Virtual Environments (VE)
     130Can be chroot or docker.
     131
    126132=item B<-s|--script script>
    127133
     
    132138Do not launch VMs in graphical mode.
    133139
    134 =item B<-i|--iso iso_image>
    135 
    136 Name of the ISO image of the distribution you want to install on the related VMs.
     140=item B<-i|--image image>
     141
     142It could be either:
     143- The name of the ISO image of the distribution you want to install on the related VMs
     144- The name of the docker image of the distribution you want to install on the related VEs
     145
    137146
    138147=item B<-a|--account account>
     
    670679
    671680GetOptions("help|?|h+" => \$opts{'h'},
     681        "account|a=s" => \$opts{'a'},
     682        "force|f" => \$opts{'f'},
     683        "nographic|g" => \$opts{'g'},
     684        "image|i=s" => \$opts{'i'},
     685        "log-files|l=s" => \$opts{'l'},
     686        "machines|mock|m=s" => \$opts{'m'},
    672687        "man" => \$opts{'man'},
    673         "verbose|v+" => \$opts{'v'},
    674         "snapshot|S" => \$opts{'S'},
    675         "quiet|q" => \$opts{'q'},
    676         "log-files|l=s" => \$opts{'l'},
    677         "force|f" => \$opts{'f'},
    678         "account|a=s" => \$opts{'a'},
    679         "revision|r=s" => \$opts{'r'},
    680         "script|s=s" => \$opts{'s'},
    681         "machines|mock|m=s" => \$opts{'m'},
    682         "target|t:s" => \$opts{'t'},
    683         "nographic|g" => \$opts{'g'},
    684688        "port|P=i" => \$opts{'P'},
    685689        "project|p=s" => \$opts{'p'},
     690        "quiet|q" => \$opts{'q'},
     691        "revision|r=s" => \$opts{'r'},
    686692        "rebuild" => \$opts{'rebuild'},
    687         "iso|i=s" => \$opts{'i'},
     693        "snapshot|S" => \$opts{'S'},
     694        "script|s=s" => \$opts{'s'},
     695        "type|T:s" => \$opts{'T'},
     696        "target|t:s" => \$opts{'t'},
    688697        "version|V=s" => \$opts{'V'},
     698        "verbose|v+" => \$opts{'v'},
    689699        "keep|k" => \$opts{'k'},
    690700        "stop-on-error!" => \$Global::pb_stop_on_error,
     
    743753}
    744754if (defined $opts{'i'}) {
    745     $iso = $opts{'i'};
     755    $pbimage = $opts{'i'};
    746756}
    747757if (defined $opts{'t'}) {
    748758    $pbtarget = $opts{'t'};
     759}
     760if (defined $opts{'T'}) {
     761    $vetype = $opts{'T'};
    749762}
    750763
     
    23532366    my ($shcmd,$shcmdroot,$cpcmd,$cptarget,$cp2target);
    23542367    my $tpdir;
     2368    my $tp;
    23552369    if ($cmt =~ /^VE/) {
    2356         my $tp = pb_path_expand($vepath->{$ENV{'PBPROJ'}});
     2370        $tp = pb_path_expand($vepath->{$ENV{'PBPROJ'}});
    23572371        $tpdir = pb_path_expand("$tp/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}");
    2358         my ($ptr) = pb_conf_get("vetype");
    2359         my $vetype = $ptr->{$ENV{'PBPROJ'}};
     2372        if (not defined $vetype) {
     2373            my ($ptr) = pb_conf_get("vetype");
     2374            $vetype = $ptr->{$ENV{'PBPROJ'}};
     2375        }
    23602376        my $arch = pb_get_arch();
    23612377        if ($vetype eq "chroot") {
     
    23642380        } elsif ($vetype eq "schroot") {
    23652381            $shcmd = "schroot $tp -u $mac -- ";
     2382        } elsif ($vetype eq "docker") {
     2383            # docker manages the storage so rely on it
     2384            $shcmdroot = "sudo /usr/bin/docker $tpdir ";
     2385            $shcmd = "$shcmdroot /bin/su - $mac -c ";
    23662386        }
    23672387        $shcmd = "setarch i386 $shcmd" if (($pbos->{'arch'} =~ /i[3456]86/) && ($arch eq 'x86_64'));
     
    25332553    }
    25342554    if (($cmt =~ /^VE/) && ($snapme != 0)) {
    2535         my $tpdir = "$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}";
    2536         pb_system("sudo tar cz -C $tpdir -f $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz .","Creating a snapshot of $tpdir");
     2555        pb_ve_snap($pbos,$tp);
    25372556    }
    25382557}
     
    26172636    # Launch the VMs/VEs
    26182637    if ($vtype eq "vm") {
    2619         die "-i iso parameter needed" if (((not defined $iso) || ($iso eq "")) && ($create != 0));
     2638        die "-i image parameter needed" if (((not defined $pbimage) || ($pbimage eq "")) && ($create != 0));
    26202639
    26212640        my ($ptr,$ptr2,$vmpath,$vmport,$vms) = pb_conf_get("vmtype","vmcmd","vmpath","vmport","vmsize");
     
    26832702        if (($vmtype eq "qemu") || ($vmtype eq "kvm")) {
    26842703            $vmm = "$vmpath->{$ENV{'PBPROJ'}}/$v.qemu";
    2685             if (($create != 0) || (defined $iso)) {
    2686                 $ENV{'PBVMOPT'} .= " -cdrom $iso -boot d";
     2704            if (($create != 0) || (defined $pbimage)) {
     2705                $ENV{'PBVMOPT'} .= " -cdrom $pbimage -boot d";
    26872706            }
    26882707            # Always redirect the network and always try to use a 'pb' snapshot
     
    27462765    } elsif ($vtype eq "ve") {
    27472766        # Force the creation of the VE and no snapshot usable
    2748         pb_ve_launch($v,$create,$usesnap);
     2767        pb_ve_launch($v,$create,$usesnap,$vetype,$pbimage);
    27492768    } else {
    27502769        # RM here
     
    35043523            # And shouldn't we be getting the one that matches the current pb version?
    35053524            # For the moment, just take the latest stable one
    3506             $cmdget = "wget --passive-ftp ftp://ftp.project-builder.org/src/ProjectBuilder-latest.tar.gz; wget --passive-ftp ftp://ftp.project-builder.org/src/project-builder-latest.tar.gz";
     3525            my $wget = pb_check_req("wget",0);
     3526            $cmdget = "$wget --passive-ftp ftp://ftp.project-builder.org/src/ProjectBuilder-latest.tar.gz; $wget --passive-ftp ftp://ftp.project-builder.org/src/project-builder-latest.tar.gz";
    35073527        }
    35083528        print SCRIPT << 'EOF';
Note: See TracChangeset for help on using the changeset viewer.