Skip to content

Commit

Permalink
Merge pull request chef#927 from chef/smarter-rake
Browse files Browse the repository at this point in the history
Smarter Rake
  • Loading branch information
Seth Thomas authored Oct 25, 2017
2 parents ffb6dbe + 4b230a6 commit eef9780
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ task :clean do
end

def build_cmd(template)
cmd = %W{bento build #{template}.json}
cmd = %W{bento build #{template}}
cmd.insert(2, "--only #{providers}")
cmd.insert(2, "--mirror #{ENV['PACKER_MIRROR']}") if ENV["PACKER_MIRROR"]
cmd.insert(2, "--version #{ENV['BENTO_VERSION']}")
Expand Down Expand Up @@ -58,20 +58,27 @@ def clean_array(*args)
args.flatten.reject { |i| i.nil? || i == "" }.map(&:to_s)
end

# create sorted list of builds matched against available templates
# ignoring known private images and working dir
# TODO: move this logic to bento-ya
def templates
bit32 = []
bit64 = []
config['public'].each do |platform, versions|
versions.each do |version, archs|
archs.each do |arch|
case arch
when "i386"
bit32 << "#{platform}/#{platform}-#{version}-#{arch}"
ts = Dir.glob('**/*.json').reject{ |f| f['builds'] }
ts.reject{ |f| f[/macos|rhel|sles|solaris|windows/] }

b32 = []
b64 = []
config['public'].each do |p, vs|
vs.each do |v, as|
as.each do |a|
case a
when "i386", "i686"
b32 << ts.select{ |i| i[/#{p}-#{v}-#{a}/] }
else
bit64 << "#{platform}/#{platform}-#{version}-#{arch}"
b64 << ts.select{ |i| i[/#{p}-#{v}-#{a}/] }
end
end
end
end
bit64 + bit32
list = b64 + b32
list.flatten
end

0 comments on commit eef9780

Please sign in to comment.