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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/indocker/directives/image_directives_runner.rb', line 35
def run_copy(directive)
directive.copy_actions.each do |from, to|
build_dir_file = File.join(directive.context.build_dir, from)
source_dir = File.join(config.root, from)
if File.directory?(from)
dest_dir = File.join(directive.context.build_dir, from)
else
dest_dir = File.join(directive.context.build_dir, File.dirname(from))
end
if File.exists?(build_dir_file) && File.file?(build_dir_file)
copy_compile_file(
from: build_dir_file,
to: build_dir_file,
locals: directive.context.storage,
compile: directive.compile
)
return
end
if File.exist?(build_dir_file) && File.directory?(build_dir_file)
files_list = Dir.glob(File.join(build_dir_file, '**', '*'), File::FNM_DOTMATCH)
files_list.each do |from|
copy_compile_file(
from: from,
to: from,
locals: directive.context.storage,
compile: directive.compile
)
end
return
end
if File.exists?(source_dir) && File.file?(source_dir)
copy_compile_file(
from: source_dir,
to: File.join(dest_dir, File.basename(source_dir)),
locals: directive.context.storage,
compile: directive.compile
)
return
end
if Dir.exist?(source_dir) && File.directory?(source_dir)
files_list = Dir.glob(File.join(source_dir, '**', '*'), File::FNM_DOTMATCH)
files_list.each do |from|
relative_to = Pathname.new(from).relative_path_from( Pathname.new(source_dir) ).to_s
absolute_to = File.join(dest_dir, relative_to)
copy_compile_file(
from: from,
to: absolute_to,
locals: directive.context.storage,
compile: directive.compile
)
end
return
end
raise Indocker::Errors::FileDoesNotExists
end
end
|