Hash :
ad514e4d
Author :
Thomas de Grivel
Date :
2023-02-26T03:15:27
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
#!/usr/bin/env ruby
load "#{File.dirname(File.dirname(__FILE__))}/lib/rbpkg.rb"
$ARGS = ARGV
def shift
usage if $ARGS == []
arg = $ARGS[0]
$ARGS = $ARGS[1..] || []
arg
end
verbose_level = 2 # print command output
case $ARGS[0]
when "-v"
verbose_level = 3 # print all messages
shift
when "-q"
verbose_level = 1 # print commands
shift
when "-qq"
verbose_level = 0 # print nothing
shift
end
Rbpkg.init("rbpkg_ci_mux", verbose_level, Rbpkg.ci_log_dir, Rbpkg.ci_status_dir)
Rbpkg.ci_init
def usage()
STDERR.puts "Usage: #{File.basename($0)} REPO BRANCH COMMIT REMOTE ..."
exit 1
end
def pop_arg
case $ARGS[0]
when "--clean"
rbpkg_ci_mux_clean
when "-h"
usage
when "--help"
usage
when "--install"
rbpkg_ci_mux_install
when "--no-remote"
Rbpkg.ci_mux
Rbpkg::Log.ok_all
exit 0
when "--upgrade"
rbpkg_ci_mux_upgrade
end
end
def rbpkg_ci_mux
while pop_arg
true
end
repo = shift
branch = shift
commit = shift
hosts = $ARGS
Thread.report_on_exception = false
threads = []
hosts.each do |host|
threads << Thread.new do
Rbpkg.ci_remote(repo, branch, commit, host)
end
end
threads.each do |t|
t.join
end
Rbpkg.ci_mux
end
def rbpkg_ci_mux_clean
shift
cmd = "rm -rf #{sh_quote(Rbpkg.ci_dir)}"
verbose(1, cmd)
raise "command failed: #{cmd.inspect}" unless system(cmd)
Rbpkg.ci_init
hosts = $ARGS
hosts.each do |host|
cmd! "ssh #{sh_quote(host)} rbpkg/bin/rbpkg_ci --clean"
end
Rbpkg::Log.ok_all
exit 0
end
def rbpkg_ci_mux_install
shift
hosts = $ARGS
hosts.each do |host|
cmd! "ssh #{sh_quote(host)} git clone https://git.kmx.io/kmx.io/rbpkg.git"
end
Rbpkg::Log.ok_all
exit 0
end
def rbpkg_ci_mux_upgrade
Rbpkg.upgrade_self
shift
hosts = $ARGS
hosts.each do |host|
cmd! "ssh #{sh_quote(host)} rbpkg/bin/rbpkg upgrade"
end
Rbpkg::Log.ok_all
exit 0
end
begin
rbpkg_ci_mux
Rbpkg::Log.ok_all
rescue => error
verbose(-1, error.backtrace.reverse.join("\n"))
verbose(-1, "#{error.class.name}: #{error.message}")
exit 1
end