1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-29 18:50:08 +03:00

OpenNebula/one#6245: Include HostSyncManager as a gem dependency (#2647)

(cherry picked from commit 44c71d9074c7e673f119fda2c5fb006def7e20d7)
(cherry picked from commit 0cf2ae97256cd0802a0bfe60f86d5184446c116d)
This commit is contained in:
Daniel Clavijo Coca 2023-06-22 04:40:29 -06:00 committed by Tino Vázquez
parent 01c475599a
commit 4edec5ba3b
No known key found for this signature in database
GPG Key ID: 14201E424D02047E

View File

@ -19,15 +19,15 @@
require 'fileutils'
require 'tmpdir'
VERSION = "6.4.5"
VERSION = '6.4.5'
def version
v = VERSION
_, min, incr = v.split(".").collect{|e| e.to_i}
_, min, incr = v.split('.').collect {|e| e.to_i }
if min >= 80 || incr >= 80
v += ".pre"
v += '.pre'
end
v
@ -35,29 +35,29 @@ end
DEFAULTS={
:version => version,
:date => Time.now.strftime("%Y-%m-%d"),
:date => Time.now.strftime('%Y-%m-%d'),
:dependencies => []
}
TEMPLATE=<<EOT
# This file is automatically generated
TEMPLATE=<<~EOT
# This file is automatically generated
Gem::Specification.new do |s|
s.name = '$(NAME)'
s.version = '$(VERSION)'
s.date = '$(DATE)'
s.summary = "$(SUMMARY)"
s.description = "$(DESCRIPTION)"
s.authors = ["OpenNebula"]
s.email = 'contact@opennebula.io'
s.license = 'Apache-2.0'
s.files = [
$(FILES)
]
s.homepage = 'http://opennebula.io'
$(EXECUTABLES)
$(DEPENDENCIES)
end
Gem::Specification.new do |s|
s.name = '$(NAME)'
s.version = '$(VERSION)'
s.date = '$(DATE)'
s.summary = "$(SUMMARY)"
s.description = "$(DESCRIPTION)"
s.authors = ["OpenNebula"]
s.email = 'contact@opennebula.io'
s.license = 'Apache-2.0'
s.files = [
$(FILES)
]
s.homepage = 'http://opennebula.io'
$(EXECUTABLES)
$(DEPENDENCIES)
end
EOT
@ -79,6 +79,7 @@ GEM_DESCRIPTION={
['src/mad/ruby/OpenNebulaDriver.rb', '/lib'],
['src/mad/ruby/CommandManager.rb', '/lib'],
['src/mad/ruby/ActionManager.rb', '/lib'],
['src/mad/ruby/HostSyncManager.rb', '/lib'],
['src/mad/ruby/DriverExecHelper.rb', '/lib'],
['src/mad/ruby/scripts_common.rb', '/lib'],
@ -132,18 +133,18 @@ def sane_prefix(prefix)
p=prefix
p.slice!(0) if p[0,1]=='/'
p<<'/' if p[-1,1]!='/'
p.slice!(0) if p[0, 1]=='/'
p<<'/' if p[-1, 1]!='/'
p
end
def file_list(description)
files=Array.new
files=[]
description[:files].each do |f, prefix, exclude|
Dir.glob(f).each do |source|
next if (! exclude.nil?) and (source.match(exclude))
next if !exclude.nil? and source.match(exclude)
files << [source, sane_prefix(prefix)+File.basename(source)]
end
@ -152,14 +153,14 @@ def file_list(description)
files
end
def copy_files(files, source_prefix='', destination_prefix='')
def copy_files(files, source_prefix = '', destination_prefix = '')
files.each do |file|
source=source_prefix+file[0]
destination=destination_prefix+file[1]
dir=File.dirname destination
FileUtils.mkdir_p(dir) if !File.exist?(dir)
FileUtils.mkdir_p(dir) unless File.exist?(dir)
FileUtils.cp(source, destination)
end
@ -172,10 +173,10 @@ def generate_gem_file_list(files)
end
def generate_gem_executable_list(files)
executables=files.
select {|f| f.last.match(/^bin\//) }.
map {|f| "'#{File.basename(f.last)}'" }.
join(", ")
executables=files
.select {|f| f.last.match(%r{^bin/}) }
.map {|f| "'#{File.basename(f.last)}'" }
.join(', ')
if !executables.empty?
" s.executables=[#{executables}]"
@ -186,9 +187,9 @@ end
def generate_dependencies(dependencies)
dependencies.map do |d|
line=" s.add_runtime_dependency "
if Array===d
line<<d.map {|part| "'#{part}'" }.join(", ")
line=' s.add_runtime_dependency '
if d.is_a?(Array)
line<<d.map {|part| "'#{part}'" }.join(', ')
else
line<<"'#{d}'"
end
@ -206,7 +207,8 @@ def populate_gem_template(description, files)
generate_gem_file_list(files)
elsif var==:dependencies
generate_dependencies(
description[:dependencies]||DEFAULTS[:dependencies])
description[:dependencies]||DEFAULTS[:dependencies]
)
elsif var==:executables
generate_gem_executable_list(files)
elsif description[var]
@ -218,7 +220,7 @@ def populate_gem_template(description, files)
end
def generate_gem_file(gem_file, description, files)
File.open(gem_file, "w") do |f|
File.open(gem_file, 'w') do |f|
f.write(populate_gem_template(description, files))
end
end
@ -226,22 +228,22 @@ end
def generate_gem(description)
Dir.mktmpdir do |tmp|
files=file_list(description)
copy_files(files, '', tmp+"/")
copy_files(files, '', tmp+'/')
gem_file=tmp+"/gem.gemspec"
gem_file=tmp+'/gem.gemspec'
generate_gem_file(gem_file, description, files)
pwd=Dir.pwd
Dir.chdir(tmp) do
system("gem build gem.gemspec")
system('gem build gem.gemspec')
if $?.exitstatus!=0
puts "Error generating gem"
puts 'Error generating gem'
exit(-1)
end
Dir.glob("*.gem").each do |f|
Dir.glob('*.gem').each do |f|
FileUtils.cp(f, pwd)
end
end
@ -250,8 +252,7 @@ end
# Go to source code root dir
root=Dir.pwd
root.gsub!(/\/share\/rubygems$/, '')
root.gsub!(%r{/share/rubygems$}, '')
Dir.chdir(root)
GEM_DESCRIPTION.each {|name, gem| generate_gem(gem) }
GEM_DESCRIPTION.each {|_name, gem| generate_gem(gem) }