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-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();
Note: See TracChangeset for help on using the changeset viewer.