-
Notifications
You must be signed in to change notification settings - Fork 0
/
signRpm
executable file
·49 lines (43 loc) · 1.28 KB
/
signRpm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/perl
#------------------------------------------------------------------------------
#
# MyRPM - Rpm Utilities
# Copyright (c) Jean-Marie RENOUARD 2014 - LightPath
# Contact : Jean-Marie Renouard <jmrenouard at gmail.com>
#
# This program is open source, licensed under the Artistic Licence v2.0.
#
# Artistic Licence 2.0
# Everyone is permitted to copy and distribute verbatim copies of
# this license document, but changing it is not allowed.
#
#------------------------------------------------------------------------------
use strict;
use Expect;
my $timeout=60;
my $passFile=$ENV{'HOME'}."/.passwords";
#print "$passFile";
my $cmdSign="addsign";
open my $fh, '<', $passFile or die "Can't open file $!";
my $text_file = do { local $/; <$fh> };
my $signPass=$1 if ($text_file=~ /gpgpassword=(.*?)\n/);
my $command="rpm --$cmdSign ". join " ", @ARGV;
print " => $command\n";
my $exp = Expect->spawn($command) or die "Cannot spawn $command: $!\n";
$exp->raw_pty(1);
SAISIE:
$exp->expect($timeout,
[ '.+ passe:' => sub {
$exp->send("$signPass\n");
goto SAISIE;
}
],
[ '.+ passphare:' => sub {
$exp->send("$signPass\n");
goto SAISIE;
}
],
[ '.+\r\n$' => sub {
goto SAISIE; } ],
);
$exp->soft_close();