| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
# SPDX-FileCopyrightText: 2001,2002 Progeny Linux Systems, Inc. |
| 4 |
# Authors: John Goerzen, Branden Robinson |
| 5 |
# SPDX-FileCopyrightText: 2009 Peter Pentchev <[email protected]> |
| 6 |
# SPDX-License-Identifier: GPL-2.0-or-later |
| 7 |
|
| 8 |
use strict; |
| 9 |
use warnings; |
| 10 |
|
| 11 |
use Getopt::Long; |
| 12 |
|
| 13 |
use Debian::debsigs::debsigsmain; |
| 14 |
|
| 15 |
sub syntax($); |
| 16 |
sub version(); |
| 17 |
|
| 18 |
Getopt::Long::Configure('no_ignore_case'); |
| 19 |
|
| 20 |
$| = 1; |
| 21 |
|
| 22 |
# set up variables |
| 23 |
|
| 24 |
my $verbose = ''; |
| 25 |
|
| 26 |
my $maint_keyid = $ENV{DEBSIGS_MAINT_ID}; |
| 27 |
my $archive_keyid = $ENV{DEBSIGS_ARCHIVE_ID}; |
| 28 |
my $origin_keyid = $ENV{DEBSIGS_ORIGIN_ID}; |
| 29 |
my $secring = $ENV{DEBSIGS_SECRING}; |
| 30 |
my ($showhelp, $showversion); |
| 31 |
|
| 32 |
GetOptions ('verbose' => \$verbose, |
| 33 |
'maint=s' => \$maint_keyid, |
| 34 |
'archive=s' => \$archive_keyid, |
| 35 |
'origin=s' => \$origin_keyid, |
| 36 |
'secring=s' => \$secring, |
| 37 |
'help|h' => \$showhelp, |
| 38 |
'version|V' => \$showversion); |
| 39 |
|
| 40 |
version() if $showversion; |
| 41 |
syntax(0) if $showhelp; |
| 42 |
exit(0) if $showhelp || $showversion; |
| 43 |
|
| 44 |
my %ids = ('maint' => $maint_keyid, |
| 45 |
'archive' => $archive_keyid, |
| 46 |
'origin' => $origin_keyid); |
| 47 |
|
| 48 |
my @tosign = @ARGV; |
| 49 |
syntax(1) unless (defined($tosign[0])); |
| 50 |
|
| 51 |
while (defined(my $line = <STDIN>)) { |
| 52 |
chomp $line; |
| 53 |
if ($verbose) { |
| 54 |
print "Signing $line:"; |
| 55 |
} |
| 56 |
foreach my $sig (@tosign) { |
| 57 |
my @cmd; |
| 58 |
if ($verbose) { |
| 59 |
print " $sig"; |
| 60 |
} |
| 61 |
@cmd = ("debsigs", "--sign=$sig"); |
| 62 |
push @cmd, '-K', $secring if $secring; |
| 63 |
push @cmd, "--default-key=$ids{$sig}" if $ids{$sig}; |
| 64 |
push @cmd, $line; |
| 65 |
(system(@cmd) == 0) or die |
| 66 |
"Error signing!"; |
| 67 |
} |
| 68 |
if ($verbose) { |
| 69 |
print ".\n"; |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
sub syntax($) { |
| 74 |
my ($err) = @_; |
| 75 |
my $s = "Usage: debsigs-autosign [options] sigtype [ ... ]\n". |
| 76 |
"Reads package names from standard input, and signs each with debsigs.\n". |
| 77 |
"\n". |
| 78 |
"\t--archive=KEYID use KEYID for archive signature\n". |
| 79 |
"\t--maint=KEYID use KEYID for maintainer signature\n". |
| 80 |
"\t--origin=KEYID use KEYID for origin signature\n". |
| 81 |
"\t--secring=FILE use FILE as GPG secret keyring\n". |
| 82 |
"\t--verbose report status messages\n\n". |
| 83 |
"See the debsigs manual page for information about the signature types.\n"; |
| 84 |
|
| 85 |
if ($err) { |
| 86 |
print STDERR "$s"; |
| 87 |
exit(1); |
| 88 |
} else { |
| 89 |
print "$s"; |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
sub version() { |
| 94 |
print "debsigs-autosign $Debian::debsigs::debsigsmain::VERSION\n"; |
| 95 |
} |
| 96 |
|
| 97 |
__END__ |
| 98 |
|
| 99 |
=head1 NAME |
| 100 |
|
| 101 |
debsigs-autosign - batch-sign Debian package files |
| 102 |
|
| 103 |
=head1 SYNOPSIS |
| 104 |
|
| 105 |
B<debsigs-autosign> [I<options>] I<sigtype> [ I<...> ] |
| 106 |
|
| 107 |
=head1 DESCRIPTION |
| 108 |
|
| 109 |
I<debsigs-autosign> reads a newline-delimited list of file names from |
| 110 |
standard input and runs I<debsigs>(1) on each package, with arguments |
| 111 |
determined by the options, operands, and environment of |
| 112 |
I<debsigs-autosign>. See the L<debsigs(1)> manual page for more |
| 113 |
information about the signature types. |
| 114 |
|
| 115 |
=head1 OPTIONS |
| 116 |
|
| 117 |
=over 5 |
| 118 |
|
| 119 |
=item B<--archive=>I<keyid> |
| 120 |
|
| 121 |
=item B<--maint=>I<keyid> |
| 122 |
|
| 123 |
=item B<--origin=>I<keyid> |
| 124 |
|
| 125 |
The above options specify cryptographic key identifiers for use with |
| 126 |
I<gpg>(1). |
| 127 |
|
| 128 |
=item B<--secring=>I<file> |
| 129 |
|
| 130 |
This option identifies a secret keyring file for use with I<gpg>(1). |
| 131 |
|
| 132 |
=item B<--verbose> |
| 133 |
|
| 134 |
Displays verbose output. |
| 135 |
|
| 136 |
=back |
| 137 |
|
| 138 |
=head1 OPERANDS |
| 139 |
|
| 140 |
Each operand is a signature type to apply to the Debian package(s) to be |
| 141 |
processed. Currently recongnized signature types are B<archive>, |
| 142 |
B<maint>, and B<origin>. |
| 143 |
|
| 144 |
=head1 ENVIRONMENT |
| 145 |
|
| 146 |
The following environment variables are recognized by |
| 147 |
I<debsigs-autosign>: |
| 148 |
|
| 149 |
=over 5 |
| 150 |
|
| 151 |
=item I<DEBSIGS_ARCHIVE_ID> |
| 152 |
|
| 153 |
=item I<DEBSIGS_MAINT_ID> |
| 154 |
|
| 155 |
=item I<DEBSIGS_ORIGIN_ID> |
| 156 |
|
| 157 |
The above variables specify cryptographic key identifiers for use with |
| 158 |
I<gpg>(1). |
| 159 |
|
| 160 |
=item I<DEBSIGS_SECRING> |
| 161 |
|
| 162 |
This variable identifies a secret keyring file for use with I<gpg>(1). |
| 163 |
|
| 164 |
=back |
| 165 |
|
| 166 |
=head1 AUTHORS |
| 167 |
|
| 168 |
=over 5 |
| 169 |
|
| 170 |
=item John Goerzen <[email protected]> |
| 171 |
|
| 172 |
=item Branden Robinson <[email protected]> |
| 173 |
|
| 174 |
=back |
| 175 |
|
| 176 |
=head1 SEE ALSO |
| 177 |
|
| 178 |
debsigs(1), debsig-verify(1), gpg(1) |
| 179 |
|
| 180 |
=cut |
| 181 |
|
| 182 |
# vim:set ai et sts=2 sw=2 tw=72: |