From 79fcc6d914fcae6c533f74f448d1ad844d7f8814 Mon Sep 17 00:00:00 2001 From: Vassilis Rizopoulos Date: Thu, 20 Oct 2016 12:03:52 +0200 Subject: [PATCH 01/10] YAML configuration with updated tool versions --- config/tools.yaml | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 config/tools.yaml diff --git a/config/tools.yaml b/config/tools.yaml new file mode 100644 index 0000000..5641d4c --- /dev/null +++ b/config/tools.yaml @@ -0,0 +1,45 @@ +--- +git: + url: ps://github.com/git-for-windows/git/releases/download/v2.10.1.windows.1/PortableGit-2.10.1-64-bit.7z.exe" +conemu: + url: ps://github.com/Maximus5/ConEmu/releases/download/v16.10.09a/ConEmuPack.161009a.7z" +clink: + url: ps://github.com/mridgers/clink/releases/download/0.4.8/clink_0.4.8.zip" +atom: + url: ps://github.com/atom/atom/releases/download/v1.11.2/atom-windows.zip" + plugins: + - atom-beautify + - minimap + - line-ending-converter + - language-chef + - language-batchfile +boot2docker: + url: ps://github.com/boot2docker/boot2docker-cli/releases/download/v1.8.0/boot2docker-v1.8.0-windows-amd64.exe" +docker: : + url: ps://download.docker.com/win/stable/InstallDocker.msi" +ruby-devkit: + url: p://dl.bintray.com/oneclick/rubyinstaller/DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe" +kdiff3: + url: p://downloads.sourceforge.net/project/kdiff3/kdiff3/0.9.98/KDiff3-64bit-Setup_0.9.98-2.exe" +putty: + url: ps://the.earth.li/~sgtatham/putty/latest/x86/putty.zip" +cwrsync: + url: ps://www.itefix.net/dl/cwRsync_5.5.0_x86_Free.zip" +vagrant: + url: ps://releases.hashicorp.com/vagrant/1.8.6/vagrant_1.8.6.msi" + plugins: + - vagrant-toplevel-cookbooks + - vagrant-omnibus + - vagrant-cachier + - vagrant-proxyconf + - vagrant-berkshelf + - vagrant-winrm +terraform: + url: ps://releases.hashicorp.com/terraform/0.7.7/terraform_0.7.7_windows_amd64.zip" +packer: + url: ps://releases.hashicorp.com/packer/0.10.2/packer_0.10.2_windows_amd64.zip" +consul: + url: ps://releases.hashicorp.com/consul/0.7.0/consul_0.7.0_windows_amd64.zip" +chefdk: + url: ps://packages.chef.io/stable/windows/2008r2/chefdk-0.18.30-1-x86.msi" + \ No newline at end of file From e04749cfa95b16289759728447c762e0b97d088d Mon Sep 17 00:00:00 2001 From: Vassilis Rizopoulos Date: Thu, 20 Oct 2016 12:04:12 +0200 Subject: [PATCH 02/10] updated gem versions --- Gemfile | 6 +++--- Gemfile.lock | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index be8ead0..d3c8c84 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,9 @@ source 'http://rubygems.org' # gems for building the devpack -gem 'bundler', '>= 1.1.1' -gem 'rake', '>= 0.9.2' -gem 'redcarpet', '~>2.1.1' +gem 'bundler', '~> 1.13.5' +gem 'rake','~>11.3.0' +gem 'redcarpet', '~>3.3.4' gem 'albino', '~>1.3.3' gem 'rspec', '~> 2.14.1' diff --git a/Gemfile.lock b/Gemfile.lock index 776b7ef..76ffcf1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,14 +4,14 @@ GEM albino (1.3.3) posix-spawn (>= 0.3.6) diff-lcs (1.2.5) - posix-spawn (0.3.8) - rake (10.4.2) + posix-spawn (0.3.11) + rake (11.3.0) redcarpet (2.1.1) rspec (2.14.1) rspec-core (~> 2.14.0) rspec-expectations (~> 2.14.0) rspec-mocks (~> 2.14.0) - rspec-core (2.14.7) + rspec-core (2.14.8) rspec-expectations (2.14.5) diff-lcs (>= 1.1.3, < 2.0) rspec-mocks (2.14.6) @@ -26,3 +26,6 @@ DEPENDENCIES rake (>= 0.9.2) redcarpet (~> 2.1.1) rspec (~> 2.14.1) + +BUNDLED WITH + 1.13.5 From 489c5186410ab767cefb2c82c26fc483db6d6c3e Mon Sep 17 00:00:00 2001 From: Vassilis Rizopoulos Date: Thu, 20 Oct 2016 13:06:52 +0200 Subject: [PATCH 03/10] download and unpack uses the YAML config --- Gemfile.lock | 8 +-- Rakefile | 139 ++++++++++++++++++++++++---------------------- config/tools.yaml | 32 +++++------ 3 files changed, 94 insertions(+), 85 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 76ffcf1..b3f422e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,7 +6,7 @@ GEM diff-lcs (1.2.5) posix-spawn (0.3.11) rake (11.3.0) - redcarpet (2.1.1) + redcarpet (3.3.4) rspec (2.14.1) rspec-core (~> 2.14.0) rspec-expectations (~> 2.14.0) @@ -22,9 +22,9 @@ PLATFORMS DEPENDENCIES albino (~> 1.3.3) - bundler (>= 1.1.1) - rake (>= 0.9.2) - redcarpet (~> 2.1.1) + bundler (~> 1.13.5) + rake (~> 11.3.0) + redcarpet (~> 3.3.4) rspec (~> 2.14.1) BUNDLED WITH diff --git a/Rakefile b/Rakefile index 01623a7..f73a7f8 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,4 @@ -%w{ bundler/setup rubygems fileutils uri net/https tmpdir digest/md5 ./doc/markit }.each do |file| +%w{ bundler/setup yaml uri net/https tmpdir digest/md5 ./doc/markit }.each do |file| require file end @@ -6,38 +6,65 @@ end $stdout.sync = true $stderr.sync = true -VERSION = '3.1-SNAPSHOT' -BASE_DIR = File.expand_path('.', File.dirname(__FILE__)) -TARGET_DIR = "#{BASE_DIR}/target" -BUILD_DIR = "#{BASE_DIR}/target/build" -CACHE_DIR = "#{BASE_DIR}/target/cache" -ZIP_EXE = 'C:\Program Files\7-Zip\7z.exe' +module EnvironmentOptions + BASE_DIR = File.expand_path('.', File.dirname(__FILE__)) + VERSION = '3.1-SNAPSHOT' + def version + VERSION + end + def base_dir + return BASE_DIR + end + def target_dir + ddir=ENV["TARGET_DIR"] + ddir||=File.join(base_dir,"target") + File.expand_path(ddir) + end + def build_dir + ddir=ENV["BUILD_DIR"] + ddir||=File.join(base_dir,"build") + File.expand_path(ddir) + end + def cache_dir + ddir=ENV["CACHE_DIR"] + ddir||=File.join(base_dir,"cache") + File.expand_path(ddir) + end + def zip_exe + zip=ENV["ZIP_EXE"] + zip||='C:\Program Files\7-Zip\7z.exe' + return File.expand_path(zip) + end +end +include EnvironmentOptions desc 'cleans the build output directory' task :clean do purge_atom_plugins_with_insanely_long_path - FileUtils.rm_rf BUILD_DIR, secure: true + FileUtils.rm_rf build_dir, secure: true end desc 'wipes all output and cache directories' task :wipe do purge_atom_plugins_with_insanely_long_path - FileUtils.rm_rf TARGET_DIR, secure: true + FileUtils.rm_rf target_dir, secure: true end desc 'downloads required resources and builds the devpack binary' task :build => :clean do + tools_config=YAML.load(File.read("#{base_dir}/config/tools.yaml")) + p tools_config recreate_dirs - download_tools - move_chefdk - fix_chefdk - copy_files - generate_docs - install_knife_plugins - install_vagrant_plugins - install_atom_plugins - run_integration_tests + download_tools(tools_config) + # move_chefdk + # fix_chefdk + # copy_files + # generate_docs + # install_knife_plugins + # install_vagrant_plugins + # install_atom_plugins + # run_integration_tests end desc 'run integration tests' @@ -69,9 +96,9 @@ end def run_acceptance_tests(provider) Bundler.with_clean_env do - FileUtils.rm_rf "#{BUILD_DIR}/repo/vagrant-workflow-tests" - command = "#{BUILD_DIR}/set-env.bat \ - && cd #{BUILD_DIR}/repo \ + FileUtils.rm_rf "#{build_dir}/repo/vagrant-workflow-tests" + command = "#{build_dir}/set-env.bat \ + && cd #{build_dir}/repo \ && git clone https://github.com/tknerr/vagrant-workflow-tests \ && cd vagrant-workflow-tests \ && #{acceptance_test_run_cmd(provider)}" @@ -92,16 +119,16 @@ end def recreate_dirs %w{ home repo tools }.each do |dir| - FileUtils.mkdir_p "#{BUILD_DIR}/#{dir}" + FileUtils.mkdir_p "#{build_dir}/#{dir}" end - FileUtils.mkdir_p CACHE_DIR + FileUtils.mkdir_p cache_dir end # use Windows builtin robocopy command to purge overly long paths, # see https://blog.bertvanlangen.com/articles/path-too-long-use-robocopy/ def purge_atom_plugins_with_insanely_long_path - empty_dir = "#{TARGET_DIR}/empty" - atom_packages_dir = "#{BUILD_DIR}/home/.atom/packages" + empty_dir = "#{target_dir}/empty" + atom_packages_dir = "#{build_dir}/home/.atom/packages" if File.exist?(atom_packages_dir) FileUtils.rm_rf empty_dir FileUtils.mkdir_p empty_dir @@ -110,72 +137,54 @@ def purge_atom_plugins_with_insanely_long_path end def copy_files - FileUtils.cp_r Dir.glob("#{BASE_DIR}/files/*"), "#{BUILD_DIR}" + FileUtils.cp_r Dir.glob("#{base_dir}/files/*"), "#{build_dir}" end def generate_docs - Dir.glob("#{BASE_DIR}/*.md").each do |md_file| + Dir.glob("#{base_dir}/*.md").each do |md_file| html = MarkIt.to_html(IO.read(md_file)) - outfile = "#{BUILD_DIR}/_#{File.basename(md_file, '.md')}.html" + outfile = "#{build_dir}/_#{File.basename(md_file, '.md')}.html" File.open(outfile, 'w') {|f| f.write(html) } end end -def download_tools - [ - %w{ github.com/boot2docker/boot2docker-cli/releases/download/v1.7.1/boot2docker-v1.7.1-windows-amd64.exe docker/boot2docker.exe }, - %w{ get.docker.com/builds/Windows/x86_64/docker-1.7.1.exe docker/docker.exe }, - %w{ github.com/Maximus5/ConEmu/releases/download/v16.03.01/ConEmuPack.160301.7z conemu }, - %w{ github.com/mridgers/clink/releases/download/0.4.4/clink_0.4.4_setup.exe clink }, - %w{ github.com/atom/atom/releases/download/v1.7.3/atom-windows.zip atom }, - %w{ github.com/git-for-windows/git/releases/download/v2.8.2.windows.1/PortableGit-2.8.2-64-bit.7z.exe portablegit }, - %w{ cdn.rubyinstaller.org/archives/devkits/DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe devkit }, - %w{ downloads.sourceforge.net/project/kdiff3/kdiff3/0.9.96/KDiff3Setup_0.9.96.exe kdiff3 - kdiff3.exe }, - %w{ the.earth.li/~sgtatham/putty/0.63/x86/putty.zip putty }, - %w{ www.itefix.net/dl/cwRsync_5.4.1_x86_Free.zip cwrsync }, - %w{ releases.hashicorp.com/vagrant/1.8.1/vagrant_1.8.1.msi vagrant }, - %w{ releases.hashicorp.com/terraform/0.6.16/terraform_0.6.16_windows_amd64.zip terraform }, - %w{ releases.hashicorp.com/packer/0.10.1/packer_0.10.1_windows_amd64.zip packer }, - %w{ releases.hashicorp.com/consul/0.6.4/consul_0.6.4_windows_amd64.zip consul }, - %w{ packages.chef.io/stable/windows/2008r2/chefdk-0.13.21-1-x86.msi cdk } - ] - .each do |host_and_path, target_dir, includes = ''| - download_and_unpack "http://#{host_and_path}", "#{BUILD_DIR}/tools/#{target_dir}", includes.split('|') +def download_tools tools_config + tools_config.each do |tname,cfg| + download_and_unpack(cfg["url"], File.join(target_dir,tname), []) end end # move chef-dk to a shorter path to reduce the likeliness that a gem fails to install due to max path length def move_chefdk - FileUtils.mv "#{BUILD_DIR}/tools/cdk/opscode/chefdk", "#{BUILD_DIR}/tools/chefdk" + FileUtils.mv "#{build_dir}/tools/cdk/opscode/chefdk", "#{build_dir}/tools/chefdk" # chefdk requires a two step install - unpack "#{BUILD_DIR}/tools/cdk/opscode/chefdk.zip", "#{BUILD_DIR}/tools/chefdk" - FileUtils.rm_rf "#{BUILD_DIR}/tools/cdk" + unpack "#{build_dir}/tools/cdk/opscode/chefdk.zip", "#{build_dir}/tools/chefdk" + FileUtils.rm_rf "#{build_dir}/tools/cdk" end # ensure omnibus / chef-dk use the embedded ruby, see opscode/chef#1512 def fix_chefdk - Dir.glob("#{BUILD_DIR}/tools/chefdk/bin/*").each do |file| + Dir.glob("#{build_dir}/tools/chefdk/bin/*").each do |file| if File.extname(file).empty? && File.exist?("#{file}.bat") # do this only for the extensionless .bat counterparts File.write(file, File.read(file).gsub('#!C:/opscode/chefdk/embedded/bin/ruby.exe', '#!/usr/bin/env ruby')) end end - Dir.glob("#{BUILD_DIR}/tools/chefdk/embedded/bin/*").each do |file| + Dir.glob("#{build_dir}/tools/chefdk/embedded/bin/*").each do |file| if File.extname(file).empty? && File.exist?("#{file}.bat") # do this only for the extensionless .bat counterparts File.write(file, File.read(file).gsub('#!C:/opscode/chefdk/embedded/bin/ruby.exe', '#!/usr/bin/env ruby')) end end - Dir.glob("#{BUILD_DIR}/tools/chefdk/embedded/bin/*.bat").each do |file| + Dir.glob("#{build_dir}/tools/chefdk/embedded/bin/*.bat").each do |file| File.write(file, File.read(file).gsub('@"C:\opscode\chefdk\embedded\bin\ruby.exe" "%~dpn0" %*', '@"%~dp0ruby.exe" "%~dpn0" %*')) end - Dir.glob("#{BUILD_DIR}/tools/chefdk/embedded/lib/ruby/gems/2.1.0/bin/*.bat").each do |file| + Dir.glob("#{build_dir}/tools/chefdk/embedded/lib/ruby/gems/2.1.0/bin/*.bat").each do |file| File.write(file, File.read(file).gsub('@"C:\opscode\chefdk\embedded\bin\ruby.exe" "%~dpn0" %*', '@"%~dp0\..\..\..\..\..\bin\ruby.exe" "%~dpn0" %*')) end end def install_knife_plugins Bundler.with_clean_env do - command = "#{BUILD_DIR}/set-env.bat \ + command = "#{build_dir}/set-env.bat \ && chef gem install knife-audit -v 0.2.0 --no-ri --no-rdoc \ && chef gem install knife-server -v 1.1.0 --no-ri --no-rdoc" fail "knife plugin installation failed" unless system(command) @@ -184,7 +193,7 @@ end def install_vagrant_plugins Bundler.with_clean_env do - command = "#{BUILD_DIR}/set-env.bat \ + command = "#{build_dir}/set-env.bat \ && vagrant plugin install vagrant-toplevel-cookbooks --plugin-version 0.2.4 \ && vagrant plugin install vagrant-omnibus --plugin-version 1.4.1 \ && vagrant plugin install vagrant-cachier --plugin-version 1.2.1 \ @@ -197,7 +206,7 @@ end def install_atom_plugins Bundler.with_clean_env do - command = "#{BUILD_DIR}/set-env.bat \ + command = "#{build_dir}/set-env.bat \ && apm install atom-beautify \ && apm install minimap \ && apm install line-ending-converter \ @@ -209,7 +218,7 @@ end def reset_git_user Bundler.with_clean_env do - command = "#{BUILD_DIR}/set-env.bat \ + command = "#{build_dir}/set-env.bat \ && git config --global --unset user.name \ && git config --global --unset user.email" fail "resetting dummy git user failed" unless system(command) @@ -217,7 +226,7 @@ def reset_git_user end def pre_packaging_checks - chefdk_gem_bindir = "#{BUILD_DIR}/home/.chefdk/gem/ruby/2.1.0/bin" + chefdk_gem_bindir = "#{build_dir}/home/.chefdk/gem/ruby/2.1.0/bin" unless Dir.glob("#{chefdk_gem_bindir}/*").empty? raise "beware: gem binaries in '#{chefdk_gem_bindir}' might use an absolute path to ruby.exe! Use `gem pristine` to fix it." end @@ -226,7 +235,7 @@ end def assemble_kitchen pre_packaging_checks reset_git_user - pack BUILD_DIR, "#{TARGET_DIR}/bills-kitchen-#{VERSION}.7z" + pack build_dir, "#{target_dir}/bills-kitchen-#{VERSION}.7z" end def download_and_unpack(url, target_dir, includes = []) @@ -245,7 +254,7 @@ end def download(url, outfile) puts "checking cache for '#{url}'" url_hash = Digest::MD5.hexdigest(url) - cached_file = "#{CACHE_DIR}/#{url_hash}" + cached_file = "#{cache_dir}/#{url_hash}" if File.exist? cached_file puts "cache-hit: read from '#{url_hash}'" FileUtils.cp cached_file, outfile @@ -300,7 +309,7 @@ def unpack(archive, target_dir, includes = []) puts "extracting '#{archive}' to '#{target_dir}'" case File.extname(archive) when '.zip', '.7z', '.exe' - system("\"#{ZIP_EXE}\" x -o\"#{target_dir}\" -y \"#{archive}\" -r #{includes.join(' ')} 1> NUL") + system("\"#{zip_exe}\" x -o\"#{target_dir}\" -y \"#{archive}\" -r #{includes.join(' ')} 1> NUL") when '.msi' system("start /wait msiexec /a \"#{archive.gsub('/', '\\')}\" /qb TARGETDIR=\"#{target_dir.gsub('/', '\\')}\"") else @@ -311,7 +320,7 @@ end def pack(target_dir, archive) puts "packing '#{target_dir}' into '#{archive}'" Dir.chdir(target_dir) do - system("\"#{ZIP_EXE}\" a -t7z -y \"#{archive}\" \".\" 1> NUL") + system("\"#{zip_exe}\" a -t7z -y \"#{archive}\" \".\" 1> NUL") end end diff --git a/config/tools.yaml b/config/tools.yaml index 5641d4c..7409891 100644 --- a/config/tools.yaml +++ b/config/tools.yaml @@ -1,12 +1,12 @@ --- git: - url: ps://github.com/git-for-windows/git/releases/download/v2.10.1.windows.1/PortableGit-2.10.1-64-bit.7z.exe" + url: "https://github.com/git-for-windows/git/releases/download/v2.10.1.windows.1/PortableGit-2.10.1-64-bit.7z.exe" conemu: - url: ps://github.com/Maximus5/ConEmu/releases/download/v16.10.09a/ConEmuPack.161009a.7z" + url: "https://github.com/Maximus5/ConEmu/releases/download/v16.10.09a/ConEmuPack.161009a.7z" clink: - url: ps://github.com/mridgers/clink/releases/download/0.4.8/clink_0.4.8.zip" + url: "https://github.com/mridgers/clink/releases/download/0.4.8/clink_0.4.8.zip" atom: - url: ps://github.com/atom/atom/releases/download/v1.11.2/atom-windows.zip" + url: "https://github.com/atom/atom/releases/download/v1.11.2/atom-windows.zip" plugins: - atom-beautify - minimap @@ -14,19 +14,19 @@ atom: - language-chef - language-batchfile boot2docker: - url: ps://github.com/boot2docker/boot2docker-cli/releases/download/v1.8.0/boot2docker-v1.8.0-windows-amd64.exe" -docker: : - url: ps://download.docker.com/win/stable/InstallDocker.msi" + url: "https://github.com/boot2docker/boot2docker-cli/releases/download/v1.8.0/boot2docker-v1.8.0-windows-amd64.exe" +docker: + url: "https://download.docker.com/win/stable/InstallDocker.msi" ruby-devkit: - url: p://dl.bintray.com/oneclick/rubyinstaller/DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe" + url: "http://dl.bintray.com/oneclick/rubyinstaller/DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe" kdiff3: - url: p://downloads.sourceforge.net/project/kdiff3/kdiff3/0.9.98/KDiff3-64bit-Setup_0.9.98-2.exe" + url: "http://downloads.sourceforge.net/project/kdiff3/kdiff3/0.9.98/KDiff3-64bit-Setup_0.9.98-2.exe" putty: - url: ps://the.earth.li/~sgtatham/putty/latest/x86/putty.zip" + url: "https://the.earth.li/~sgtatham/putty/latest/x86/putty.zip" cwrsync: - url: ps://www.itefix.net/dl/cwRsync_5.5.0_x86_Free.zip" + url: "https://www.itefix.net/dl/cwRsync_5.5.0_x86_Free.zip" vagrant: - url: ps://releases.hashicorp.com/vagrant/1.8.6/vagrant_1.8.6.msi" + url: "https://releases.hashicorp.com/vagrant/1.8.6/vagrant_1.8.6.msi" plugins: - vagrant-toplevel-cookbooks - vagrant-omnibus @@ -35,11 +35,11 @@ vagrant: - vagrant-berkshelf - vagrant-winrm terraform: - url: ps://releases.hashicorp.com/terraform/0.7.7/terraform_0.7.7_windows_amd64.zip" + url: "https://releases.hashicorp.com/terraform/0.7.7/terraform_0.7.7_windows_amd64.zip" packer: - url: ps://releases.hashicorp.com/packer/0.10.2/packer_0.10.2_windows_amd64.zip" + url: "https://releases.hashicorp.com/packer/0.10.2/packer_0.10.2_windows_amd64.zip" consul: - url: ps://releases.hashicorp.com/consul/0.7.0/consul_0.7.0_windows_amd64.zip" + url: "https://releases.hashicorp.com/consul/0.7.0/consul_0.7.0_windows_amd64.zip" chefdk: - url: ps://packages.chef.io/stable/windows/2008r2/chefdk-0.18.30-1-x86.msi" + url: "https://packages.chef.io/stable/windows/2008r2/chefdk-0.18.30-1-x86.msi" \ No newline at end of file From ec601085e497a8131f510aaf84c0477c0918fb9e Mon Sep 17 00:00:00 2001 From: Vassilis Rizopoulos Date: Thu, 20 Oct 2016 13:38:35 +0200 Subject: [PATCH 04/10] chef, atom and vagrant plugins read plugin list and versions from the YAML configuration. All chef, vagrant and atom extras are conditional on the presence of the tool in the configuration --- Rakefile | 72 ++++++++++++++++++++++++++--------------------- config/tools.yaml | 17 ++++++----- 2 files changed, 50 insertions(+), 39 deletions(-) diff --git a/Rakefile b/Rakefile index f73a7f8..ac84809 100644 --- a/Rakefile +++ b/Rakefile @@ -54,17 +54,25 @@ end desc 'downloads required resources and builds the devpack binary' task :build => :clean do tools_config=YAML.load(File.read("#{base_dir}/config/tools.yaml")) - p tools_config recreate_dirs download_tools(tools_config) - # move_chefdk - # fix_chefdk - # copy_files - # generate_docs - # install_knife_plugins - # install_vagrant_plugins - # install_atom_plugins - # run_integration_tests + if tools_config.keys.include?("chefdk") + move_chefdk + fix_chefdk + end + copy_files + generate_docs + if tools_config.keys.include?("chefdk") + install_knife_plugins + end + if tools_config.keys.include?("atom") + atom_config=tools_config.fetch("atom",{}) + install_atom_plugins(atom_config) + end + if tools_config.keys.include?("vagrant") + install_vagrant_plugins + end + run_integration_tests end desc 'run integration tests' @@ -156,10 +164,11 @@ end # move chef-dk to a shorter path to reduce the likeliness that a gem fails to install due to max path length def move_chefdk - FileUtils.mv "#{build_dir}/tools/cdk/opscode/chefdk", "#{build_dir}/tools/chefdk" - # chefdk requires a two step install - unpack "#{build_dir}/tools/cdk/opscode/chefdk.zip", "#{build_dir}/tools/chefdk" - FileUtils.rm_rf "#{build_dir}/tools/cdk" + #chefdk install package contains a zip file + extra_pkg="#{target_dir}/chefdk/opscode/chefdk.zip" + tgt_dir="#{target_dir}/chefdk/opscode/" + unpack(extra_pkg, tgt_dir, includes = []) + FileUtils.mv "#{target_dir}/chefdk/opscode/", "#{build_dir}/tools/chefdk" end # ensure omnibus / chef-dk use the embedded ruby, see opscode/chef#1512 @@ -182,36 +191,35 @@ def fix_chefdk end end -def install_knife_plugins +def install_knife_plugins tool_config + commands=["#{build_dir}/set-env.bat"] + tool_config.fetch("plugins",{}).each do |plug,ver| + commands<<"chef gem install #{plug} -v #{ver} --no-ri --no-rdoc" + end Bundler.with_clean_env do - command = "#{build_dir}/set-env.bat \ - && chef gem install knife-audit -v 0.2.0 --no-ri --no-rdoc \ - && chef gem install knife-server -v 1.1.0 --no-ri --no-rdoc" + command = commands.join(" && ") fail "knife plugin installation failed" unless system(command) end end -def install_vagrant_plugins +def install_vagrant_plugins tool_config + commands=["#{build_dir}/set-env.bat"] + tool_config.fetch("plugins",{}).each do |plug,ver| + commands<<"vagrant plugin install #{plug} --plugin-version#{ver}" + end Bundler.with_clean_env do - command = "#{build_dir}/set-env.bat \ - && vagrant plugin install vagrant-toplevel-cookbooks --plugin-version 0.2.4 \ - && vagrant plugin install vagrant-omnibus --plugin-version 1.4.1 \ - && vagrant plugin install vagrant-cachier --plugin-version 1.2.1 \ - && vagrant plugin install vagrant-proxyconf --plugin-version 1.5.2 \ - && vagrant plugin install vagrant-berkshelf --plugin-version 4.1.0 \ - && vagrant plugin install vagrant-winrm --plugin-version 0.7.0" + command = commands.join(" && ") fail "vagrant plugin installation failed" unless system(command) end end -def install_atom_plugins +def install_atom_plugins tool_config + commands=["#{build_dir}/set-env.bat"] + commands+=tool_config.fetch("plugins",{}).keys.map do |plug| + "apm install #{plug}" + end Bundler.with_clean_env do - command = "#{build_dir}/set-env.bat \ - && apm install atom-beautify \ - && apm install minimap \ - && apm install line-ending-converter \ - && apm install language-chef \ - && apm install language-batchfile" + command = commands.join(" && ") fail "atom plugins installation failed" unless system(command) end end diff --git a/config/tools.yaml b/config/tools.yaml index 7409891..64d8280 100644 --- a/config/tools.yaml +++ b/config/tools.yaml @@ -8,7 +8,7 @@ clink: atom: url: "https://github.com/atom/atom/releases/download/v1.11.2/atom-windows.zip" plugins: - - atom-beautify + - atom-beautify: "" - minimap - line-ending-converter - language-chef @@ -28,12 +28,12 @@ cwrsync: vagrant: url: "https://releases.hashicorp.com/vagrant/1.8.6/vagrant_1.8.6.msi" plugins: - - vagrant-toplevel-cookbooks - - vagrant-omnibus - - vagrant-cachier - - vagrant-proxyconf - - vagrant-berkshelf - - vagrant-winrm + - vagrant-toplevel-cookbooks: "0.2.4" + - vagrant-omnibus: "1.4.1" + - vagrant-cachier: "1.2.1" + - vagrant-proxyconf: "1.5.2" + - vagrant-berkshelf: "4.1.0" + - vagrant-winrm: "0.7.0" terraform: url: "https://releases.hashicorp.com/terraform/0.7.7/terraform_0.7.7_windows_amd64.zip" packer: @@ -42,4 +42,7 @@ consul: url: "https://releases.hashicorp.com/consul/0.7.0/consul_0.7.0_windows_amd64.zip" chefdk: url: "https://packages.chef.io/stable/windows/2008r2/chefdk-0.18.30-1-x86.msi" + plugins: + - knife-audit: "0.2.0" + - knife-server: "1.1.0" \ No newline at end of file From 3153baeaab2bd55619e9beb34216e144272823ab Mon Sep 17 00:00:00 2001 From: Vassilis Rizopoulos Date: Thu, 20 Oct 2016 13:42:40 +0200 Subject: [PATCH 05/10] pass the tool config --- Rakefile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Rakefile b/Rakefile index ac84809..986cba4 100644 --- a/Rakefile +++ b/Rakefile @@ -63,14 +63,13 @@ task :build => :clean do copy_files generate_docs if tools_config.keys.include?("chefdk") - install_knife_plugins + install_knife_plugins(tools_config.fetch("chefdk",{})) end if tools_config.keys.include?("atom") - atom_config=tools_config.fetch("atom",{}) - install_atom_plugins(atom_config) + install_atom_plugins(tools_config.fetch("atom",{})) end if tools_config.keys.include?("vagrant") - install_vagrant_plugins + install_vagrant_plugins(tools_config.fetch("vagrant",{})) end run_integration_tests end From 3463e76d1c5ff2ddb8402b309b9c7e8e22a9834c Mon Sep 17 00:00:00 2001 From: Vassilis Rizopoulos Date: Thu, 20 Oct 2016 14:55:23 +0200 Subject: [PATCH 06/10] not an Array of Hashes, just a Hash with name= Date: Wed, 26 Oct 2016 00:29:30 +0200 Subject: [PATCH 07/10] correct some paths and restore the original logic in move_chefdk both the build_dir and cache_dir were nested under target_dir originally. restoring that for now... --- Rakefile | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Rakefile b/Rakefile index 986cba4..41450ac 100644 --- a/Rakefile +++ b/Rakefile @@ -22,12 +22,12 @@ module EnvironmentOptions end def build_dir ddir=ENV["BUILD_DIR"] - ddir||=File.join(base_dir,"build") + ddir||=File.join(target_dir,"build") File.expand_path(ddir) end def cache_dir ddir=ENV["CACHE_DIR"] - ddir||=File.join(base_dir,"cache") + ddir||=File.join(target_dir,"cache") File.expand_path(ddir) end def zip_exe @@ -157,17 +157,16 @@ end def download_tools tools_config tools_config.each do |tname,cfg| - download_and_unpack(cfg["url"], File.join(target_dir,tname), []) + download_and_unpack(cfg["url"], File.join(build_dir,'tools',tname), []) end end # move chef-dk to a shorter path to reduce the likeliness that a gem fails to install due to max path length def move_chefdk + FileUtils.mv "#{build_dir}/tools/chef_dk/opscode/chefdk", "#{build_dir}/tools/chefdk" #chefdk install package contains a zip file - extra_pkg="#{target_dir}/chefdk/opscode/chefdk.zip" - tgt_dir="#{target_dir}/chefdk/opscode/" - unpack(extra_pkg, tgt_dir, includes = []) - FileUtils.mv "#{target_dir}/chefdk/opscode/", "#{build_dir}/tools/chefdk" + unpack("#{build_dir}/tools/chef_dk/opscode/chefdk.zip", "#{build_dir}/tools/chefdk") + FileUtils.rm_rf "#{build_dir}/tools/chef_dk" end # ensure omnibus / chef-dk use the embedded ruby, see opscode/chef#1512 From 57fae34bf481af2d3a6df4017845d839fd3c37b9 Mon Sep 17 00:00:00 2001 From: Torben Knerr Date: Wed, 26 Oct 2016 00:31:29 +0200 Subject: [PATCH 08/10] adapt tool name to chef_dk as expected in the Rakefile (earlier this was cdk, hope it won't hit the max path length issue with chef_dk...) --- config/tools.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/tools.yaml b/config/tools.yaml index e138773..794b14e 100644 --- a/config/tools.yaml +++ b/config/tools.yaml @@ -40,9 +40,9 @@ packer: url: "https://releases.hashicorp.com/packer/0.10.2/packer_0.10.2_windows_amd64.zip" consul: url: "https://releases.hashicorp.com/consul/0.7.0/consul_0.7.0_windows_amd64.zip" -chefdk: +chef_dk: url: "https://packages.chef.io/stable/windows/2008r2/chefdk-0.18.30-1-x86.msi" plugins: knife-audit: "0.2.0" knife-server: "1.1.0" - \ No newline at end of file + From 33da03db099e2fc4da39b64f14a39243c03e71f5 Mon Sep 17 00:00:00 2001 From: Torben Knerr Date: Wed, 26 Oct 2016 00:39:24 +0200 Subject: [PATCH 09/10] restore the original tool names so they match the paths defined in set-env.bat --- config/tools.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/tools.yaml b/config/tools.yaml index 794b14e..c6a88d0 100644 --- a/config/tools.yaml +++ b/config/tools.yaml @@ -1,5 +1,5 @@ --- -git: +portablegit: url: "https://github.com/git-for-windows/git/releases/download/v2.10.1.windows.1/PortableGit-2.10.1-64-bit.7z.exe" conemu: url: "https://github.com/Maximus5/ConEmu/releases/download/v16.10.09a/ConEmuPack.161009a.7z" @@ -17,7 +17,7 @@ boot2docker: url: "https://github.com/boot2docker/boot2docker-cli/releases/download/v1.8.0/boot2docker-v1.8.0-windows-amd64.exe" docker: url: "https://download.docker.com/win/stable/InstallDocker.msi" -ruby-devkit: +devkit: url: "http://dl.bintray.com/oneclick/rubyinstaller/DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe" kdiff3: url: "http://downloads.sourceforge.net/project/kdiff3/kdiff3/0.9.98/KDiff3-64bit-Setup_0.9.98-2.exe" From c797e585e1f2d608a9ed9d100b575028b0acdb6a Mon Sep 17 00:00:00 2001 From: Torben Knerr Date: Wed, 26 Oct 2016 00:52:58 +0200 Subject: [PATCH 10/10] fix vagrant plugin installation --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 41450ac..9a10f5c 100644 --- a/Rakefile +++ b/Rakefile @@ -203,7 +203,7 @@ end def install_vagrant_plugins tool_config commands=["#{build_dir}/set-env.bat"] tool_config.fetch("plugins",{}).each do |plug,ver| - commands<<"vagrant plugin install #{plug} --plugin-version#{ver}" + commands<<"vagrant plugin install #{plug} --plugin-version #{ver}" end Bundler.with_clean_env do command = commands.join(" && ")