This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=d861e635c7bef4dda9afd758ec90bb93be3ebe27 commit d861e635c7bef4dda9afd758ec90bb93be3ebe27 Author: Guillem Jover <[email protected]> AuthorDate: Fri Jul 29 19:59:18 2022 +0200 Dpkg::OpenPGP: Pass opts as a hash ref on the first argument This unifies the current interface, and takes it closer to the Stateless OpenPGP CLI draft. --- scripts/Dpkg/OpenPGP.pm | 26 +++++++++++++------------- scripts/Dpkg/Source/Package.pm | 22 +++++++++++----------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/scripts/Dpkg/OpenPGP.pm b/scripts/Dpkg/OpenPGP.pm index 71be17d79..04b35e869 100644 --- a/scripts/Dpkg/OpenPGP.pm +++ b/scripts/Dpkg/OpenPGP.pm @@ -91,7 +91,7 @@ sub openpgp_sig_to_asc sub _exec_openpgp { - my ($exec, $opts, $errmsg) = @_; + my ($opts, $exec, $errmsg) = @_; my ($stdout, $stderr); spawn(exec => $exec, wait_child => 1, nocheck => 1, timeout => 10, @@ -110,14 +110,14 @@ sub _exec_openpgp } sub import_key { - my ($asc, %opts) = @_; + my ($opts, $asc) = @_; - $opts{require_valid_signature} //= 1; + $opts->{require_valid_signature} //= 1; my @exec; if (find_command('gpg')) { push @exec, 'gpg'; - } elsif ($opts{require_valid_signature}) { + } elsif ($opts->{require_valid_signature}) { error(g_('cannot import key in %s since GnuPG is not installed'), $asc); } else { @@ -130,17 +130,17 @@ sub import_key { push @exec, '--homedir', $gpghome; push @exec, '--no-options', '--no-default-keyring', '-q', '--import'; - push @exec, '--keyring', $opts{keyring}; + push @exec, '--keyring', $opts->{keyring}; push @exec, $asc; - my $errmsg = sprintf g_('cannot import key %s into %s'), $asc, $opts{keyring}; - _exec_openpgp(\@exec, \%opts, $errmsg); + my $errmsg = sprintf g_('cannot import key %s into %s'), $asc, $opts->{keyring}; + _exec_openpgp($opts, \@exec, $errmsg); } sub verify_signature { - my ($sig, %opts) = @_; + my ($opts, $sig) = @_; - $opts{require_valid_signature} //= 1; + $opts->{require_valid_signature} //= 1; my @gpg_weak_digest = map { (qw(--weak-digest), $_) @@ -152,7 +152,7 @@ sub verify_signature { } elsif (find_command('gpg')) { my @gpg_opts = (qw(--no-options --no-default-keyring -q), @gpg_weak_digest); push @exec, 'gpg', @gpg_opts, '--verify'; - } elsif ($opts{require_valid_signature}) { + } elsif ($opts->{require_valid_signature}) { error(g_('cannot verify signature on %s since GnuPG is not installed'), $sig); } else { @@ -163,14 +163,14 @@ sub verify_signature { my $gpghome = File::Temp->newdir('dpkg-verify-sig.XXXXXXXX', TMPDIR => 1); push @exec, '--homedir', $gpghome; - foreach my $keyring (@{$opts{keyrings}}) { + foreach my $keyring (@{$opts->{keyrings}}) { push @exec, '--keyring', $keyring; } push @exec, $sig; - push @exec, $opts{datafile} if exists $opts{datafile}; + push @exec, $opts->{datafile} if exists $opts->{datafile}; my $errmsg = sprintf g_('cannot verify signature %s'), $sig; - _exec_openpgp(\@exec, \%opts, $errmsg); + _exec_openpgp($opts, \@exec, $errmsg); } 1; diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index 35f5b8350..fdd05d6cf 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -436,21 +436,21 @@ sub check_original_tarball_signature { } my $keyring = File::Temp->new(UNLINK => 1, SUFFIX => '.gpg'); - my %opts = ( + my $opts = { require_valid_signature => $self->{options}{require_valid_signature}, - ); - Dpkg::OpenPGP::import_key($upstream_key, - %opts, + }; + Dpkg::OpenPGP::import_key({ + %{$opts}, keyring => $keyring, - ); + }, $upstream_key); foreach my $asc (@asc) { info(g_('verifying %s'), $asc); - Dpkg::OpenPGP::verify_signature($asc, - %opts, + Dpkg::OpenPGP::verify_signature({ + %{$opts}, keyrings => [ $keyring ], datafile => $asc =~ s/\.asc$//r, - ); + }, $asc); } } @@ -490,11 +490,11 @@ sub check_signature { } } - my %opts = ( + my $opts = { keyrings => \@keyrings, require_valid_signature => $self->{options}{require_valid_signature}, - ); - Dpkg::OpenPGP::verify_signature($dsc, %opts); + }; + Dpkg::OpenPGP::verify_signature($opts, $dsc); } sub describe_cmdline_options { -- Dpkg.Org's dpkg

