Changeset 2410


Ignore:
Timestamp:
Apr 6, 2019, 3:24:26 AM (3 weeks ago)
Author:
bruno
Message:

2 fixes for debian repositories

  • Fix #178 by changing key detection in a more simple and compatible way
  • Fix #179 by adding a new pbgpgserver configuration parameter and its doc
Location:
devel/pb-modules
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/etc/pb.yml

    r2388 r2410  
    840840  default: origin
    841841
     842pbgpgserver:
     843  default: ipv4.pool.sks-keyservers.net
     844
    842845# Number of process in // for pb
    843846#pbparallel:
  • devel/pb-modules/etc/pb.yml.pod

    r2375 r2410  
    610610 Example: pbgpgcheck:
    611611            Lintel: 0
     612
     613=item B<pbgpgserver>
     614
     615 Nature: Mandatory
     616 Key: project (as defined in the -p option or PBPROJ environment variable)
     617 Value: The GPG server to use when looking for GPG keys.
     618 Conffile: pb
     619 Example: pbgpgserver:
     620            default: ipv4.pool.sks-keyservers.net
    612621
    613622=item B<pbinstalltype>
  • devel/pb-modules/lib/ProjectBuilder/Distribution.pm

    r2394 r2410  
    571571}
    572572
    573 =item B<pb_distro_setuposrepo>
    574 
    575 This function sets up potential additional repository for the setup phase
    576 
    577 =cut
    578 
    579 sub pb_distro_setuposrepo {
    580 
    581 my $pbos = shift;
    582 
    583 return(pb_distro_setuprepo_gen_conf($pbos,pb_distro_conffile(),"osrepo"));
    584 }
    585 
    586 =item B<pb_distro_setuprepo>
    587 
    588 This function sets up potential additional repository to the build environment
    589 
    590 =cut
    591 
    592 sub pb_distro_setuprepo {
    593 
    594 my $pbos = shift;
    595 
    596 return(pb_distro_setuprepo_gen_conf($pbos,"$ENV{'PBDESTDIR'}/pbrc.yml","addrepo"));
    597 }
    598 
    599573# Internal
    600574sub pb_distro_compare_repo {
     
    619593}
    620594
     595
     596=item B<pb_distro_setuposrepo>
     597
     598This function sets up potential additional repository for the setup phase
     599
     600=cut
     601
     602sub pb_distro_setuposrepo {
     603
     604my $pbos = shift;
     605
     606pb_log(3, "INFO: Adding osrepo from config file\n");
     607return(pb_distro_setuprepo_gen_conf($pbos,pb_distro_conffile(),"osrepo"));
     608}
     609
     610=item B<pb_distro_setuprepo>
     611
     612This function sets up potential additional repository to the build environment
     613
     614=cut
     615
     616sub pb_distro_setuprepo {
     617
     618my $pbos = shift;
     619
     620pb_log(3, "INFO: Adding addrepo from config file\n");
     621return(pb_distro_setuprepo_gen_conf($pbos,"$ENV{'PBDESTDIR'}/pbrc.yml","addrepo"));
     622}
    621623=item B<pb_distro_setuprepo_gen_conf>
    622624
     
    639641return undef if ($param eq "");
    640642
     643pb_log(1, "INFO: Adding repos $param\n");
    641644return(pb_distro_setuprepo_gen($pbos,$param));
    642645}
     
    752755            pb_system("wget -O $ENV{'PBTMP'}/Release $debrepo/Release","Downloading $debrepo/Release");
    753756            pb_system("wget -O $ENV{'PBTMP'}/Release.gpg $debrepo/Release.gpg","Downloading $debrepo/Release.gpg");
    754             my $signature;
    755             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;
     757            my $signature = undef;
     758            my ($pbgpgserver) = pb_conf_get("pbgpgserver");
     759            confess "Unable to find a GPG server in configuration, please define pbgpgserver" if (not defined $pbgpgserver);
     760            my $keyserver = $pbgpgserver->{$ENV{'PBPROJ'}};
     761            $keyserver = $pbgpgserver->{'default'} if (not defined $keyserver);
     762            confess "Unable to find a GPG server in configuration, please define correctly pbgpgserver" if (not defined $keyserver);
     763            open(SIGN,"LANGUAGE=C LANG=C gpg --verify --keyid-format=long $ENV{'PBTMP'}/Release.gpg $ENV{'PBTMP'}/Release 2>&1 |") || cluck "Unable to verify GPG signature from Release.gpg\n" && next;
    756764            while(<SIGN>) {
    757765                chomp();
    758                 if (/^gpg: .*key ID/) {
     766                if (/^gpg: .*key /) {
    759767                    $signature = $_;
    760                     $signature =~ s/^gpg: .*key ID ([A-Z0-9]+)/$1/;
    761                     #TODO: create a pbkeyserver conf var for that
    762                     pb_system("gpg --recv-keys --keyserver hkp://pgp.mit.edu $signature","Importing GPG signature for $signature");
    763                     $signature = undef;
     768                    $signature =~ s/^gpg: .*key [ID ]*([A-Z0-9]+)/$1/;
     769                    pb_system("gpg --recv-keys --keyserver $keyserver $signature","Importing GPG signature for $signature");
    764770                    last;
    765771                }
    766772            }
    767773            close(SIGN);
    768             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;
    769             while(<SIGN>) {
    770                 chomp();
    771                 if (/^gpg: Good signature/) {
    772                     $signature = $_;
    773                     $signature =~ s/^gpg: Good signature from "([^\"]+)"/$1/;
    774                 }
    775             }
    776             close(SIGN);
    777 
    778774            return if (not defined $signature);
     775
    779776            pb_log(3, "GnuPG repo verify returned: $signature\n");
    780             unlink("$ENV{'PBTMP'}/apt.sig");
    781777            pb_system("gpg -a --export -o $ENV{'PBTMP'}/apt.sig \'$signature\'","Exporting GnuPG signature of $signature");
    782778            pb_system("sudo apt-key add $ENV{'PBTMP'}/apt.sig","Adding GnuPG signature of $signature to APT key ring");
Note: See TracChangeset for help on using the changeset viewer.