public
Fork of jamis/capistrano
Description: Remote multi-server automation tool
Homepage: http://www.capify.org
Clone URL: git://github.com/halorgium/capistrano.git
Add deploy:check test for verifying that dependencies are in order for 
deploying


git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@6487 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
jamis (author)
Wed Mar 28 21:48:34 -0700 2007
commit  aab2ea25f305fd2da2b762bd7e894bdffbd3342b
tree    41f3be82c9ea4116a506205663e323fd2638a8ed
parent  4331e3bb673f0a5f1f3710c3ee43fb7694a6a9a1
...
148
149
150
151
152
 
 
153
154
155
...
255
256
257
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
259
260
...
148
149
150
 
 
151
152
153
154
155
...
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
0
@@ -148,8 +148,8 @@ comma-delimited list in the FILES environment variable. All directories will \
0
 be processed recursively, with all files being pushed to the deployment \
0
 servers. Any file or directory starting with a '.' character will be ignored.
0
 
0
- $ cap deploy:update_files FILES=templates,controller.rb"
0
- task :update_files, :except => { :no_release => true } do
0
+ $ cap deploy:upload FILES=templates,controller.rb"
0
+ task :upload, :except => { :no_release => true } do
0
     files = (ENV["FILES"] || "").
0
       split(",").
0
       map { |f| f.strip!; File.directory?(f) ? Dir["#{f}/**/*"] : f }.
0
@@ -255,6 +255,22 @@ environment, set the :cleanup_via variable to :run instead."
0
     end
0
   end
0
 
0
+desc "Test deployment dependencies. Checks things like directory permissions, \
0
+necessary utilities, and so forth, reporting on the things that appear to be \
0
+incorrect or missing. This is good for making sure a deploy has a chance of \
0
+working before you actually run `cap deploy'!"
0
+ task :check, :except => { :no_release => true } do
0
+ dependencies = strategy.check!
0
+ if dependencies.pass?
0
+ puts "You appear to have all necessary dependencies installed"
0
+ else
0
+ puts "The following dependencies failed. Please check them and try again:"
0
+ dependencies.reject { |d| d.pass? }.each do |d|
0
+ puts "--> #{d.message}"
0
+ end
0
+ end
0
+ end
0
+
0
   namespace :pending do
0
 desc "Displays the `diff' since your last deploy. This is useful if you want \
0
 to examine what changes are about to be deployed. Note that this might not be \
...
84
85
86
 
 
 
 
 
 
 
87
88
89
...
105
106
107
108
109
110
111
112
113
114
115
116
117
...
84
85
86
87
88
89
90
91
92
93
94
95
96
...
112
113
114
 
 
 
 
 
 
 
115
116
117
0
@@ -84,6 +84,13 @@ module Capistrano
0
           nil
0
         end
0
 
0
+ # Returns the name of the command-line utility for this SCM. It first
0
+ # looks at the :scm_command variable, and if it does not exist, it
0
+ # then falls back to whatever was defined by +default_command+.
0
+ def command
0
+ configuration[:scm_command] || default_command
0
+ end
0
+
0
         private
0
 
0
           # A reference to a Logger instance that the SCM can use to log
0
@@ -105,13 +112,6 @@ module Capistrano
0
             [command, *args].compact.join(" ")
0
           end
0
 
0
- # Returns the name of the command-line utility for this SCM. It first
0
- # looks at the :scm_command variable, and if it does not exist, it
0
- # then falls back to whatever was defined by +default_command+.
0
- def command
0
- configuration[:scm_command] || default_command
0
- end
0
-
0
           # A convenience method for accessing the declared repository value.
0
           def repository
0
             configuration[:repository]
...
 
 
1
2
3
...
22
23
24
 
 
 
 
 
 
 
 
 
 
25
26
27
...
1
2
3
4
5
...
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
0
@@ -1,3 +1,5 @@
0
+require 'capistrano/recipes/deploy/dependencies'
0
+
0
 module Capistrano
0
   module Deploy
0
     module Strategy
0
@@ -22,6 +24,16 @@ module Capistrano
0
           raise NotImplementedError, "`deploy!' is not implemented by #{self.class.name}"
0
         end
0
 
