Browse files

fixed signing rpms with a GPG key

  • Loading branch information...
1 parent 425e859 commit 12a4cf862af0ef1a6632351dfd6de552ef8d94ab @goldmann goldmann committed Oct 22, 2009
Showing with 39 additions and 91 deletions.
  1. +36 −26 lib/cantiere/config.rb
  2. +3 −2 lib/cantiere/gpg-sign.rb
  3. +0 −58 lib/cantiere/rpm-gpg-sign.rb
  4. +0 −5 lib/cantiere/rpm.rb
View
62 lib/cantiere/config.rb
@@ -22,8 +22,10 @@
require 'ostruct'
module Cantiere
+ CONFIG_FILE = "#{ENV['HOME']}/.cantiere/config"
+
class Config
- RELEASE_FILE = '/etc/redhat-release'
+ RELEASE_FILE = "/etc/redhat-release"
def initialize( project_config = Hash.new )
@@ -34,47 +36,54 @@ def initialize( project_config = Hash.new )
@version.release = project_config[:release] || DEFAULT_PROJECT_CONFIG[:release]
@dir = OpenStruct.new
- @dir.root = `pwd`.strip
- @dir.build = project_config[:dir_build] || DEFAULT_PROJECT_CONFIG[:dir_build]
- @dir.top = project_config[:dir_top] || "#{@dir.build}/topdir"
- @dir.src_cache = project_config[:dir_sources_cache] || DEFAULT_PROJECT_CONFIG[:dir_sources_cache]
- @dir.rpms_cache = project_config[:dir_rpms_cache] || DEFAULT_PROJECT_CONFIG[:dir_rpms_cache]
- @dir.specs = project_config[:dir_specs] || DEFAULT_PROJECT_CONFIG[:dir_specs]
- @dir.appliances = project_config[:dir_appliances] || DEFAULT_PROJECT_CONFIG[:dir_appliances]
- @dir.src = project_config[:dir_src] || DEFAULT_PROJECT_CONFIG[:dir_src]
- @dir.kickstarts = project_config[:dir_kickstarts] || DEFAULT_PROJECT_CONFIG[:dir_kickstarts]
+ @dir.root = `pwd`.strip
+ @dir.build = project_config[:dir_build] || DEFAULT_PROJECT_CONFIG[:dir_build]
+ @dir.top = project_config[:dir_top] || "#{@dir.build}/topdir"
+ @dir.src_cache = project_config[:dir_sources_cache] || DEFAULT_PROJECT_CONFIG[:dir_sources_cache]
+ @dir.rpms_cache = project_config[:dir_rpms_cache] || DEFAULT_PROJECT_CONFIG[:dir_rpms_cache]
+ @dir.specs = project_config[:dir_specs] || DEFAULT_PROJECT_CONFIG[:dir_specs]
+ @dir.appliances = project_config[:dir_appliances] || DEFAULT_PROJECT_CONFIG[:dir_appliances]
+ @dir.src = project_config[:dir_src] || DEFAULT_PROJECT_CONFIG[:dir_src]
+ @dir.kickstarts = project_config[:dir_kickstarts] || DEFAULT_PROJECT_CONFIG[:dir_kickstarts]
# TODO better way to get this directory
- @dir.base = "#{File.dirname( __FILE__ )}/../.."
- @dir.tmp = "#{@dir.build}/tmp"
+ @dir.base = "#{File.dirname( __FILE__ )}/../.."
+ @dir.tmp = "#{@dir.build}/tmp"
- @arch = (-1.size) == 8 ? "x86_64" : "i386"
- @os = OpenStruct.new
+ @arch = (-1.size) == 8 ? "x86_64" : "i386"
+ @os = OpenStruct.new
if File.exists?( RELEASE_FILE )
release_match = File.read( RELEASE_FILE ).match(/^(.*) release ([\d\.]+) \((.*)\)$/)
- @os.full_name = release_match[1]
+ @os.full_name = release_match[1]
case @os.full_name
when /^Red Hat Enterprise Linux(.*)/ then
- @os.name = "rhel"
- @os.package_suffix = 'el'
+ @os.name = "rhel"
+ @os.package_suffix = 'el'
when /^Fedora$/ then
- @os.name = "fedora"
- @os.package_suffix = 'f'
+ @os.name = "fedora"
+ @os.package_suffix = 'f'
end
- @os.version = release_match[2]
- @os.main_version = @os.version.match( /^([\d]+)[\.]?(.*)?$/ )[1]
- @os.package_suffix = @os.package_suffix + @os.main_version
- @os.code_name = release_match[3]
+ @os.version = release_match[2]
+ @os.main_version = @os.version.match( /^([\d]+)[\.]?(.*)?$/ )[1]
+ @os.package_suffix = @os.package_suffix + @os.main_version
+ @os.code_name = release_match[3]
else
raise "OS'es other than Fedora or Red Hat are currently unsupported"
end
- @build_arch = ENV['CANTIERE_ARCH'].nil? ? @arch : ENV['CANTIERE_ARCH']
- @os_name = @os.name #ENV['CANTIERE_OS_NAME'].nil? ? APPLIANCE_DEFAULTS['os_name'] : ENV['CANTIERE_OS_NAME']
- @os_version = @os.version #ENV['CANTIERE_OS_VERSION'].nil? ? APPLIANCE_DEFAULTS['os_version'] : ENV['CANTIERE_OS_VERSION']
+ if File.exists?( CONFIG_FILE )
+ @data = YAML.load_file( CONFIG_FILE )
+ raise "Your config file (#{CONFIG_FILE}) has incorrect format. Please correct it." if @data.nil?
+ else
+ @data = {}
+ end
+
+ @build_arch = ENV['CANTIERE_ARCH'].nil? ? @arch : ENV['CANTIERE_ARCH']
+ @os_name = @os.name #ENV['CANTIERE_OS_NAME'].nil? ? APPLIANCE_DEFAULTS['os_name'] : ENV['CANTIERE_OS_NAME']
+ @os_version = @os.version #ENV['CANTIERE_OS_VERSION'].nil? ? APPLIANCE_DEFAULTS['os_version'] : ENV['CANTIERE_OS_VERSION']
end
attr_reader :name
@@ -85,6 +94,7 @@ def initialize( project_config = Hash.new )
attr_reader :os_version
attr_reader :os
attr_reader :dir
+ attr_reader :data
def os_path
"#{@os.name}/#{@os.version}"
View
5 lib/cantiere/gpg-sign.rb
@@ -36,7 +36,7 @@ def define_tasks
task 'rpm:sign:all:srpms' => [ 'rpm:all' ] do
sign_srpms
end
-
+
task 'rpm:sign:all:rpms' => [ 'rpm:all' ] do
sing_rpms
end
@@ -57,7 +57,8 @@ def validate_and_sign( command, type )
@log.info "Signing #{type}..."
begin
- @config.helper.validate_gpg_password
+ raise ValidationError, "You have no GPG password specified in Cantiere config file (#{CONFIG_FILE})." if @config.data['gpg_password'].nil?
+ #@config.helper.validate_gpg_password
@exec_helper.execute( command )
rescue => e
@log.fatal "An error occured, some #{type} may be not signed. Possible errors: key exists?, wrong passphrase, expect package installed?, %_gpg_name in ~/.rpmmacros set?"
View
58 lib/cantiere/rpm-gpg-sign.rb
@@ -1,58 +0,0 @@
-# JBoss, Home of Professional Open Source
-# Copyright 2009, Red Hat Middleware LLC, and individual contributors
-# by the @authors tag. See the copyright.txt in the distribution for a
-# full listing of individual contributors.
-#
-# This is free software; you can redistribute it and/or modify it
-# under the terms of the GNU Lesser General Public License as
-# published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-#
-# This software is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this software; if not, write to the Free
-# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
-require 'rake/tasklib'
-
-module Cantiere
- class RPMGPGSign < Rake::TaskLib
-
- def initialize( config, spec_file, rpm_file )
- @config = config
- @spec_file = spec_file
-
- @rpm_file = rpm_file
-
- @rpm_file_basename = File.basename( @rpm_file )
- @simple_name = File.basename( @spec_file, ".spec" )
-
- @log = LOG
- @exec_helper = EXEC_HELPER
-
- define_tasks
- end
-
- def define_tasks
- task "rpm:#{@simple_name}:sign" => [ "rpm:#{@simple_name}" ] do
- sign_rpm
- end
- end
-
- def sign_rpm
- @log.info "Signing package '#{@rpm_file_basename}'..."
-
- @config.helper.validate_gpg_password
- out = @exec_helper.execute( "#{@config.dir.base}/extras/sign-rpms #{@config.data['gpg_password']} #{@rpm_file}" )
-
- raise "An error occured. Possible errors: key exists?, wrong passphrase, expect package installed?, %_gpg_name in ~/.rpmmacros set?" if out =~ /Pass phrase check failed/
-
- @log.info "Package '#{@rpm_file_basename}' successfully signed!"
- end
- end
-end
View
5 lib/cantiere/rpm.rb
@@ -18,8 +18,6 @@
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-require 'cantiere/rpm-gpg-sign'
-
module Cantiere
class RPM < Rake::TaskLib
@@ -58,8 +56,6 @@ def initialize( config, spec_file, options = {} )
RPM.provides[@simple_name] = "#{@simple_name}-#{@rpm_version}-#{@rpm_release}"
RPM.provides_rpm_path[@simple_name] = @rpm_file
- RPMGPGSign.new( @config, @spec_file, @rpm_file )
-
define_tasks
end
@@ -161,7 +157,6 @@ def handle_remote_source(rpm_file, source)
def build_source_dependencies( rpm_file, version=nil, release=nil)
File.open( @spec_file).each_line do |line|
line.gsub!( /#.*$/, '' )
- puts line
if ( line =~ /Requires:(.*)/ )
requirement = $1.strip
handle_requirement( rpm_file, requirement )

0 comments on commit 12a4cf8

Please sign in to comment.