1 |
#!/usr/bin/perl -w |
2 |
|
3 |
use strict; |
4 |
use Parallel::ForkManager; |
5 |
use File::Glob ':glob'; |
6 |
use File::Basename; |
7 |
use Expect; |
8 |
|
9 |
|
10 |
my $NB_FORK=15; |
11 |
# password file |
12 |
my $pwd_file = "/home/plop/.signature.gpg"; |
13 |
my $rpmrc = "/home/plop/.rpmrc"; |
14 |
my $path = $ARGV[0]; |
15 |
|
16 |
$ARGV[0] or die "First arg must be a path to rpm\n"; |
17 |
|
18 |
my $password = `cat $pwd_file`; |
19 |
my $verbose = "0" ; |
20 |
|
21 |
my $pm = new Parallel::ForkManager($NB_FORK); |
22 |
my @list_pkg = glob("$path/*.rpm"); |
23 |
my $count = @list_pkg; |
24 |
print "$count transactions to do ... be patient !!!!"; |
25 |
my $status = "0"; |
26 |
foreach my $pkg (@list_pkg) { |
27 |
$pkg or next; |
28 |
my $basename_pkg = basename($pkg); |
29 |
$status++; |
30 |
my $pid = $pm->start and next; |
31 |
print("$basename_pkg ($status/$count)\n"); |
32 |
my $command = Expect->spawn("LC_ALL=C rpm --rcfile=$rpmrc --resign $pkg") or die "Couldn't start rpm: $!\n"; |
33 |
$command->log_stdout($verbose); |
34 |
$command->expect(20, -re, 'Enter pass phrase:' => sub { print $command $password; }); |
35 |
$command->expect(undef); |
36 |
$command->soft_close(); |
37 |
$pm->finish; |
38 |
} |
39 |
print "Waiting for the end of some signature...\n"; |
40 |
$pm->wait_all_children; |
41 |
print "all signature are done...\n"; |