33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/capistrano/local.rb', line 33
def release
archive = ''
compression_flag = fetch(:scm_local_archive_compression_flag, 'z');
case compression_flag
when 'z'
archive_extension = '.tar.gz'
when 'j'
archive_extension = '.tar.bz'
else
archive_extension = '.tar'
compression_flag = ''
end
run_locally do
archive = fetch(:tmp_dir, Dir::tmpdir()) + '/capistrano/' + fetch(:application, 'distr') + "-#{fetch(:current_revision, 'UNKNOWN').strip}#{archive_extension}"
archive_sha1 = "#{archive}.sha1"
debug "Archiving #{repo_url} to #{archive}"
execute :mkdir, '-p', File.dirname(archive)
if File.exists?(archive) && !fetch(:scm_local_skip_tar_check, false) && (!File.exists?(archive_sha1) || !test(:shasum, '-s', '-c', archive_sha1))
execute :rm, '-f', archive
end
unless File.exists?(archive)
if File.directory?(repo_url) || !File.fnmatch("*#{archive_extension}", repo_url)
within repo_url do
execute :tar, "c#{compression_flag}f", archive, '.'
end
unless fetch(:scm_local_skip_tar_check, false)
execute :tar, "t#{compression_flag}f", archive
execute :shasum, archive, '>', archive_sha1
end
else
execute :cp, repo_url, archive
end
end
end
on release_roles :all do |host|
debug "Uploading #{archive} to #{host}:#{release_path}"
upload! archive, releases_path, verbose: false
remote_archive = File.join(releases_path, File.basename(archive))
execute :tar, "x#{compression_flag}f", remote_archive, '-C', release_path
execute :rm, '-f', remote_archive
end
run_locally do
execute :rm, '-f', archive
end
end
|