#!/usr/bin/perl -w use strict; use Parallel::ForkManager; use File::Glob ':glob'; use File::Basename; use Expect; my $NB_FORK=8; # password file my $path = $ARGV[1]; my $media = $ARGV[0]; sub usage { print "\n First arg must be main or contrib\n"; print " Second arg must be a path to rpm\n"; print " # 26752624 main cooker key # 26752624 contrib cooker key # --------------------------------- # 70771ff3 main official key # 78d019f5 contrib official key \n"; print "ie: ./resign_official_rpm_by_path.pl main /mnt/BIG/dis/cooker/i586/media/main/\n"; print "will resign this directory with the official main key\n\n"; exit; } $ARGV[0] or usage; $ARGV[1] or usage; # password file my $class; if ($ARGV[0] =~ /contrib/) { $class = "contrib" } else { $class = ""; } my $pwd_file = "/root/." . ( $class ? $class : 'signature') . ".gpg"; my $rpmrc = "/root/etc/rpmrc" . ($class ? "_$class" : ''); print "using $pwd_file\n"; print "using $rpmrc\n"; my $password = `cat $pwd_file`; my $verbose = "0" ; my $pm = new Parallel::ForkManager($NB_FORK); my @list_pkg = glob("$path/*.rpm"); my $count = @list_pkg; print "$count transactions to do ... be patient !!!!"; my $status = "0"; foreach my $pkg (@list_pkg) { $pkg or next; my $basename_pkg = basename($pkg); $status++; my $pid = $pm->start and next; print("$basename_pkg ($status/$count)\n"); my $command = Expect->spawn("LC_ALL=C rpm --rcfile=$rpmrc --resign $pkg") or die "Couldn't start rpm: $!\n"; $command->log_stdout($verbose); $command->expect(20, -re, 'Enter pass phrase:' => sub { print $command $password; }); $command->expect(undef); $command->soft_close(); $pm->finish; } print "Waiting for the end of some signature...\n"; $pm->wait_all_children; print "all signature are done...\n";