mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Add a sanity check to make sure the correct versions of Net::SSH and Net::SFTP are installed
git-svn-id: http://svn.rubyonrails.org/rails/tools/switchtower@3373 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
c3c3b8ab4a
commit
dce7ac5c13
6 changed files with 45 additions and 4 deletions
|
@ -1,5 +1,7 @@
|
||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
|
* Add a sanity check to make sure the correct versions of Net::SSH and Net::SFTP are installed.
|
||||||
|
|
||||||
* Added a cleanup task to remove unused releases from the deployment directory
|
* Added a cleanup task to remove unused releases from the deployment directory
|
||||||
|
|
||||||
* Allow password to be reentered on sudo if it was entered incorrectly
|
* Allow password to be reentered on sudo if it was entered incorrectly
|
||||||
|
|
|
@ -3,7 +3,6 @@ require 'switchtower/logger'
|
||||||
require 'switchtower/scm/subversion'
|
require 'switchtower/scm/subversion'
|
||||||
|
|
||||||
module SwitchTower
|
module SwitchTower
|
||||||
|
|
||||||
# Represents a specific SwitchTower configuration. A Configuration instance
|
# Represents a specific SwitchTower configuration. A Configuration instance
|
||||||
# may be used to load multiple recipe files, define and describe tasks,
|
# may be used to load multiple recipe files, define and describe tasks,
|
||||||
# define roles, create an actor, and set configuration variables.
|
# define roles, create an actor, and set configuration variables.
|
||||||
|
|
|
@ -1,6 +1,16 @@
|
||||||
require 'net/ssh'
|
require 'net/ssh'
|
||||||
|
|
||||||
module SwitchTower
|
module SwitchTower
|
||||||
|
unless ENV['SKIP_VERSION_CHECK']
|
||||||
|
require 'switchtower/version'
|
||||||
|
require 'net/ssh/version'
|
||||||
|
ssh_version = [Net::SSH::Version::MAJOR, Net::SSH::Version::MINOR, Net::SSH::Version::TINY]
|
||||||
|
required_version = [1,0,5]
|
||||||
|
if !Version.check(required_version, ssh_version)
|
||||||
|
raise "You have Net::SSH #{ssh_version.join(".")}, but you need at least #{required_version.join(".")}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# A helper class for dealing with SSH connections.
|
# A helper class for dealing with SSH connections.
|
||||||
class SSH
|
class SSH
|
||||||
# An abstraction to make it possible to connect to the server via public key
|
# An abstraction to make it possible to connect to the server via public key
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
begin
|
begin
|
||||||
|
require 'switchtower/version'
|
||||||
require 'net/sftp'
|
require 'net/sftp'
|
||||||
SwitchTower::SFTP = true
|
require 'net/sftp/version'
|
||||||
|
sftp_version = [Net::SFTP::Version::MAJOR, Net::SFTP::Version::MINOR, Net::SFTP::Version::TINY]
|
||||||
|
required_version = [1,1,0]
|
||||||
|
if !version_check(required_version, sftp_version)
|
||||||
|
warn "You have Net::SFTP #{sftp_version.join(".")}, but you need at least #{required_version.join(".")}. Net::SFTP will not be used."
|
||||||
|
SwitchTower::SFTP = false
|
||||||
|
else
|
||||||
|
SwitchTower::SFTP = true
|
||||||
|
end
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
SwitchTower::SFTP = false
|
SwitchTower::SFTP = false
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,30 @@
|
||||||
module SwitchTower
|
module SwitchTower
|
||||||
module Version #:nodoc:
|
module Version #:nodoc:
|
||||||
|
# A method for comparing versions of required modules. It expects two
|
||||||
|
# arrays as parameters, and returns true if the first is no more than the
|
||||||
|
# second.
|
||||||
|
def self.check(expected, actual) #:nodoc:
|
||||||
|
good = false
|
||||||
|
if actual[0] > expected[0]
|
||||||
|
good = true
|
||||||
|
elsif actual[0] == expected[0]
|
||||||
|
if actual[1] > expected[1]
|
||||||
|
good = true
|
||||||
|
elsif actual[1] == expected[1] && actual[2] >= expected[2]
|
||||||
|
good = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
good
|
||||||
|
end
|
||||||
|
|
||||||
MAJOR = 0
|
MAJOR = 0
|
||||||
MINOR = 10
|
MINOR = 10
|
||||||
TINY = 0
|
TINY = 0
|
||||||
|
|
||||||
STRING = [MAJOR, MINOR, TINY].join(".")
|
STRING = [MAJOR, MINOR, TINY].join(".")
|
||||||
|
|
||||||
|
SSH_REQUIRED = [1,0,5]
|
||||||
|
SFTP_REQUIRED = [1,1,0]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,8 +19,8 @@ Gem::Specification.new do |s|
|
||||||
s.bindir = "bin"
|
s.bindir = "bin"
|
||||||
s.executables << "switchtower"
|
s.executables << "switchtower"
|
||||||
|
|
||||||
s.add_dependency 'net-ssh', '>= 1.0.5'
|
s.add_dependency 'net-ssh', ">= #{SwitchTower::Version::SSH_REQUIRED.join(".")}"
|
||||||
s.add_dependency 'net-sftp', '>= 1.1.0'
|
s.add_dependency 'net-sftp', ">= #{SwitchTower::Version::SFTP_REQUIRED.join(".")}"
|
||||||
|
|
||||||
s.author = "Jamis Buck"
|
s.author = "Jamis Buck"
|
||||||
s.email = "jamis@37signals.com"
|
s.email = "jamis@37signals.com"
|
||||||
|
|
Loading…
Reference in a new issue