capistrano-strategy-copy-bundled 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/capistrano-strategy-copy-bundled.gemspec +24 -0
- data/lib/capistrano-strategy-copy-bundled.rb +5 -0
- data/lib/capistrano/recipes/deploy/strategy/copy_bundled.rb +108 -0
- metadata +71 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require 'capistrano-strategy-copy-bundled'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "capistrano-strategy-copy-bundled"
|
|
7
|
+
s.version =CapistranoStrategyCopyBundled::VERSION
|
|
8
|
+
s.authors = ["Rudolf Schmidt"]
|
|
9
|
+
|
|
10
|
+
s.homepage = "http://github.com/rudionrails/capistrano-strategy-copy-bundled"
|
|
11
|
+
s.summary = %q{Capistrano copy recipe to transfer files already pre-bundled}
|
|
12
|
+
s.description = %q{Bundled all gems in the copy directory and then send it to all servers already packaged}
|
|
13
|
+
|
|
14
|
+
s.rubyforge_project = "capistrano-strategy-copy-bundled"
|
|
15
|
+
|
|
16
|
+
s.files = `git ls-files`.split("\n")
|
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
19
|
+
s.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
# specify any dependencies here; for example:
|
|
22
|
+
# s.add_development_dependency "rspec"
|
|
23
|
+
s.add_runtime_dependency "capistrano", "~> 2"
|
|
24
|
+
end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
require 'capistrano/recipes/deploy/strategy/copy'
|
|
2
|
+
|
|
3
|
+
module Capistrano
|
|
4
|
+
module Deploy
|
|
5
|
+
module Strategy
|
|
6
|
+
|
|
7
|
+
class CopyBundled < Copy
|
|
8
|
+
|
|
9
|
+
# @overload
|
|
10
|
+
def deploy!
|
|
11
|
+
if copy_cache
|
|
12
|
+
if File.exists?(copy_cache)
|
|
13
|
+
logger.debug "refreshing local cache to revision #{revision} at #{copy_cache}"
|
|
14
|
+
system(source.sync(revision, copy_cache))
|
|
15
|
+
else
|
|
16
|
+
logger.debug "preparing local cache at #{copy_cache}"
|
|
17
|
+
system(source.checkout(revision, copy_cache))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Check the return code of last system command and rollback if not 0
|
|
21
|
+
unless $? == 0
|
|
22
|
+
raise Capistrano::Error, "shell command failed with return code #{$?}"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
FileUtils.mkdir_p(destination)
|
|
26
|
+
|
|
27
|
+
logger.debug "copying cache to deployment staging area #{destination}"
|
|
28
|
+
Dir.chdir(copy_cache) do
|
|
29
|
+
queue = Dir.glob("*", File::FNM_DOTMATCH)
|
|
30
|
+
while queue.any?
|
|
31
|
+
item = queue.shift
|
|
32
|
+
name = File.basename(item)
|
|
33
|
+
|
|
34
|
+
next if name == "." || name == ".."
|
|
35
|
+
next if copy_exclude.any? { |pattern| File.fnmatch(pattern, item) }
|
|
36
|
+
|
|
37
|
+
if File.symlink?(item)
|
|
38
|
+
FileUtils.ln_s(File.readlink(item), File.join(destination, item))
|
|
39
|
+
elsif File.directory?(item)
|
|
40
|
+
queue += Dir.glob("#{item}/*", File::FNM_DOTMATCH)
|
|
41
|
+
FileUtils.mkdir(File.join(destination, item))
|
|
42
|
+
else
|
|
43
|
+
FileUtils.ln(item, File.join(destination, item))
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
else
|
|
48
|
+
logger.debug "getting (via #{copy_strategy}) revision #{revision} to #{destination}"
|
|
49
|
+
system(command)
|
|
50
|
+
|
|
51
|
+
if copy_exclude.any?
|
|
52
|
+
logger.debug "processing exclusions..."
|
|
53
|
+
|
|
54
|
+
copy_exclude.each do |pattern|
|
|
55
|
+
delete_list = Dir.glob(File.join(destination, pattern), File::FNM_DOTMATCH)
|
|
56
|
+
# avoid the /.. trap that deletes the parent directories
|
|
57
|
+
delete_list.delete_if { |dir| dir =~ /\/\.\.$/ }
|
|
58
|
+
FileUtils.rm_rf(delete_list.compact)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
File.open(File.join(destination, "REVISION"), "w") { |f| f.puts(revision) }
|
|
64
|
+
|
|
65
|
+
# execute bundler
|
|
66
|
+
bundle!
|
|
67
|
+
|
|
68
|
+
logger.trace "compressing #{destination} to #{filename}"
|
|
69
|
+
Dir.chdir(copy_dir) { system(compress(File.basename(destination), File.basename(filename)).join(" ")) }
|
|
70
|
+
|
|
71
|
+
distribute!
|
|
72
|
+
ensure
|
|
73
|
+
FileUtils.rm filename rescue nil
|
|
74
|
+
FileUtils.rm_rf destination rescue nil
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
private
|
|
79
|
+
|
|
80
|
+
def bundle!
|
|
81
|
+
logger.trace "running bundler in #{destination}..."
|
|
82
|
+
|
|
83
|
+
bundle_cmd = configuration[:bundle_cmd] || "bundle"
|
|
84
|
+
bundle_flags = configuration[:bundle_flags] || "--deployment --quiet"
|
|
85
|
+
bundle_dir = configuration[:bundle_dir] || File.join('vendor', 'bundle')
|
|
86
|
+
bundle_gemfile = configuration[:bundle_gemfile] || File.join("Gemfile")
|
|
87
|
+
bundle_without = [*(configuration[:bundle_without] || [:development, :test])].compact
|
|
88
|
+
|
|
89
|
+
args = ["--gemfile #{File.join(destination, bundle_gemfile)}"]
|
|
90
|
+
args << "--path #{bundle_dir}" unless bundle_dir.to_s.empty?
|
|
91
|
+
args << bundle_flags.to_s
|
|
92
|
+
args << "--without #{bundle_without.join(" ")}" unless bundle_without.empty?
|
|
93
|
+
|
|
94
|
+
cmd = "#{bundle_cmd} install #{args.join(' ')}"
|
|
95
|
+
Dir.chdir( destination ) do
|
|
96
|
+
if defined?( Bundler )
|
|
97
|
+
Bundler.with_clean_env { system(cmd) }
|
|
98
|
+
else
|
|
99
|
+
system(cmd)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: capistrano-strategy-copy-bundled
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
prerelease:
|
|
5
|
+
version: 0.3.0
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Rudolf Schmidt
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
|
|
13
|
+
date: 2011-09-15 00:00:00 +02:00
|
|
14
|
+
default_executable:
|
|
15
|
+
dependencies:
|
|
16
|
+
- !ruby/object:Gem::Dependency
|
|
17
|
+
name: capistrano
|
|
18
|
+
prerelease: false
|
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
20
|
+
none: false
|
|
21
|
+
requirements:
|
|
22
|
+
- - ~>
|
|
23
|
+
- !ruby/object:Gem::Version
|
|
24
|
+
version: "2"
|
|
25
|
+
type: :runtime
|
|
26
|
+
version_requirements: *id001
|
|
27
|
+
description: Bundled all gems in the copy directory and then send it to all servers already packaged
|
|
28
|
+
email:
|
|
29
|
+
executables: []
|
|
30
|
+
|
|
31
|
+
extensions: []
|
|
32
|
+
|
|
33
|
+
extra_rdoc_files: []
|
|
34
|
+
|
|
35
|
+
files:
|
|
36
|
+
- .gitignore
|
|
37
|
+
- Gemfile
|
|
38
|
+
- Rakefile
|
|
39
|
+
- capistrano-strategy-copy-bundled.gemspec
|
|
40
|
+
- lib/capistrano-strategy-copy-bundled.rb
|
|
41
|
+
- lib/capistrano/recipes/deploy/strategy/copy_bundled.rb
|
|
42
|
+
has_rdoc: true
|
|
43
|
+
homepage: http://github.com/rudionrails/capistrano-strategy-copy-bundled
|
|
44
|
+
licenses: []
|
|
45
|
+
|
|
46
|
+
post_install_message:
|
|
47
|
+
rdoc_options: []
|
|
48
|
+
|
|
49
|
+
require_paths:
|
|
50
|
+
- lib
|
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
|
+
none: false
|
|
53
|
+
requirements:
|
|
54
|
+
- - ">="
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: "0"
|
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
|
+
none: false
|
|
59
|
+
requirements:
|
|
60
|
+
- - ">="
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: "0"
|
|
63
|
+
requirements: []
|
|
64
|
+
|
|
65
|
+
rubyforge_project: capistrano-strategy-copy-bundled
|
|
66
|
+
rubygems_version: 1.5.1
|
|
67
|
+
signing_key:
|
|
68
|
+
specification_version: 3
|
|
69
|
+
summary: Capistrano copy recipe to transfer files already pre-bundled
|
|
70
|
+
test_files: []
|
|
71
|
+
|