2013-06-24 19:25:42 -04:00
|
|
|
require "net/http"
|
|
|
|
|
|
|
|
raise "PACKER_VERSION must be set." if !ENV["PACKER_VERSION"]
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
# Download the list of Packer downloads
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
$packer_files = {}
|
2013-06-27 11:17:00 -04:00
|
|
|
$packer_os = []
|
|
|
|
|
|
|
|
if !ENV["PACKER_DISABLE_DOWNLOAD_FETCH"]
|
2013-07-02 13:47:44 -04:00
|
|
|
raise "BINTRAY_API_KEY must be set." if !ENV["BINTRAY_API_KEY"]
|
2013-06-27 11:17:00 -04:00
|
|
|
http = Net::HTTP.new("dl.bintray.com", 80)
|
2014-02-21 23:38:58 -05:00
|
|
|
req = Net::HTTP::Get.new("/mitchellh/packer/")
|
2013-06-27 11:17:00 -04:00
|
|
|
req.basic_auth "mitchellh", ENV["BINTRAY_API_KEY"]
|
|
|
|
response = http.request(req)
|
|
|
|
|
|
|
|
response.body.split("\n").each do |line|
|
2014-09-08 20:03:38 -04:00
|
|
|
next if line !~ /\/mitchellh\/packer\/packer_(#{Regexp.quote(ENV["PACKER_VERSION"])}.+?)'/
|
2013-06-28 11:56:11 -04:00
|
|
|
filename = $1.to_s
|
2013-06-27 11:17:00 -04:00
|
|
|
os = filename.split("_")[1]
|
2013-06-28 11:56:11 -04:00
|
|
|
next if os == "SHA256SUMS"
|
2013-06-27 11:17:00 -04:00
|
|
|
|
|
|
|
$packer_files[os] ||= []
|
|
|
|
$packer_files[os] << filename
|
|
|
|
end
|
|
|
|
|
|
|
|
$packer_os = ["darwin", "linux", "windows"] & $packer_files.keys
|
|
|
|
$packer_os += $packer_files.keys
|
|
|
|
$packer_os.uniq!
|
|
|
|
|
|
|
|
$packer_files.each do |key, value|
|
|
|
|
value.sort!
|
|
|
|
end
|
2013-06-24 19:25:42 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
# Configure Middleman
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
2013-06-08 01:41:02 -04:00
|
|
|
set :css_dir, 'stylesheets'
|
|
|
|
set :js_dir, 'javascripts'
|
|
|
|
set :images_dir, 'images'
|
|
|
|
|
|
|
|
# Use the RedCarpet Markdown engine
|
|
|
|
set :markdown_engine, :redcarpet
|
2013-08-18 07:34:35 -04:00
|
|
|
set :markdown,
|
|
|
|
:fenced_code_blocks => true,
|
|
|
|
:with_toc_data => true
|
2013-06-08 01:41:02 -04:00
|
|
|
|
|
|
|
# Build-specific configuration
|
|
|
|
configure :build do
|
|
|
|
activate :asset_hash
|
|
|
|
activate :minify_css
|
|
|
|
activate :minify_html
|
|
|
|
activate :minify_javascript
|
|
|
|
end
|
2013-06-24 19:25:42 -04:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
# Helpers
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
helpers do
|
|
|
|
def download_arch(file)
|
2013-06-28 11:56:11 -04:00
|
|
|
parts = file.split("_")
|
|
|
|
return "" if parts.length != 3
|
|
|
|
parts[2].split(".")[0]
|
2013-06-24 19:25:42 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def download_os_human(os)
|
|
|
|
if os == "darwin"
|
|
|
|
return "Mac OS X"
|
|
|
|
elsif os == "freebsd"
|
|
|
|
return "FreeBSD"
|
|
|
|
elsif os == "openbsd"
|
|
|
|
return "OpenBSD"
|
|
|
|
elsif os == "Linux"
|
|
|
|
return "Linux"
|
|
|
|
elsif os == "windows"
|
|
|
|
return "Windows"
|
|
|
|
else
|
|
|
|
return os
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def download_url(file)
|
2014-09-08 20:03:38 -04:00
|
|
|
"https://dl.bintray.com/mitchellh/packer/packer_#{file}"
|
2013-06-24 19:25:42 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def latest_version
|
|
|
|
ENV["PACKER_VERSION"]
|
|
|
|
end
|
|
|
|
end
|