Fix package signing for newer rpm versions

This commit is contained in:
DJ Mountney 2019-06-14 11:49:58 -07:00 committed by Balasankar "Balu" C
parent bf05c22f83
commit e4bd279bb7
No known key found for this signature in database
GPG Key ID: B77D2E2E23735427
2 changed files with 39 additions and 0 deletions

View File

@ -154,6 +154,8 @@ package :deb do
signing_passphrase Gitlab::Util.get_env('GPG_PASSPHRASE')
end
resources_path "#{Omnibus::Config.project_root}/resources"
# Our package scripts are generated from .erb files,
# so we will grab them from an excluded folder
package_scripts_path "#{install_dir}/.package_util/package-scripts"

37
resources/rpm/signing.erb Normal file
View File

@ -0,0 +1,37 @@
#!/usr/bin/env ruby
unless (rpm_cmd = ARGV[0])
STDERR.puts 'Usage: sign-rpm RPM_COMMAND'
exit 1
end
password = '<%= passphrase %>'
require 'pty'
puts rpm_cmd
PTY.spawn(rpm_cmd) do |r, w, pid|
# Older versions of rpmsign will prompt right away for the passphrase
prompt = r.read(19)
if prompt == 'Enter pass phrase: '
STDOUT.puts prompt
w.write("#{password}\n")
end
# Keep printing output unti the command exits
loop do
begin
line = r.gets
puts line
if 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
rescue Errno::EIO
break
end
end
end