Use releases for releases

This commit is contained in:
Seth Vargo 2015-10-26 11:29:54 -04:00
parent d142640d85
commit 23990e34e9
21 changed files with 207 additions and 228 deletions

View File

@ -1,7 +1,7 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
activesupport (3.2.21) activesupport (3.2.22)
i18n (~> 0.6, >= 0.6.4) i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0) multi_json (~> 1.0)
builder (3.2.2) builder (3.2.2)
@ -9,7 +9,7 @@ GEM
coffee-script (2.2.0) coffee-script (2.2.0)
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.9.1) coffee-script-source (1.9.1.1)
commonjs (0.2.7) commonjs (0.2.7)
compass (1.0.3) compass (1.0.3)
chunky_png (~> 1.2) chunky_png (~> 1.2)
@ -23,20 +23,20 @@ GEM
sass (>= 3.3.0, < 3.5) sass (>= 3.3.0, < 3.5)
compass-import-once (1.0.5) compass-import-once (1.0.5)
sass (>= 3.2, < 3.5) sass (>= 3.2, < 3.5)
daemons (1.1.9) daemons (1.2.3)
eventmachine (1.0.7) eventmachine (1.0.8)
execjs (1.4.1) execjs (1.4.1)
multi_json (~> 1.0) multi_json (~> 1.0)
ffi (1.9.6) ffi (1.9.10)
haml (4.0.6) haml (4.0.7)
tilt tilt
highline (1.6.21) highline (1.6.21)
hike (1.2.3) hike (1.2.3)
i18n (0.6.11) i18n (0.6.11)
kramdown (1.5.0) kramdown (1.9.0)
less (2.2.2) less (2.2.2)
commonjs (~> 0.2.6) commonjs (~> 0.2.6)
libv8 (3.16.14.7) libv8 (3.16.14.13)
listen (1.3.1) listen (1.3.1)
rb-fsevent (>= 0.9.3) rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9) rb-inotify (>= 0.9)
@ -75,25 +75,25 @@ GEM
sprockets-helpers (~> 1.0.0) sprockets-helpers (~> 1.0.0)
sprockets-sass (~> 1.0.0) sprockets-sass (~> 1.0.0)
mini_portile (0.6.2) mini_portile (0.6.2)
multi_json (1.10.1) multi_json (1.11.2)
nokogiri (1.6.6.2) nokogiri (1.6.6.2)
mini_portile (~> 0.6.0) mini_portile (~> 0.6.0)
rack (1.6.0) rack (1.6.4)
rack-contrib (1.1.0) rack-contrib (1.1.0)
rack (>= 0.9.1) rack (>= 0.9.1)
rack-protection (1.5.3) rack-protection (1.5.3)
rack rack
rack-test (0.6.3) rack-test (0.6.3)
rack (>= 1.0) rack (>= 1.0)
rb-fsevent (0.9.4) rb-fsevent (0.9.6)
rb-inotify (0.9.5) rb-inotify (0.9.5)
ffi (>= 0.5.0) ffi (>= 0.5.0)
rb-kqueue (0.2.3) rb-kqueue (0.2.4)
ffi (>= 0.5.0) ffi (>= 0.5.0)
redcarpet (3.0.0) redcarpet (3.0.0)
ref (1.0.5) ref (2.0.0)
sass (3.4.13) sass (3.4.19)
sprockets (2.12.3) sprockets (2.12.4)
hike (~> 1.2) hike (~> 1.2)
multi_json (~> 1.0) multi_json (~> 1.0)
rack (~> 1.0) rack (~> 1.0)
@ -103,7 +103,7 @@ GEM
sprockets-sass (1.0.3) sprockets-sass (1.0.3)
sprockets (~> 2.0) sprockets (~> 2.0)
tilt (~> 1.1) tilt (~> 1.1)
therubyracer (0.12.1) therubyracer (0.12.2)
libv8 (~> 3.16.14.0) libv8 (~> 3.16.14.0)
ref ref
thin (1.5.1) thin (1.5.1)
@ -112,7 +112,7 @@ GEM
rack (>= 1.0.0) rack (>= 1.0.0)
thor (0.19.1) thor (0.19.1)
tilt (1.3.7) tilt (1.3.7)
tzinfo (0.3.43) tzinfo (0.3.45)
uglifier (2.1.2) uglifier (2.1.2)
execjs (>= 0.3.0) execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2) multi_json (~> 1.0, >= 1.0.2)

