diff --git a/lib/rbpkg.rb b/lib/rbpkg.rb
index 651766b..76eed8e 100644
--- a/lib/rbpkg.rb
+++ b/lib/rbpkg.rb
@@ -56,47 +56,11 @@ module Rbpkg
def self.ci_mux
verbose(3, "Rbpkg.ci_mux")
status = {}
- Dir.chdir("#{ci_dir}/status") do
- Dir["*/*"].each do |d|
- Dir.chdir(d) do
- Dir["*/*.status"].each do |subdir_file|
- name = File.basename(subdir_file, ".status")
- file = "#{name}.status"
- if ! status[name] || ! FileUtils.uptodate?(file, [subdir_file])
- FileUtils.cp(subdir_file, file)
- FileUtils.touch(file, mtime: File.mtime(subdir_file))
- status[name] = true
- end
- end
- end
- end
- status.each do |name, s|
- sh_name = sh_quote(name)
- s = if system("grep -q running */*/#{sh_name}.status")
- :running
- elsif system("grep -q ko */*/#{sh_name}.status")
- :ko
- else
- :ok
- end
- File.write("#{name}.status", s)
- end
- end
+ ci_mux_host_status(status)
+ ci_mux_status(status)
log = {}
Dir.chdir("#{Rbpkg.ci_dir}/log") do
- Dir["*/*"].each do |d|
- Dir.chdir(d) do
- Dir["*/*.log"].each do |subdir_file|
- name = File.basename(subdir_file, ".log")
- file = "#{name}.log"
- if ! log[name] || ! FileUtils.uptodate?(file, [subdir_file])
- FileUtils.cp(subdir_file, file)
- FileUtils.cp("#{subdir_file}.html", "#{file}.html")
- log[name] = true
- end
- end
- end
- end
+ ci_mux_log(log)
log.each do |name, l|
File.open("#{name}.html", "w") do |output|
status_file = "#{Rbpkg.ci_dir}/status/#{name}.status"
@@ -124,7 +88,7 @@ module Rbpkg
</h1>
<ul class="list-group">
EOF
- logs = Dir["*/*/#{name}.log.html"].map do |subdir_file|
+ Dir["*/*/#{name}.log.html"].each do |subdir_file|
status_file = "#{Rbpkg.ci_dir}/status/#{subdir_file.gsub(/.log.html$/, ".status")}"
s = File.read(status_file).strip
img = status_img(s)
@@ -146,6 +110,56 @@ EOF
end
end
+ def self.ci_mux_log(logs)
+ Dir["*/*"].each do |d|
+ Dir.chdir(d) do
+ Dir["*/*.log"].each do |subdir_file|
+ name = File.basename(subdir_file, ".log")
+ file = "#{name}.log"
+ if ! log[name] || ! FileUtils.uptodate?(file, [subdir_file])
+ FileUtils.cp(subdir_file, file)
+ FileUtils.cp("#{subdir_file}.html", "#{file}.html")
+ log[name] = true
+ end
+ end
+ end
+ end
+ end
+
+ def self.ci_mux_host_status(status)
+ Dir.chdir("#{ci_dir}/status") do
+ Dir["*/*"].each do |d|
+ Dir.chdir(d) do
+ Dir["*/*.status"].each do |subdir_file|
+ name = File.basename(subdir_file, ".status")
+ puts "status[#{name.inspect}]"
+ file = "#{name}.status"
+ if ! FileUtils.uptodate?(file, [subdir_file])
+ cmd! "cp -a #{sh_quote(subdir_file)} #{sh_quote(file)}"
+ status[name] = true
+ end
+ end
+ end
+ end
+ end
+ end
+
+ def self.ci_mux_status(status)
+ Dir.chdir("#{ci_dir}/status") do
+ status.each do |name, s|
+ sh_name = sh_quote(name)
+ s = if system("grep -q running */*/#{sh_name}.status")
+ "running\n"
+ elsif system("grep -q ko */*/#{sh_name}.status")
+ "ko\n"
+ else
+ "ok\n"
+ end
+ File.write("#{name}.status", s)
+ end
+ end
+ end
+
def self.ci_remote(repo, branch, commit, host)
verbose(3, "Rbpkg.ci_remote(#{repo.inspect}, #{branch.inspect}, #{commit.inspect}, #{host.inspect})")
sh_host = sh_quote(host)