0
+ # Performs a check on the remote hosts to determine whether everything
0
+ # is setup such that a deploy could succeed.
0
+ def check!
0
+ Dependencies.new(configuration) do |d|
0
+ d.remote.expect_directory(configuration[:releases_path]).or("`#{configuration[:releases_path]}' does not exist. Please run `cap deploy:setup'.")
0
+ d.remote.expect_writable(configuration[:deploy_to]).or("You do not have permissions to write to `#{configuration[:deploy_to]}'.")
0
+ d.remote.expect_writable(configuration[:releases_path]).or("You do not have permissions to write to `#{configuration[:releases_path]}'.")
0
+ end
0
+ end
0
+
0
         protected
0
 
0
           # This is to allow helper methods like "run" and "put" to be more
...
38
39
40
 
 
 
 
 
 
 
 
41
42
43
...
92
93
94
95
 
 
96
97
98
99
100
 
 
 
 
101
102
103
104
105
106
 
 
 
107
108
109
110
111
 
 
 
 
112
113
114
...
38
39
40
41
42
43
44
45
46
47
48
49
50
51
...
100
101
102
 
103
104
105
106
 
 
 
107
108
109
110
111
112
113
114
115
 
116
117
118
119
120
 
 
 
121
122
123
124
125
126
127
0
@@ -38,6 +38,14 @@ module Capistrano
0
           FileUtils.rm_rf destination rescue nil
0
         end
0
 
0
+ def check!
0
+ super.check do |d|
0
+ d.local.expects_in_path(source.command)
0
+ d.local.expects_in_path(compress(nil, nil).first)
0
+ d.remote.expects_in_path(decompress(nil).first)
0
+ end
0
+ end
0
+
0
         private
0
 
0
           # Returns the basename of the release_path, which will be used to
0
@@ -92,23 +100,28 @@ module Capistrano
0
           end
0
 
0
           # Returns the command necessary to compress the given directory
0
- # into the given file.
0
+ # into the given file. The command is returned as an array, where
0
+ # the first element is the utility to be used to perform the compression.
0
           def compress(directory, file)
0
             case compression
0
- when :gzip, :gz then "tar czf #{file} #{directory}"
0
- when :bzip2, :bz2 then "tar cjf #{file} #{directory}"
0
- when :zip then "zip -qr #{file} #{directory}"
0
+ when :gzip, :gz then ["tar", "czf", file, directory]
0
+ when :bzip2, :bz2 then ["tar", "cjf", file, directory]
0
+ when :zip then ["zip", "-qr", file, directory]
0
+ else raise ArgumentError, "invalid compression type #{compression.inspect}"
0
             end
0
           end
0
 
0
           # Returns the command necessary to decompress the given file,
0
           # relative to the current working directory. It must also
0
- # preserve the directory structure in the file.
0
+ # preserve the directory structure in the file. The command is returned
0
+ # as an array, where the first element is the utility to be used to
0
+ # perform the decompression.
0
           def decompress(file)
0
             case compression
0
- when :gzip, :gz then "tar xzf #{file}"
0
- when :bzip2, :bz2 then "tar xjf #{file}"
0
- when :zip then "unzip -q #{file}"
0
+ when :gzip, :gz then ["tar", "xzf", file]
0
+ when :bzip2, :bz2 then ["tar", "xjf", file]
0
+ when :zip then ["unzip", "-q", file]
0
+ else raise ArgumentError, "invalid compression type #{compression.inspect}"
0
             end
0
           end
0
       end
...
15
16
17
 
 
 
 
 
18
19
20
...
15
16
17
18
19
20
21
22
23
24
25
0
@@ -15,6 +15,11 @@ module Capistrano
0
           scm_run "#{command} && #{mark}"
0
         end
0
 
0
+ def check!
0
+ result = super
0
+ test("type -p #{source.command}", "could not find `#{source.command}'") && result
0
+ end
0
+
0
         protected
0
 
0
           # Runs the given command, filtering output back through the
...
1178
1179
1180
1181
 
1182
1183
1184
...
1178
1179
1180
 
1181
1182
1183
1184
0
@@ -1178,7 +1178,7 @@ class Installer
0
   end
0
 
0
   def ruby_scripts
0
- collect_filenames_auto().select {|n| /\.r(b|html)\z/ =~ n}
0
+ collect_filenames_auto().select {|n| /\.(r(b|html)|txt)\z/ =~ n}
0
   end
0
   
0
   # picked up many entries from cvs-1.11.1/src/ignore.c

Comments

    No one has commented yet.