View File

@ -1,13 +1,10 @@
require File.expand_path("../helpers/download_helpers", __FILE__) require_relative "helpers/middleman_hashicorp_shim"
helpers MiddlemanHashiCorpHelpers
page "/blog_feed.xml", layout: false page "/blog_feed.xml", layout: false
ignore "/download-archive-single.html"
# Archived download pages # The version of Vagrant - update this to update the downloads page
$vagrant_versions.each do |version| set :latest_version, '1.7.4'
proxy "/download-archive/v#{version}.html", "/download-archive-single.html",
locals: { version: version }, ignore: true
end
set :css_dir, 'stylesheets' set :css_dir, 'stylesheets'
set :js_dir, 'javascripts' set :js_dir, 'javascripts'

View File

@ -6,6 +6,7 @@ require "rack/contrib/try_static"
require "rack/protection" require "rack/protection"
require File.expand_path("../lib/legacy_redirect", __FILE__) require File.expand_path("../lib/legacy_redirect", __FILE__)
require File.expand_path("../lib/redirect_to_releases", __FILE__)
# Protect against various bad things # Protect against various bad things
use Rack::Protection::JsonCsrf use Rack::Protection::JsonCsrf
@ -23,6 +24,9 @@ use Rack::Deflater
# Redirect the legacy URLs that point to www.vagrantup.com # Redirect the legacy URLs that point to www.vagrantup.com
use HashiCorp::Rack::LegacyRedirect use HashiCorp::Rack::LegacyRedirect
# Redirect the archive page to releases
use HashiCorp::Rack::RedirectToReleases
# Set the "forever expire" cache headers for these static assets. Since # Set the "forever expire" cache headers for these static assets. Since
# we hash the contents of the assets to determine filenames, this is safe # we hash the contents of the assets to determine filenames, this is safe
# to do. # to do.

View File

@ -1,85 +0,0 @@
require "json"
require "net/http"
require "net/https"
$vagrant_files = {}
$vagrant_os = []
$vagrant_os_mappings = {
".deb" => "debian",
".dmg" => "darwin",
".msi" => "windows",
".rpm" => "rpm",
}
$vagrant_os_order = ["darwin", "windows", "debian", "rpm"]
$vagrant_downloads = {}
$vagrant_versions = []
if ENV["VAGRANT_VERSION"]
puts "Finding downloads for Vagrant"
raise "BINTRAY_API_KEY must be set." if !ENV["BINTRAY_API_KEY"]
http = Net::HTTP.new("bintray.com", 443)
http.use_ssl = true
req = Net::HTTP::Get.new("/api/v1/packages/mitchellh/vagrant/vagrant/files")
req.basic_auth "mitchellh", ENV["BINTRAY_API_KEY"]
response = http.request(req)
data = JSON.parse(response.body)
data.each do |file|
filename = file["name"]
# Ignore any files that don't appear to have a version in it
next if filename !~ /[-_]?(\d+\.\d+\.\d+[^-_.]*)/
version = Gem::Version.new($1.to_s)
$vagrant_downloads[version] ||= {}
$vagrant_os_mappings.each do |suffix, os|
if filename.end_with?(suffix)
$vagrant_downloads[version][os] ||= []
$vagrant_downloads[version][os] << filename
end
end
end
$vagrant_versions = $vagrant_downloads.keys.sort.reverse
$vagrant_versions.each do |v|
puts "- Version #{v} found"
end
else
puts "Not generating downloads."
end
module DownloadHelpers
def download_arch(file)
if file.include?("i686")
return "32-bit"
elsif file.include?("x86_64")
return "64-bit"
else
return "Universal (32 and 64-bit)"
end
end
def download_os_human(os)
if os == "darwin"
return "Mac OS X"
elsif os == "debian"
return "Linux (Deb)"
elsif os == "rpm"
return "Linux (RPM)"
elsif os == "windows"
return "Windows"
else
return os
end
end
def download_url(file)
"https://dl.bintray.com/mitchellh/vagrant/#{file}"
end
def latest_version
$vagrant_versions.first
end
end

View File

