forked from sensu/uchiwa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request sensu#747 from sensu/feature/pkg-sign
Sign RPM packages
- Loading branch information
Showing
5 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
%_signature gpg | ||
%_gpg_name Sensu, Inc. <[email protected]> | ||
%_gpg_path /home/travis/.gnupg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
rm -rf /home/travis/.gnupg | ||
|
||
aws s3 cp s3://sensu-omnibus-cache/gpg/sensu-io-gpg.tar . | ||
tar -xvf sensu-io-gpg.tar | ||
|
||
cp .rpmmacros /home/travis/.rpmmacros | ||
cp -R .gnupg /home/travis/.gnupg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env ruby | ||
require "open3" | ||
require "pty" | ||
require "shellwords" | ||
|
||
module Process | ||
def exist?(pid) | ||
Process.kill(0, pid) | ||
true | ||
rescue Errno::ESRCH | ||
false | ||
end | ||
|
||
module_function :exist? | ||
end | ||
|
||
rpm_cmd, *rpm_args = ARGV | ||
|
||
unless (rpm_cmd) | ||
STDERR.puts 'Usage: sign-rpm RPM_COMMAND' | ||
exit 1 | ||
end | ||
|
||
password = "passphrase_here" | ||
cmd = [rpm_cmd].concat(rpm_args) | ||
|
||
puts cmd.inspect | ||
puts Shellwords.join(cmd) | ||
|
||
PTY.spawn(Shellwords.join(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 until the command exits | ||
loop do | ||
begin | ||
line = r.gets | ||
puts line | ||
if (line =~ /failed/) && !(line =~ /warning:/) | ||
STDERR.puts 'RPM signing failure' | ||
exit 1 | ||
end | ||
rescue Errno::EIO | ||
break | ||
end | ||
end | ||
end |