rbbt-util 5.44.0 → 6.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rbbt +67 -90
- data/etc/app.d/base.rb +3 -3
- data/etc/app.d/semaphores.rb +3 -3
- data/lib/rbbt/annotations/annotated_array.rb +207 -207
- data/lib/rbbt/annotations/refactor.rb +27 -0
- data/lib/rbbt/annotations/util.rb +282 -282
- data/lib/rbbt/annotations.rb +343 -320
- data/lib/rbbt/association/database.rb +200 -225
- data/lib/rbbt/association/index.rb +294 -291
- data/lib/rbbt/association/item.rb +227 -227
- data/lib/rbbt/association/open.rb +35 -34
- data/lib/rbbt/association/util.rb +0 -169
- data/lib/rbbt/association.rb +2 -4
- data/lib/rbbt/entity/identifiers.rb +119 -118
- data/lib/rbbt/entity/refactor.rb +12 -0
- data/lib/rbbt/entity.rb +319 -315
- data/lib/rbbt/hpc/batch.rb +72 -53
- data/lib/rbbt/hpc/lsf.rb +2 -2
- data/lib/rbbt/hpc/orchestrate/batches.rb +2 -2
- data/lib/rbbt/hpc/orchestrate/chains.rb +25 -5
- data/lib/rbbt/hpc/orchestrate/rules.rb +2 -2
- data/lib/rbbt/hpc/orchestrate.rb +19 -13
- data/lib/rbbt/hpc/slurm.rb +18 -18
- data/lib/rbbt/knowledge_base/entity.rb +13 -5
- data/lib/rbbt/knowledge_base/query.rb +2 -2
- data/lib/rbbt/knowledge_base/registry.rb +32 -31
- data/lib/rbbt/knowledge_base/traverse.rb +1 -1
- data/lib/rbbt/knowledge_base.rb +1 -1
- data/lib/rbbt/monitor.rb +36 -25
- data/lib/rbbt/persist/refactor.rb +166 -0
- data/lib/rbbt/persist/tsv/sharder.rb +1 -1
- data/lib/rbbt/persist/tsv/tokyocabinet.rb +105 -105
- data/lib/rbbt/persist/tsv.rb +187 -185
- data/lib/rbbt/persist.rb +556 -551
- data/lib/rbbt/refactor.rb +20 -0
- data/lib/rbbt/resource/path/refactor.rb +178 -0
- data/lib/rbbt/resource/path.rb +317 -497
- data/lib/rbbt/resource/util.rb +0 -48
- data/lib/rbbt/resource.rb +3 -390
- data/lib/rbbt/tsv/accessor.rb +2 -838
- data/lib/rbbt/tsv/attach.rb +303 -299
- data/lib/rbbt/tsv/change_id.rb +244 -245
- data/lib/rbbt/tsv/csv.rb +87 -85
- data/lib/rbbt/tsv/dumper.rb +2 -100
- data/lib/rbbt/tsv/excel.rb +26 -24
- data/lib/rbbt/tsv/field_index.rb +4 -1
- data/lib/rbbt/tsv/filter.rb +3 -2
- data/lib/rbbt/tsv/index.rb +2 -284
- data/lib/rbbt/tsv/manipulate.rb +750 -747
- data/lib/rbbt/tsv/marshal.rb +3 -3
- data/lib/rbbt/tsv/matrix.rb +2 -2
- data/lib/rbbt/tsv/parallel/through.rb +2 -1
- data/lib/rbbt/tsv/parallel/traverse.rb +783 -781
- data/lib/rbbt/tsv/parser.rb +678 -678
- data/lib/rbbt/tsv/refactor.rb +195 -0
- data/lib/rbbt/tsv/stream.rb +253 -251
- data/lib/rbbt/tsv/util.rb +420 -420
- data/lib/rbbt/tsv.rb +210 -208
- data/lib/rbbt/util/R/eval.rb +4 -4
- data/lib/rbbt/util/R/plot.rb +62 -166
- data/lib/rbbt/util/R.rb +21 -18
- data/lib/rbbt/util/cmd.rb +2 -318
- data/lib/rbbt/util/color.rb +269 -269
- data/lib/rbbt/util/colorize.rb +89 -89
- data/lib/rbbt/util/concurrency/processes/refactor.rb +22 -0
- data/lib/rbbt/util/concurrency/processes/worker.rb +2 -2
- data/lib/rbbt/util/concurrency/processes.rb +389 -386
- data/lib/rbbt/util/config.rb +169 -167
- data/lib/rbbt/util/iruby.rb +20 -0
- data/lib/rbbt/util/log/progress/report.rb +241 -241
- data/lib/rbbt/util/log/progress/util.rb +99 -99
- data/lib/rbbt/util/log/progress.rb +102 -102
- data/lib/rbbt/util/log/refactor.rb +49 -0
- data/lib/rbbt/util/log.rb +486 -532
- data/lib/rbbt/util/migrate.rb +1 -1
- data/lib/rbbt/util/misc/concurrent_stream.rb +248 -246
- data/lib/rbbt/util/misc/development.rb +12 -11
- data/lib/rbbt/util/misc/exceptions.rb +117 -112
- data/lib/rbbt/util/misc/format.rb +2 -230
- data/lib/rbbt/util/misc/indiferent_hash.rb +2 -107
- data/lib/rbbt/util/misc/inspect.rb +2 -476
- data/lib/rbbt/util/misc/lock.rb +109 -106
- data/lib/rbbt/util/misc/omics.rb +10 -1
- data/lib/rbbt/util/misc/pipes.rb +765 -793
- data/lib/rbbt/util/misc/refactor.rb +20 -0
- data/lib/rbbt/util/misc/ssw.rb +308 -0
- data/lib/rbbt/util/misc/system.rb +0 -15
- data/lib/rbbt/util/misc.rb +39 -20
- data/lib/rbbt/util/named_array/refactor.rb +4 -0
- data/lib/rbbt/util/named_array.rb +3 -220
- data/lib/rbbt/util/open/refactor.rb +7 -0
- data/lib/rbbt/util/open.rb +3 -857
- data/lib/rbbt/util/procpath.rb +6 -6
- data/lib/rbbt/util/python/paths.rb +27 -0
- data/lib/rbbt/util/python/run.rb +115 -0
- data/lib/rbbt/util/python/script.rb +110 -0
- data/lib/rbbt/util/python/util.rb +3 -3
- data/lib/rbbt/util/python.rb +22 -81
- data/lib/rbbt/util/semaphore.rb +152 -148
- data/lib/rbbt/util/simpleopt.rb +9 -8
- data/lib/rbbt/util/ssh/refactor.rb +19 -0
- data/lib/rbbt/util/ssh.rb +122 -118
- data/lib/rbbt/util/tar.rb +117 -115
- data/lib/rbbt/util/tmpfile.rb +69 -67
- data/lib/rbbt/util/version.rb +2 -0
- data/lib/rbbt/workflow/refactor/entity.rb +11 -0
- data/lib/rbbt/workflow/refactor/export.rb +66 -0
- data/lib/rbbt/workflow/refactor/inputs.rb +24 -0
- data/lib/rbbt/workflow/refactor/recursive.rb +64 -0
- data/lib/rbbt/workflow/refactor/task_info.rb +65 -0
- data/lib/rbbt/workflow/refactor.rb +153 -0
- data/lib/rbbt/workflow/remote_workflow/driver/ssh.rb +55 -32
- data/lib/rbbt/workflow/remote_workflow/remote_step/rest.rb +3 -1
- data/lib/rbbt/workflow/remote_workflow/remote_step/ssh.rb +14 -5
- data/lib/rbbt/workflow/remote_workflow/remote_step.rb +19 -7
- data/lib/rbbt/workflow/remote_workflow.rb +6 -1
- data/lib/rbbt/workflow/step/info.rb +2 -2
- data/lib/rbbt/workflow/step/run.rb +766 -766
- data/lib/rbbt/workflow/step/save_load_inputs.rb +254 -254
- data/lib/rbbt/workflow/step.rb +2 -362
- data/lib/rbbt/workflow/task.rb +118 -118
- data/lib/rbbt/workflow/usage.rb +289 -287
- data/lib/rbbt/workflow/util/archive.rb +6 -5
- data/lib/rbbt/workflow/util/data.rb +1 -1
- data/lib/rbbt/workflow/util/orchestrator.rb +249 -246
- data/lib/rbbt/workflow/util/trace.rb +79 -44
- data/lib/rbbt/workflow.rb +4 -882
- data/lib/rbbt-util.rb +21 -13
- data/lib/rbbt.rb +16 -3
- data/python/rbbt/__init__.py +19 -1
- data/share/Rlib/plot.R +37 -37
- data/share/Rlib/svg.R +22 -5
- data/share/install/software/lib/install_helpers +1 -1
- data/share/rbbt_commands/hpc/list +2 -3
- data/share/rbbt_commands/hpc/orchestrate +4 -4
- data/share/rbbt_commands/hpc/tail +2 -0
- data/share/rbbt_commands/hpc/task +10 -7
- data/share/rbbt_commands/lsf/list +2 -3
- data/share/rbbt_commands/lsf/orchestrate +4 -4
- data/share/rbbt_commands/lsf/tail +2 -0
- data/share/rbbt_commands/lsf/task +10 -7
- data/share/rbbt_commands/migrate +1 -1
- data/share/rbbt_commands/pbs/list +2 -3
- data/share/rbbt_commands/pbs/orchestrate +4 -4
- data/share/rbbt_commands/pbs/tail +2 -0
- data/share/rbbt_commands/pbs/task +10 -7
- data/share/rbbt_commands/resource/produce +8 -1
- data/share/rbbt_commands/slurm/list +2 -3
- data/share/rbbt_commands/slurm/orchestrate +4 -4
- data/share/rbbt_commands/slurm/tail +2 -0
- data/share/rbbt_commands/slurm/task +10 -7
- data/share/rbbt_commands/system/clean +5 -5
- data/share/rbbt_commands/system/status +5 -5
- data/share/rbbt_commands/tsv/get +2 -3
- data/share/rbbt_commands/tsv/info +10 -13
- data/share/rbbt_commands/tsv/keys +18 -14
- data/share/rbbt_commands/tsv/slice +2 -2
- data/share/rbbt_commands/tsv/transpose +6 -2
- data/share/rbbt_commands/workflow/info +20 -24
- data/share/rbbt_commands/workflow/list +1 -1
- data/share/rbbt_commands/workflow/prov +20 -13
- data/share/rbbt_commands/workflow/server +16 -1
- data/share/rbbt_commands/workflow/task +76 -71
- data/share/rbbt_commands/workflow/write_info +26 -9
- data/share/software/opt/ssw/ssw.c +861 -0
- data/share/software/opt/ssw/ssw.h +130 -0
- data/share/workflow_config.ru +3 -3
- metadata +42 -3
data/lib/rbbt/resource/util.rb
CHANGED
@@ -1,49 +1,3 @@
|
|
1
|
-
module Path
|
2
|
-
|
3
|
-
def self.caller_lib_dir(file = nil, relative_to = ['lib', 'bin', 'LICENSE'])
|
4
|
-
#file = caller.reject{|l|
|
5
|
-
# l =~ /rbbt\/(?:resource\.rb|workflow\.rb)/ or
|
6
|
-
# l =~ /rbbt\/resource\/path\.rb/ or
|
7
|
-
# l =~ /rbbt\/persist.rb/ or
|
8
|
-
# l =~ /rbbt\/util\/misc\.rb/ or
|
9
|
-
# l =~ /progress-monitor\.rb/
|
10
|
-
#}.first.sub(/\.rb[^\w].*/,'.rb') if file.nil?
|
11
|
-
|
12
|
-
|
13
|
-
if file.nil?
|
14
|
-
caller_dup = caller.dup
|
15
|
-
while file = caller_dup.shift
|
16
|
-
break unless file =~ /rbbt\/(?:resource\.rb|workflow\.rb)/ or
|
17
|
-
file =~ /rbbt\/resource\/path\.rb/ or
|
18
|
-
file =~ /rbbt\/persist.rb/ or
|
19
|
-
file =~ /rbbt\/util\/misc\.rb/ or
|
20
|
-
file =~ /progress-monitor\.rb/
|
21
|
-
end
|
22
|
-
file = file.sub(/\.rb[^\w].*/,'.rb')
|
23
|
-
end
|
24
|
-
|
25
|
-
relative_to = [relative_to] unless Array === relative_to
|
26
|
-
file = File.expand_path(file)
|
27
|
-
return Path.setup(file) if relative_to.select{|d| File.exist? File.join(file, d)}.any?
|
28
|
-
|
29
|
-
while file != '/'
|
30
|
-
dir = File.dirname file
|
31
|
-
|
32
|
-
return dir if relative_to.select{|d| File.exist? File.join(dir, d)}.any?
|
33
|
-
|
34
|
-
file = File.dirname file
|
35
|
-
end
|
36
|
-
|
37
|
-
return nil
|
38
|
-
end
|
39
|
-
|
40
|
-
SLASH = "/"[0]
|
41
|
-
DOT = "."[0]
|
42
|
-
def located?
|
43
|
-
self.byte(0) == SLASH || (self.byte(0) == DOT && self.byte(1) == SLASH) || (resource != Rbbt && (Open.remote?(self) || Open.ssh?(self)))
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
1
|
module Resource
|
48
2
|
def set_software_env(software_dir = self.root.software)
|
49
3
|
software_dir.opt.find_all.collect{|d| d.annotate(File.dirname(d)) }.reverse.each do |software_dir|
|
@@ -158,5 +112,3 @@ module Resource
|
|
158
112
|
end
|
159
113
|
end
|
160
114
|
end
|
161
|
-
|
162
|
-
|
data/lib/rbbt/resource.rb
CHANGED
@@ -1,390 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
require 'net/http'
|
5
|
-
require 'set'
|
6
|
-
|
7
|
-
module Resource
|
8
|
-
class ResourceNotFound < RbbtException; end
|
9
|
-
|
10
|
-
|
11
|
-
class << self
|
12
|
-
attr_accessor :lock_dir
|
13
|
-
|
14
|
-
def lock_dir
|
15
|
-
@lock_dir ||= Rbbt.tmp.produce_locks.find
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.remote_servers
|
20
|
-
@remote_servers = Rbbt.etc.file_servers.exists? ? Rbbt.etc.file_servers.yaml : {}
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.extended(base)
|
24
|
-
base.pkgdir = 'rbbt'
|
25
|
-
base.subdir = ''
|
26
|
-
base.resources = {}
|
27
|
-
base.rake_dirs = {}
|
28
|
-
base.search_paths = Path::SEARCH_PATHS.dup
|
29
|
-
base.remote_server = Resource.remote_servers[base.to_s] || Resource.remote_servers["*"]
|
30
|
-
base
|
31
|
-
end
|
32
|
-
|
33
|
-
attr_accessor :pkgdir, :subdir, :resources, :rake_dirs, :remote_server, :search_paths
|
34
|
-
|
35
|
-
def set_libdir(value = nil)
|
36
|
-
_libdir = value || Path.caller_lib_dir
|
37
|
-
search_paths.merge!(:lib => File.join(_libdir, '{TOPLEVEL}', '{SUBPATH}'))
|
38
|
-
end
|
39
|
-
|
40
|
-
def root
|
41
|
-
Path.setup @subdir || "", @pkgdir, self, @search_paths
|
42
|
-
end
|
43
|
-
|
44
|
-
def method_missing(name, prev = nil, *args)
|
45
|
-
if prev.nil?
|
46
|
-
root.send(name, *args)
|
47
|
-
else
|
48
|
-
root.send(name, prev, *args)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def [](file = nil)
|
53
|
-
if file.nil?
|
54
|
-
root
|
55
|
-
else
|
56
|
-
root.send(file)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def claim(path, type, content = nil, &block)
|
61
|
-
if type == :rake
|
62
|
-
@rake_dirs[path] = content || block
|
63
|
-
else
|
64
|
-
@resources[path] = [type, content || block]
|
65
|
-
|
66
|
-
if type == :install
|
67
|
-
software_dir = path.resource.root.software
|
68
|
-
set_software_env(software_dir) unless $set_software_env
|
69
|
-
$set_software_env = true
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def claims
|
75
|
-
resources.keys.collect{|path| path.sub(subdir, '').sub(/^\//,'') }
|
76
|
-
end
|
77
|
-
|
78
|
-
attr_accessor :server_missing_resource_cache
|
79
|
-
def get_from_server(path, final_path, remote_server = nil)
|
80
|
-
remote_server ||= self.remote_server
|
81
|
-
remote_server = "http://" + remote_server unless remote_server =~ /^[a-z]+:\/\//
|
82
|
-
url = File.join(remote_server, '/resource/', self.to_s, 'get_file')
|
83
|
-
url << "?" << Misc.hash2GET_params(:file => path, :create => false)
|
84
|
-
|
85
|
-
begin
|
86
|
-
@server_missing_resource_cache ||= Set.new
|
87
|
-
raise "Resource Not Found" if @server_missing_resource_cache.include? url
|
88
|
-
|
89
|
-
#lock_filename = Persist.persistence_path(final_path, {:dir => Resource.lock_dir})
|
90
|
-
|
91
|
-
lock_filename = nil # it seems like this was locked already.
|
92
|
-
|
93
|
-
Log.low "Downloading #{path} from #{url} file server"
|
94
|
-
Misc.lock lock_filename do
|
95
|
-
begin
|
96
|
-
uri = URI(url)
|
97
|
-
|
98
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
99
|
-
|
100
|
-
if uri.scheme == "https"
|
101
|
-
http.use_ssl = true
|
102
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
103
|
-
http.instance_variable_set("@ssl_options", OpenSSL::SSL::OP_NO_SSLv2 + OpenSSL::SSL::OP_NO_SSLv3 + OpenSSL::SSL::OP_NO_COMPRESSION)
|
104
|
-
end
|
105
|
-
|
106
|
-
timeout = 60 * 10
|
107
|
-
http.read_timeout = timeout
|
108
|
-
http.open_timeout = timeout
|
109
|
-
request = Net::HTTP::Get.new(uri.request_uri)
|
110
|
-
http.request request do |response|
|
111
|
-
filename = if response["Content-Disposition"]
|
112
|
-
response["Content-Disposition"].split(";").select{|f| f.include? "filename"}.collect{|f| f.split("=").last.gsub('"','')}.first
|
113
|
-
else
|
114
|
-
nil
|
115
|
-
end
|
116
|
-
|
117
|
-
if filename && filename =~ /\.b?gz$/ && final_path !~ /\.b?gz$/
|
118
|
-
extension = filename.split(".").last
|
119
|
-
final_path += '.' + extension
|
120
|
-
end
|
121
|
-
case response
|
122
|
-
when Net::HTTPSuccess, Net::HTTPOK
|
123
|
-
Misc.sensiblewrite(final_path) do |file|
|
124
|
-
response.read_body do |chunk|
|
125
|
-
file.write chunk
|
126
|
-
end
|
127
|
-
end
|
128
|
-
when Net::HTTPRedirection, Net::HTTPFound
|
129
|
-
location = response['location']
|
130
|
-
if location.include? 'get_directory'
|
131
|
-
Log.debug("Feching directory from: #{location}. Into: #{final_path}")
|
132
|
-
FileUtils.mkdir_p final_path unless File.exist? final_path
|
133
|
-
TmpFile.with_file do |tmp_dir|
|
134
|
-
Misc.in_dir tmp_dir do
|
135
|
-
CMD.cmd('tar xvfz -', :in => Open.open(location, :nocache => true))
|
136
|
-
end
|
137
|
-
FileUtils.mv tmp_dir, final_path
|
138
|
-
end
|
139
|
-
else
|
140
|
-
url = location
|
141
|
-
raise TryAgain
|
142
|
-
#Open.open(location, :nocache => true) do |s|
|
143
|
-
# Misc.sensiblewrite(final_path, s)
|
144
|
-
#end
|
145
|
-
end
|
146
|
-
when Net::HTTPInternalServerError
|
147
|
-
@server_missing_resource_cache << url
|
148
|
-
raise "Resource Not Found"
|
149
|
-
else
|
150
|
-
raise "Response not understood: #{response.inspect}"
|
151
|
-
end
|
152
|
-
end
|
153
|
-
rescue TryAgain
|
154
|
-
retry
|
155
|
-
end
|
156
|
-
end
|
157
|
-
rescue
|
158
|
-
Log.warn "Could not retrieve (#{self.to_s}) #{ path } from #{ remote_server }"
|
159
|
-
Log.error $!.message
|
160
|
-
FileUtils.rm_rf final_path if File.exist? final_path
|
161
|
-
return false
|
162
|
-
end
|
163
|
-
|
164
|
-
final_path
|
165
|
-
end
|
166
|
-
|
167
|
-
def produce(path, force = false)
|
168
|
-
case
|
169
|
-
when @resources.include?(path)
|
170
|
-
type, content = @resources[path]
|
171
|
-
when (Path === path && @resources.include?(path.original))
|
172
|
-
type, content = @resources[path.original]
|
173
|
-
when has_rake(path)
|
174
|
-
type = :rake
|
175
|
-
rake_dir, content = rake_for(path)
|
176
|
-
rake_dir = Path.setup(rake_dir.dup, self.pkgdir, self)
|
177
|
-
else
|
178
|
-
if path !~ /\.(gz|bgz)$/
|
179
|
-
begin
|
180
|
-
produce(path.annotate(path + '.gz'), force)
|
181
|
-
rescue ResourceNotFound
|
182
|
-
begin
|
183
|
-
produce(path.annotate(path + '.bgz'), force)
|
184
|
-
rescue ResourceNotFound
|
185
|
-
raise ResourceNotFound, "Resource is missing and does not seem to be claimed: #{ self } -- #{ path } "
|
186
|
-
end
|
187
|
-
end
|
188
|
-
else
|
189
|
-
raise ResourceNotFound, "Resource is missing and does not seem to be claimed: #{ self } -- #{ path } "
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
if path.respond_to?(:find)
|
194
|
-
final_path = force ? path.find(:default) : path.find
|
195
|
-
else
|
196
|
-
final_path = path
|
197
|
-
end
|
198
|
-
|
199
|
-
if type and not File.exist?(final_path) or force
|
200
|
-
Log.medium "Producing: (#{self.to_s}) #{ final_path }"
|
201
|
-
lock_filename = Persist.persistence_path(final_path, {:dir => Resource.lock_dir})
|
202
|
-
|
203
|
-
Misc.lock lock_filename do
|
204
|
-
FileUtils.rm_rf final_path if force and File.exist? final_path
|
205
|
-
|
206
|
-
if ! File.exist?(final_path) || force
|
207
|
-
|
208
|
-
begin
|
209
|
-
case type
|
210
|
-
when :string
|
211
|
-
Misc.sensiblewrite(final_path, content)
|
212
|
-
when :csv
|
213
|
-
require 'rbbt/tsv/csv'
|
214
|
-
tsv = TSV.csv Open.open(content)
|
215
|
-
Misc.sensiblewrite(final_path, tsv.to_s)
|
216
|
-
when :url
|
217
|
-
options = {}
|
218
|
-
options[:noz] = true if Open.gzip?(final_path) || Open.bgzip?(final_path) || Open.zip?(final_path)
|
219
|
-
Misc.sensiblewrite(final_path, Open.open(content, options))
|
220
|
-
when :proc
|
221
|
-
data = case content.arity
|
222
|
-
when 0
|
223
|
-
content.call
|
224
|
-
when 1
|
225
|
-
content.call final_path
|
226
|
-
end
|
227
|
-
case data
|
228
|
-
when String, IO, StringIO
|
229
|
-
Misc.sensiblewrite(final_path, data)
|
230
|
-
when Array
|
231
|
-
Misc.sensiblewrite(final_path, data * "\n")
|
232
|
-
when TSV
|
233
|
-
Misc.sensiblewrite(final_path, data.dumper_stream)
|
234
|
-
when TSV::Dumper
|
235
|
-
Misc.sensiblewrite(final_path, data.stream)
|
236
|
-
when nil
|
237
|
-
else
|
238
|
-
raise "Unkown object produced: #{Misc.fingerprint data}"
|
239
|
-
end
|
240
|
-
when :rake
|
241
|
-
run_rake(path, content, rake_dir)
|
242
|
-
when :install
|
243
|
-
Log.debug "Installing software: #{path}"
|
244
|
-
|
245
|
-
$set_software_env = false unless File.exist? path
|
246
|
-
|
247
|
-
software_dir = path.resource.root.software.find :user
|
248
|
-
helper_file = File.expand_path(Rbbt.share.install.software.lib.install_helpers.find(:lib, caller_lib_dir(__FILE__)))
|
249
|
-
#helper_file = File.expand_path(Rbbt.share.install.software.lib.install_helpers.find)
|
250
|
-
|
251
|
-
preamble = <<-EOF
|
252
|
-
#!/bin/bash
|
253
|
-
|
254
|
-
RBBT_SOFTWARE_DIR="#{software_dir}"
|
255
|
-
|
256
|
-
INSTALL_HELPER_FILE="#{helper_file}"
|
257
|
-
source "$INSTALL_HELPER_FILE"
|
258
|
-
EOF
|
259
|
-
|
260
|
-
content = content.call if Proc === content
|
261
|
-
|
262
|
-
content = if content =~ /git:|\.git$/
|
263
|
-
{:git => content}
|
264
|
-
else
|
265
|
-
{:src => content}
|
266
|
-
end if String === content and Open.remote?(content)
|
267
|
-
|
268
|
-
script_text = case content
|
269
|
-
when nil
|
270
|
-
raise "No way to install #{path}"
|
271
|
-
when Path
|
272
|
-
Open.read(content)
|
273
|
-
when String
|
274
|
-
if Misc.is_filename?(content) and Open.exists?(content)
|
275
|
-
Open.read(content)
|
276
|
-
else
|
277
|
-
content
|
278
|
-
end
|
279
|
-
when Hash
|
280
|
-
name = content[:name] || File.basename(path)
|
281
|
-
git = content[:git]
|
282
|
-
src = content[:src]
|
283
|
-
url = content[:url]
|
284
|
-
jar = content[:jar]
|
285
|
-
extra = content[:extra]
|
286
|
-
commands = content[:commands]
|
287
|
-
if git
|
288
|
-
<<-EOF
|
289
|
-
|
290
|
-
name='#{name}'
|
291
|
-
url='#{git}'
|
292
|
-
|
293
|
-
install_git "$name" "$url" #{extra}
|
294
|
-
|
295
|
-
#{commands}
|
296
|
-
EOF
|
297
|
-
elsif src
|
298
|
-
<<-EOF
|
299
|
-
|
300
|
-
name='#{name}'
|
301
|
-
url='#{src}'
|
302
|
-
|
303
|
-
install_src "$name" "$url" #{extra}
|
304
|
-
|
305
|
-
#{commands}
|
306
|
-
EOF
|
307
|
-
elsif jar
|
308
|
-
<<-EOF
|
309
|
-
|
310
|
-
name='#{name}'
|
311
|
-
url='#{jar}'
|
312
|
-
|
313
|
-
install_jar "$name" "$url" #{extra}
|
314
|
-
|
315
|
-
#{commands}
|
316
|
-
EOF
|
317
|
-
else
|
318
|
-
<<-EOF
|
319
|
-
|
320
|
-
name='#{name}'
|
321
|
-
url='#{url}'
|
322
|
-
|
323
|
-
#{commands}
|
324
|
-
EOF
|
325
|
-
end
|
326
|
-
end
|
327
|
-
|
328
|
-
script = preamble + "\n" + script_text
|
329
|
-
Log.debug "Installing software with script:\n" << script
|
330
|
-
CMD.cmd_log('bash', :in => script)
|
331
|
-
|
332
|
-
set_software_env(software_dir) unless $set_software_env
|
333
|
-
$set_software_env = true
|
334
|
-
else
|
335
|
-
raise "Could not produce #{ resource }. (#{ type }, #{ content })"
|
336
|
-
end
|
337
|
-
rescue
|
338
|
-
FileUtils.rm_rf final_path if File.exist? final_path
|
339
|
-
raise $!
|
340
|
-
end unless (remote_server && get_from_server(path, final_path))
|
341
|
-
end
|
342
|
-
end
|
343
|
-
end
|
344
|
-
|
345
|
-
# After producing a file, make sure we recheck all locations, the file
|
346
|
-
# might have appeared with '.gz' extension for instance
|
347
|
-
path.instance_variable_set("@path", {})
|
348
|
-
|
349
|
-
path
|
350
|
-
end
|
351
|
-
|
352
|
-
def identify(path)
|
353
|
-
return path unless path.start_with?("/")
|
354
|
-
path = File.expand_path(path)
|
355
|
-
path += "/" if File.directory?(path)
|
356
|
-
resource ||= Rbbt
|
357
|
-
locations = (Path::STANDARD_SEARCH + resource.search_order + resource.search_paths.keys).uniq
|
358
|
-
locations -= [:current, "current"]
|
359
|
-
locations << :current
|
360
|
-
search_paths = IndiferentHash.setup(resource.search_paths)
|
361
|
-
choices = []
|
362
|
-
locations.uniq.each do |name|
|
363
|
-
pattern = search_paths[name]
|
364
|
-
pattern = resource.search_paths[pattern] while Symbol === pattern
|
365
|
-
next if pattern.nil?
|
366
|
-
|
367
|
-
pattern = pattern.sub('{PWD}', Dir.pwd)
|
368
|
-
if String === pattern and pattern.include?('{')
|
369
|
-
regexp = "^" + pattern
|
370
|
-
.gsub(/{(TOPLEVEL)}/,'(?<\1>[^/]+)')
|
371
|
-
.gsub(/{([^}]+)}/,'(?<\1>[^/]+)?') +
|
372
|
-
"(?:/(?<REST>.*))?/?$"
|
373
|
-
if m = path.match(regexp)
|
374
|
-
if ! m.named_captures.include?("PKGDIR") || m["PKGDIR"] == resource.pkgdir
|
375
|
-
unlocated = ([m["TOPLEVEL"],m["SUBPATH"],m["REST"]] * "/")
|
376
|
-
unlocated.gsub!(/\/+/,'/')
|
377
|
-
if self.subdir && ! self.subdir.empty? && unlocated.include?(subdir)
|
378
|
-
subdir = self.subdir
|
379
|
-
subdir += "/" unless subdir.end_with?("/")
|
380
|
-
unlocated[subdir] = ""
|
381
|
-
end
|
382
|
-
choices << self.annotate(unlocated)
|
383
|
-
end
|
384
|
-
end
|
385
|
-
end
|
386
|
-
end
|
387
|
-
choices.sort_by{|s| s.length }.first
|
388
|
-
end
|
389
|
-
end
|
390
|
-
|
1
|
+
require_relative 'refactor'
|
2
|
+
Rbbt.require_instead 'scout/resource'
|
3
|
+
require_relative 'resource/path'
|