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


Ignore:
Timestamp:
Feb 25, 2019, 12:20:27 PM (5 years ago)
Author:
Bruno Cornec
Message:

better usae of cluck instead of confess to avoid exiting abrutely when not needed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r2357 r2362  
    19851985            my $keyfile = pb_ssh_get(1);
    19861986            pb_mkdir_p("$ENV{'HOME'}/.abuild");
    1987             open(CONF,"> $ENV{'HOME'}/.abuild/abuild.conf") || confess "Unable to create the abuild conf file";
     1987            open(CONF,"> $ENV{'HOME'}/.abuild/abuild.conf") || cluck "Unable to create the abuild conf file" && return;
    19881988            print CONF "PACKAGER_PRIVKEY=\"$keyfile\"\n" if (defined $keyfile);
    19891989            close(CONF);
     
    26182618    # Remove a potential $ENV{'HOME'} as tdir should be relative to pb's home
    26192619    if ($cmt =~ /^VE/o) {
    2620         $tdir =~ s|\$ENV.+\}/|| or confess "for $cmt: $tdir must have \$ENV{'HOME'} in it or the remainder of the code won't work since some parts use relative pathing and others will try absolute.  Use a symlink if necessary to place the real files in a different place than under your home directory";
     2620        $tdir =~ s|\$ENV.+\}/|| or cluck "for $cmt: $tdir must have \$ENV{'HOME'} in it or the remainder of the code won't work since some parts use relative pathing and others will try absolute.  Use a symlink if necessary to place the real files in a different place than under your home directory" && return;
    26212621    } else {
    26222622        # process, ok if not present.
     
    26822682            # TODO: we don't do anything with found !!
    26832683            my $found = pb_ve_docker_get_image($tag{$pbstep});
    2684             confess "No image $tag{$pbstep} available in Docker, please create one first\n" if (not defined $found);
     2684            cluck "No image $tag{$pbstep} available in Docker, please create one first\n" if (not defined $found);
    26852685            # Now we use that image to do what is needed
    26862686            # use a dockerfile to ease the creation of next images
     
    27232723                $homedir = `$cmd1 run --cidfile="$cidfile" $tag{$pbstep} grep -E '^$dkaccount:' /etc/passwd | cut -d: -f6`;
    27242724                chomp($homedir);
    2725                 open(CID,"$cidfile") || confess "Unable to open $cidfile";
     2725                open(CID,"$cidfile") || cluck "Unable to open $cidfile" && return;
    27262726                my $cid = <CID>;
    27272727                close(CID);
     
    27932793        my ($pkg) = pb_conf_read("$ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.yml","pbpkg");
    27942794        my $pbextdir = pb_get_extdir();
    2795         confess "Unable to get package list" if (not defined $pkg);
     2795        if (not defined $pkg) {
     2796            cluck "Unable to get package list";
     2797            return
     2798        }
    27962799
    27972800        # We consider 2 specific packages
     
    28912894        }
    28922895        my $ts = "$ENV{'PBTMP'}/vebuild/".basename($pbscript2);
    2893         open(DOCKER," > $ts") || confess "Unable to create $ts";
     2896        open(DOCKER," > $ts") || cluck "Unable to create $ts" && return;
    28942897        print DOCKER "#!/bin/bash\n";
    28952898        print DOCKER "# Put content from host to guest, copying to have the correct uid/gid and rights to do so\n";
     
    35323535
    35333536    if (($action eq "test") && (! -x "$ENV{'PBDESTDIR'}/pbtest")) {
    3534         confess "No test script ($ENV{'PBDESTDIR'}/pbtest) found when in test mode. Aborting ...";
     3537        cluck "No test script ($ENV{'PBDESTDIR'}/pbtest) found when in test mode. Aborting ...";
     3538        next;
    35353539    }
    35363540    print SCRIPT "pb --version\n";
     
    37743778    # Do not use the one passed potentially with -a
    37753779    my ($pbac) = pb_conf_get($vtype."login");
    3776     confess "No $vtype"."login defined in your project yml conf file" if ((not defined $pbac) || (not defined $pbac->{$ENV{'PBPROJ'}}));
     3780    if ((not defined $pbac) || (not defined $pbac->{$ENV{'PBPROJ'}})) {
     3781        cluck "No $vtype"."login defined in your project yml conf file";
     3782        next;
     3783    }
    37773784
    37783785    my $key = "";
     
    48984905my $bdir;
    48994906
    4900 opendir($bdir,"$dir") || confess "Unable to open directory $dir: $!";
     4907opendir($bdir,"$dir") || cluck "Unable to open directory $dir: $!" && return;
    49014908foreach my $f (readdir($bdir)) {
    49024909    next if ($f =~ /^\./);
     
    51675174if (not defined $ENV{'PBPASSPHRASE'}) {
    51685175    if (not defined $ENV{'PBPASSFILE'}) {
    5169         confess("No pbpassphrase nor pbpassfile defined, unable to handle GPG Release file\n");
     5176        cluck("No pbpassphrase nor pbpassfile defined, unable to handle GPG Release file\n");
    51705177    } else {
    5171         open(PASS,"$ENV{'PBPASSFILE'}") || confess("Unable to open $ENV{'PBPASSFILE'}\n");
     5178        open(PASS,"$ENV{'PBPASSFILE'}") || cluck("Unable to open $ENV{'PBPASSFILE'}\n") && return;
    51725179        my $pass = <PASS>;
    51735180        chomp($pass);
Note: See TracChangeset for help on using the changeset viewer.