Changeset 2362


Ignore:
Timestamp:
Feb 25, 2019, 12:20:27 PM (8 months ago)
Author:
bruno
Message:

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

Location:
devel
Files:
5 edited

Legend:

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

    r2300 r2362  
    1515
    1616use strict;
    17 use Carp 'confess';
     17use Carp qw/cluck confess/;
    1818use Data::Dumper;
    1919use ProjectBuilder::Base;
     
    185185# Read the content of the config file and cache it in the %h hash then available for queries
    186186if ($PBCONFVER < 1) {
    187     open(CONF,$cf) || confess "Unable to open $cf";
     187    open(CONF,$cf) || cluck "Unable to open $cf" && return($lh);
    188188    # This is the original conf file format for versions up to 0.14
    189189    while(<CONF>) {
     
    331331confess "No configuration file defined to write into !" if (not defined $conffile);
    332332confess "No hash defined to read from !" if (not defined $h);
    333 open(CONF,"> $conffile") || confess "Unable to write into $conffile";
     333open(CONF,"> $conffile") || cluck "Unable to write into $conffile" && return;
    334334
    335335if ($PBCONFVER < 1) {
     
    547547my $dest = shift;
    548548
    549 open(ORIG,$orig) || confess "Unable to open $orig";
     549open(ORIG,$orig) || cluck "Unable to open $orig" && return;
    550550confess "Will not erase existing $dest while transforming $orig" if (-f $dest);
    551 open(DEST,"> $dest") || confess "Unable to write into $dest";
     551open(DEST,"> $dest") || cluck "Unable to write into $dest" && return;
    552552print DEST "---\n";
    553553my $pbconfverbkp = $PBCONFVER;
  • devel/pb-modules/lib/ProjectBuilder/Distribution.pm

    r2361 r2362  
    1414use strict;
    1515use Data::Dumper;
    16 use Carp 'confess';
     16use Carp qw/cluck confess/;
    1717use ProjectBuilder::Version;
    1818use ProjectBuilder::Base;
     
    228228while (($d,$r) = each %$single_rel_files) {
    229229    if (defined $ambiguous_rel_files->{$d}) {
    230         print STDERR "The key $d is considered as both unambiguous and ambigous.\n";
     230        print STDERR "The key $d is considered as both unambiguous and ambiguous.\n";
    231231        confess "Please fix your configuration file.\n"
    232232    }
     
    291291if ($found == 0) {
    292292    print STDERR "Unable to find a version in ".join(' ',keys %$ambiguous_rel_files)." (ambiguous)\n";
    293     print STDERR "Please report to the maintainer bruno_at_project-builder.org\n";
    294293    confess "Please report to the maintainer bruno_at_project-builder.org\n";
    295294} else {
     
    450449my $oldsep = $/;
    451450$/ = $sep;
    452 open(DESC,"$f") || confess "Unable to open $f";
     451open(DESC,"$f") || cluck "Unable to open $f" && return("");
    453452while (<DESC>) {
    454453    pb_log(4,"read: $_\n");
     
    541540        my $res = pb_system("dpkg -L $p","Looking for $p","mayfail");
    542541        next if ($res eq 0);
    543         open(CMD,"dpkg -l $p |") or confess "Unable to run dpkg -l $p: $!";
     542        open(CMD,"dpkg -l $p |") || cluck "Unable to run dpkg -l $p: $!" && next;
    544543        my $ok = 0;
    545544        while (<CMD>) {
     
    689688                $dirdest = "/etc/zypp/repos.d";
    690689            } else {
    691                 confess "Unknown location for repository file for '$pbos->{install}' command";
     690                cluck "Unknown location for repository file for '$pbos->{install}' command";
     691                next;
    692692            }
    693693            my $dest = "$dirdest/$bn";
    694694            return undef if (pb_distro_compare_repo("$ENV{'PBTMP'}/$bn",$dest) == 1);
    695             confess "Missing directory $dirdest ($reponame)" unless (-d $dirdest);
     695            if (! -d $dirdest) {
     696                cluck "Missing directory $dirdest ($reponame)";
     697                return undef;
     698            }
    696699            pb_system("sudo mv $ENV{'PBTMP'}/$bn $dest","Adding $reponame repository") if (not -f "$dest");
    697700            # OpenSUSE does't seem to import keys automatically
     
    699702            if ($pbos->{install} =~ /\bzypper\b/) {
    700703                my $keyfile = undef;
    701                 open(REPO,"$dest") || confess "Unable to open $dest";
     704                open(REPO,"$dest") || cluck "Unable to open $dest" && next;
    702705                while (<REPO>) {
    703706                    $keyfile = $_;
     
    728731            # Check whether GPG keys for this repo are already known and if
    729732            # not add them
    730             open(REPO,"$dest") || confess "Unable to open $dest";
     733            open(REPO,"$dest") || cluck "Unable to open $dest" && next;
    731734            my $debrepo;
    732735            while (<REPO>) {
     
    744747            pb_system("wget -O $ENV{'PBTMP'}/Release.gpg $debrepo/Release.gpg","Downloading $debrepo/Release.gpg");
    745748            my $signature;
    746             open(SIGN,"LANGUAGE=C LANG=C gpg --verify $ENV{'PBTMP'}/Release.gpg $ENV{'PBTMP'}/Release 2>&1 |") || confess "Unable to verify GPG signature from Release.gpg\n";
     749            open(SIGN,"LANGUAGE=C LANG=C gpg --verify $ENV{'PBTMP'}/Release.gpg $ENV{'PBTMP'}/Release 2>&1 |") || cluck "Unable to verify GPG signature from Release.gpg\n" && next;
    747750            while(<SIGN>) {
    748751                chomp();
     
    757760            }
    758761            close(SIGN);
    759             open(SIGN,"LANGUAGE=C LANG=C gpg --verify $ENV{'PBTMP'}/Release.gpg $ENV{'PBTMP'}/Release 2>&1 |") || confess "Unable to verify GPG signature from $debrepo/Release.gpg\n";
     762            open(SIGN,"LANGUAGE=C LANG=C gpg --verify $ENV{'PBTMP'}/Release.gpg $ENV{'PBTMP'}/Release 2>&1 |") || cluck "Unable to verify GPG signature from $debrepo/Release.gpg\n" && next;
    760763            while(<SIGN>) {
    761764                chomp();
  • 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);
  • devel/pb/lib/ProjectBuilder/CMS.pm

    r2333 r2362  
    1414
    1515use strict 'vars';
    16 use Carp 'confess';
     16use Carp 'cluck';
    1717use Data::Dumper;
    1818use English;
     
    194194if ((defined $testver) && (defined $testver->{$ENV{'PBPROJ'}}) && ($testver->{$ENV{'PBPROJ'}} =~ /true/i)) {
    195195    if (! -f "$dest/ChangeLog") {
    196         open(CL,"> $dest/ChangeLog") || confess "Unable to create $dest/ChangeLog";
     196        open(CL,"> $dest/ChangeLog") || cluck "Unable to create $dest/ChangeLog" && return;
    197197        # We need a minimal version for debian type of build
    198198        print CL "\n";
  • devel/pbmkbm/bin/pbmkbm

    r2279 r2362  
    457457
    458458my $busycmd = pb_distro_get_param($pbos,pb_conf_get("ospathcmd-busybox"));
    459 open(BUSY,"$busycmd |") || confess "ERROR: Unable to execute $busycmd";
     459open(BUSY,"$busycmd |") || cluck "ERROR: Unable to execute $busycmd" && return;
    460460my $cmdlist = 0;
    461461while (<BUSY>) {
Note: See TracChangeset for help on using the changeset viewer.