@ -0,0 +1,103 @@
# This file is a shim that mirrors the behavior or middleman-hashicorp without
# fully importing it. Vagrant is somewhat of a beast and cannot be easily
# updated due to older versions of bootstrap and javascript and whatnot.
require "open-uri"
class MiddlemanHashiCorpReleases
RELEASES_URL = "https://releases.hashicorp.com".freeze
class Build < Struct.new(:name, :version, :os, :arch, :url); end
def self.fetch(product, version)
url = "#{RELEASES_URL}/#{product}/#{version}/index.json"
r = JSON.parse(open(url).string,
create_additions: false,
symbolize_names: true,
)
# Convert the builds into the following format:
#
# {
# "os" => {
# "arch" => "https://download.url"
# }
# }
#
{}.tap do |h|
r[:builds].each do |b|
build = Build.new(*b.values_at(*Build.members))
h[build.os] ||= {}
h[build.os][build.arch] = build.url
end
end
end
end
module MiddlemanHashiCorpHelpers
#
# Output an image that corresponds to the given operating system using the
# vendored image icons.
#
# @return [String] (html)
#
def system_icon(name)
image_tag("icons/icon_#{name.to_s.downcase}.png")
end
#
# The formatted operating system name.
#
# @return [String]
#
def pretty_os(os)
case os
when /darwin/
"Mac OS X"
when /freebsd/
"FreeBSD"
when /openbsd/
"OpenBSD"
when /linux/
"Linux"
when /windows/
"Windows"
else
os.capitalize
end
end
#
# The formatted architecture name.
#
# @return [String]
#
def pretty_arch(arch)
case arch
when /all/
"Universal (32 and 64-bit)"
when /686/, /386/
"32-bit"
when /86_64/, /amd64/
"64-bit"
else
parts = arch.split("_")
if parts.empty?
raise "Could not determine pretty arch `#{arch}'!"
end
parts.last.capitalize
end
end
#
# Query the Bintray API to get the real product download versions.
#
# @return [Hash]
#
def product_versions
MiddlemanHashiCorpReleases.fetch("vagrant", latest_version)
end
end

View File

@ -0,0 +1,37 @@
module HashiCorp
module Rack
# This redirects to releases.hashicorp.com when a user tries to download
# an old version of Vagrant.
class RedirectToReleases
def initialize(app)
@app = app
end
def call(env)
if env["PATH_INFO"] =~ /^\/downloads-archive/
headers = {
"Content-Type" => "text/html",
"Location" => "https://releases.hashicorp.com/vagrant",
}
message = "Redirecting to releases archive..."
return [301, headers, [message]]
end
if env["PATH_INFO"] =~ /^\/download-archive\/v(.+)\.html/
headers = {
"Content-Type" => "text/html",
"Location" => "https://releases.hashicorp.com/vagrant/#{$1}",
}
message = "Redirecting to releases archive..."
return [301, headers, [message]]
end
@app.call(env)
end
end
end
end

View File

@ -1,4 +1,4 @@
<ul class="unstyled"> <ul class="unstyled">
<li<%= sidebar_current("downloads") %>><a href="/downloads.html">Latest</a></li> <li<%= sidebar_current("downloads") %>><a href="/downloads.html">Latest</a></li>
<li<%= sidebar_current("downloads-archive") %>><a href="/downloads-archive.html">Old Versions</a></li> <li><a href="/downloads-archive.html">Old Versions</a></li>
</ul> </ul>

View File

@ -1,51 +0,0 @@
---
layout: "inner"
sidebar_current: "downloads"
sidebar_template: "downloads"
sidebar_title: "Download"
page_title: "Download Old Vagrant Version"
---
<h2>Old Vagrant Version: <%= version %></h2>
<div class="alert alert-block alert-info">
This is the downloads page for an <em>old</em> version of Vagrant.
The latest version of Vagrant can always be found on the
<a href="/downloads.html">main downloads page</a>.
</div>
<div class="downloads">
<div class="description">
<p>
You can find the SHA256 checksums for this version of Vagrant
<a href="https://dl.bintray.com/mitchellh/vagrant/<%= version %>_SHA256SUMS?direct">here</a>.
</p>
</div>
<% $vagrant_os_order.each do |os| %>
<% downloads = $vagrant_downloads[version] %>
<% if downloads[os] && !downloads[os].empty? %>
<div class="row">
<div class="span8 download">
<div class="icon pull-left"><%= image_tag "/images/icons/icon_#{os}.png" %></div>
<div class="details">
<h2 class="os-name"><%= download_os_human(os) %></h2>
<ul>
<% downloads[os].each do |file| %>
<li><a href="<%= download_url(file) %>"><%= download_arch(file) %></a></li>
<% end %>
</ul>
<div class="clearfix"></div>
</div>
</div>
</div>
<% end %>
<% end %>
<div class="poweredby">
<a href='https://www.bintray.com'>
<img src='https://www.bintray.com/docs/images/poweredByBintray_ColorTransparent.png'>
</a>
</div>
</div>

