Skip to content

Commit

Permalink
Update the rpm package signing to work with newer rpm version
Browse files Browse the repository at this point in the history
Newer versions of rpmsign (rpm 4.13+), no longer prompt for the pass
phrase, but instead provide gpg with access to stdin/out to request it.

Because this process is deferred, you will also often end up with
warning output from rpmbuild before the prompt, so we can no longer
assume the prompt will be the first output.

This issue was discovered while trying to build rpm packages for
OpenSUSE 15 which has the newer rpm.

Signed-off-by: DJ Mountney <david@twkie.net>
  • Loading branch information
twk3 committed Jun 15, 2019
1 parent 035cc83 commit 962b20e
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions resources/rpm/signing.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,14 @@ require 'pty'

puts rpm_cmd
PTY.spawn(rpm_cmd) do |r, w, pid|
prompt = r.read(19)

# match the expected prompt exactly, since that's the only way we know if
# something went wrong.
unless prompt == 'Enter pass phrase: '
STDERR.puts "unexpected output from `#{rpm_cmd}`: '#{prompt}'"
Process.kill(:KILL, pid)
exit 1
end

STDOUT.puts prompt
w.write("#{password}\n")

# Keep printing output unti the command exits
loop do
begin
line = r.gets
puts line
if (line =~ /failed/) && !(line =~ /warning:/)
if line =~ /Enter pass phrase:/ || line =~ /Please enter the passphrase to unlock the OpenPGP secret key:/
w.write("#{password}\n")
elsif (line =~ /failed/) && !(line =~ /warning:/)
STDERR.puts 'RPM signing failure'
exit 1
end
Expand Down

0 comments on commit 962b20e

Please sign in to comment.