Permalink
Browse files

Merge branch 'master' of github.com:stormgrind/cantiere

  • Loading branch information...
2 parents 5539912 + 9fe86e2 commit a836003e9b167cccf17f501acdac5c7afc9a609f @goldmann goldmann committed Mar 17, 2010
View
@@ -29,10 +29,10 @@
module Cantiere
class Cantiere
- def initialize( project_config = Hash.new )
+ def initialize( config, project_config = Hash.new )
@log = LOG
- @config = Config.new( project_config )
+ @config = config.nil? ? Config.new( project_config ) : config
ConfigValidator.new( @config ).validate
View
@@ -82,8 +82,8 @@ def initialize( project_config = Hash.new )
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']
+ @os_name = ENV['CANTIERE_OS_NAME'].nil? ? @os.name : ENV['CANTIERE_OS_NAME']
+ @os_version = ENV['CANTIERE_OS_VERSION'].nil? ? @os.version : ENV['CANTIERE_OS_VERSION']
end
attr_reader :name
View
@@ -28,7 +28,7 @@ module Cantiere
# here are global variables
SUPPORTED_ARCHES = [ "i386", "x86_64" ]
SUPPORTED_OSES = {
- "fedora" => [ "11", "rawhide" ]
+ "fedora" => [ "12", "11", "rawhide" ]
}
LATEST_STABLE_RELEASES = {
View
@@ -46,18 +46,18 @@ def define_tasks
end
def sign_srpms
- validate_and_sign( "#{@config.dir.base}/extras/sign-rpms #{@config.data['gpg_password']} #{@config.dir.top}/#{APPLIANCE_DEFAULTS['os_name']}/#{APPLIANCE_DEFAULTS['os_version']}/SRPMS/*.src.rpm > /dev/null 2>&1", "SRPMs" )
+ validate_and_sign( "#{@config.dir.base}/extras/sign-rpms #{@config.definition['gpg_password']} #{@config.dir.top}/#{APPLIANCE_DEFAULTS['os_name']}/#{APPLIANCE_DEFAULTS['os_version']}/SRPMS/*.src.rpm > /dev/null 2>&1", "SRPMs" )
end
def sing_rpms
- validate_and_sign( "#{@config.dir.base}/extras/sign-rpms #{@config.data['gpg_password']} #{@config.dir.top}/#{@config.os_path}/RPMS/*/*.rpm > /dev/null 2>&1", "RPMs" )
+ validate_and_sign( "#{@config.dir.base}/extras/sign-rpms #{@config.definition['gpg_password']} #{@config.dir.top}/#{@config.os_path}/RPMS/*/*.rpm > /dev/null 2>&1", "RPMs" )
end
def validate_and_sign( command, type )
@log.info "Signing #{type}..."
begin
- raise ValidationError, "You have no GPG password specified in Cantiere config file (#{CONFIG_FILE})." if @config.data['gpg_password'].nil?
+ raise ValidationError, "You have no GPG password specified in Cantiere config file (#{CONFIG_FILE})." if @config.definition['gpg_password'].nil?
#@config.helper.validate_gpg_password
@exec_helper.execute( command )
rescue => e
@@ -29,7 +29,7 @@ def initialize( config )
# TODO this is not good, remove this
def validate_gpg_password
- raise ValidationError, "You have no GPG password specified in JBoss Cloud config file." if @config.data['gpg_password'].nil?
+ raise ValidationError, "You have no GPG password specified in JBoss Cloud config file." if @config.definition['gpg_password'].nil?
end
end
@@ -22,11 +22,11 @@
module Rake
class Task
- alias_method :execute_original, :execute
+ alias_method :execute_original_cantiere, :execute
def execute( args=nil )
begin
- execute_original( args )
+ execute_original_cantiere( args )
rescue => e
Cantiere::LOG.fatal e
Cantiere::LOG.fatal e.message
@@ -38,11 +38,11 @@ def execute( args=nil )
module Cantiere
class RakeHelper
- def initialize
+ def initialize( config = nil )
begin
LOG.debug "Running new Rake session..."
- Cantiere.new
+ Cantiere.new( config )
rescue ValidationError => e
LOG.fatal "ValidationError: #{e.message}."
abort
@@ -32,15 +32,19 @@ def initialize( config )
@options['sftp_overwrite'] = false
@options['sftp_default_permissions'] = 0644
+ raise ValidationError, "Specified configuration file (#{CONFIG_FILE}) doesn't exists. #{DEFAULT_HELP_TEXT[:general]}" unless File.exists?( CONFIG_FILE )
+
+ @config_file = YAML.load_file( CONFIG_FILE )
+
validate
end
def validate
- raise ValidationError, "Specified configuration file (#{CONFIG_FILE}) doesn't exists. #{DEFAULT_HELP_TEXT[:general]}" unless File.exists?( CONFIG_FILE )
- raise ValidationError, "No 'ssh' section in config file in configuration file '#{CONFIG_FILE}'. #{DEFAULT_HELP_TEXT[:general]}" if @config.data['ssh'].nil?
+ raise ValidationError, "Your config file (#{CONFIG_FILE}) has incorrect format. Please correct it." if @config_file.nil?
+ raise ValidationError, "No 'ssh' section in config file in configuration file '#{CONFIG_FILE}'. #{DEFAULT_HELP_TEXT[:general]}" if @config_file['ssh'].nil?
# we need only ssh section
- @cfg = @config.data['ssh']
+ @cfg = @config_file['ssh']
raise ValidationError, "Host not specified in configuration file '#{CONFIG_FILE}' in ssh section. #{DEFAULT_HELP_TEXT[:general]}" if @cfg['host'].nil?
raise ValidationError, "Username not specified in configuration file '#{CONFIG_FILE}' in ssh section. #{DEFAULT_HELP_TEXT[:general]}" if @cfg['username'].nil?

0 comments on commit a836003

Please sign in to comment.