View File

@ -1,32 +0,0 @@
---
layout: "inner"
sidebar_current: "downloads-archive"
sidebar_template: "downloads"
sidebar_title: "Download"
page_title: "Download Old Versions of Vagrant"
---
<h2>Old Versions</h2>
<p>
This webpage lists the older versions of Vagrant that are available for
download. Some even older versions are available from the
<a href="https://www.vagrantup.com/downloads-archive.html">legacy downloads page</a>.
</p>
<p>
The latest version of Vagrant can be found on the
<a href="/downloads.html">main downloads page</a>.
</p>
<% if $vagrant_versions.length > 1 %>
<ul>
<% $vagrant_versions[1..-1].each do |version| %>
<li><p><a href="/download-archive/v<%= version.to_s %>.html"><%= version.to_s %></a></p></li>
<% end %>
</ul>
<% else %>
<p>
No old Vagrant versions could be found.
</p>
<% end %>

View File

@ -9,41 +9,47 @@ page_title: "Download Vagrant"
<h2>Download Vagrant</h2> <h2>Download Vagrant</h2>
<div class="downloads"> <div class="downloads">
<div class="description"> <div class="description">
<p> <p>
Below are all available downloads for the latest version of Vagrant Below are the available downloads for the latest version of Vagrant
(<%= latest_version %>). Please download the proper package for your (<%= latest_version %>). Please download the proper package for your
operating system and architecture. You can find SHA256 checksums operating system and architecture.
for packages <a href="https://dl.bintray.com/mitchellh/vagrant/<%= latest_version %>_SHA256SUMS?direct">here</a>, </p>
and you can find the version changelog <a href="https://github.com/mitchellh/vagrant/blob/master/CHANGELOG.md">here</a>. <p>
</p> You can find the
</div> <a href="https://releases.hashicorp.com/vagrant/<%= latest_version %>/vagrant_<%= latest_version %>_SHA256SUMS">
SHA256 checksums for Vagrant <%= latest_version %>
</a>
online and you can
<a href="https://releases.hashicorp.com/vagrant/<%= latest_version %>/vagrant_<%= latest_version %>_SHA256SUMS.sig">
verify the checksums signature file
</a>
which has been signed using <a href="https://hashicorp.com/security.html" target="_TOP">HashiCorp's GPG key</a>.
You can also <a href="https://releases.hashicorp.com/vagrant" target="_TOP">download older versions of Vagrant</a> from the releases service.
</p>
</div>
<% if latest_version %> <% product_versions.each do |os, arches| %>
<% $vagrant_os_order.each do |os| %> <% next if os == "web" %>
<% downloads = $vagrant_downloads[latest_version] %> <div class="row">
<% if downloads[os] && !downloads[os].empty? %> <div class="col-md-12 download">
<div class="row"> <div class="icon pull-left"><%= system_icon(os) %></div>
<div class="span8 download"> <div class="details">
<div class="icon pull-left"><%= image_tag "/images/icons/icon_#{os}.png" %></div> <h2 class="os-name"><%= pretty_os(os) %></h2>
<div class="details"> <ul>
<h2 class="os-name"><%= download_os_human(os) %></h2> <% arches.each do |arch, url| %>
<ul> <li><a href="<%= url %>"><%= pretty_arch(arch) %></a></li>
<% downloads[os].each do |file| %> <% end %>
<li><a href="<%= download_url(file) %>"><%= download_arch(file) %></a></li> </ul>
<% end %> <div class="clearfix"></div>
</ul> </div>
<div class="clearfix"></div> </div>
</div> </div>
</div> <% end %>
</div>
<% end %>
<% end %>
<% end %>
<div class="poweredby"> <div class="poweredby">
<a href='https://www.bintray.com'> <a href="https://www.fastly.com?utm_source=hashicorp" target="_TOP">
<img src='https://www.bintray.com/docs/images/poweredByBintray_ColorTransparent.png'> <%= image_tag "fastly_logo.png" %>
</a> </a>
</div> </div>
</div> </div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 848 B

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB