aboutsummaryrefslogtreecommitdiffstats
path: root/BCD/Resign.pm
diff options
context:
space:
mode:
Diffstat (limited to 'BCD/Resign.pm')
-rw-r--r--BCD/Resign.pm56
1 files changed, 56 insertions, 0 deletions
diff --git a/BCD/Resign.pm b/BCD/Resign.pm
new file mode 100644
index 0000000..4a0e02c
--- /dev/null
+++ b/BCD/Resign.pm
@@ -0,0 +1,56 @@
+package Resign;
+
+use strict;
+use Parallel::ForkManager;
+use File::Glob ':glob';
+use File::Basename;
+use Expect;
+
+use BCD::Common qw(:DEFAULT $isoconf $NB_FORK $rpmrc $pwd_file);
+
+our @ISA = qw(Exporter);
+our @EXPORT = qw(resign_media);
+
+my $verbose;
+my $LOG="MEDIA -";
+my $color = "purple";
+
+my $password = `cat $pwd_file`;
+my $verbose = "0" ;
+
+sub print_info {
+ print_color("$LOG i will resign using info in those files: $rpmrc $pwd_file", $color);
+}
+
+sub resign_media {
+ print_info();
+ my $pm = new Parallel::ForkManager($NB_FORK);
+ my @list_path;
+ foreach my $media (@{$isoconf->{media}{list}}) {
+ push @list_path, $media->{destmedia};
+ }
+ foreach (@list_path) {
+ my @list_pkg = glob("$_/*.rpm");
+ my $count = @list_pkg;
+ print_color("$count transactions to do ... be patient !!!!", $color);
+ 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_color("Waiting for the end of some signature...", $color);
+ $pm->wait_all_children;
+ print_color("all signature are done...", $color);
+ }
+}
+
+1;