11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/bosh/director/core/tar_gzipper.rb', line 11
def compress(base_dir, sources, dest, options = {})
sources = [*sources]
sources.each do |source|
source = source.gsub(%r(^\./), '')
if source.include?(File::SEPARATOR)
raise "Sources must have a path depth of 1 and contain no '#{File::SEPARATOR}'"
end
end
base_dir_path = Pathname.new(base_dir)
raise "The base directory #{base_dir} could not be found." unless base_dir_path.exist?
raise "The base directory #{base_dir} is not an absolute path." unless base_dir_path.absolute?
if options[:copy_first]
Dir.mktmpdir do |tmpdir|
FileUtils.cp_r(sources.map { |s| File.join(base_dir, s) }, "#{tmpdir}/")
tar(tmpdir, dest, sources)
end
else
tar(base_dir, dest, sources)
end
end
|