require "BuildComm"
require "FileTransferViaFTP"
require "FileTransferViaDirect"
+require "JobLog"
+require "BuildServerException"
+require "RemoteBuilder"
#option parsing
option = option_parse
rescue => e
puts e.message
- exit 0
+ exit 1
end
# check HOST OS
if not Utils.check_host_OS() then
- puts "Error: Your host OS is not supported!"
- exit 1
+
+ if Utils.is_linux_like_os Utils::HOST_OS then
+ Utils.set_default_linux_host_os
+ puts "Warning: Your host OS is not supported!\nWe assume your host OS as #{Utils::HOST_OS} !!!"
+ else
+ puts "Error: Your host OS is not supported!"
+ exit 1
+ end
end
def query( ip, port, sym )
end
def upload_request(bs_ip, bs_port, dock, transporter, package )
- client = BuildCommClient.create( bs_ip, bs_port, nil, 0 )
- if client.nil? then
- raise RuntimeError, "Can't access server #{bs_ip}:#{bs_port}"
+ result = false
+ begin
+ client = BuildCommClient.create( bs_ip, bs_port, nil, 0 )
+ if client.nil? then
+ raise RuntimeError, "Can't access server #{bs_ip}:#{bs_port}"
+ end
+ msg = "UPLOAD|#{dock}"
+ client.send( msg )
+ result = client.send_file(package, transporter)
+ ensure
+ client.terminate if not client.nil?
end
- msg = "UPLOAD|#{dock}"
- client.send( msg )
- result = client.send_file(package, transporter)
- client.terminate
+
if not result then
- raise RuntimeError, "Uploading file failed!.. #{result}"
- else
- puts "Uploading file success!.. #{result}"
+ raise RuntimeError, "Uploading file failed!..."
end
end
begin
case option[:cmd]
when "build"
- result = Utils.parse_server_addr(option[:domain])
- if result.nil? then
+ client = nil
+ result = false
+ job_id = nil
+ job_status = ""
+ job_error = ""
+
+ addr = Utils.parse_server_addr(option[:domain])
+ if addr.nil? then
puts "Server address is incorrect. (#{option[:domain]})"
puts "Tune as following format."
puts " <ip>:<port>"
exit 1
end
- client = BuildCommClient.create( result[0], result[1], nil, 0 )
- if not client.nil? then
- client.send "BUILD|GIT|#{option[:project]}|#{option[:passwd]}|#{option[:os]}|#{option[:async]}|#{option[:noreverse]}|#{option[:dist]}|#{option[:user]}|#{option[:verbose]}"
- if not client.print_stream then
- puts "ERROR: #{client.get_error_msg()}"
- end
- client.terminate
- else
- puts "Connection to server failed!"
- exit 1
+ builder = RemoteBuilder.new(addr[0], addr[1], nil, nil, nil, nil)
+ options = RemoteBuilder.init_options()
+ options[:projects] = option[:project]
+ options[:passwd] = option[:passwd]
+ options[:os] = option[:os]
+ options[:noreverse] = (option[:noreverse] == "YES") ? true : false
+ options[:dist] = option[:dist]
+ options[:user] = option[:user]
+ options[:rebuild] = (option[:rebuild] == "YES") ? true : false
+ options[:async] = (option[:async] == "YES") ? true : false
+ options[:monitor_level] = Log::LV_USER
+ options[:save] = option[:save]
+ if options[:save] then
+ options[:dock] = Utils.create_uniq_name()
+ options[:src_path] = Utils::WORKING_DIR
end
-# when "resolve"
-# result = Utils.parse_server_addr(option[:domain])
-# if result.nil? then
-# puts "Server address is incorrect. (#{option[:domain]})"
-# puts "Tune as following format."
-# puts " <ip>:<port>"
-# exit 1
-# end
-# client = BuildCommClient.create( result[0], result[1], nil, 0 )
-# if not client.nil? then
-# client.send "RESOLVE|GIT|#{option[:project]}|#{option[:passwd]}|#{option[:os]}|#{option[:async]}|#{option[:dist]}|#{option[:user]}|#{option[:verbose]}"
-# if not client.print_stream then
-# puts "ERROR: #{client.get_error_msg()}"
-# end
-# client.terminate
-# end
+ result = builder.build(options)
+
+ if not result then exit(-1) end
+
when "query"
result = Utils.parse_server_addr(option[:domain])
if result.nil? then
query_job_list( result[0], result[1] )
+ when "query-log"
+ result = false
+ addr = Utils.parse_server_addr(option[:domain])
+ if addr.nil? then
+ puts "Server address is incorrect. (#{option[:domain]})"
+ puts "Tune as following format."
+ puts " <ip>:<port>"
+ exit 1
+ end
+ output = option[:output]
+ flock = "ON"
+
+ begin
+ if output.nil? then
+ log = STDOUT
+ else
+ if File.exist? output
+ raise RuntimeError, "The output file is already exist."
+ end
+
+ log = File.open(output, "w")
+ if not log.flock(File::LOCK_EX|File::LOCK_NB) then
+ raise RuntimeError, "The output file is already exist."
+ end
+ log.sync = true
+ puts "Started query log, writing to the file \"#{output}\""
+ end
+
+ result = JobLog.monitor(addr[0], addr[1], option[:job].strip) do |line,status,errmsg|
+ if line.nil? then
+ next
+ end
+
+ if line.eql? "=LOG_ERROR" then
+ result = false
+ end
+
+ log.puts line
+ if not output.nil? and flock.eql? "ON" then
+ log.flock(File::LOCK_UN)
+ flock = "OFF"
+ end
+ end
+ if result and not output.nil? then
+ log.puts "=LOG_END"
+ puts "End query log, check file \"#{output}\""
+ end
+ rescue BuildServerException => e
+ log.puts e.err_message()
+ result = false
+ rescue => e
+ puts "ERROR: #{e}"
+ puts e.backtrace.inspect
+ result = false
+ ensure
+ if not output.nil? then
+ log.close if not log.nil?
+ end
+ end
+
+ if not result then
+ puts "Fail query-log #{option[:job]}."
+ FileUtils.rm output if not output.nil?
+ exit(1)
+ end
+
when "cancel"
result = Utils.parse_server_addr(option[:domain])
if result.nil? then
end
when "register"
+ client = nil
+ result = false
+ job_id = nil
+ job_status = ""
+ job_error = ""
+
# check file exist
if not File.exist? option[:package] then
puts "The file does not exist!.. #{option[:package]}"
begin
dock = Utils.create_uniq_name()
client.send("REGISTER|BINARY|#{File.basename(option[:package])}|#{option[:passwd]}|#{dock}|#{option[:dist]}|#{option[:user]}|#{option[:noreverse]}")
- client.read_lines do |line|
- if line.eql?("WAITFORUPLOAD") then
+ result = client.read_lines do |line|
+ if line.strip.eql?("WAITFORUPLOAD") then
# upload
thread = Thread.new do
begin
thread.join
client.send("REGISTERCONTINUE")
+ elsif line.strip.start_with?("=JOB_START") then
+ job_id = line.strip.split(",")[1]
+ elsif line.strip.start_with?("=JOB_STATUS") then
+ data = line.strip.split(",")
+ job_status = data[1]
+ job_error = data[2]
else
+ # print log
puts line
end
end
+
+ if not result then
+ puts "Error: Communication failed! #{client.get_error_msg()}"
+ elsif job_id.nil? then
+ puts job_error
+ result = false
+ end
ensure
client.terminate
end
+
+ if not result then exit(1) end
+
+ # Query log in case sync
+ begin
+ result = JobLog.monitor(bs_ip, bs_port, job_id) do |line,status,errmsg|
+ job_status = status
+ job_error = errmsg
+ if line.nil? then
+ next
+ end
+
+ category, level, contents = JobLog.parse_log(line)
+ if level < Log::LV_USER then next end
+
+ if category == "INFO" then
+ puts "Info: #{contents}"
+ elsif category == "WARN" then
+ puts "Warn: #{contents}"
+ elsif category == "ERROR" then
+ puts "Error: #{contents}"
+ else
+ next
+ end
+ end
+
+ # Check job status
+ if not job_status.eql? "FINISHED" then
+ result = false
+ end
+ rescue BuildServerException => e
+ puts e.err_message()
+ result = false
+ rescue => e
+ puts "ERROR: #{e}"
+ result = false
+ end
+
+ if not result then exit(-1) end
+
else
raise RuntimeError, "input option incorrect : #{option[:cmd]}"
end
# check HOST OS
if not Utils.check_host_OS() then
- puts "Error: Your host OS is not supported!"
- exit 1
+
+ if Utils.is_linux_like_os Utils::HOST_OS then
+ Utils.set_default_linux_host_os
+ puts "Warning: Your host OS is not supported!\nWe assume your host OS as #{Utils::HOST_OS} !!!"
+ else
+ puts "Error: Your host OS is not supported!"
+ exit 1
+ end
end
begin
log = Log.new( "#{BuildServer::CONFIG_ROOT}/#{option[:name]}/main.log" )
begin
while(true)
- log.info "Build Server[#{option[:name]}] Start - PORT:[#{option[:port]}]"
+ log.info "Build Server[#{option[:name]}] Start - PORT: [#{option[:port]}]"
+
+ # set port option
+ port_option = ((option[:port] != "") and (option[:port] != nil)) ? "-p #{option[:port]}" : ""
+
# Start child process
- cmd = Utils.generate_shell_command("#{File.dirname(__FILE__)}/build-svr start -n #{option[:name]} -p #{option[:port]} --CHILD")
- IO.popen(cmd)
+ cmd = Utils.generate_shell_command("#{File.dirname(__FILE__)}/build-svr start -n #{option[:name]} #{port_option} --CHILD")
+
+ io = IO.popen(cmd)
+ puts io.readlines()
+
pid = Process.wait
# End chlid process
log.info "Down Build Server."
break
elsif ($?.exitstatus == 99) then # DIBS UPGRADE
- cmd = "#{File.dirname(__FILE__)}/upgrade -l #{File.dirname(__FILE__)} -S -t BUILDSERVER -n #{option[:name]} -p #{option[:port]}"
+ cmd = "#{File.dirname(__FILE__)}/upgrade -l #{File.dirname(__FILE__)} -S -t BUILDSERVER -n #{option[:name]} #{port_option}"
if File.exist? "#{BuildServer::CONFIG_ROOT}/#{option[:name]}/upgrade_dist" then
File.open("#{BuildServer::CONFIG_ROOT}/#{option[:name]}/upgrade_dist","r") do |f|
f.each_line do |l|
- cmd += " -D #{l.strip}"
+ cmd += " -u #{l.strip}"
break
end
end
log.info "Down Build Server for DIBS upgrade."
break
else
+ log.error("Exit value : #{$?.exitstatus}")
log.error "Down Build Server. Try reboot Build Server."
end
end
when "upgrade"
if not (option[:dist].nil? or option[:dist].empty?) then
build_server = BuildServerController.get_server(option[:name])
- # distribution check
- if not build_server.distmgr.get_distribution(option[:dist]).nil? then
- File.open("#{BuildServer::CONFIG_ROOT}/#{option[:name]}/upgrade_dist","w") do |f|
- f.puts option[:dist]
- end
- else
- puts "Distribution \"#{option[:dist]}\" is not exits"
- puts "Upgrade Failed!!"
- exit 1
- end
end
- BuildServerController.upgrade_server( option[:name] )
+ BuildServerController.upgrade_server( option[:name], option[:url], option[:dist] )
when "add-svr"
svr_result = Utils.parse_server_addr(option[:domain])
when "add-prj"
if not option[:git].nil? then
BuildServerController.add_project( option[:name], option[:pid],
- option[:git], option[:branch], option[:remote], option[:passwd],
+ option[:git], option[:branch], option[:remote],
option[:os], option[:dist] )
else
BuildServerController.add_binary_project( option[:name], option[:pid],
- option[:package], option[:passwd], option[:os], option[:dist] )
+ option[:package], option[:os], option[:dist] )
end
when "remove-prj"
BuildServerController.remove_project( option[:name], option[:pid], option[:dist] )
- when "fullbuild"
- BuildServerController.build_all_projects( option[:name], option[:dist] )
-
when "register"
BuildServerController.register_package( option[:name], option[:package], option[:dist] )
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
-gem 'sqlite3'
-
gem 'json'
gem 'execjs'
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
- sqlite3 (1.3.6)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.10)
mysql2 (> 0.3)
rails (= 3.2.8)
sass-rails (~> 3.2.3)
- sqlite3
uglifier (>= 1.0.3)
before_filter :check_login_status, :check_admin_group
def queryAllOS
- os_list = SupportedOs.find_by_sql("SELECT supported_os.name AS os_name
+ os_list = SupportedOs.find_by_sql("SELECT supported_os.id AS os_id
+ , supported_os.name AS os_name
+ , os_category.id AS category_id
, os_category.name AS category_name
FROM supported_os
, os_category
doc.Data {
os_list.each do |os|
doc.OS {
- doc.OsName(os.os_name)
- doc.OsCategory(os.category_name)
+ doc.Id(os.os_id)
+ doc.Name(os.os_name)
+ doc.CategoryId(os.category_id)
+ doc.CategoryName(os.category_name)
}
end
}
doc.Data {
os_category_list.each do |category|
- doc.OsCategoryName(category.name)
+ doc.OsCategory{
+ doc.Id(category.id)
+ doc.Name(category.name)
+ }
end
}
}
before_filter :check_login_status, :check_admin_group
def queryDistributionInfo
- dist_name = params[:distribution]
+ dist_id = params[:distId]
- if dist_name.nil? or dist_name.empty?
- render :text => "Distribution name is empty", :content_type => "text/xml", :status => 406
+ if dist_id.nil? or dist_id.empty?
+ render :text => "Distribution id is empty", :content_type => "text/xml", :status => 406
return
end
# get distribution
- distribution = Distribution.find(:first, :conditions => ["name = ?", dist_name])
+ distribution = Distribution.find(:first, :conditions => ["id = ?", dist_id])
if distribution.nil?
- render :text => "Can't find distribution : #{dist_name}", :content_type => "text/xml", :status => 406
+ render :text => "Can't find distribution: [#{dist_id}]", :content_type => "text/xml", :status => 406
return
end
# get sync package server
- sync_package_server = SyncPkgServer.find(:first, :conditions => ["distribution_id = ?", distribution.id])
+ sync_package_server = SyncPkgServer.find(:first, :conditions => ["distribution_id = ?", dist_id])
doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
doc.Response {
#generate to XML
doc.Data{
doc.DistributionInfo{
- doc.DistributionName(distribution.name)
+ doc.Id(distribution.id)
+ doc.Name(distribution.name)
doc.PackageServerUrl(distribution.pkgsvr_url)
doc.PackageServerAddress(distribution.pkgsvr_addr)
doc.Status(distribution.status)
dist_name = change_item[:DistributionName]
if dist_name.nil? or dist_name.empty? then
- errmsg = "Can't find [#{dist_name}] information"
+ errmsg = "Distribution name is empty"
render :json => { :error => errmsg }, :status => 406
return
end
dist = Distribution.find(:first, :conditions => ["name = ?", dist_name])
if dist.nil?
dist = Distribution.new
- dist.name = change_item[:DistributionName]
+ dist.name = dist_name
dist.pkgsvr_url = change_item[:URL]
dist.pkgsvr_addr = change_item[:Address]
dist.status = change_item[:DistStatus]
sync_pkg_svr.description = change_item[:SyncPkgSvrDescription]
sync_pkg_svr.save
else
- errmsg = "Distribution[#{dist_name}] already exist"
+ errmsg = "Distribution [#{dist_name}] already exist"
end
if errmsg.empty?
change_item = change_group_list[0]
errmsg = ""
- dist_name = change_item[:DistributionName]
- if dist_name.nil? or dist_name.empty? then
- errmsg = "Can't find [#{dist_name}] information"
+ dist_id = change_item[:DistributionId]
+ if dist_id.nil? or dist_id.empty? then
+ errmsg = "Distribution id is empty"
render :json => { :error => errmsg }, :status => 406
return
end
- dist = Distribution.find(:first, :conditions => ["name = ?", dist_name])
+ dist = Distribution.find(:first, :conditions => ["id = ?", dist_id])
if dist.nil?
- errmsg = "Distribution[#{dist_name}] not exist"
+ errmsg = "Can't find distribution: [#{dist_id}]"
else
# first, remove sync package server
sync_pkg_svr = SyncPkgServer.find(:first, :conditions => ["distribution_id = ?", dist.id])
change_item = change_group_list[0]
errmsg = ""
- dist_name = change_item[:DistributionName]
- if dist_name.nil? or dist_name.empty? then
- errmsg = "Can't find [#{dist_name}] information"
+ dist_id = change_item[:DistributionId]
+ if dist_id.nil? or dist_id.empty? then
+ errmsg = "Distribution id is empty"
render :json => { :error => errmsg }, :status => 406
return
end
- dist = Distribution.find(:first, :conditions => ["name = ?", dist_name])
+ dist = Distribution.find(:first, :conditions => ["id = ?", dist_id])
if dist.nil?
- errmsg = "Distribution[#{dist_name}] not exist"
+ errmsg = "Can't find distribution: [#{dist_id}]"
else
dist.pkgsvr_url = change_item[:URL]
dist.pkgsvr_addr = change_item[:Address]
render :json => { :error=> errmsg }, :status => 406
end
end
-
- def fullBuildDistribution
- change_group_list = params[:ChangeInfoList]
- change_item = change_group_list[0]
- errmsg = ""
-
- dist_name = change_item[:DistributionName]
- if dist_name.nil? or dist_name.empty? then
- errmsg = "Can't find [#{dist_name}] information"
- render :json => { :error => errmsg }, :status => 406
- return
- end
-
- dist = Distribution.find(:first, :conditions => ["name = ?", dist_name])
- if dist.nil?
- errmsg = "Distribution[#{dist_name}] not exist"
- end
-
- server_config = Server_config.find(:first, :conditions => ["property = \"id\""])
- if server_config.nil?
- errmsg = "Server name can't find"
- else
- server_name = server_config.value
-
- if server_name.nil? or server_name.empty?
- errmsg = "Server name can't find"
- end
- end
-
- if errmsg.empty?
- Utils.sbi_fullbuild_command(server_name, dist_name)
- render :json => { :success => "OK!" }
- else
- render :json => { :error=> errmsg }, :status => 406
- end
- end
end
doc.Data {
group_list.each do |group|
doc.Group {
+ doc.GroupId(group.id)
doc.GroupName(group.name)
doc.AdminFlag(group.admin)
doc.Description(group.description)
WHERE group_project_accesses.group_id = #{group.id}
AND projects.id = group_project_accesses.project_id
AND distributions.id = projects.distribution_id
+ AND distributions.status = 'OPEN'
ORDER BY projects.name")
project_list.each do |project|
end
def queryGroupInfo
- group_name = params[:groupName]
- if group_name.nil? or group_name.empty?
- render :text => "Group name is empty", :content_type => "text/xml", :status => 406
+ group_id = params[:groupId]
+ if group_id.nil? or group_id.empty?
+ render :text => "Group id is empty", :content_type => "text/xml", :status => 406
return
end
- group = Group.find(:first, :conditions => ["name = ?", group_name])
+ group = Group.find(:first, :conditions => ["id = ?", group_id])
if group.nil?
- render :text => "Can't find group : #{group_name}", :content_type => "text/xml", :status => 406
+ render :text => "Can't find group: #{group_id}", :content_type => "text/xml", :status => 406
return
end
FROM projects
, distributions
WHERE distributions.id = projects.distribution_id
+ AND distributions.status = 'OPEN'
ORDER BY projects.name")
project_list.each do |project|
doc.Project{
- doc.Name(project.project_name)
doc.Id(project.project_id)
+ doc.Name(project.project_name)
doc.DistName(project.distribution_name)
}
end
change_item = change_group_list[0]
errmsg = ""
- group_name = change_item[:GroupName]
- if group_name.nil? or group_name.empty?
- render :text => "Group name is invalid", :status => 406
+ group_id = change_item[:GroupId]
+ if group_id.nil? or group_id.empty?
+ errmsg = "group id is empty"
+ render :json => { :error => errmsg }, :status => 406
return
else
- group = Group.find(:first, :conditions => ["name= ?", group_name])
+ group = Group.find(:first, :conditions => ["id= ?", group_id])
end
if group.nil?
- errmsg = "Can't find group"
+ errmsg = "Can't find group: #{group_id}"
else
- new_group_name = change_item[:NewGroupName]
+ group_name = change_item[:GroupName]
admin_flag = change_item[:AdminFlag]
description = change_item[:Description]
project_id_list = change_item[:ProjectList].split(",")
- group.name = new_group_name
+ group.name = group_name
group.admin = admin_flag
group.description = description
group.save
if errmsg.empty?
render :json => { :success => "OK!" }
else
- render :text => errmsg, :status => 406
+ render :json => { :error=> errmsg }, :status => 406
end
end
change_item = change_group_list[0]
errmsg = ""
- group_name = change_item[:GroupName]
- if group_name.nil? or group_name.empty?
- render :text => "Group name is invalid", :status => 406
+ group_id = change_item[:GroupId].to_s
+ if group_id.nil? or group_id.empty?
+ errmsg = "group id is empty"
+ render :json => { :error => errmsg }, :status => 406
return
else
- group = Group.find(:first, :conditions => ["name= ?", group_name])
+ group = Group.find(:first, :conditions => ["id = ?", group_id])
end
if group.nil?
- errmsg = "Can't find group"
+ errmsg = "Can't find group: #{group_id}"
else
user_group = UserGroup.find(:first, :conditions => ["group_id = ?", group.id])
if user_group.nil?
GroupProjectAccess.delete_all(["group_id = ?", group.id])
group.destroy
else
- errmsg = "Can't remove. #{group_name} has users."
+ errmsg = "Can't remove. #{group.id} has users."
end
end
if errmsg.empty?
render :json => { :success => "OK!" }
else
- render :text => errmsg, :status => 406
+ render :json => { :error=> errmsg }, :status => 406
end
end
group_name = change_item[:GroupName]
if group_name.nil? or group_name.empty?
- render :text => "Group name is invalid", :status => 406
+ errmsg = "Group name is invalid"
+ render :json => { :error => errmsg }, :status => 406
return
else
group = Group.find(:first, :conditions => ["name= ?", group_name])
if errmsg.empty?
render :json => { :success => "OK!" }
else
- render :text => errmsg, :status => 406
+ render :json => { :error=> errmsg }, :status => 406
end
end
end
=end
class AdminProjectController < ApplicationController
- def queryAllProject
- project_list = Project.find_by_sql("SELECT projects.name AS project_name
- , projects.id AS project_id
- , distributions.name AS distribution_name
- FROM projects
- , distributions
- WHERE distributions.id = projects.distribution_id
- ORDER BY projects.name")
-
- doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
- doc.Response {
- generate_xml_header(doc)
-
- doc.Data {
- project_list.each do |project|
- doc.Project{
- doc.Name(project.project_name)
- doc.Id(project.project_id)
- doc.DistName(project.distribution_name)
- }
- end
- }
- }
-
- #send_data
- render :text => out_string, :content_type => "text/xml"
- end
-
def queryProjectsInDistributionForAdmin
- dist_name = params[:distribution]
-
- if dist_name.nil? or dist_name.empty?
- render :text => "Distribution name is empty", :content_type => "text/xml", :status => 406
- return
- end
+ dist_id = params[:distId]
- # get distribution
- distribution = Distribution.find(:first, :conditions => ["name = ?", dist_name])
- if distribution.nil?
- render :text => "Can't find distribution : #{dist_name}", :content_type => "text/xml", :status => 406
+ if dist_id.nil? or dist_id.empty?
+ render :text => "Distribution id is empty", :content_type => "text/xml", :status => 406
return
end
project_list = Project.find_by_sql("SELECT projects.id
, projects.name
, projects.ptype
+ , projects.status
FROM projects
, distributions
- WHERE distributions.name = \"#{dist_name}\"
+ WHERE distributions.id = \"#{dist_id}\"
AND distributions.id = projects.distribution_id
ORDER BY projects.name")
project_list.each do |project|
doc.Project {
- doc.ProjectName(project.name)
+ doc.Id(project.id)
+ doc.Name(project.name)
doc.Type(project.ptype)
+ doc.ProjectStatus(project.status)
os_list = ProjectOs.find_by_sql("SELECT supported_os.name AS name
FROM project_os
change_item = change_group_list[0]
errmsg = ""
+ dist_id = change_item[:DistId]
project_name = change_item[:Name]
project_type = change_item[:ProjectType].upcase
- project_dist_name = change_item[:Distribution]
- project_password = change_item[:ProjectPass]
+ project_status = change_item[:ProjectStatus].upcase
- if project_name.nil? or project_name.empty? then
- errmsg = "Can't find [Name] information"
+ if dist_id.nil? or dist_id.empty? or
+ project_name.nil? or project_name.empty? or
+ project_type.nil? or project_type.empty? or
+ project_status.nil? or project_status.empty? then
+ errmsg = "add project information invalid"
render :json => { :error => errmsg }, :status => 406
return
end
- distribution = Distribution.find(:first, :conditions => ["name = ?", project_dist_name])
- project = Project.find(:first, :conditions => ["name = ? and distribution_id = ? and ptype = ?", project_name, distribution.id, project_type])
+ if not project_type.eql? "GIT" and not project_type.eql? "BINARY"
+ errmsg = "project type is invalid"
+ render :json => { :error => errmsg }, :status => 406
+ return
+ end
+ if not project_status.eql? "OPEN" and not project_status.eql? "CLOSE"
+ errmsg = "project status is invalid"
+ render :json => { :error => errmsg }, :status => 406
+ return
+ end
- if not project.nil?
- errmsg = "project already exist"
+ distribution = Distribution.find(:first, :conditions => ["id = ?", dist_id])
+ if distribution.nil?
+ errmsg = "Can't find distribution: #{dist_id}"
render :json => { :error => errmsg }, :status => 406
return
end
- if not project_type.eql? "GIT" and not project_type.eql? "BINARY"
- errmsg = "project type is invalid"
+ project = Project.find(:first, :conditions => ["name = ? and distribution_id = ?", project_name, dist_id])
+
+ if not project.nil?
+ errmsg = "project already exist"
render :json => { :error => errmsg }, :status => 406
return
end
project = Project.new
project.name = project_name
project.ptype = project_type
- project.password = project_password
- project.distribution_id = distribution.id
+ project.status = project_status
+ project.distribution_id = dist_id
#TODO: set project user is admin. admin user id is '1'
project.user_id = 1
project.save
- if not change_item[:OSNameList].nil?
- os_name_list = change_item[:OSNameList].split(",")
- os_name_list.each do |os_name|
- supported_os = SupportedOs.find(:first, :conditions => ["name = ?", os_name])
- #need check not found
+ if not change_item[:OSIdList].nil?
+ os_id_list = change_item[:OSIdList].split(",")
+ os_id_list.each do |os_id|
+ supported_os = SupportedOs.find(:first, :conditions => ["id = ?", os_id])
+ if supported_os.nil?
+ errmsg = "project os id is invalid: #{os_id}"
+ render :json => { :error => errmsg }, :status => 406
+ return
+ end
+
project_os = ProjectOs.new
project_os.project_id = project.id
project_os.supported_os_id = supported_os.id
change_item = change_group_list[0]
errmsg = ""
- if change_item[:Name].nil? or change_item[:Name].empty? then
- errmsg = "Can't find [Name] information"
+ if change_item[:ProjectId].nil? or change_item[:ProjectId].empty? then
+ errmsg = "project id is empty"
render :json => { :error => errmsg }, :status => 406
return
end
- dist_name = change_item[:Distribution]
- project_name = change_item[:Name]
- project_type = change_item[:ProjectType]
- distribution = Distribution.find(:first, :conditions => ["name = ?", dist_name])
- project = Project.find(:first, :conditions => ["name = ? and distribution_id = ?", project_name, distribution.id])
+ project_id = change_item[:ProjectId]
+
+ project = Project.find(:first, :conditions => ["id = ?", project_id])
if project.nil?
- errmsg = "project does not exist"
+ errmsg = "project does not exist: #{project_id}"
render :json => { :error => errmsg }, :status => 406
return
end
- case project_type.upcase
+ case project.ptype
when "GIT"
- ProjectGit.delete_all(["project_id = ?", project.id])
- ProjectOs.delete_all(["project_id = ?", project.id])
- GroupProjectAccess.delete_all(["project_id = ?", project.id])
+ ProjectGit.delete_all(["project_id = ?", project_id])
+ ProjectOs.delete_all(["project_id = ?", project_id])
+ GroupProjectAccess.delete_all(["project_id = ?", project_id])
when "BINARY"
- ProjectBin.delete_all(["project_id = ?", project.id])
- GroupProjectAccess.delete_all(["project_id = ?", project.id])
+ ProjectBin.delete_all(["project_id = ?", project_id])
+ GroupProjectAccess.delete_all(["project_id = ?", project_id])
else
errmsg = "project type is invalid"
render :json => { :error => errmsg }, :status => 406
end
# remove project os
- ProjectOs.delete_all(["project_id = ?", project.id])
+ ProjectOs.delete_all(["project_id = ?", project_id])
# remove project
project.destroy
change_item = change_group_list[0]
errmsg = ""
- dist_name = change_item[:Distribution]
- old_project_name = change_item[:Name]
- project_type = change_item[:ProjectType].upcase
+ project_id = change_item[:Id]
+ project_name = change_item[:Name]
+ project_status = change_item[:ProjectStatus].upcase
- if old_project_name.nil? or old_project_name.empty? then
- errmsg = "Can't find [#{old_project_name}] information"
+ if project_id.nil? or project_id.empty? or
+ project_name.nil? or project_name.empty? or
+ project_status.nil? or project_status.empty? then
+ errmsg = "project information invalid"
render :json => { :error => errmsg }, :status => 406
return
end
- if not project_type.eql? "GIT" and not project_type.eql? "BINARY"
- errmsg = "project type is invalid"
+ if not project_status.eql? "OPEN" and not project_status.eql? "CLOSE"
+ errmsg = "project status is invalid"
render :json => { :error => errmsg }, :status => 406
return
end
- distribution = Distribution.find(:first, :conditions => ["name = ?", dist_name])
- project = Project.find(:first, :conditions => ["name = ? and distribution_id = ? and ptype = ?", old_project_name, distribution.id, project_type])
- project.name = change_item[:NewProjectName]
- project.password = change_item[:ProjectPass]
+ project = Project.find(:first, :conditions => ["id = ?", project_id])
+ if project.nil?
+ errmsg = "project does not exist"
+ render :json => { :error => errmsg }, :status => 406
+ return
+ end
+
+ # project data update
+ if not project.name.eql? project_name then
+ name_check_project = Project.find(:first, :conditions => ["name = ? and distribution_id = ?", project_name, project.distribution_id])
+
+ if not name_check_project.nil?
+ errmsg = "project already exist"
+ render :json => { :error => errmsg }, :status => 406
+ return
+ end
+
+ project.name = project_name
+ end
+ project.status = project_status
# remove project os and reset project os
- ProjectOs.delete_all(["project_id = ?", project.id])
- if not change_item[:OSNameList].nil?
- os_name_list = change_item[:OSNameList].split(",")
- os_name_list.each do |os_name|
- supported_os = SupportedOs.find(:first, :conditions => ["name = ?", os_name])
- #need check not found
+ ProjectOs.delete_all(["project_id = ?", project_id])
+ if not change_item[:OSIdList].nil?
+ os_id_list = change_item[:OSIdList].split(",")
+ os_id_list.each do |os_id|
+ supported_os = SupportedOs.find(:first, :conditions => ["id = ?", os_id])
+ if supported_os.nil?
+ errmsg = "project os id is invalid: #{os_id}"
+ render :json => { :error => errmsg }, :status => 406
+ return
+ end
+
project_os = ProjectOs.new
- project_os.project_id = project.id
+ project_os.project_id = project_id
project_os.supported_os_id = supported_os.id
project_os.save
end
end
- case project_type
+ case project.ptype
when "GIT"
- project_git = ProjectGit.find(:first, :conditions => ["project_id = ?", project.id])
+ project_git = ProjectGit.find(:first, :conditions => ["project_id = ?", project_id])
if project_git.nil?
- project_git.project_id = project.id
+ project_git.project_id = project_id
project_git = ProjectGit.new
end
project_git.git_repos = change_item[:ProjectAddress]
project_git.save
when "BINARY"
- project_bin = ProjectBin.find(:first, :conditions => ["project_id = ?", project.id])
+ project_bin = ProjectBin.find(:first, :conditions => ["project_id = ?", project_id])
if project_bin.nil?
project_bin = ProjectBin.new
- project_bin.project_id = project.id
+ project_bin.project_id = project_id
end
project_bin.pkg_name = change_item[:PackageName]
project_bin.save
project.save
render :json => { :success => "OK!" }
end
+
+ def changeAllProjectStatus
+ change_group_list = params[:ChangeInfoList]
+ change_item = change_group_list[0]
+ errmsg = ""
+
+ dist_id = change_item[:DistId]
+ projectStatus = change_item[:ProjectStatus]
+
+ if projectStatus.nil? or not (projectStatus.eql? "OPEN" or projectStatus.eql? "CLOSE") then
+ errmsg = "project status must be OPEN or CLOSE"
+ render :json => { :error => errmsg }, :status => 406
+ return
+ end
+
+ distribution = Distribution.find(:first, :conditions => ["id = ?", dist_id])
+ Project.update_all("status=\"#{projectStatus}\"", :distribution_id => distribution.id)
+
+ render :json => { :success => "OK!" }
+ end
end
doc.Data {
server_config.each do |info|
doc.ServerConfig {
+ doc.Id( info.id )
doc.Property( info.property )
doc.Value( info.value )
}
remote_build_servers.each do |server|
doc.RemoteBuildServer {
+ doc.Id(server.id)
doc.Address(server.svr_addr)
supported_os = SupportedOs.find(:first, :conditions => ["id = ?", server.supported_os_id])
if supported_os.nil?
render :text => out_string, :content_type => "text/xml"
end
+ def queryServerConfig
+ config_id = params[:configId]
+ if config_id.nil?
+ #send_data
+ render :text => "Config id value is invalid", :content_type => "text/xml"
+ return
+ end
+
+ server_config = Server_config.find(:first, :conditions => ["id = ?", config_id])
+ if server_config.nil?
+ #send_data
+ render :text => "Can't find server config: #{config_id}", :content_type => "text/xml"
+ return
+ end
+
+ doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
+ doc.Response {
+ generate_xml_header(doc)
+
+ #generate to XML
+ doc.Data {
+ doc.Id(server_config.id)
+ doc.Property(server_config.property)
+ doc.Value(server_config.value)
+ }
+ }
+
+ #send_data
+ render :text => out_string, :content_type => "text/xml"
+ end
+
+ def querySupportedOS
+ os_id = params[:osId]
+ if os_id.nil?
+ #send_data
+ render :text => "Supported os id is invalid", :content_type => "text/xml"
+ return
+ end
+
+ supported_os = SupportedOs.find(:first, :conditions => ["id = ?", os_id])
+ if supported_os.nil?
+ #send_data
+ render :text => "Can't find supported os: #{os_id}", :content_type => "text/xml"
+ return
+ end
+
+ doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
+ doc.Response {
+ generate_xml_header(doc)
+
+ #generate to XML
+ doc.Data {
+ doc.Id(supported_os.id)
+ doc.Name(supported_os.name)
+ doc.CategoryId(supported_os.os_category_id)
+ }
+ }
+
+ #send_data
+ render :text => out_string, :content_type => "text/xml"
+ end
+
+ def queryRemoteBuildServer
+ server_id = params[:serverId]
+ remote_server = RemoteBuildServer.find(:first, :conditions => ["id = ?", server_id])
+ if remote_server.nil?
+ #send_data
+ render :text => "Can't find server: #{server_id}", :content_type => "text/xml"
+ return
+ end
+
+ doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
+ doc.Response {
+ generate_xml_header(doc)
+
+ #generate to XML
+ doc.Data {
+ doc.Id(remote_server.id)
+ doc.Address(remote_server.svr_addr)
+ doc.Description(remote_server.description)
+ }
+ }
+
+ #send_data
+ render :text => out_string, :content_type => "text/xml"
+ end
+
def addRemoteBuildServer
change_group_list = params[:ChangeInfoList]
change_item = change_group_list[0]
if server.nil?
server = RemoteBuildServer.new
- server.svr_addr = address
+ server.svr_addr = address.strip
server.description = description
server.save
render :json => { :success => "OK!" }
else
errmsg = "Server already exist"
-
render :json => { :error => errmsg }, :status => 406
end
end
change_item = change_group_list[0]
errmsg = ""
+ id = change_item[:Id]
address = change_item[:Address]
- if address.nil? or address.empty?
- errmsg = "Server address is empty"
+ description = change_item[:Description]
+ if id.nil? or
+ address.nil? or address.empty?
+ errmsg = "Server information is invalid"
render :json => { :error => errmsg }, :status => 406
return
end
- server = RemoteBuildServer.find(:first, :conditions => ["svr_addr = ?", address])
+ server = RemoteBuildServer.find(:first, :conditions => ["id = ?", id])
if server.nil?
errmsg = "Server does not exist"
else
- new_address = change_item[:NewAddress]
- description = change_item[:Description]
-
# error check for server already exist
- if not address.eql? new_address
- new_server = RemoteBuildServer.find(:first, :conditions => ["svr_addr = ?", new_address])
+ if not server.svr_addr.eql? address
+ check_server = RemoteBuildServer.find(:first, :conditions => ["svr_addr = ?", address])
- if not new_server.nil?
+ if not check_server.nil?
errmsg = "Server already exist"
+ render :json => { :error => errmsg }, :status => 406
+ return
end
end
- server.svr_addr = new_address
- server.description = description
+ server.svr_addr = address.strip
+ server.description = description.strip
server.save
end
change_item = change_group_list[0]
errmsg = ""
- address = change_item[:Address]
- if address.nil? or address.empty?
- errmsg = "Server address is empty"
+ id = change_item[:Id]
+ if id.nil? or id.empty?
+ errmsg = "Server id is empty"
render :json => { :error => errmsg }, :status => 406
return
end
- server = RemoteBuildServer.find(:first, :conditions => ["svr_addr = ?", address])
+ server = RemoteBuildServer.find(:first, :conditions => ["id = ?", id])
if server.nil?
errmsg = "Server does not exist"
end
end
- def addOsCategory
+ def addOSCategory
change_group_list = params[:ChangeInfoList]
change_item = change_group_list[0]
errmsg = ""
render :json => { :success => "OK!" }
else
errmsg = "Os category already exist"
-
render :json => { :error => errmsg }, :status => 406
end
end
- def removeOsCategory
+ def removeOSCategory
change_group_list = params[:ChangeInfoList]
change_item = change_group_list[0]
errmsg = ""
- name = change_item[:Name]
- if name.nil? or name.empty?
- errmsg = "Os category name is empty"
+ id = change_item[:Id]
+ if id.nil? or id.empty?
+ errmsg = "Os category id is empty"
render :json => { :error => errmsg }, :status => 406
return
end
# get server for error check
- osCategory = OsCategory.find(:first, :conditions => ["name = ?", name])
+ osCategory = OsCategory.find(:first, :conditions => ["id = ?", id])
if osCategory.nil?
errmsg = "Can't find os category"
errmsg = ""
os_name = change_item[:Name]
- category_name = change_item[:OsCategory]
+ category_id = change_item[:OsCategoryId]
if os_name.nil? or os_name.empty?
errmsg = "Os name is empty"
render :json => { :error => errmsg }, :status => 406
return
end
- if category_name.nil? or category_name.empty?
+ if category_id.nil? or category_id.empty?
errmsg = "Os category is empty"
render :json => { :error => errmsg }, :status => 406
return
end
# get server for error check
- os_category = OsCategory.find(:first, :conditions => ["name = ?", category_name])
+ os_category = OsCategory.find(:first, :conditions => ["id = ?", category_id])
supported_os = SupportedOs.find(:first, :conditions => ["name = ?", os_name])
if os_category.nil?
errmsg = "Os category does not exist"
-
render :json => { :error => errmsg }, :status => 406
elsif not supported_os.nil?
errmsg = "supported os already exist"
-
render :json => { :error => errmsg }, :status => 406
else
supported_os = SupportedOs.new
- supported_os.name = os_name
+ supported_os.name = os_name.strip
supported_os.os_category_id = os_category.id
supported_os.save
-
render :json => { :success => "OK!" }
end
end
change_item = change_group_list[0]
errmsg = ""
- os_name = change_item[:Name]
- if os_name.nil? or os_name.empty?
- errmsg = "Os name is empty"
+ os_id = change_item[:Id]
+ if os_id.nil? or os_id.empty?
+ errmsg = "Os id is empty"
render :json => { :error => errmsg }, :status => 406
return
end
# get server for error check
- supported_os = SupportedOs.find(:first, :conditions => ["name = ?", os_name])
+ supported_os = SupportedOs.find(:first, :conditions => ["id = ?", os_id])
if supported_os.nil?
errmsg = "supported os does not exist"
-
render :json => { :error => errmsg }, :status => 406
- else
- supported_os.destroy
-
- render :json => { :success => "OK!" }
end
+
+ supported_os.destroy
+ render :json => { :success => "OK!" }
end
def modifySupportedOS
change_item = change_group_list[0]
errmsg = ""
+ os_id = change_item[:Id]
os_name = change_item[:Name]
- new_os_name = change_item[:NewName]
- category_name = change_item[:OsCategory]
- if os_name.nil? or os_name.empty?
- errmsg = "Os name is empty"
+ category_id = change_item[:OsCategoryId]
+ if os_id.nil? or os_id.empty? or
+ os_name.nil? or os_name.empty? or
+ category_id.nil? or category_id.empty?
+ errmsg = "modify os data is invalid"
render :json => { :error => errmsg }, :status => 406
return
end
# get server for error check
- os_category = OsCategory.find(:first, :conditions => ["name = ?", category_name])
- supported_os = SupportedOs.find(:first, :conditions => ["name = ?", os_name])
+ os_category = OsCategory.find(:first, :conditions => ["id = ?", category_id])
+ supported_os = SupportedOs.find(:first, :conditions => ["id = ?", os_id])
if os_category.nil?
errmsg = "Os category does not exist"
render :json => { :error => errmsg }, :status => 406
else
- if not os_name.eql? new_os_name
- new_supported_os = SupportedOs.find(:first, :conditions => ["name = ?", new_os_name])
- if new_supported_os.nil?
- supported_os.name = new_os_name
+ if not supported_os.name.eql? os_name
+ check_supported_os = SupportedOs.find(:first, :conditions => ["name = ?", os_name])
+ if check_supported_os.nil?
+ supported_os.name = os_name
else
errmsg = "supported os already exist"
-
render :json => { :error => errmsg }, :status => 406
return
end
supported_os.os_category_id = os_category.id
supported_os.save
-
render :json => { :success => "OK!" }
end
end
change_item = change_group_list[0]
errmsg = ""
+ id = change_item[:Id]
property = change_item[:Property]
value = change_item[:Value]
- if property.nil? or property.empty?
- errmsg = "Property is empty"
- render :json => { :error => errmsg }, :status => 406
- return
- end
- if value.nil? or value.empty?
- errmsg = "Value is empty"
+ if id.nil? or id.empty? or
+ value.nil? or value.empty? or
+ property.nil? or property.empty?
+ errmsg = "server info is invalid"
render :json => { :error => errmsg }, :status => 406
return
end
# get server for error check
- config = Server_config.find(:first, :conditions => ["property = ?", property])
+ config = Server_config.find(:first, :conditions => ["id = ?", id])
if config.nil?
errmsg = "Config does not exist"
render :json => { :error => errmsg }, :status => 406
else
+ config.property = property
config.value = value
config.save
change_item = change_user_list[0]
errmsg = ""
+ id = change_item[:Id]
email = change_item[:Email]
+ name = change_item[:Name]
group_id_list = change_item[:GroupIdList].split(",")
- user_name = change_item[:UserName]
- if email.nil? or email.empty?
- render :text => "Email is invalid", :status => 406
+ if id.nil? or
+ email.nil? or email.empty?
+ render :text => "User data is invalid", :status => 406
return
- else
- user = User.find(:first, :conditions => ["email = ?", email])
+ end
+
+ user = User.find(:first, :conditions => ["id = ?", id])
+
+ if user.nil?
+ errmsg = "Can't find user information"
+ render :text => errmsg, :status => 406
+ return
+ end
- if user.nil?
- errmsg = "Can't find user information"
+ if not user.email.eql? email
+ check_user = User.find(:first, :conditions => ["email = ?", email])
+ if not check_user.nil?
+ errmsg = "Email address already used"
render :text => errmsg, :status => 406
return
end
+
+ user.email = email
end
- user.name = user_name
+ user.name = name
user.save
UserGroup.delete_all(["user_id = ?", user.id])
change_item = change_user_list[0]
errmsg = ""
- email = change_item[:Email]
- if email.nil? or email.empty?
- render :text => "Email is invalid", :status => 406
+ id = change_item[:Id]
+ if id.nil?
+ render :text => "User infomation invalid", :status => 406
return
- else
- user = User.find(:first, :conditions => ["email = ?", email])
end
+
+ user = User.find(:first, :conditions => ["id = ?", id])
if user.nil?
errmsg = "Can't find user information"
render :text => errmsg, :status => 406
- else
- UserGroup.delete_all(["user_id = ?", user.id])
-
- user.destroy
- render :json => { :success => "OK!" }
+ return
end
+
+ UserGroup.delete_all(["user_id = ?", user.id])
+
+ user.destroy
+ render :json => { :success => "OK!" }
end
end
end
end
+ def get_user_password
+ if @current_user.nil?
+ current_user
+ end
+
+ if not @current_user.nil?
+ return @current_user.password_hash
+ else
+ return nil
+ end
+ end
+
def get_group_list(email)
if not email.nil?
group_list = Group.find_by_sql("SELECT groups.id
doc.UserName(job.user_name)
doc.StartTime(job.start_time)
doc.EndTime(job.end_time)
- }
+ doc.ErrorCode(job.error_code)
- if job.job_attribute == "MULTI"
- child_jobs = get_child_job_info(job.job_id)
- child_jobs.each {|job|
- doc.Job {
- doc.Id(job.job_id)
- doc.Distribution(job.distribution_name)
- doc.ProjectName(job.project_name)
- doc.JobType(job.job_type)
- doc.JobAttribute("CHILD")
- doc.ParentJobId(job.parent_job_id)
- doc.Os(job.supported_os_name)
- doc.Status(job.status)
- doc.UserName(job.user_name)
- doc.StartTime(job.start_time)
- doc.EndTime(job.end_time)
- }
- }
- end
+ project_list = get_child_job_project_name(job.job_id)
+ doc.ProjectList(project_list)
+ }
+ generate_xml_sub_jobs(doc,job.job_id)
end
end
}
end
if(status == "ALL")
- status = "'FINISHED', 'JUST_CREATED', 'WAITING', 'WORKING', 'REMOTE_WORKING', 'PENDING', 'ERROR', 'CANCELED'"
+ status = "'FINISHED', 'INITIALIZING', 'JUST_CREATED', 'WAITING', 'WORKING', 'REMOTE_WORKING', 'PENDING', 'ERROR', 'CANCELED'"
elsif(status == "SUCCESS")
status = "'FINISHED'"
elsif(status == "WORKING")
- status = "'JUST_CREATE', 'WAITING', 'WORKING', 'REMOTE_WORKING', 'PENDING'"
+ status = "'INITIALIZING', 'JUST_CREATED', 'WAITING', 'WORKING', 'REMOTE_WORKING', 'PENDING'"
elsif(status == "ERROR")
status = "'ERROR', 'CANCELED'"
end
doc.JobList {
jobs.each {|job_list|
job = get_job_info(job_list.id)
-
doc.Job {
doc.Id(job.job_id)
doc.Distribution(job.distribution_name)
doc.UserName(job.user_name)
doc.StartTime(job.start_time)
doc.EndTime(job.end_time)
- }
+ doc.ErrorCode(job.error_code)
- if job_list.job_attribute == "MULTI"
- child_jobs = get_child_job_info(job.job_id)
- child_jobs.each {|job|
- doc.Job {
- doc.Id(job.job_id)
- doc.Distribution(job.distribution_name)
- doc.ProjectName(job.project_name)
- doc.JobType(job.job_type)
- doc.JobAttribute("CHILD")
- doc.Os(job.supported_os_name)
- doc.Status(job.status)
- doc.UserName(job.user_name)
- doc.StartTime(job.start_time)
- doc.EndTime(job.end_time)
- }
- }
- end
+ project_list = get_child_job_project_name(job.job_id)
+ doc.ProjectList(project_list)
+ }
+ generate_xml_sub_jobs(doc,job.job_id)
}
}
end
end
if(status == "ALL")
- status = "'FINISHED', 'JUST_CREATED', 'WAITING', 'WORKING', 'REMOTE_WORKING', 'PENDING', 'ERROR', 'CANCELED'"
+ status = "'FINISHED', 'INITIALIZING', 'JUST_CREATED', 'WAITING', 'WORKING', 'REMOTE_WORKING', 'PENDING', 'ERROR', 'CANCELED'"
elsif(status == "SUCCESS")
status = "'FINISHED'"
elsif(status == "WORKING")
- status = "'JUST_CREATE', 'WAITING', 'WORKING', 'REMOTE_WORKING', 'PENDING'"
+ status = "'INITIALIZING', 'JUST_CREATED', 'WAITING', 'WORKING', 'REMOTE_WORKING', 'PENDING'"
elsif(status == "ERROR")
status = "'ERROR', 'CANCELED'"
end
doc.UserName(job.user_name)
doc.StartTime(job.start_time)
doc.EndTime(job.end_time)
- }
+ doc.ErrorCode(job.error_code)
- if job_list.job_attribute == "MULTI"
- child_jobs = get_child_job_info(job.job_id)
- child_jobs.each {|job|
- doc.Job {
- doc.Id(job.job_id)
- doc.Distribution(job.distribution_name)
- doc.ProjectName(job.project_name)
- doc.JobType(job.job_type)
- doc.JobAttribute("CHILD")
- doc.Os(job.supported_os_name)
- doc.Status(job.status)
- doc.UserName(job.user_name)
- doc.StartTime(job.start_time)
- doc.EndTime(job.end_time)
- }
- }
- end
+ project_list = get_child_job_project_name(job.job_id)
+ doc.ProjectList(project_list)
+ }
+ generate_xml_sub_jobs(doc,job.job_id)
}
}
}
end
if(status == "ALL")
- status = "'FINISHED', 'JUST_CREATED', 'WAITING', 'WORKING', 'REMOTE_WORKING', 'PENDING', 'ERROR', 'CANCELED'"
+ status = "'FINISHED', 'INITIALIZING', 'JUST_CREATED', 'WAITING', 'WORKING', 'REMOTE_WORKING', 'PENDING', 'ERROR', 'CANCELED'"
elsif(status == "SUCCESS")
status = "'FINISHED'"
elsif(status == "WORKING")
- status = "'JUST_CREATE', 'WAITING', 'WORKING', 'REMOTE_WORKING', 'PENDING'"
+ status = "'INITIALIZING', 'JUST_CREATED', 'WAITING', 'WORKING', 'REMOTE_WORKING', 'PENDING'"
elsif(status == "ERROR")
status = "'ERROR', 'CANCELED'"
end
doc.UserName(job.user_name)
doc.StartTime(job.start_time)
doc.EndTime(job.end_time)
+ doc.ErrorCode(job.error_code)
+
+ project_list = get_child_job_project_name(job.job_id)
+ doc.ProjectList(project_list)
}
}
}
, jobs.jtype AS job_type
, jobs.status AS status
, jobs.parent_job_id AS parent_job_id
+ , jobs.error_code AS error_code
, DATE_FORMAT(jobs.start_time, '%Y-%m-%d %H:%i:%s') AS start_time
, DATE_FORMAT(jobs.end_time, '%Y-%m-%d %H:%i:%s') AS end_time
, CASE WHEN jobs.jtype like \"MULTI%\" THEN \"MULTI\"
ELSE \"SINGLE\" END \"job_attribute\"
, projects.name AS project_name
, projects.ptype AS project_type
- , projects.password AS project_password
, users.name AS user_name
, users.email AS user_email
, supported_os.name AS supported_os_name
, jobs.jtype AS job_type
, jobs.status AS status
, jobs.parent_job_id AS parent_job_id
+ , jobs.error_code AS error_code
, DATE_FORMAT(jobs.start_time, '%Y-%m-%d %H:%i:%s') AS start_time
, DATE_FORMAT(jobs.end_time, '%Y-%m-%d %H:%i:%s') AS end_time
, projects.name AS project_name
return job
end
- def log_more
- @cursor = nil
- @file = nil
+ def get_child_job_project_name(parent_job_id)
+ project_list = nil
+ job = Job.find_by_sql("SELECT DISTINCT projects.name AS project_name
+ FROM jobs
+ LEFT JOIN projects
+ ON jobs.project_id = projects.id
+ WHERE jobs.parent_job_id = #{parent_job_id}
+ ORDER BY projects.name")
+ job.each do |job|
+ if project_list.nil? then
+ project_list = job.project_name
+ else
+ project_list = project_list + ', ' + job.project_name
+ end
+ end
+ return project_list
+ end
+
+ def get_sub_job_count(job_id)
+ return Job.where(:parent_job_id => job_id).count
+ end
+ def generate_xml_sub_jobs(doc, job_id)
+ sub_job_cnt = get_sub_job_count(job_id)
+ if sub_job_cnt > 0
+ child_jobs = get_child_job_info(job_id)
+ child_jobs.each {|job|
+ doc.Job {
+ doc.Id(job.job_id)
+ doc.Distribution(job.distribution_name)
+ doc.ProjectName(job.project_name)
+ doc.JobType(job.job_type)
+ doc.JobAttribute("CHILD")
+ doc.ParentJobId(job.parent_job_id)
+ doc.Os(job.supported_os_name)
+ doc.Status(job.status)
+ doc.UserName(job.user_name)
+ doc.StartTime(job.start_time)
+ doc.EndTime(job.end_time)
+ doc.ErrorCode(job.error_code)
+
+ project_list = get_child_job_project_name(job.job_id)
+ doc.ProjectList(project_list)
+ }
+ generate_xml_sub_jobs(doc,job.job_id)
+ }
+ end
+ end
+
+ def log_more
line_cnt = 999
conti= 1
id = params[:id]
end
# Get log file infomation
- file_name = "log"
- buildsvr_path = Server_config.find(:first, :conditions => ["property = ?", "path"])
- directory = "#{buildsvr_path.value}/jobs/#{id}"
-
- # create the file path
- path = File.join(directory, file_name)
-
- # read the file
- if File.exist?(path)
- @cursor = File.size(path)
- @file = File.open(path, 'r')
- data = @file.readlines
- end
+ server_id = Server_config.find(:first, :conditions => ["property = \"id\""])
+ svr_dir = File.join(Utils::DIBS_WEB_CONFIG_PATH, server_id.value)
+ log_dir = File.join(svr_dir, "log")
+ path = File.join(log_dir, "#{id}.log")
time = Time.new
timestamp = time.getlocal
-
- start_line = line
- last_line = start_line + line_cnt
-
- #count line
- tok = nil
- IO.popen("wc -l #{path}") do |wc|
- tok = wc.read.split(" ")
+
+ #check svr dir
+ if not File.exist?(svr_dir) then
+ render :text => "[#{svr_dir}] does not exist. please mail to server administrator", :status => 406
+ return
end
- end_line = tok[0].to_i
-
- #check line
- if last_line > end_line
- last_line = end_line
+
+ #check log dir
+ if not File.exist?(log_dir) then
+ FileUtils.mkdir_p(log_dir)
end
+
+ #check file exist
+ if not File.exist?(path) then
+ #if file does not exist then execute query-log command
+ Utils.sbi_query_log_command(id, path)
+ sleep(1)
+ conti = 1
+ else
+ start_line = line
+ last_line = start_line + line_cnt
+
+ #count line
+ tok = nil
+ IO.popen("wc -l #{path}") do |wc|
+ tok = wc.read.split(" ")
+ end
+ end_line = tok[0].to_i
+
+ #check line
+ if last_line > end_line
+ last_line = end_line
+ end
- #read log file
- temp = nil
- if start_line < end_line
- IO.popen("sed -n \"#{start_line},#{last_line}p\" #{path}") do |sed|
- temp = sed.read
+ #read log file
+ log_contents = nil
+ if start_line <= end_line
+ IO.popen("sed -n \"#{start_line},#{last_line}p\" #{path}") do |sed|
+ log_contents = sed.read
+ if log_contents.include? "=LOG_END" then
+ conti = 0
+ end
+ end
end
- else
- conti= 0
end
#generate to XML
doc.Status(job.status)
doc.Time(timestamp)
doc.Continue(conti)
- if temp
- temp.each do |data|
+ if log_contents
+ log_contents.each do |data|
doc.LogData(data, "Line" => line)
line = line + 1
end
# Check job builder
if get_user_email != job.user_email
if not is_admin(get_user_email)
- render :text => "You don't have authority to calcel.", :status => 406
+ render :text => "You don't have authority to cancel.", :status => 406
return
end
end
# Excute command
+ message = ""
begin
- Utils.sbi_cancel_command(id, job.project_password)
+ result, message = Utils.sbi_cancel_command(id, get_user_email, get_user_password)
rescue => e
render :text => e.message, :status => 406
- return
end
- render :xml=> "<Message>OK</Message>"
+
+ #generate to XML
+ doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
+ doc.Responser {
+ generate_xml_header(doc)
+ doc.Data {
+ doc.JobId(id)
+ doc.Distribution(job.distribution_name)
+ doc.Project(job.project_name)
+ doc.Builder(job.user_name)
+ doc.Status(job.status)
+ doc.Message(message)
+ }
+ }
+
+ render :text => out_string, :content_type => "text/xml"
end
end
# get information : dist_name, project_hash, password
change_group_list = params[:ChangeInfoList]
+ distribution_list = []
project_list = []
os_list = []
- password_list = []
dist_name = nil
+ if change_group_list.nil? or change_group_list.empty?
+ errmsg = "Build project is empty"
+ render :json => { :error => errmsg }, :status => 406
+ return
+ end
+
change_group_list.each do |change_item|
- dist_name = change_item[:distribution]
- project_name = change_item[:projectName]
- os = change_item[:os]
+ project_id = change_item[:projectId]
+ os_id = change_item[:osId]
- distribution = Distribution.find(:first, :conditions => ["name = ?", dist_name])
- project = Project.find(:first, :conditions => ["name = ? AND distribution_id =?", project_name, distribution.id])
+ project = Project.find(:first, :conditions => ["id = ?", project_id])
+ if project_list.nil?
+ errmsg = "Can't find project information: [#{project_id}]"
+ render :json => { :error => errmsg }, :status => 406
+ return
+ end
+ os = SupportedOs.find(:first, :conditions => ["id = ?", os_id])
+ if os.nil?
+ errmsg = "Can't find os information: [#{os_id}]"
+ render :json => { :error => errmsg }, :status => 406
+ return
+ end
+ distribution_list.push project.distribution_id
project_list.push project.name
- password_list.push project.password
- os_list.push os
+ os_list.push os.name
end
+ distribution_list.uniq!
project_list.uniq!
os_list.uniq!
- password_list.uniq!
-
- if (project_list.length > 1) or (not (project_list[0].nil? or project_list[0].empty?))
- # execute build command
- begin
- Utils.sbi_build_command(dist_name, project_list, os_list, password_list, get_user_email)
- rescue => e
- render :text => e.message, :status => 406
- return
+
+ if(distribution_list.length > 1)
+ errmsg = "Can't build multiple distribution"
+ render :json => { :error => errmsg }, :status => 406
+ return
+ end
+ distribution = Distribution.find(:first, :conditions => ["id = ?", distribution_list[0]])
+
+ # execute build command
+ begin
+ result, job_id, msg = Utils.sbi_build_command(distribution.name, project_list, os_list, get_user_email, get_user_password)
+ if result then
+ render :json => { :result => "SUCCESS", :job_id => job_id }
+ else
+ render :json => { :result => "ERROR", :message => msg }
end
-
- render :json => { :success => "OK!" }
- else
- render :text => "Can't build project", :status => 406
+ rescue => e
+ render :text => e.message, :status => 406
end
end
end
def queryProjectsInfoInDistribution
- dist_name = params[:distribution]
+ dist_id = params[:distId]
+ if dist_id.nil?
+ errmsg = "Distribution id is null"
+ render :json => { :error => errmsg }, :status => 406
+ return
+ end
user_id = get_user_id
projects = Project.find_by_sql("SELECT projects.name AS project_name
, projects.id AS project_id
, users.email AS maintainer
FROM projects
- , distributions
, users
- WHERE distributions.name = \"#{dist_name}\"
- AND projects.distribution_id = distributions.id
- AND users.id = projects.user_id")
+ WHERE projects.distribution_id = #{dist_id}
+ AND users.id = projects.user_id
+ ORDER BY projects.name")
#generate to XML
doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
doc.ProjectList {
projects.each { |project|
doc.Project {
+ doc.Id(project.project_id)
doc.Name(project.project_name)
doc.Type(project.project_type)
doc.Maintainer(project.maintainer)
end
def queryProjectsInDistribution
- dist_name = params[:distribution]
+ dist_id = params[:distId]
+ if dist_id.nil?
+ render :text => "Distribution id is empty", :content_type => "text/xml", :status => 406
+ return
+ end
+
+ distribution = Distribution.find(:first, :conditions => ["id = ?", dist_id])
+ if distribution.nil?
+ render :text => "Can't find distribution information: #{dist_id}", :content_type => "text/xml", :status => 406
+ return
+ end
- distribution = Distribution.find(:first, :conditions => ["name = ?", dist_name])
projects = Project.find(:all, :conditions => ["distribution_id = ?", distribution.id], :order => "name")
osList = SupportedOs.find(:all)
generate_xml_header(doc)
doc.Data {
doc.BuildServerInfo {
- if not osList.nil?
- osList.each do |os|
- doc.supportedOs(os.name)
- end
+ osList.each do |os|
+ doc.SupportedOs{
+ doc.Id(os.id)
+ doc.Name(os.name)
+ }
end
+ doc.DistributionStatus(distribution.status)
}
projects.each do |project|
bin = ProjectBin.find(:first, :conditions => ["project_id = ?", project.id])
if checkUserAccessProject(user_id, project.id)
doc.BinaryProject {
- doc.ProjectName(project.name)
+ doc.Id(project.id)
+ doc.Name(project.name)
+ doc.Status(project.status)
if not bin.nil? then
doc.PackageName(bin.pkg_name)
end
}
else
doc.OtherBinaryProject {
- doc.ProjectName(project.name)
+ doc.Id(project.id)
+ doc.Name(project.name)
+ doc.Status(project.status)
if not bin.nil? then
doc.PackageName(bin.pkg_name)
end
}
end
else
- buildOsNameList = []
- prjOsLists = ProjectOs.find(:all, :conditions => ["project_id = ?", project.id])
-
- prjOsLists.each do |list|
- supported_os = SupportedOs.find(:first, :conditions => ["id = ?", list.supported_os_id])
- buildOsNameList.push(supported_os.name)
+ buildOsIdList = []
+ projectOsList = ProjectOs.find(:all, :conditions => ["project_id = ?", project.id])
+ projectOsList.each do |projectOs|
+ buildOsIdList.push(projectOs.supported_os_id)
end
if checkUserAccessProject(user_id, project.id)
doc.Project {
- doc.ProjectName(project.name)
- doc.OsList(buildOsNameList.join(","))
+ doc.Id(project.id)
+ doc.Name(project.name)
+ doc.Status(project.status)
+ doc.OsList(buildOsIdList.join(","))
}
else
doc.OtherProject {
- doc.ProjectName(project.name)
- doc.OsList(buildOsNameList.join(","))
+ doc.Id(project.id)
+ doc.Name(project.name)
+ doc.Status(project.status)
+ doc.OsList(buildOsIdList.join(","))
}
end
end
def queryDistribution
# get full distribution list
+ distribution_list = Distribution.find(:all, :conditions => ["status = 'OPEN'"])
+
+ #generate to XML
+ doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
+ doc.Response {
+ generate_xml_header(doc)
+
+ doc.Data {
+ distribution_list.each do |distribution|
+ doc.Distribution {
+ doc.Id(distribution.id)
+ doc.Name(distribution.name)
+ }
+ end
+ }
+ }
+
+ #send_data
+ render :text => out_string, :content_type => "text/xml"
+ end
+
+ def queryAllDistribution
+ # get full distribution list
distribution_list = Distribution.find(:all)
#generate to XML
doc.Data {
distribution_list.each do |distribution|
- doc.DistributionName(distribution.name)
+ doc.Distribution {
+ doc.Id(distribution.id)
+ doc.Name(distribution.name)
+ }
end
}
}
render :text => out_string, :content_type => "text/xml"
end
+ def queryAllProjectInOpenStatus
+ project_list = Project.find_by_sql("SELECT projects.name AS project_name
+ , projects.id AS project_id
+ , distributions.id AS distribution_id
+ , distributions.name AS distribution_name
+ FROM projects
+ , distributions
+ WHERE distributions.id = projects.distribution_id
+ AND distributions.status = 'OPEN'
+ ORDER BY projects.name")
+
+ doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 )
+ doc.Response {
+ generate_xml_header(doc)
+
+ doc.Data {
+ project_list.each do |project|
+ doc.Project{
+ doc.Id(project.project_id)
+ doc.Name(project.project_name)
+ doc.DistId(project.distribution_id)
+ doc.DistName(project.distribution_name)
+ }
+ end
+ }
+ }
+
+ #send_data
+ render :text => out_string, :content_type => "text/xml"
+ end
+
def projects
end
end
def binaryFileUpload
- dist_name = params[:distribution]
- project = params[:project]
+ project_id = params[:ProjectId]
uploaded_io = params[:file]
file_path = Rails.root.join('public', 'data', uploaded_io.original_filename)
file.write(uploaded_io.read)
end
- distribution = Distribution.find(:first, :conditions => ["name = ?", dist_name])
- project = Project.find(:first, :conditions => ["name = ? AND distribution_id =?", project, distribution.id])
+ project = Project.find(:first, :conditions => ["id = ?", project_id])
+ distribution = Distribution.find(:first, :conditions => ["id = ?", project.distribution_id])
if project.nil?
- render :nothing => true
+ render :text => "Can't find project information: [#{project_id}]", :content_type => "text/xml"
return
end
begin
- Utils.sbi_register_command(distribution.name, file_path, project.password, get_user_email)
+ Utils.sbi_register_command(distribution.name, file_path, get_user_email, get_user_password)
rescue => e
render :text => e.message, :status => 406
return
# constant
BUILD_SERVER_ADDRESS = "127.0.0.1"
+DIBS_PATH = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__))))
class Utils < ApplicationController
- def Utils.sbi_build_command(distribution, project_list, os_list, password_list, email)
- dibs_path = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__))))
+ def Utils.sbi_build_command(distribution, project_list, os_list, email, password)
+ job_id = nil
dibs_config = Server_config.find(:first, :conditions => ["property = \"port\""])
if dibs_config.nil?
- raise RuntimeError, "Build sever not started"
+ raise RuntimeError, "Can't find server port information"
else
dibs_address = BUILD_SERVER_ADDRESS + ":" + dibs_config.value
end
- options = "-d #{dibs_address} --async "
+ options = "-d #{dibs_address} --async -U #{email} -w \'#{password}\'"
options = options + " -N #{project_list.join(",")} -D #{distribution} "
if (os_list.length > 1) or (not os_list[0].nil?)
options = options + " -o #{os_list.join(",")} "
end
- if (password_list.length > 1) or (not (password_list[0].nil? or password_list[0].empty?))
- options = options + " -w #{password_list.join(",")} "
- end
- if not email.nil?
- options = options + " -U #{email} "
- end
- cmd = "#{dibs_path}/build-cli build #{options}"
+ cmd = "#{DIBS_PATH}/build-cli build #{options}"
puts "Build command"
puts "[[[#{cmd}]]]"
- return execute_shell_return(cmd)
+ result, msg = execute_shell_return(cmd)
+ msg.each { |line|
+ if line =~ /Info: Added new job "([0-9][0-9]*)" for.*/ then
+ job_id = $1
+ end
+ }
+ return result, job_id, msg
end
- def Utils.sbi_register_command(distribution, file_path, password, email)
- dibs_path = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__))))
+ def Utils.sbi_register_command(distribution, file_path, email, password)
dibs_config = Server_config.find(:first, :conditions => ["property = \"port\""])
if dibs_config.nil?
- raise RuntimeError, "Build sever not started"
+ raise RuntimeError, "Can't find server port information"
else
dibs_address = BUILD_SERVER_ADDRESS + ":" + dibs_config.value
end
- options = "-P #{file_path} -d #{dibs_address} -D #{distribution} --async "
- if (not password.nil?)
- options = options + " -w #{password}"
- end
- if not email.nil?
- options = options + " -U #{email} "
- end
+ options = "-P #{file_path} -d #{dibs_address} -D #{distribution} --async -U #{email} -w \'#{password}\' "
- cmd = "#{dibs_path}/build-cli register #{options}"
+ cmd = "#{DIBS_PATH}/build-cli register #{options}"
puts "Register command"
puts "[[[#{cmd}]]]"
return execute_shell_return(cmd)
end
- def Utils.sbi_cancel_command(job_id, password)
- dibs_path = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__))))
+ def Utils.sbi_cancel_command(job_id, email, password)
dibs_config = Server_config.find(:first, :conditions => ["property = \"port\""])
if dibs_config.nil?
- raise RuntimeError, "Build sever not started"
+ raise RuntimeError, "Can't find server port information"
else
dibs_address = BUILD_SERVER_ADDRESS + ":" + dibs_config.value
end
raise RuntimeError, "Invalid job id : #{job_id}"
end
- options = "-d #{dibs_address} "
- options = options + " -j #{job_id}"
- if (not password.nil?)
- options = options + " -w #{password}"
- end
+ options = "-d #{dibs_address} -j #{job_id} -U #{email} -w \'#{password}\' "
- cmd = "#{dibs_path}/build-cli cancel #{options}"
+ cmd = "#{DIBS_PATH}/build-cli cancel #{options}"
puts "Cancel command"
puts "[[[#{cmd}]]]"
- return execute_shell_return(cmd)
+ result, msg = execute_shell_return(cmd)
+ return result, msg
end
def Utils.sbi_fullbuild_command(server_name, dist_name)
- dibs_path = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__))))
-
options = "-n #{server_name} --dist #{dist_name} "
- cmd = "#{dibs_path}/build-svr fullbuild #{options}"
+ cmd = "#{DIBS_PATH}/build-svr fullbuild #{options}"
cmd = "which ruby"
puts "Fullbuild command"
puts "[[[#{cmd}]]]"
return execute_shell_return(cmd)
end
+ def Utils.sbi_query_log_command(job_id, path)
+ dibs_web_config_path = File.join(Utils::HOME,".build_tools","web_server")
+ dibs_config = Server_config.find(:first, :conditions => ["property = \"port\""])
+ if dibs_config.nil?
+ raise RuntimeError, "Can't find server port information"
+ else
+ dibs_address = BUILD_SERVER_ADDRESS + ":" + dibs_config.value
+ end
+
+ if job_id.nil? or path.nil? then
+ raise RuntimeError, "Invalid query command id : #{job_id} path : #{path}"
+ end
+
+ options = "-d #{dibs_address} "
+ options = options + " -j #{job_id}"
+ options = options + " --output #{path}"
+
+ cmd = "#{DIBS_PATH}/build-cli query-log #{options}"
+puts "Query-log command"
+puts "[[[#{cmd}]]]"
+
+ Thread.new do
+ system(cmd)
+ end
+
+ return path
+ end
+
def Utils.execute_shell_return(cmd)
+ result = false
result_lines = []
- ret = false
# get result
- #IO.popen("#{cmd}")
- system "#{cmd}"
+ IO.popen("#{cmd} 2>&1") do |io|
+ io.each do |line|
+ result_lines.push line
+ end
+ end
- return true
+ if $? == 0 then
+ result = true
+ end
+
+ return result, result_lines
end
+ # set static variable in WORKING_DIR, HOME
+ if defined?(WORKING_DIR).nil? then WORKING_DIR = Dir.pwd end
+ if defined?(HOME).nil? then
+ # get home directory, using Dir.chdir
+ Dir.chdir
+ HOME = Dir.pwd
+ Dir.chdir WORKING_DIR
+ end
+ DIBS_WEB_CONFIG_PATH = File.join(HOME,".build_tools","web_server")
end
class Job < ActiveRecord::Base
- attr_accessible :distribution_id, :id, :supported_os_id, :project_id, :status, :user_id, :remote_build_server_id, :parent_job_id, :source_id, :jtype, :start_time, :end_time
+ attr_accessible :distribution_id, :id, :supported_os_id, :project_id, :status, :user_id, :remote_build_server_id, :parent_job_id, :source_id, :jtype, :start_time, :end_time, :error_code
end
class Project < ActiveRecord::Base
- attr_accessible :id, :distribution_id, :name, :ptype, :password
+ attr_accessible :id, :distribution_id, :name, :ptype, :status
end
class User < ActiveRecord::Base
# has_many :user_groups
# has_many :groups, :through => :user_groups
- attr_accessible :id, :email, :password, :password_confirmation, :name
+ attr_accessible :id, :email, :password, :password_confirmation, :password_hash, :name
attr_accessor :password
before_save :encrypt_password
get "jobs" => "jobs#list"
- get "projects" => "projects#projects"
get "projects/fileUpload"
get "signup" => "users#new", :as => "signup"
get "jobs/list/date/:date/:distribution/:status/:lastID" => "jobs#listSearchDate", :constraints => { :distribution => /[0-9A-Za-z\-\.\_]+/ }
match "jobs/update" => "jobs#updateList", :format => "json"
- match "jobs/log/:id" => "jobs#log"
match "jobs/log/:id/:line" => "jobs#log_more"
match "jobs/cancel/:id" => "jobs#cancelJob"
get "projects/queryDistribution"
- match "projects/queryProject/:distribution" => "projects#queryProject", :constraints => { :distribution => /[0-9A-Za-z\-\.\_]+/ }
+ get "projects/queryAllDistribution"
+ get "projects/queryAllProjectInOpenStatus"
post "projects/binaryFileUpload"
# projects
- match "projects/queryRunningProjectsInfoInDistribution/:distribution" => "projects#queryRunningProjectsInfoInDistribution", :constraints => { :distribution => /[0-9A-Za-z\-\.\_]+/ }
- match "projects/queryProjectsInfoInDistribution/:distribution" => "projects#queryProjectsInfoInDistribution", :constraints => { :distribution => /[0-9A-Za-z\-\.\_]+/ }
- match "projects/queryProjectsInDistribution/:distribution" => "projects#queryProjectsInDistribution" , :constraints => { :distribution => /[0-9A-Za-z\-\.\_]+/ }
+ match "projects/queryProjectsInfoInDistribution/:distId" => "projects#queryProjectsInfoInDistribution"
+ match "projects/queryProjectsInDistribution/:distId" => "projects#queryProjectsInDistribution"
post "projects/buildProject"
# admin group
get "admin_group/queryAllGroup"
- match "admin_group/queryGroupInfo/:groupName" => "admin_group#queryGroupInfo"
+ match "admin_group/queryGroupInfo/:groupId" => "admin_group#queryGroupInfo"
post "admin_group/addGroup"
post "admin_group/removeGroup"
post "admin_group/modifyGroup"
# admin server
get "admin_server/queryAllServer"
+ match "admin_server/queryServerConfig/:configId" => "admin_server#queryServerConfig"
+ match "admin_server/querySupportedOS/:osId" => "admin_server#querySupportedOS"
+ match "admin_server/queryRemoteBuildServer/:serverId" => "admin_server#queryRemoteBuildServer"
post "admin_server/addRemoteBuildServer"
post "admin_server/removeRemoteBuildServer"
post "admin_server/modifyRemoteBuildServer"
- post "admin_server/addOsCategory"
- post "admin_server/removeOsCategory"
- post "admin_server/modifyOsCategory"
+ post "admin_server/addOSCategory"
+ post "admin_server/removeOSCategory"
+ post "admin_server/modifyOSCategory"
post "admin_server/addSupportedOS"
post "admin_server/removeSupportedOS"
post "admin_server/modifySupportedOS"
post "admin_server/modifyServerInfo"
# admin project
- get "admin_project/queryAllProject"
- match "admin_project/queryProjectsInDistributionForAdmin/:distribution" => "admin_project#queryProjectsInDistributionForAdmin", :constraints => { :distribution => /[0-9A-Za-z\-\.\_]+/ }
+ match "admin_project/queryProjectsInDistributionForAdmin/:distId" => "admin_project#queryProjectsInDistributionForAdmin"
post "admin_project/addProject"
post "admin_project/removeProject"
post "admin_project/modifyProject"
+ post "admin_project/changeAllProjectStatus"
# admin distribution
- match "admin_distribution/queryDistributionInfo/:distribution" => "admin_distribution#queryDistributionInfo", :constraints => { :distribution => /[0-9A-Za-z\-\.\_]+/ }
+ match "admin_distribution/queryDistributionInfo/:distId" => "admin_distribution#queryDistributionInfo"
post "admin_distribution/addDistribution"
post "admin_distribution/removeDistribution"
post "admin_distribution/modifyDistribution"
- post "admin_distribution/fullBuildDistribution"
-
get "admin/queryAllOS"
get "admin/queryAllOSCategory"
<div data-role="content">
<form id="login-form">
<label for="login-form-email" >Email</label>
- <input id="login-form-email" type="email" name="email"/>
- <label for="login-form-password">Password</label>
- <input id="login-form-password" type="password" name="password"/>
+ <span style="float: left; width: 80%;">
+ <input id="login-form-email" type="email" name="email" autocomplete="on"/>
+ </span>
+ <span style="float: right;">
+ <input id="login-form-save" type="checkbox" name="save" class="custom" data-mini="true" checked/>
+ <label for="login-form-save">Save</label>
+ </span>
+ <div style="clear: both; float: left;">
+ <label for="login-form-password">Password</label>
+ </div>
+ <div style="clear: both;">
+ <input id="login-form-password" type="password" name="password"/>
+ </div>
<br/>
- <div data-role="controlgroup" data-type="horizontal">
+ <div data-role="controlgroup" data-type="horizontal" style="float: left;">
<a href="#" data-rel="back" data-role="button" data-mini="true" >Cancel</a>
<a href="#" onClick="sessionLogin()" data-role="button" data-mini="true" >Log in</a>
</div>
<div data-role="content" >
<div class="content-primary">
<div data-role="fieldcontain" style="text-align: center; font-size: 14px;">
- <select id="projects-distribution-select" data-native-menu="false" onchange='projectsQueryProjectListType("MY")'>
+ <select id="projects-distribution-select" data-native-menu="false" onchange='projectsQueryProjectListType()'>
</select>
</div>
<br>
<div id="projects-type-select">
<fieldset data-role="controlgroup" data-type="horizontal" data-mini="true">
<form>
- <input type="radio" name="radio-choice" id="projects-type-select-1" checked="checked" onClick='projectsQueryProjectListType("MY")' />
+ <input type="radio" name="projects-type-select" id="projects-type-select-1" value="MY" checked="checked" onClick='projectsQueryProjectListType()' />
<label for="projects-type-select-1">MY PROJECT</label>
- <input type="radio" name="radio-choice" id="projects-type-select-2" onClick='projectsQueryProjectListType("ALL")'/>
+ <input type="radio" name="projects-type-select" id="projects-type-select-2" value="ALL" onClick='projectsQueryProjectListType()'/>
<label for="projects-type-select-2">ALL PROJECT</label>
- <input type="radio" name="radio-choice" id="projects-type-select-3" onClick='projectsQueryProjectListType("GIT")' />
+ <input type="radio" name="projects-type-select" id="projects-type-select-3" value="GIT" onClick='projectsQueryProjectListType()' />
<label for="projects-type-select-3">GIT PROJECT</label>
- <input type="radio" name="radio-choice" id="projects-type-select-4" onClick='projectsQueryProjectListType("BINARY")' />
+ <input type="radio" name="projects-type-select" id="projects-type-select-4" value="BINARY" onClick='projectsQueryProjectListType()' />
<label for="projects-type-select-4">BINARY PROJECT</label>
</form>
</fieldset>
</select>
</div>
</div>
+ <div id="build-distribution-lock"> </div>
<div data-role="collapsible" data-collapsed="false" style="width: auto;" >
<h3>Git project</h3>
<div align="right" style="font-size: 10px">
<a href="#" onClick="searchJobDate()" data-role="button" data-mini="true" data-inline="true">Search</a>
</div>
<br>
-
+ <br>
<ul id="jobs-job-list" data-role="listview">
</ul>
<br>
</div>
<div data-role="content">
<form method="post" style="font-size: 12px">
+ <input type="hidden" id="adminUserModify-id" name="id" />
+ <br>
<label for="adminUserModify-name"> User name </label>
- <input type="text" id="adminUserModify-name" name="adminUserModify-contents" />
+ <input type="text" id="adminUserModify-name" name="name" />
<br>
<label for="adminUserModify-email"> Email </label>
- <input type="text" id="adminUserModify-email" name="adminUserModify-contents" disabled="disabled"/>
+ <input type="text" id="adminUserModify-email" name="email" />
<br>
<div>
<fieldset data-role="controlgroup" data-mini="true" data-role="fieldcontain" id="adminUserModify-group">
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href=#adminUser onClick="adminUserModify()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href=#adminUser onClick="adminUserModify()" data-role="button" data-inline="true" data-mini="true" data-icon="gear" id="adminUserModify-save">Save</a>
</div>
</div><!-- /page -->
<div class="content-primary">
<h2>Group information</h2>
<div align="right" style="font-size: 10px">
- <a href="#adminGroupAdd" data-role="button" data-rel="dialog" data-inline="true" data-icon="plus"> Add group </a>
+ <a href="#adminGroupAdd" data-role="button" data-rel="dialog" data-inline="true" data-mini="ture" data-icon="plus"> Add group </a>
</div>
<div data-role="content" class="container">
<table class="imagetable" style="font-size: 14px" id="adminGroup-contents">
<div class="content-primary">
<h2>Server information</h2>
<div align="right" style="font-size: 10px">
- <a href="#adminServerAddServerInfo" data-role="button" data-rel="dialog" data-inline="true" data-icon="plus"> Add server config </a>
+ <a href="#adminServerAddServerInfo" data-role="button" data-rel="dialog" data-inline="true" data-mini="ture" data-icon="plus"> Add server config </a>
</div>
<div data-role="collapsible" data-theme="c" data-content-theme="d" data-collapsed="false">
<h2> Server info </h2>
</ul>
</div>
<div align="right" style="font-size: 10px">
- <a href="#adminServerAddSupportedOs" data-role="button" data-rel="dialog" data-inline="true" data-icon="plus"> Add supported os</a>
- <a href="#adminServerAddOSCategory" data-role="button" data-rel="dialog" data-inline="true" data-icon="plus"> Add os category</a>
- <a href="#adminServerRemoveOSCategory" data-role="button" data-rel="dialog" data-inline="true" data-icon="minus"> Remove os category</a>
+ <a href="#adminServerAddSupportedOs" data-role="button" data-rel="dialog" data-inline="true" data-mini="ture" data-icon="plus"> Add supported os</a>
+ <a href="#adminServerAddOSCategory" data-role="button" data-rel="dialog" data-inline="true" data-mini="ture" data-icon="plus"> Add os category</a>
+ <a href="#adminServerRemoveOSCategory" data-role="button" data-rel="dialog" data-inline="true" data-mini="ture" data-icon="minus"> Remove os category</a>
</div>
<div data-role="collapsible" data-theme="c" data-content-theme="d" data-collapsed="false">
<h2> Supported OS </h2>
</ul>
</div>
<div align="right" style="font-size: 10px">
- <a href="#adminServerAddRemoteBuildServer" data-role="button" data-rel="dialog" data-inline="true" data-icon="plus"> Add remote build server </a>
+ <a href="#adminServerAddRemoteBuildServer" data-role="button" data-rel="dialog" data-inline="true" data-mini="ture" data-icon="plus"> Add remote build server </a>
</div>
<div data-role="collapsible" data-theme="c" data-content-theme="d" data-collapsed="false">
<h2> Remote build server </h2>
</div>
</div>
<div>
+ <div align="right" style="font-size: 10px">
+ <a href="#" data-role="button" data-inline="true" data-mini="true" onClick='adminProjectAllProjectStatusChange("OPEN")'>ALL project OPEN</a>
+ <a href="#" data-role="button" data-inline="true" data-mini="true" onClick='adminProjectAllProjectStatusChange("CLOSE")'>ALL project CLOSE</a>
+ </div>
<div style="margin-left: 20px; margin-right: 20px; margin-top: 10px">
<div data-role="collapsible" data-theme="b" data-content-theme="c" data-collapsed="false" >
<h2> Git project </h2>
<div align="right" style="font-size: 10px">
- <a href="#adminProjectAddGit" data-role="button" data-rel="dialog" data-inline="true" data-icon="plus"> Add git project</a>
+ <a href="#adminProjectAddGit" data-role="button" data-rel="dialog" data-inline="true" data-mini="true" data-icon="plus"> Add git project</a>
</div>
<br>
<table class="imagetable" id="adminProject-git" style="font-size: 14px">
<div data-role="collapsible" data-theme="b" data-content-theme="c" data-collapsed="false" >
<h2> Binary project </h2>
<div align="right" style="font-size: 10px">
- <a href="#adminProjectAddBinary" data-role="button"data-rel="dialog" data-inline="true" data-icon="plus"> Add binary project</a>
+ <a href="#adminProjectAddBinary" data-role="button"data-rel="dialog" data-inline="true" data-mini="true" data-icon="plus"> Add binary project</a>
</div>
<table class="imagetable" id="adminProject-binary" style="font-size: 14px">
</table>
<select id="adminDistribution-distribution-select" data-native-menu="false" onchange="adminDistributionSetInfo()">
</select>
</div>
- <div align="right" style="font-size: 10px">
- <a href="javascript:adminDistributionFullBuild()" data-role="button" data-inline="true" data-icon="gear"> Full build</a>
- </div>
<div data-role="collapsible" data-theme="c" data-content-theme="d" data-collapsed="false" >
<h2> Package server url </h2>
<p id="adminDistribution-url" style="font-size: 14px"> </p>
</div>
<br>
<div align="right" style="font-size: 10px">
- <a href="#adminDistributionAdd" data-role="button" data-rel="dialog" data-inline="true" data-icon="plus"> Add distribution</a>
- <a href="#adminDistributionModify" data-role="button" data-rel="dialog" data-inline="true" data-icon="gear"> Modify distribution</a>
- <a href="javascript:adminDistributionRemove()" data-role="button" data-rel="dialog" data-inline="true" data-icon="minus"> Remove distribution</a>
+ <a href="#adminDistributionAdd" data-role="button" data-rel="dialog" data-inline="true" data-mini="true" data-icon="plus"> Add distribution</a>
+ <a href="#adminDistributionModify" data-role="button" data-rel="dialog" data-inline="true" data-mini="true" data-icon="gear"> Modify distribution</a>
+ <a href="javascript:adminDistributionRemove()" data-role="button" data-rel="dialog" data-inline="true" data-mini="true" data-icon="minus"> Remove distribution</a>
</div>
</div>
</div><!--/content-primary -->
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href=# onClick="adminDistributionAdd()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href=# onClick="adminDistributionAdd()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
</div>
<div data-role="content">
<form method="post" style="font-size: 12px">
+ <input type="hidden" id="adminDistributionModify-id" name="id" />
+ <br>
<label for="adminDistributionModify-url"> Package server url </label>
<input type="text" id="adminDistributionModify-url" name="description" />
<br>
<label for="adminProjectAddGit-name"> Project name </label>
<input type="text" id="adminProjectAddGit-name" name="name" />
<br>
- <label for="adminProjectAddGit-password"> Project password </label>
- <input type="text" id="adminProjectAddGit-password" name="password" />
- <br>
<label for="adminProjectAddGit-address"> Git address </label>
<input type="text" id="adminProjectAddGit-address" name="address" />
<br>
<label for="adminProjectAddGit-branch"> Git Branch </label>
<input type="text" id="adminProjectAddGit-branch" name="branch" />
<br>
+ <label for="adminProjectAddGit-status"> Project status </label>
+ <select id="adminProjectAddGit-status" name="status" >
+ </select>
+ <br>
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" data-mini="true" id="adminProjectAddGit-os" name="os" >
</fieldset>
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href="#adminProject" onClick="adminProjectAddGitProject()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href="#adminProject" onClick="adminProjectAddGitProject()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
<label for="adminProjectAddBinary-name"> Project name </label>
<input type="text" id="adminProjectAddBinary-name" name="name" />
<br>
- <label for="adminProjectAddBinary-password"> Project password</label>
- <input type="text" id="adminProjectAddBinary-password" name="password" />
- <br>
<label for="adminProjectAddBinary-packagename"> Pakcage name</label>
<input type="text" id="adminProjectAddBinary-packagename" name="name" />
+ <br>
+ <label for="adminProjectAddBinary-status"> Project status </label>
+ <select id="adminProjectAddBinary-status" name="status" >
+ </select>
+ <br>
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" data-mini="true" id="adminProjectAddBinary-os" name="os" >
</fieldset>
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href="#" onClick="adminProjectAddBinaryProject()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href="#" onClick="adminProjectAddBinaryProject()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
</div>
<div data-role="content">
<form method="post" style="font-size: 12px">
- <input type="hidden" id="adminProjectModifyBinary-oldName" disabled="disabled" name="name" />
+ <input type="hidden" id="adminProjectModifyBinary-id" disabled="disabled" name="id" />
<br>
- <label for="adminProjectModifyBinary-newName"> New Project name </label>
- <input type="text" id="adminProjectModifyBinary-newName" name="name" />
+ <label for="adminProjectModifyBinary-name"> Project name </label>
+ <input type="text" id="adminProjectModifyBinary-name" name="name" />
<br>
- <label for="adminProjectModifyBinary-password"> Project password</label>
- <input type="text" id="adminProjectModifyBinary-password" name="name" />
+ <label for="adminProjectModifyBinary-status"> Project status </label>
+ <select id="adminProjectModifyBinary-status" name="status" >
+ </select>
<br>
<label for="adminProjectModifyBinary-packageName"> Pakcage name</label>
<input type="text" id="adminProjectModifyBinary-packageName" name="name" />
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href="#" onClick="adminProjectModfyBinaryProject()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href="#" onClick="adminProjectModfyBinaryProject()" data-role="button" data-inline="true" data-mini="true" data-icon="gear" id="adminProjectModifyBinary-save">Save</a>
</div>
</div><!-- /page -->
</div>
<div data-role="content">
<form method="post" style="font-size: 12px">
- <input type="hidden" id="adminProjectModifyGit-oldName" disabled="disabled" name="name" />
+ <input type="hidden" id="adminProjectModifyGit-id" disabled="disabled" name="id" />
<br>
- <label for="adminProjectModifyGit-newName"> New Project name </label>
- <input type="text" id="adminProjectModifyGit-newName" name="name" />
+ <label for="adminProjectModifyGit-name"> Project name </label>
+ <input type="text" id="adminProjectModifyGit-name" name="name" />
<br>
- <label for="adminProjectModifyGit-password"> Project password</label>
- <input type="text" id="adminProjectModifyGit-password" name="password" />
+ <label for="adminProjectModifyGit-status"> Project status </label>
+ <select id="adminProjectModifyGit-status" name="status" >
+ </select>
<br>
<label for="adminProjectModifyGit-address"> Git address </label>
<input type="text" id="adminProjectModifyGit-address" name="address" />
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href="#" onClick="adminProjectModfyGitProject()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href="#" onClick="adminProjectModfyGitProject()" data-role="button" data-inline="true" data-mini="true" data-icon="gear" id="adminProjectModifyGit-save">Save</a>
</div>
</div><!-- /page -->
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href=# onClick="adminGroupAddGroup()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href=# onClick="adminGroupAddGroup()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
</div>
<div data-role="content" data-role="fieldcontain">
<form method="post" style="font-size: 12px">
- <input type="hidden" id="adminGroupModify-oldName" name="name" />
+ <input type="hidden" id="adminGroupModify-id" name="id" />
<br>
- <label for="adminGroupModify-newName"> New group name </label>
- <input type="text" id="adminGroupModify-newName" name="name" />
+ <label for="adminGroupModify-name"> Group name </label>
+ <input type="text" id="adminGroupModify-name" name="name" />
<br>
<div data-role="fieldcontain">
<label for="adminGroupModify-admin"> Admin Flag </label>
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href="#" onClick="adminGroupModifyGroup()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href="#" onClick="adminGroupModifyGroup()" data-role="button" data-inline="true" data-mini="true" data-icon="gear" id="adminGroupModify-save">Save</a>
</div>
</div><!-- /page -->
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href=# onClick="adminServerAddRemoteBuildServer()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href=# onClick="adminServerAddRemoteBuildServer()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
</div>
<div data-role="content" data-role="fieldcontain">
<form method="post" style="font-size: 12px">
- <input type="hidden" id="adminServer-modifyRemoteBuildServer-OldAddress" name="address" />
+ <input type="hidden" id="adminServer-modifyRemoteBuildServer-id" name="id" />
<br>
- <label for="adminServer-modifyRemoteBuildServer-newAddress"> New server address </label>
- <input type="text" id="adminServer-modifyRemoteBuildServer-newAddress" name="address" />
+ <label for="adminServer-modifyRemoteBuildServer-address"> Server address </label>
+ <input type="text" id="adminServer-modifyRemoteBuildServer-address" name="address" />
<br>
<label for="adminServer-modifyRemoteBuildServer-description"> Description </label>
<input type="text" id="adminServer-modifyRemoteBuildServer-description" name="description" />
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href=# onClick="adminServerModifyRemoteBuildServer()" data-role="button" data-inline="true" data-icon="gear">Save</a>
- <a href=# onClick="adminServerRemoveRemoteBuildServer()" data-role="button" data-inline="true" data-icon="minus">Delete</a>
+ <a href=# onClick="adminServerModifyRemoteBuildServer()" data-role="button" data-inline="true" data-mini="true" data-icon="gear" id="adminServer-modifyRemoteBuildServer-save" >Save</a>
+ <a href=# onClick="adminServerRemoveRemoteBuildServer()" data-role="button" data-inline="true" data-mini="true" data-icon="minus">Delete</a>
</div>
</div><!-- /page -->
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href="#" onClick="userModifyUserInfo()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href="#" onClick="userModifyUserInfo()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
</div>
<div data-role="content" data-role="fieldcontain">
<form method="post" style="font-size: 12px">
- <label for="adminServer-AddSupportedOs-OsName">Supported os name</label>
- <input type="text" id="adminServer-AddSupportedOs-OsName" name="os" />
+ <input type="hidden" id="adminServer-AddSupportedOs-id" name="id" />
+ <br>
+ <label for="adminServer-AddSupportedOs-name">Supported os name</label>
+ <input type="text" id="adminServer-AddSupportedOs-name" name="name" />
<br>
<div data-role="fieldcontain">
<label for="adminServer-AddSupportedOs-OsCategory"> Os category </label>
<br>
- <select id="adminServer-AddSupportedOs-OsCategory" name="os-category" >
+ <select id="adminServer-AddSupportedOs-OsCategory" name="category" >
</select>
</div>
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href="#" onClick="adminServerAddSupportedOs()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href="#" onClick="adminServerAddSupportedOs()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
</div>
<div data-role="content" data-role="fieldcontain">
<form method="post" style="font-size: 12px">
- <input type="hidden" id="adminServer-ModifySupportedOs-OldOsName" disabled="disabled" name="name" />
- <label for="adminServer-ModifySupportedOs-OsName">Supported os name</label>
- <input type="text" id="adminServer-MoidfySupportedOs-OsName" name="name" />
+ <input type="hidden" id="adminServer-ModifySupportedOs-id" name="id" />
+ <br>
+ <label for="adminServer-ModifySupportedOs-name">Supported os name</label>
+ <input type="text" id="adminServer-MoidfySupportedOs-name" name="name" />
<br>
<div data-role="fieldcontain">
<label for="adminServer-ModifySupportedOs-OsCategory"> Os category </label>
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href="#" onClick="adminServerRemoveSupportedOS()" data-role="button" data-inline="true" data-icon="minus">Remove</a>
- <a href="#" onClick="adminServerModifySupportedOS()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href="#" onClick="adminServerModifySupportedOS()" data-role="button" data-inline="true" data-mini="true" data-icon="gear" id="adminServer-ModifySupportedOs-save" >Save</a>
+ <a href="#" onClick="adminServerRemoveSupportedOS()" data-role="button" data-inline="true" data-mini="true" data-icon="minus">Remove</a>
</div>
</div><!-- /page -->
</div>
<div data-role="content" data-role="fieldcontain">
<form method="post" style="font-size: 12px">
- <label for="adminServer-AddOsCategory-Name">OS category name</label>
- <input type="text" id="adminServer-AddOsCategory-Name" name="name" />
+ <label for="adminServer-AddOsCategory-name">OS category name</label>
+ <input type="text" id="adminServer-AddOsCategory-name" name="name" />
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href="#" onClick="adminServerAddOSCategory()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href="#" onClick="adminServerAddOSCategory()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
<div data-role="page" id="adminServerRemoveOSCategory" style="height: 800px; width: 800px">
<div data-role="header" >
- <h1>Add os category</h1>
+ <h1>Remove os category</h1>
</div>
<div data-role="content" data-role="fieldcontain">
<form method="post" style="font-size: 12px">
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href="#" onClick="adminServerRemoveOSCategory()" data-role="button" data-inline="true" data-icon="minus">Delete</a>
+ <a href="#" onClick="adminServerRemoveOSCategory()" data-role="button" data-inline="true" data-mini="true" data-icon="minus">Delete</a>
</div>
</div><!-- /page -->
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href=# onClick="adminServerAddServerInfo()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href=# onClick="adminServerAddServerInfo()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
</div>
<div data-role="content" data-role="fieldcontain">
<form method="post" style="font-size: 12px">
+ <input type="hidden" id="adminServer-modifyServerInfo-id" name="property" />
+ <br>
<label for="adminServer-modifyServerInfo-property"> Property</label>
- <input type="text" id="adminServer-modifyServerInfo-property" disabled="disabled" name="property" />
+ <input type="text" id="adminServer-modifyServerInfo-property" name="property" />
<br>
<label for="adminServer-modifyServerInfo-value"> Value </label>
<input type="text" id="adminServer-modifyServerInfo-value" name="value" />
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href=# onClick="adminServerModifyServerInfo()" data-role="button" data-inline="true" data-icon="gear">Save</a>
- <a href=# onClick="adminServerRemoveServerInfo()" data-role="button" data-inline="true" data-icon="minus">Delete</a>
+ <a href=# onClick="adminServerModifyServerInfo()" data-role="button" data-inline="true" data-mini="true" data-icon="gear" id="adminServer-modifyServerInfo-save">Save</a>
+ <a href=# onClick="adminServerRemoveServerInfo()" data-role="button" data-inline="true" data-mini="true" data-icon="minus">Delete</a>
</div>
</div><!-- /page -->
*/
function adminDistributionModifyPopupInit() {
- var distName = $("#adminDistribution-distribution-select option:selected").val();
+ var distId = $("#adminDistribution-distribution-select option:selected").val();
var packageServerUrl = $("#adminDistribution-url").html();
var packageServeraddress = $("#adminDistribution-address").html();
var serverStatusText = $("#adminDistribution-status").html();
syncPkgSvrDescription = ""
}
+ $("#adminDistributionModify-id").val(distId);
$("#adminDistributionModify-url").val(packageServerUrl);
$("#adminDistributionModify-address").val(packageServeraddress);
$("#adminDistributionModify-description").val(serverDescription);
if(serverStatusText.toUpperCase() == "CLOSE") {
option = '<option value="CLOSE" selected="selected">CLOSE</option>';
} else {
- option = '<option value="CLOSE">FALSE</option>';
+ option = '<option value="CLOSE">CLOSE</option>';
}
$("#adminDistributionModify-status").append(option);
+
$("#adminDistributionModify-status").selectmenu("refresh");
}
function adminDistributionModify() {
var changeInfoList = [];
var changeInfoItem;
- var distName = $("#adminDistribution-distribution-select option:selected").val();
+ var distId = $("#adminDistributionModify-id").val();
var url = $("#adminDistributionModify-url").val();
var address = $("#adminDistributionModify-address").val();
var description = $("#adminDistributionModify-description").val();
var syncPkgSvrPeriod = $("#adminDistributionModify-syncPackageServer-period").val();
var syncPkgSvrDescription = $("#adminDistributionModify-syncPackageServer-description").val();
- if(distName == "" || url == "" || address == ""){
+ if(distId == "" || url == "" || address == ""){
alert("You must input full data");
return;
}
distStatus = "OPEN";
}
- changeInfoItem = {"DistributionName":distName, "URL":url, "Address":address, "DistStatus":distStatus, "Description":description, "SyncPkgSvrUrl":syncPkgSvrUrl, "SyncPkgSvrPeriod":syncPkgSvrPeriod, "SyncPkgSvrDescription":syncPkgSvrDescription};
+ changeInfoItem = {"DistributionId":distId, "URL":url, "Address":address, "DistStatus":distStatus, "Description":description, "SyncPkgSvrUrl":syncPkgSvrUrl, "SyncPkgSvrPeriod":syncPkgSvrPeriod, "SyncPkgSvrDescription":syncPkgSvrDescription};
changeInfoList.push(changeInfoItem);
modifyDistribution( changeInfoList, function () {
*/
function adminDistributionInit() {
- queryDistribution( function (xml) {
- var oldDistName = $("#adminDistribution-distribution-select option:selected").val();
+ queryAllDistribution( function (xml) {
+ var oldDistId = $("#adminDistribution-distribution-select option:selected").val();
var find = false;
- var distributionList = $(xml).find("Data").find("DistributionName");
+ var distributionList = $(xml).find("Data").find("Distribution");
// remove old select options
$("#adminDistribution-distribution-select").empty();
distributionList.each(function(){
- var name = $(this).text();
+ var distId = $(this).find("Id").text();
+ var distName = $(this).find("Name").text();
- if( oldDistName == name ) {
- $("#adminDistribution-distribution-select").append("<option value=\'"+name+"\' selected=\"selected\">"+name+"</option>");
+ if( oldDistId == distId ) {
+ $("#adminDistribution-distribution-select").append("<option value=\'"+distId+"\' selected=\"selected\">"+distName+"</option>");
find = true;
} else {
- $("#adminDistribution-distribution-select").append("<option value=\'"+name+"\'>"+name+"</option>");
+ $("#adminDistribution-distribution-select").append("<option value=\'"+distId+"\'>"+distName+"</option>");
}
});
}
function adminDistributionSetInfo() {
- var distName = $("#adminDistribution-distribution-select option:selected").val();
+ var distId = $("#adminDistribution-distribution-select option:selected").val();
- queryDistributionInfo( distName, function (xml) {
- var data = $(xml).find("Data").find("DistributionInfo");
+ queryDistributionInfo( distId, function (xml) {
var syncPackageServer = $(xml).find("Data").find("SyncPackageServer");
- var name = data.find("DistributionName").text();
- var url = data.find("PackageServerUrl").text();
- var address = data.find("PackageServerAddress").text();
- var distStatus = data.find("Status").text();
- var distDescription = data.find("Description").text();
+ var distInfo = $(xml).find("Data").find("DistributionInfo");
+ var id = distInfo.find("Id").text();
+ var name = distInfo.find("Name").text();
+ var url = distInfo.find("PackageServerUrl").text();
+ var address = distInfo.find("PackageServerAddress").text();
+ var distStatus = distInfo.find("Status").text();
+ var distDescription = distInfo.find("Description").text();
$("#adminDistribution-url").text(url);
$("#adminDistribution-address").text(address);
function adminDistributionRemove() {
var changeInfoList = [];
var changeInfoItem;
- var distName = $("#adminDistribution-distribution-select option:selected").val();
+ var distId = $("#adminDistribution-distribution-select option:selected").val();
- changeInfoItem = {"DistributionName":distName};
+ changeInfoItem = {"DistributionId":distId};
changeInfoList.push(changeInfoItem);
- var r=confirm("Distribution ["+distName+"] will be removed!!!");
+ var r=confirm("Distribution will be removed!!!");
if (r==false)
{
return;
$("#adminDistribution-syncPackageServer").append(info);
}
-
-function adminDistributionFullBuild() {
- var changeInfoList = [];
- var changeInfoItem;
- var distName = $("#adminDistribution-distribution-select option:selected").val();
-
- changeInfoItem = {"DistributionName":distName};
- changeInfoList.push(changeInfoItem);
-
- var r=confirm("Distribution ["+distName+"] fullbuild will be started!!! it takes several time");
- if (r==false)
- {
- return;
- }
-
- fullBuildDistribution( changeInfoList, function (xml) {
- $.mobile.changePage("#adminDistribution");
- });
-}
-
$("#adminGroupAdd-name").val("");
$("#adminGroupAdd-description").val("");
- queryAllProject( function(xml) {
+ queryAllProjectInOpenStatus( function(xml) {
var fullProjectList = $(xml).find("Data").find("Project");
adminGroupAddGenerateProjectSelect(fullProjectList);
- S-Core Co., Ltd
*/
-function adminGroupModifyInit() {
- var index = localStorage.groupTableIndex;
- var groupName = $("#adminGroup-contents-"+index+"-name").html();
- var adminFlagText = $("#adminGroup-contents-"+index+"-flag").html();
- var description = $("#adminGroup-contents-"+index+"-description").html();
-
- $("#adminGroupModify-oldName").val(groupName);
- $("#adminGroupModify-newName").val(groupName);
+function adminGroupModifyInit(groupId) {
+ var groupName = $("#adminGroup-contents-"+groupId+"-name").html();
+ var adminFlagText = $("#adminGroup-contents-"+groupId+"-flag").html();
+ var description = $("#adminGroup-contents-"+groupId+"-description").html();
+
+ $("#adminGroupModify-save").attr("onClick", "");
+ $("#adminGroupModify-id").val(groupId);
+ $("#adminGroupModify-name").val(groupName);
$("#adminGroupModify-description").val(description);
$("#adminGroupModify-admin").empty();
} else {
$("#adminGroupModify-admin").append('<option value="FALSE">FALSE</option>');
}
+ $("#adminGroupModify-admin").selectmenu();
$("#adminGroupModify-admin").selectmenu("refresh");
- queryGroupInfo(groupName, function(xml) {
+ queryGroupInfo(groupId, function(xml) {
var fullProjectList = $(xml).find("Data").find("Project");
var projectIdList = $(xml).find("Data").find("Group").find("ProjectIdList").text().split(",");
adminGroupModifyGenerateProjectSelect(fullProjectList, projectIdList);
+ $("#adminGroupModify-save").attr("onClick", "adminGroupModifyGroup()");
});
}
function adminGroupModifyGenerateProjectSelect(fullProjectList, projectIdList) {
$("#adminGroupModify-project").empty();
fullProjectList.each(function(){
- var projectName = $(this).find("Name").text();
var projectId = $(this).find("Id").text();
+ var projectName = $(this).find("Name").text();
var projectDistName = $(this).find("DistName").text();
var input;
}
function adminGroupModifyGroup() {
- var oldGroupName = $("#adminGroupModify-oldName").val();
- var groupName = $("#adminGroupModify-newName").val();
+ var groupId = $("#adminGroupModify-id").val();
+ var groupName = $("#adminGroupModify-name").val();
var description = $("#adminGroupModify-description").val();
var adminFlag = $("#adminGroupModify-admin option:selected").val();
var selectProjectList = [];
var changeInfoList = [];
- var selectArray = $("input[name='adminGroupModify-project-checkbox']");
- for(var i = 0; i < selectArray.length; i++) {
- if (selectArray[i].checked == true) {
- selectProjectList.push(selectArray[i].value);
- }
- }
+ $("input[name='adminGroupModify-project-checkbox']:checked").each(function() {
+ selectProjectList.push($(this).val());
+ });
- changeItem = {"GroupName" : oldGroupName, "NewGroupName":groupName, "AdminFlag":adminFlag, "Description":description, "ProjectList":selectProjectList.toString()};
+ changeItem = {"GroupId" : groupId, "GroupName":groupName, "AdminFlag":adminFlag, "Description":description, "ProjectList":selectProjectList.toString()};
changeInfoList.push(changeItem);
changeGroup(changeInfoList, function() {
$("#adminGroup-contents").append(tableHeader);
- var index = 2;
-
groupList.each(function(){
var row = groupTable.insertRow(-1);
var cell;
+ var groupId = $(this).find("GroupId").text();
var groupName = $(this).find("GroupName").text();
var adminFlag = $(this).find("AdminFlag").text();
var description = $(this).find("Description").text();
var projectList = $(this).find("AccessableProject");
- row.setAttribute('id', 'table:'+index);
+ row.setAttribute('id', 'adminGroup-contents-'+groupId);
cell = row.insertCell(-1);
- cell.setAttribute('id', 'adminGroup-contents-'+index+'-name');
+ cell.setAttribute('id', 'adminGroup-contents-'+groupId+'-name');
cell.innerHTML = groupName
cell = row.insertCell(-1);
cell.appendChild(div);
cell = row.insertCell(-1);
- cell.setAttribute('id', 'adminGroup-contents-'+index+'-flag');
+ cell.setAttribute('id', 'adminGroup-contents-'+groupId+'-flag');
cell.innerHTML = adminFlag;
cell = row.insertCell(-1);
- cell.setAttribute('id', 'adminGroup-contents-'+index+'-description');
+ cell.setAttribute('id', 'adminGroup-contents-'+groupId+'-description');
cell.innerHTML = description;
cell = row.insertCell(-1);
button.setAttribute('href','#adminGroupModify');
button.setAttribute('data-role','button');
button.setAttribute('data-rel','dialog');
- button.setAttribute('onClick','adminGroupModifySetup(\"'+index+'\")');
+ button.setAttribute('onClick','adminGroupModifyInit(\"'+groupId+'\")');
button.setAttribute('class','adminGroup-contents-button');
button.innerHTML = " "
cell.appendChild(button);
cell = row.insertCell(-1);
var button = document.createElement('input');
button.setAttribute('type','button');
- button.setAttribute('onClick','adminGroupRemoveGroup('+index+')');
+ button.setAttribute('onClick','adminGroupRemoveGroup('+groupId+')');
button.setAttribute('class','adminGroup-contents-button');
cell.appendChild(button);
-
- index = index + 1;
});
$(".adminGroup-projectList").collapsible();
$(".adminGroup-contents-button").button();
}
-function adminGroupModifySetup(index) {
- localStorage.groupTableIndex = index;
-}
-
function adminGroupGenerateProjectListCell(projectList) {
var div = document.createElement('div');
div.setAttribute('data-role', 'collapsible');
return div;
}
-function adminGroupRemoveGroup(index) {
- var groupName = $("#adminGroup-contents-"+index+"-name").html();
+function adminGroupRemoveGroup(groupId) {
+ var groupName = $("#adminGroup-contents-"+groupId+"-name").html();
var r=confirm("User ["+groupName+"] will be removed!!!");
if (r==false)
var changeInfoList = [];
var changeInfoItem;
- changeInfoItem = {"GroupName":groupName};
+ changeInfoItem = {"GroupId":groupId};
changeInfoList.push(changeInfoItem);
removeGroup(changeInfoList, function() {
function adminProjectAddGitInit() {
$("#adminProjectAddGit-name").val("");
- $("#adminProjectAddGit-password").val("");
$("#adminProjectAddGit-address").val("");
$("#adminProjectAddGit-branch").val("");
+ $("#adminProjectAddGit-status").empty();
+
+ var option;
+ option = '<option value="OPEN" selected="selected">OPEN</option>';
+ $("#adminProjectAddGit-status").append(option);
+ option = '<option value="CLOSE">CLOSE</option>';
+ $("#adminProjectAddGit-status").append(option);
+ $("#adminProjectAddGit-status").selectmenu("refresh");
queryAllOS( function (xml) {
- var osList = $(xml).find("Data").find("OsName");
+ var osList = $(xml).find("Data").find("OS");
$("#adminProjectAddGit-os").empty();
$("#adminProjectAddGit-os").append("<legend>os list</legend>");
osList.each(function(){
- var osName = $(this).text();
+ var osId = $(this).find("Id").text();
+ var osName = $(this).find("Name").text();
- var input = '<input type=checkbox id=adminProjectAddGit-os-checkbox-'+osName+' name=adminProjectAddGit-os-checkbox value='+osName+' checked=checked />'
- var label = '<label for=adminProjectAddGit-os-checkbox-'+osName+'> '+osName+'<label>';
+ var input = '<input type=checkbox id=adminProjectAddGit-os-checkbox-'+osId+' name=adminProjectAddGit-os-checkbox value='+osId+' checked=checked />'
+ var label = '<label for=adminProjectAddGit-os-checkbox-'+osId+'> '+osName+'<label>';
$("#adminProjectAddGit-os").append(input);
$("#adminProjectAddGit-os").append(label);
});
function adminProjectAddBinaryInit() {
$("#adminProjectAddBinary-name").val("");
- $("#adminProjectAddBinary-password").val("");
$("#adminProjectAddBinary-packagename").val("");
+ $("#adminProjectAddBinary-status").empty();
+
+ var option;
+ option = '<option value="OPEN" selected="selected">OPEN</option>';
+ $("#adminProjectAddBinary-status").append(option);
+ option = '<option value="CLOSE">CLOSE</option>';
+ $("#adminProjectAddBinary-status").append(option);
+ $("#adminProjectAddBinary-status").selectmenu("refresh");
queryAllOS( function (xml) {
- var osList = $(xml).find("Data").find("OsName");
+ var osList = $(xml).find("Data").find("OS");
$("#adminProjectAddBinary-os").empty();
$("#adminProjectAddBinary-os").append("<legend>os list</legend>");
osList.each(function(){
- var osName = $(this).text();
+ var osId = $(this).find("Id").text();
+ var osName = $(this).find("Name").text();
- var input = '<input type=checkbox id=adminProjectAddBinary-os-checkbox-'+osName+' name=adminProjectAddBinary-os-checkbox value='+osName+' checked=checked />'
- var label = '<label for=adminProjectAddBinary-os-checkbox-'+osName+'> '+osName+'<label>';
+ var input = '<input type=checkbox id=adminProjectAddBinary-os-checkbox-'+osId+' name=adminProjectAddBinary-os-checkbox value='+osId+' checked=checked />'
+ var label = '<label for=adminProjectAddBinary-os-checkbox-'+osId+'> '+osName+'<label>';
$("#adminProjectAddBinary-os").append(input);
$("#adminProjectAddBinary-os").append(label);
});
function adminProjectAddGitProject() {
var changeInfoList = [];
var changeInfoItem;
- var distName = $("#adminProject-distribution-select option:selected").val();
- var type = "GIT";
+ var distId = $("#adminProject-distribution-select option:selected").val();
var name = $("#adminProjectAddGit-name").val();
- var password = $("#adminProjectAddGit-password").val();
var address = $("#adminProjectAddGit-address").val();
var branch = $("#adminProjectAddGit-branch").val();
+ var projectStatus = $("#adminProjectAddGit-status option:selected").val();
var selectOsList = [];
var selectArray = $("input[name='adminProjectAddGit-os-checkbox']");
}
}
- if(name == "" || password == "" || address == "" || branch == ""){
- alert("You must input full data(Project name, Git password, Git address, Branch)");
+ if(name == "" || address == "" || branch == ""){
+ alert("You must input full data(Project name, Git address, Branch)");
return;
}
- changeInfoItem = {"Distribution":distName, "Name":name, "ProjectType":type, "ProjectPass":password, "Address":address, "Branch":branch, "OSNameList":selectOsList.toString()};
+ changeInfoItem = {"DistId":distId, "Name":name, "Address":address, "Branch":branch, "ProjectStatus":projectStatus, "ProjectType":"GIT", "OSIdList":selectOsList.toString()};
changeInfoList.push(changeInfoItem);
addProject(changeInfoList, function () {
function adminProjectAddBinaryProject() {
var changeInfoList = [];
var changeInfoItem;
- var distName = $("#adminProject-distribution-select option:selected").val();
- var type = "BINARY";
+ var distId = $("#adminProject-distribution-select option:selected").val();
var name = $("#adminProjectAddBinary-name").val();
- var password = $("#adminProjectAddBinary-password").val();
var pkgName = $("#adminProjectAddBinary-packagename").val();
+ var projectStatus = $("#adminProjectAddBinary-status option:selected").val();
var selectOsList = [];
var selectArray = $("input[name='adminProjectAddBinary-os-checkbox']");
return;
}
- changeInfoItem = {"Distribution":distName, "Name":name, "ProjectType":type, "ProjectPass":password, "PackageName":pkgName, "OSNameList":selectOsList.toString()};
+ changeInfoItem = {"DistId":distId, "Name":name, "PackageName":pkgName, "ProjectStatus":projectStatus, "ProjectType":"BINARY", "OSIdList":selectOsList.toString()};
changeInfoList.push(changeInfoItem);
addProject(changeInfoList, function () {
- S-Core Co., Ltd
*/
-function adminProjectModifyBinaryProjectInit() {
- var projectName = localStorage.projectName;
- var packageName = $("#adminProject-binary-packageName-"+projectName).html();
-
- $("#adminProjectModifyBinary-oldName").val(projectName);
- $("#adminProjectModifyBinary-newName").val(projectName);
- $("#adminProjectModifyBinary-password").val("");
+function adminProjectModifyBinaryProjectInit(projectId) {
+ var projectName = $("#adminProject-binary-"+projectId+"-name").html();
+ var projectStatus = $("#adminProject-binary-"+projectId+"-status").html();
+ var packageName = $("#adminProject-binary-"+projectId+"-packageName").html();
+
+ $("#adminProjectModifyBinary-save").attr("onClick", "");
+ $("#adminProjectModifyBinary-id").val(projectId);
+ $("#adminProjectModifyBinary-name").val(projectName);
$("#adminProjectModifyBinary-packageName").val(packageName);
+ $("#adminProjectModifyBinary-status").empty();
$("#adminProjectModifyBinary-os").empty();
$("#adminProjectModifyBinary-os").append("<legend> os list </legend>");
+ $("#adminProjectModifyBinary-status").empty();
+
+ var option;
+ if(projectStatus.toUpperCase() == "OPEN") {
+ option = '<option value="OPEN" selected="selected">OPEN</option>';
+ } else {
+ option = '<option value="OPEN">OPEN</option>';
+ }
+ $("#adminProjectModifyBinary-status").append(option);
+
+ if(projectStatus.toUpperCase() == "CLOSE") {
+ option = '<option value="CLOSE" selected="selected">CLOSE</option>';
+ } else {
+ option = '<option value="CLOSE">CLOSE</option>';
+ }
+ $("#adminProjectModifyBinary-status").append(option);
+ $("#adminProjectModifyBinary-status").selectmenu();
+ $("#adminProjectModifyBinary-status").selectmenu("refresh");
queryAllOS( function (xml) {
- var osList = $(xml).find("Data").find("OsName");
+ var osList = $(xml).find("Data").find("OS");
var selectedOsList = [];
- var projectName = localStorage.projectName;
- var osListElement = document.getElementById("adminProject-binary-"+projectName+"-osList");
+ var osListElement = document.getElementById("adminProject-binary-"+projectId+"-osList");
for(var i = 0; i < osListElement.childNodes.length; i++)
{
selectedOsList.push(osListElement.childNodes[i].innerHTML);
}
osList.each(function(){
- var osName = $(this).text();
+ var osId = $(this).find("Id").text();
+ var osName = $(this).find("Name").text();
var input;
if(contains(selectedOsList, osName))
{
- input = '<input type=checkbox id=adminProjectModifyBinary-os-checkbox-'+osName+' name=adminProjectModifyBinary-os-checkbox value='+osName+' checked=checked />';
+ input = '<input type=checkbox id=adminProjectModifyBinary-os-checkbox-'+osId+' name=adminProjectModifyBinary-os-checkbox value='+osId+' checked=checked />';
} else {
- input = '<input type=checkbox id=adminProjectModifyBinary-os-checkbox-'+osName+' name=adminProjectModifyBinary-os-checkbox value='+osName+' />';
+ input = '<input type=checkbox id=adminProjectModifyBinary-os-checkbox-'+osId+' name=adminProjectModifyBinary-os-checkbox value='+osId+' />';
}
- var label = '<label for=adminProjectModifyBinary-os-checkbox-'+osName+'> '+osName+' <label>';
+ var label = '<label for=adminProjectModifyBinary-os-checkbox-'+osId+'> '+osName+' <label>';
$("#adminProjectModifyBinary-os").append(input);
$("#adminProjectModifyBinary-os").append(label);
});
$("input[name='adminProjectModifyBinary-os-checkbox']").checkboxradio();
+ $("#adminProjectModifyBinary-save").attr("onClick", "adminProjectModfyBinaryProject()");
});
}
-function adminProjectModifyGitProjectInit() {
- var projectName = localStorage.projectName;
- var projectAddress = $("#adminProject-git-"+projectName+"-address").html();
- var projectBranch = $("#adminProject-git-"+projectName+"-branch").html();
+function adminProjectModifyGitProjectInit(projectId) {
+ var projectName = $("#adminProject-git-"+projectId+"-name").html();
+ var projectAddress = $("#adminProject-git-"+projectId+"-address").html();
+ var projectBranch = $("#adminProject-git-"+projectId+"-branch").html();
+ var projectStatus = $("#adminProject-git-"+projectId+"-status").html();
- $("#adminProjectModifyGit-oldName").val(projectName);
- $("#adminProjectModifyGit-newName").val(projectName);
- $("#adminProjectModifyGit-password").val("");
+ $("#adminProjectModifyGit-save").attr("onClick", "");
+ $("#adminProjectModifyGit-id").val(projectId);
+ $("#adminProjectModifyGit-name").val(projectName);
$("#adminProjectModifyGit-address").val(projectAddress);
$("#adminProjectModifyGit-branch").val(projectBranch);
+ $("#adminProjectModifyGit-status").empty();
$("#adminProjectModifyGit-os").empty();
$("#adminProjectModifyGit-os").append("<legend> os list </legend>");
+ var option;
+ if(projectStatus.toUpperCase() == "OPEN") {
+ option = '<option value="OPEN" selected="selected">OPEN</option>';
+ } else {
+ option = '<option value="OPEN">OPEN</option>';
+ }
+ $("#adminProjectModifyGit-status").append(option);
+
+ if(projectStatus.toUpperCase() == "CLOSE") {
+ option = '<option value="CLOSE" selected="selected">CLOSE</option>';
+ } else {
+ option = '<option value="CLOSE">CLOSE</option>';
+ }
+ $("#adminProjectModifyGit-status").append(option);
+ $("#adminProjectModifyGit-status").selectmenu();
+ $("#adminProjectModifyGit-status").selectmenu("refresh");
queryAllOS( function (xml) {
- var osList = $(xml).find("Data").find("OsName");
+ var osList = $(xml).find("Data").find("OS");
var selectedOsList = [];
- var projectName = localStorage.projectName;
- var osListElement = document.getElementById("adminProject-git-"+projectName+"-osList");
+ var osListElement = document.getElementById("adminProject-git-"+projectId+"-osList");
for(var i = 0; i < osListElement.childNodes.length; i++)
{
selectedOsList.push(osListElement.childNodes[i].innerHTML);
}
osList.each(function(){
- var osName = $(this).text();
+ var osId = $(this).find("Id").text();
+ var osName = $(this).find("Name").text();
var input;
if(contains(selectedOsList, osName))
{
- input = '<input type=checkbox id=adminProjectModifyGit-os-checkbox-'+osName+' name=adminProjectModifyGit-os-checkbox value='+osName+' checked=checked />';
+ input = '<input type=checkbox id=adminProjectModifyGit-os-checkbox-'+osId+' name=adminProjectModifyGit-os-checkbox value='+osId+' checked=checked />';
} else {
- input = '<input type=checkbox id=adminProjectModifyGit-os-checkbox-'+osName+' name=adminProjectModifyGit-os-checkbox value='+osName+' />';
+ input = '<input type=checkbox id=adminProjectModifyGit-os-checkbox-'+osId+' name=adminProjectModifyGit-os-checkbox value='+osId+' />';
}
- var label = '<label for=adminProjectModifyGit-os-checkbox-'+osName+'> '+osName+' <label>';
+ var label = '<label for=adminProjectModifyGit-os-checkbox-'+osId+'> '+osName+' <label>';
$("#adminProjectModifyGit-os").append(input);
$("#adminProjectModifyGit-os").append(label);
});
$("input[name='adminProjectModifyGit-os-checkbox']").checkboxradio();
+ $("#adminProjectModifyGit-save").attr("onClick", "adminProjectModfyGitProject()");
});
}
function adminProjectModfyBinaryProject() {
- var distName = $("#adminProject-distribution-select option:selected").val();
var changeInfoList = [];
var changeInfoItem;
- var oldProjectName = $("#adminProjectModifyBinary-oldName").val();
- var newProjectName = $("#adminProjectModifyBinary-newName").val();
- var projectPassword = $("#adminProjectModifyBinary-password").val();
+ var projectId = $("#adminProjectModifyBinary-id").val();
+ var projectName = $("#adminProjectModifyBinary-name").val();
+ var projectStatus = $("#adminProjectModifyBinary-status option:selected").val();
var packageName = $("#adminProjectModifyBinary-packageName").val();
var selectOsList = [];
- var selectArray = $("input[name='adminProjectModifyBinary-os-checkbox']");
- for(var i = 0; i < selectArray.length; i++) {
- if (selectArray[i].checked == true) {
- selectOsList.push(selectArray[i].value);
- }
- }
+ $("input[name='adminProjectModifyBinary-os-checkbox']:checked").each(function() {
+ selectOsList.push($(this).val());
+ });
- if(oldProjectName == "" || newProjectName == "" || projectPassword == "" || packageName == ""){
+ if(projectId == "" || projectName == "" || packageName == ""){
alert("You must input full data");
return;
}
- changeInfoItem = {"Distribution":distName, "Name":oldProjectName, "NewProjectName":newProjectName, "ProjectType":"BINARY", "ProjectPass":projectPassword, "PackageName":packageName, "OSNameList":selectOsList.toString()};
+ changeInfoItem = {"Id":projectId, "Name":projectName, "ProjectStatus":projectStatus, "PackageName":packageName, "OSIdList":selectOsList.toString()};
changeInfoList.push(changeInfoItem);
modifyProject(changeInfoList, function () {
var distName = $("#adminProject-distribution-select option:selected").val();
var changeInfoList = [];
var changeInfoItem;
- var oldProjectName = $("#adminProjectModifyGit-oldName").val();
- var newProjectName = $("#adminProjectModifyGit-newName").val();
- var projectPassword = $("#adminProjectModifyGit-password").val();
+ var projectId = $("#adminProjectModifyGit-id").val();
+ var projectName = $("#adminProjectModifyGit-name").val();
var projectAddress = $("#adminProjectModifyGit-address").val();
var projectBranch = $("#adminProjectModifyGit-branch").val();
+ var projectStatus = $("#adminProjectModifyGit-status option:selected").val();
var selectOsList = [];
- var selectArray = $("input[name='adminProjectModifyGit-os-checkbox']");
- for(var i = 0; i < selectArray.length; i++) {
- if (selectArray[i].checked == true) {
- selectOsList.push(selectArray[i].value);
- }
- }
+ $("input[name='adminProjectModifyGit-os-checkbox']:checked").each(function() {
+ selectOsList.push($(this).val());
+ });
- if(oldProjectName == "" || newProjectName == "" || projectPassword == "" || projectAddress == "" || projectBranch == ""){
+ if(projectId == "" || projectName == "" || projectAddress == "" || projectBranch == ""){
alert("You must input full data");
return;
}
- changeInfoItem = {"Distribution":distName, "Name":oldProjectName, "NewProjectName":newProjectName, "ProjectType":"GIT", "ProjectPass":projectPassword, "ProjectAddress":projectAddress, "ProjectBranch":projectBranch, "OSNameList":selectOsList.toString()};
+ changeInfoItem = {"Id":projectId, "Name":projectName, "ProjectAddress":projectAddress, "ProjectBranch":projectBranch, "ProjectStatus":projectStatus, "OSIdList":selectOsList.toString()};
changeInfoList.push(changeInfoItem);
modifyProject(changeInfoList, function () {
function adminProjectInit() {
if( $("#adminProject-distribution-select").children().length == 0 ) {
queryDistribution( function(xml) {
- $(xml).find("Data").find("DistributionName").each(function(){
- var name = $(this).text();
+ $(xml).find("Data").find("Distribution").each(function(){
+ var distId = $(this).find("Id").text();
+ var distName = $(this).find("Name").text();
- $("#adminProject-distribution-select").append("<option value=\'"+name+"\'>"+name+"</option>");
+ $("#adminProject-distribution-select").append("<option value=\'"+distId+"\'>"+distName+"</option>");
});
/* default distribution selection */
}
function adminProjectSetProjectInfo() {
- var distName = $("#adminProject-distribution-select option:selected").val();
+ var distId = $("#adminProject-distribution-select option:selected").val();
- queryProjectsInDistributionForAdmin( distName, function (xml) {
+ queryProjectsInDistributionForAdmin( distId, function (xml) {
var projectList = $(xml).find("Data").find("Project");
// update project info
});
}
-function popupModifyProject(projectName) {
- localStorage.projectName = projectName;
-}
-
-function adminProjectRemoveProject(projectType, projectName ) {
- var distName = $("#adminProject-distribution-select option:selected").val();
+function adminProjectRemoveProject(projectType, projectId) {
+ var projectName = $("#adminProject-"+projectType+"-"+projectId+"-name").html();
var r=confirm("Project ["+projectName+"] is removed!!!");
if (r==false)
var changeInfoList = [];
var changeInfoItem;
- changeInfoItem = {"Distribution":distName, "ProjectType":projectType, "Name":projectName};
+ changeInfoItem = {"ProjectId":projectId};
changeInfoList.push(changeInfoItem);
removeProject(changeInfoList, function () {
$("#adminProject-binary").empty();
// Project table header
- var tableHeader = "<tr><th>Project</th><th>Git repos</th><th>Branch</th><th>OS list</th><th>Modify</th><th>Delete</th>";
+ var tableHeader = "<tr><th>Project</th><th>Git repos</th><th>Branch</th><th>OS list</th><th>Status</th><th>Modify</th><th>Delete</th>";
$("#adminProject-git").append(tableHeader);
// Binary project table header
- var tableHeader = "<tr><th>Project</th><th>Package name</th><th>OS list</th><th>Modify</th><th>Delete</th>";
+ var tableHeader = "<tr><th>Project</th><th>Package name</th><th>OS list</th><th>Status</th><th>Modify</th><th>Delete</th>";
+
$("#adminProject-binary").append(tableHeader);
- var projectIdx = 1;
var binaryProjectIdx = 1;
// add project information
projectList.each(function(){
- var name = $(this).find("ProjectName").text();
+ var id = $(this).find("Id").text();
+ var name = $(this).find("Name").text();
var type = $(this).find("Type").text();
+ var projectStatus = $(this).find("ProjectStatus").text();
+ var projectPassword = $(this).find("ProjectPassword").text();
var osList = $(this).find("OS");
if(type.toUpperCase() == "GIT")
cell = row.insertCell(-1);
cell.setAttribute('style', 'text-align: left');
+ cell.setAttribute('id',"adminProject-git-"+id+"-name");
cell.innerHTML = name;
cell = row.insertCell(-1);
cell.setAttribute('style', 'text-align: left');
- cell.setAttribute('id',"adminProject-git-"+name+"-address");
+ cell.setAttribute('id',"adminProject-git-"+id+"-address");
cell.innerHTML = $(this).find("GitRepos").text();
cell = row.insertCell(-1);
cell.setAttribute('style', 'text-align: left');
- cell.setAttribute('id',"adminProject-git-"+name+"-branch");
+ cell.setAttribute('id',"adminProject-git-"+id+"-branch");
cell.innerHTML = $(this).find("GitBranch").text();
cell = row.insertCell(-1);
- div = adminProjectApendOsCell(osList, name, "GIT");
+ div = adminProjectApendOsCell(osList, id, "git");
cell.appendChild(div);
cell = row.insertCell(-1);
+ cell.setAttribute('id',"adminProject-git-"+id+"-status");
+ cell.innerHTML = projectStatus;
+
+ cell = row.insertCell(-1);
var button = document.createElement('a');
button.setAttribute('href','#adminProjectModifyGit');
button.setAttribute('data-role','button');
button.setAttribute('data-rel','dialog');
button.setAttribute('data-mini','true');
- button.setAttribute('onClick','popupModifyProject(\"'+name+'\")');
+ button.setAttribute('onClick','adminProjectModifyGitProjectInit(\"'+id+'\")');
button.setAttribute('class','binaryProjectTableButton');
button.innerHTML = " "
cell.appendChild(button);
cell = row.insertCell(-1);
var button = document.createElement('input');
button.setAttribute('type','button');
- button.setAttribute('id','button:git:'+projectIdx+':'+name);
button.setAttribute('data-mini','true');
button.setAttribute('name',name);
button.setAttribute('class','binaryProjectTableButton');
- button.setAttribute('onClick','adminProjectRemoveProject(\"GIT\"'+',\"'+name+'\"'+')');
+ button.setAttribute('onClick','adminProjectRemoveProject(\"git\"'+',\"'+id+'\"'+')');
cell.appendChild(button);
-
- projectIdx = projectIdx + 1;
}
else if (type.toUpperCase() == "BINARY")
{
cell = row.insertCell(-1);
cell.setAttribute('style', 'text-align: left');
+ cell.setAttribute('id',"adminProject-binary-"+id+"-name");
cell.innerHTML = name;
cell = row.insertCell(-1);
cell.setAttribute('style', 'text-align: left');
- cell.setAttribute('id',"adminProject-binary-packageName-"+name);
+ cell.setAttribute('id',"adminProject-binary-"+id+"-packageName");
cell.innerHTML = $(this).find("PackageName").text();
cell = row.insertCell(-1);
- div = adminProjectApendOsCell(osList, name, "BINARY");
+ div = adminProjectApendOsCell(osList, id, "binary");
cell.appendChild(div);
cell = row.insertCell(-1);
+ cell.setAttribute('id',"adminProject-binary-"+id+"-status");
+ cell.innerHTML = projectStatus;
+
+ cell = row.insertCell(-1);
var button = document.createElement('a');
button.setAttribute('href','#adminProjectModifyBinary');
button.setAttribute('data-role','button');
button.setAttribute('data-inline','true');
button.setAttribute('data-mini','true');
button.setAttribute('data-rel','dialog');
- button.setAttribute('onClick','popupModifyProject(\"'+name+'\")');
+ button.setAttribute('onClick','adminProjectModifyBinaryProjectInit(\"'+id+'\")');
button.setAttribute('class','binaryProjectTableButton');
cell.appendChild(button);
button.setAttribute('class','binaryProjectTableButton');
button.setAttribute('data-mini','true');
button.setAttribute('name',name);
- button.setAttribute('onClick','adminProjectRemoveProject(\"BINARY\"'+',\"'+name+'\"'+')');
+ button.setAttribute('onClick','adminProjectRemoveProject(\"binary\"'+',\"'+id+'\"'+')');
cell.appendChild(button);
binaryProjectIdx = binaryProjectIdx + 1;
$(".adminProject-OsList").collapsible();
}
-function adminProjectApendOsCell(osList, projectName, projectType) {
+function adminProjectApendOsCell(osList, projectId, projectType) {
var div = document.createElement('div');
div.appendChild(header);
var ul = document.createElement('ul');
- ul.setAttribute('id', 'adminProject-'+projectType.toLowerCase()+'-'+projectName+'-osList');
+ ul.setAttribute('id', 'adminProject-'+projectType+'-'+projectId+'-osList');
// if osList does not exist then just return
if (osList != undefined) {
return div;
}
+function adminProjectAllProjectStatusChange(projectStatus) {
+ var distId = $("#adminProject-distribution-select option:selected").val();
+ var changeInfoList = [];
+ var changeInfoItem;
+
+ var r=confirm("All project status is changed to "+projectStatus+"!!!");
+ if (r==false)
+ {
+ return;
+ }
+
+ changeInfoItem = {"DistId":distId, "ProjectStatus":projectStatus}
+ changeInfoList.push(changeInfoItem);
+ changeAllProjectStatus(changeInfoList, function () {
+ $.mobile.changePage("#adminProject");
+ });
+}
*/
function adminServerAddSupportedOsInit() {
- // Remove select option
- $("#adminServer-AddSupportedOs-OsCategory").empty();
-
queryAllOSCategory(function(xml){
- $(xml).find("Data").find("OsCategoryName").each(function(){
- var name = $(this).text();
+ $(xml).find("Data").find("OsCategory").each(function(){
+ var categoryId = $(this).find("Id").text();
+ var categoryName = $(this).find("Name").text();
- $('#adminServer-AddSupportedOs-OsCategory').append("<option value=\'"+name+"\'>"+name+"</option>");
+ $('#adminServer-AddSupportedOs-OsCategory').append("<option value=\'"+categoryId+"\'>"+categoryName+"</option>");
$('#adminServer-AddSupportedOs-OsCategory').selectmenu('refresh');
});
var changeInfoList = [];
var changeInfoItem;
- var osName = $("#adminServer-AddSupportedOs-OsName").val();
- var osCategory = $("#adminServer-AddSupportedOs-OsCategory option:selected").val();
+ var osName = $("#adminServer-AddSupportedOs-name").val();
+ var osCategoryId = $("#adminServer-AddSupportedOs-OsCategory option:selected").val();
- if(osName == ""){
- alert("You must input server address");
+ if(osName == "" || osCategoryId == ""){
+ alert("You must input os name");
return;
}
- changeInfoItem = {"Name":osName, "OsCategory":osCategory};
+ changeInfoItem = {"Name":osName, "OsCategoryId":osCategoryId};
changeInfoList.push(changeInfoItem);
addSupportedOS(changeInfoList, function () {
- $("#adminServer-AddSupportedOs-OsName").val("");
+ // Remove select option
+ $("#adminServer-AddSupportedOs-name").val("");
+ $("#adminServer-AddSupportedOs-OsCategory").empty();
$.mobile.changePage("#adminServer");
});
var changeInfoList = [];
var changeInfoItem;
- var categoryName = $("#adminServer-AddOsCategory-Name").val();
+ var categoryName = $("#adminServer-AddOsCategory-name").val();
if(categoryName == ""){
alert("You must input category name");
changeInfoList.push(changeInfoItem);
addOSCategory(changeInfoList, function () {
- $("#adminServer-AddOsCategory-Name").val("");
+ $("#adminServer-AddOsCategory-name").val("");
$.mobile.changePage("#adminServer");
});
- S-Core Co., Ltd
*/
-function adminServerModifyRemoteBuildServerInit() {
- var serverAddress = localStorage.remoteBuildServerAddress;
- var serverDescription = localStorage.remoteBuildServerDescription;
+function adminServerModifyServerInfoInit(configId) {
+ $("#adminServer-modifyServerInfo-id").val(configId);
+ $("#adminProjectModifyBinary-save").attr("onClick", "");
- $("#adminServer-modifyRemoteBuildServer-OldAddress").val(serverAddress);
- $("#adminServer-modifyRemoteBuildServer-newAddress").val(serverAddress);
- $("#adminServer-modifyRemoteBuildServer-description").val(serverDescription);
+ queryServerConfig(configId, function(xml) {
+ var property = $(xml).find("Data").find("Property").text();
+ var value = $(xml).find("Data").find("Value").text();
+
+ $("#adminServer-modifyServerInfo-property").val(property);
+ $("#adminServer-modifyServerInfo-value").val(value);
+ $("#adminProjectModifyBinary-save").attr("onClick", "adminServerModifyServerInfo()");
+ });
}
-function adminServerModifyServerInfoInit(property, value) {
- $("#adminServer-modifyServerInfo-property").val(property);
- $("#adminServer-modifyServerInfo-value").val(value);
+function adminServerModifyRemoteBuildServerInit(serverId) {
+ $("#adminServer-modifyRemoteBuildServer-id").val(serverId);
+ $("#adminServer-modifyRemoteBuildServer-save").attr("onClick", "");
+
+ queryRemoteBuildServer(serverId, function(xml) {
+ var address = $(xml).find("Data").find("Address").text();
+ var description = $(xml).find("Data").find("Description").text();
+
+ $("#adminServer-modifyRemoteBuildServer-address").val(address);
+ $("#adminServer-modifyRemoteBuildServer-description").val(description);
+ $("#adminServer-modifyRemoteBuildServer-save").attr("onClick", "adminServerModifyRemoteBuildServer()");
+ });
+
}
-function adminServerModifySupportedOSInit(osName, osCategory) {
- // Remove select option
- $('#adminServer-ModifySupportedOs-OsCategory').empty();
-
- $("#adminServer-ModifySupportedOs-OldOsName").val(osName);
- $("#adminServer-MoidfySupportedOs-OsName").val(osName);
-
- queryAllOSCategory( function(xml){
- $(xml).find("Data").find("OsCategoryName").each(function(){
- var name = $(this).text();
- var option = ""
-
- if(name == osCategory) {
- option = '<option value="'+name+'" selected="selected">'+name+'</option>'
- } else {
- option = '<option value="'+name+'">'+name+'</option>'
- }
-
- $('#adminServer-ModifySupportedOs-OsCategory').append(option);
- $('#adminServer-ModifySupportedOs-OsCategory').selectmenu("refresh");
+function adminServerModifySupportedOSInit(osId) {
+ $("#adminServer-ModifySupportedOs-OsCategory").empty();
+ $("#adminServer-ModifySupportedOs-id").val(osId);
+ $("#adminServer-ModifySupportedOs-save").attr("onClick", "");
+
+ querySupportedOS(osId, function(xml) {
+ var name = $(xml).find("Data").find("Name").text();
+ var category = $(xml).find("Data").find("CategoryId").text();
+
+ $("#adminServer-MoidfySupportedOs-name").val(name);
+
+ queryAllOSCategory( function(xml){
+ $(xml).find("Data").find("OsCategory").each(function(){
+ var categoryId = $(this).find("Id").text();
+ var categoryName = $(this).find("Name").text();
+ var option = ""
+
+ if(categoryId == category) {
+ option = '<option value="'+categoryId+'" selected="selected">'+categoryName+'</option>'
+ } else {
+ option = '<option value="'+categoryId+'">'+categoryName+'</option>'
+ }
+
+ $('#adminServer-ModifySupportedOs-OsCategory').append(option);
+ $('#adminServer-ModifySupportedOs-OsCategory').selectmenu("refresh");
+ $("#adminServer-ModifySupportedOs-save").attr("onClick", "adminServerModifySupportedOS()");
+ });
});
});
}
function adminServerModifyRemoteBuildServer() {
var changeInfoList = [];
var changeInfoItem;
- var serverAddress = $("#adminServer-modifyRemoteBuildServer-OldAddress").val();
- var newServerAddress = $("#adminServer-modifyRemoteBuildServer-newAddress").val();
+ var id = $("#adminServer-modifyRemoteBuildServer-id").val();
+ var address = $("#adminServer-modifyRemoteBuildServer-address").val();
var description = $("#adminServer-modifyRemoteBuildServer-description").val();
- if(serverAddress == ""){
- alert("server address is invalid");
+ if(id == "" || address == ""){
+ alert("server infomation is invalid");
return;
}
- changeInfoItem = {"Address":serverAddress, "NewAddress":newServerAddress, "Description":description};
+ changeInfoItem = {"Id":id, "Address":address, "Description":description};
changeInfoList.push(changeInfoItem);
modifyRemoteBuildServer(changeInfoList, function () {
function adminServerModifySupportedOS() {
var changeInfoList = [];
var changeInfoItem;
- var oldOsName = $("#adminServer-ModifySupportedOs-OldOsName").val();
- var osName = $("#adminServer-MoidfySupportedOs-OsName").val();
+ var id = $("#adminServer-ModifySupportedOs-id").val();
+ var name = $("#adminServer-MoidfySupportedOs-name").val();
var osCategory = $("#adminServer-ModifySupportedOs-OsCategory option:selected").val();
- changeInfoItem = {"Name":oldOsName, "NewName":osName, "OsCategory":osCategory};
+ changeInfoItem = {"Id":id, "Name":name, "OsCategoryId":osCategory};
changeInfoList.push(changeInfoItem);
modifySupportedOS(changeInfoList, function () {
}
function adminServerModifyServerInfo() {
+ var id = $("#adminServer-modifyServerInfo-id").val();
var property = $("#adminServer-modifyServerInfo-property").val();
var value = $("#adminServer-modifyServerInfo-value").val();
var changeInfoList = [];
var changeInfoItem;
+ if(id == ""){
+ alert("info data is invalid");
+ return;
+ }
+
if(property == ""){
alert("property is empty");
return;
return;
}
- changeInfoItem = {"Property":property, "Value":value};
+ changeInfoItem = {"Id":id, "Property":property, "Value":value};
changeInfoList.push(changeInfoItem);
modifyServerInfo(changeInfoList, function () {
$('#adminServer-RemoveOSCategory-CategorySelect').empty();
queryAllOSCategory(function(xml){
- $(xml).find("Data").find("OsCategoryName").each(function(){
- var name = $(this).text();
+ $(xml).find("Data").find("OsCategory").each(function(){
+ var categoryId = $(this).find("Id").text();
+ var categoryName = $(this).find("Name").text();
- $('#adminServer-RemoveOSCategory-CategorySelect').append("<option value=\'"+name+"\'>"+name+"</option>");
+ $('#adminServer-RemoveOSCategory-CategorySelect').append("<option value=\'"+categoryId+"\'>"+categoryName+"</option>");
- $('#adminServer-RemoveOSCategory-CategorySelect').selectmenu('refresh');
});
});
+
+ $('#adminServer-RemoveOSCategory-CategorySelect').selectmenu('refresh');
}
function adminServerRemoveOSCategory() {
var changeInfoList = [];
var changeInfoItem;
- var osCategory = $("#adminServer-RemoveOSCategory-CategorySelect option:selected").val();
+ var osCategoryId = $("#adminServer-RemoveOSCategory-CategorySelect option:selected").val();
- if(osCategory == ""){
+ if(osCategoryId == ""){
alert("Os category is invalid");
return;
}
- changeInfoItem = {"Name":osCategory};
+ changeInfoItem = {"Id":osCategoryId};
changeInfoList.push(changeInfoItem);
removeOSCategory(changeInfoList, function () {
function adminServerRemoveSupportedOS() {
var changeInfoList = [];
var changeInfoItem;
- var oldOsName = $('#adminServer-ModifySupportedOs-OldOsName').val();
- var osName = $('#adminServer-MoidfySupportedOs-OsName').val();
-
- if(oldOsName != osName ){
- alert("Remove command must be same to original os name");
- return;
- }
+ var id = $('#adminServer-ModifySupportedOs-id').val();
- changeInfoItem = {"Name":osName};
+ changeInfoItem = {"Id":id};
changeInfoList.push(changeInfoItem);
removeSupportedOS(changeInfoList, function () {
function adminServerRemoveRemoteBuildServer() {
var changeInfoList = [];
var changeInfoItem;
- var serverAddress = $('#adminServer-modifyRemoteBuildServer-OldAddress').val();
+ var serverId = $('#adminServer-modifyRemoteBuildServer-id').val();
- if(serverAddress == ""){
+ if(serverId == ""){
alert("server address is invalid");
return;
}
- changeInfoItem = {"Address":serverAddress};
+ changeInfoItem = {"Id":serverId};
changeInfoList.push(changeInfoItem);
removeRemoteBuildServer(changeInfoList, function () {
$("#adminServer-SupportedOS").empty();
$(xml).find("Data").find("OS").each(function(){
- var osName = $(this).find("OsName").text();
- var osCategory = $(this).find("OsCategory").text();
+ var id = $(this).find("Id").text();
+ var name = $(this).find("Name").text();
+ var categoryId = $(this).find("CategoryId").text();
+ var categoryName = $(this).find("CategoryName").text();
var li = '<li><a href="#adminServerModifySupportedOS" ';
- li += 'onClick="adminServerModifySupportedOSInit(\''+osName+'\',\''+osCategory+'\')" ';
+ li += 'onClick="adminServerModifySupportedOSInit(\''+id+'\')" ';
li += 'data-rel="dialog">';
- li += '<h3>'+osName+'</h3>';
- li += '<p>OS category : '+osCategory+'</p>';
+ li += '<h3>'+name+'</h3>';
+ li += '<p>OS category : '+categoryName+'</p>';
li += '</a></li>';
$("#adminServer-SupportedOS").append(li);
$("#adminServer-ServerInfo").empty();
serverConfig.each(function(){
+ var id = $(this).find("Id").text();
var property = $(this).find("Property").text();
var value = $(this).find("Value").text();
var li = '<li><a href="#adminServerModifyServerInfo" ';
- li += 'onClick="adminServerModifyServerInfoInit(\''+property+'\',\''+value+'\')" ';
+ li += 'onClick="adminServerModifyServerInfoInit('+id+')" ';
li += 'data-rel="dialog">';
li += '<p>'+property+' : '+value+'</p>';
li += '</a></li>';
$("#adminServer-RemoteBuildServer").empty();
serverList.each(function(){
+ var id = $(this).find("Id").text();
var address = $(this).find("Address").text();
var description = $(this).find("Description").text();
var li = '<li><a href="#adminServerModifyRemoteBuildServer" ';
- li += 'onClick="popupModifyRemoteBuildServerInfo(\''+address+'\',\''+description+'\')" ';
+ li += 'onClick="adminServerModifyRemoteBuildServerInit(\''+id+'\')" ';
li += 'data-rel="dialog">';
li += '<h3>'+address+'</h3>';
li += '<p>Description : '+$(this).find("Description").text()+'</p>';
$("#adminServer-RemoteBuildServer").listview('refresh');
}
-
-function popupModifyRemoteBuildServerInfo(address, description) {
- localStorage.remoteBuildServerAddress = address;
- localStorage.remoteBuildServerDescription = description;
-}
-
- S-Core Co., Ltd
*/
-function adminUserModifyInit() {
- var userId = localStorage.userId;
- var userName = $("#adminUser-contents-"+userId+"-name").html();
+function adminUserModifyInit(userId) {
+ var name = $("#adminUser-contents-"+userId+"-name").html();
var email = $("#adminUser-contents-"+userId+"-email").html();
- $("#adminUserModify-name").val(userName);
+ $("#adminUserModify-id").val(userId);
+ $("#adminUserModify-name").val(name);
$("#adminUserModify-email").val(email);
+ $("#adminUserModify-save").attr("onClick", "");
queryUserInfoForAdmin(userId, function(xml) {
var fullGroupList = $(xml).find("Data").find("GroupInfo").find("Group");
var userGroupIdList = $(xml).find("Data").find("GroupInfo").find("GroupIdList").text().split(",");
adminUserModifyGenerateGroupSelect(fullGroupList, userGroupIdList);
+ $("#adminUserModify-save").attr("onClick", "adminUserModify()");
});
}
function adminUserModify() {
var changeInfoList = [];
var changeInfoItem;
- var userName = $("#adminUserModify-name").val();
+ var id = $("#adminUserModify-id").val();
+ var name = $("#adminUserModify-name").val();
var email = $("#adminUserModify-email").val();
var selectGroupList = [];
- var selectArray = $("input[name='adminUserModify-group-checkbox']");
- for(var i = 0; i < selectArray.length; i++) {
- if (selectArray[i].checked == true) {
- selectGroupList.push(selectArray[i].value);
- }
- }
+ $("input[name='adminUserModify-group-checkbox']:checked").each(function() {
+ selectGroupList.push($(this).val());
+ });
- changeInfoItem = {"Type":"ModifyUser", "Email":email, "UserName":userName, "GroupIdList":selectGroupList.toString()};
+ changeInfoItem = {"Type":"ModifyUser", "Id":id, "Email":email, "Name":name, "GroupIdList":selectGroupList.toString()};
changeInfoList.push(changeInfoItem);
changeUser(changeInfoList, function () {
userList.each(function(){
var row = userTable.insertRow(-1);
var cell;
+ var userId = $(this).find("Id").text();
var userName = $(this).find("Name").text();
var groupList = $(this).find("GroupName");
var email = $(this).find("Email").text();
- var userId = $(this).find("Id").text();
cell = row.insertCell(-1);
cell.setAttribute('id',"adminUser-contents-"+userId+"-name");
button.setAttribute('href','#adminUserModify');
button.setAttribute('data-role','button');
button.setAttribute('data-rel','dialog');
+ button.setAttribute('data-mini','ture');
button.setAttribute('class','adminUser-contentsButton');
- button.setAttribute('onClick','adminUserModifySetup('+userId+')');
+ button.setAttribute('onClick','adminUserModifyInit('+userId+')');
button.innerHTML = " "
cell.appendChild(button);
var button = document.createElement('input');
button.setAttribute('type','button');
button.setAttribute('name',email);
+ button.setAttribute('data-mini','ture');
button.setAttribute('class','adminUser-contentsButton');
button.setAttribute('onClick','adminUserRemoveUser('+userId+')');
cell.appendChild(button);
return div;
}
-function adminUserModifySetup(id) {
- localStorage.userId = id;
-}
-
function adminUserRemoveUser(userId) {
- var email = $("#adminUser-contents-"+userId+"-email").val();
+ var email = $("#adminUser-contents-"+userId+"-email").html();
var r=confirm("User ["+email+"] is removed!!!");
if (r==false)
var changeInfoList = [];
var changeInfoItem;
- changeInfoItem = {"Type":"RemoveUser", "Email":email};
+ changeInfoItem = {"Type":"RemoveUser", "Id":userId};
changeInfoList.push(changeInfoItem);
removeUser(changeInfoList, function () {
function buildInit() {
if( $("#build-distribution-select").children().length == 0 ) {
queryDistribution( function(xml) {
- $(xml).find("Data").find("DistributionName").each(function(){
- var name = $(this).text();
+ $(xml).find("Data").find("Distribution").each(function(){
+ var id = $(this).find("Id").text();
+ var name = $(this).find("Name").text();
- $("#build-distribution-select").append("<option value=\'"+name+"\'>"+name+"</option>");
+ $("#build-distribution-select").append("<option value=\'"+id+"\'>"+name+"</option>");
});
/* default distribution selection */
- $("#build-distribution-select option:eq(0)").attr("selected", "selected");
+ defualt_dist_id = buildGetCookieDistribution();
+ $("#build-distribution-select").val(defualt_dist_id);
$("#build-distribution-select").selectmenu('refresh');
// query Project list
buildQueryProjectList();
- // query Running project list
- //buildQueryRunningProjectList();
-
// add batch file selector event
//buildBatchFilePathSelector();
});
// query Project list
buildQueryProjectList();
- // query Running project list
- //buildQueryRunningProjectList();
-
// add batch file selector event
//buildBatchFilePathSelector();
}
}
function buildQueryProjectList() {
- var distName = $("#build-distribution-select option:selected").val();
+ var distId = $("#build-distribution-select option:selected").val();
+
+ buildSetCookieDistribution(distId);
- queryProjectsInDistribution( distName, function(xml) {
+ queryProjectsInDistribution( distId, function(xml) {
$("#build-git-table").empty();
$("#build-binary-table").empty();
var xmlBody = $(xml).find("Data");
- buildAddTableRow( xmlBody.find("BuildServerInfo").find("supportedOs"),
+ var distributionStatus = xmlBody.find("BuildServerInfo").find("DistributionStatus").text();
+ if (distributionStatus == "CLOSE") {
+ var distributionLock = document.getElementById("build-distribution-lock");
+ distributionLock.innerHTML = '<p> Distribution is locked </p>';
+ } else {
+ var distributionLock = document.getElementById("build-distribution-lock");
+ distributionLock.innerHTML = '';
+ }
+
+ buildAddGitTableRow( xmlBody.find("BuildServerInfo").find("SupportedOs"),
+ distributionStatus,
xmlBody.find("Project"),
xmlBody.find("OtherProject"));
- buildAddBinaryTableRow( xmlBody.find("BinaryProject"),
+ buildAddBinaryTableRow( distributionStatus,
+ xmlBody.find("BinaryProject"),
xmlBody.find("OtherBinaryProject"));
});
}
-function buildQueryRunningProjectList() {
- var distName = $("#build-distribution-select option:selected").val();
-
- queryRunningProjectsInfoInDistribution( distName, function(xml) {
- var running_project = $(xml).find("RunProjectInfo");
- running_project.each(function(){
- var project_name = $(this).find("ProjectName").text();
- var project_os = $(this).find("ProjectOs").text();
- var project_type = $(this).find("ProjectType").text();
- var project_status = $(this).find("Status").text();
-
- if (project_type == "GIT") {
- var cell = document.getElementById("buildGitProjectTable"+":"+project_name+':'+project_os);
-
- if(cell){
- cell.setAttribute('bgcolor', '#fbff00');
- }
- }
- });
- });
-}
-
-function buildSelectAll(element) {
- var checkboxes = document.getElementsByName(element.id);
- var checked = element.checked;
+function buildSelectAll(id, flag) {
+ var checkboxes = document.getElementsByName('buildGitProjectTable-checkbox-'+id);
for(var i in checkboxes) {
if(!checkboxes[i].disabled) {
- checkboxes[i].checked = checked;
+ checkboxes[i].checked = flag;
}
}
}
return false;
}
-function buildAddTableRow(supportedOs, projectList, otherProjectList) {
+function buildAddGitTableRow(supportedOs, distributionStatus, projectList, otherProjectList) {
// Table header
var idx = 0;
var tableHeader = "";
// Project table header
tableHeader = "<tr><th>Project</th>";
supportedOs.each(function(){
- var osName = $(this).text();
+ var osId = $(this).find("Id").text();
+ var osName = $(this).find("Name").text();
tableHeader = tableHeader + "<th>"+osName+"</th>";
- osArray[idx] = osName;
+ osArray[idx] = osId;
idx++;
});
$("#build-git-table").append(tableHeader);
// table row - projectList
- var index = 2;
-
projectList.each(function(){
- var name = $(this).find("ProjectName").text();
- var osLists = $(this).find("OsList").text();
- var osList = osLists.split(",");
+ var id = $(this).find("Id").text();
+ var name = $(this).find("Name").text();
+ var projectOsArray = $(this).find("OsList").text().split(",");
+ var projectStatus = $(this).find("Status").text();
+ var buildAvailable = true;
var row = projectTable.insertRow(-1);
cell.setAttribute('bgcolor', '#dcddc0');
cell.innerHTML = name;
- for (i=0;i<osArray.length;i++)
- {
- var cell = row.insertCell(-1);
- var os = osArray[i];
-
- cell.setAttribute('id', "buildGitProjectTable"+":"+name+":"+os);
- cell.setAttribute('style', 'text-align: center');
- cell.setAttribute('bgcolor', '#dcddc0');
-
- var buttonnode = document.createElement('input');
- buttonnode.setAttribute('type','checkbox');
- buttonnode.setAttribute('id',"table"+":"+name+':'+os);
- buttonnode.setAttribute('name','projectBuildCheckbox'+":"+name);
- buttonnode.setAttribute('class','projectTableBuildButton');
- cell.appendChild(buttonnode);
-
- if(!contains(osList, os))
- {
- buttonnode.setAttribute('disabled','disabled');
- }
+ if (distributionStatus == "CLOSE" || projectStatus == "CLOSE") {
+ buildAvailable = false;
}
-
- /* append all checkbox */
- var cell = row.insertCell(-1);
- cell.setAttribute('style', 'text-align: center');
- cell.setAttribute('bgcolor', '#dcddc0');
-
- var buttonnode = document.createElement('input');
- buttonnode.setAttribute('type','checkbox');
- buttonnode.setAttribute('id','projectBuildCheckbox'+":"+name);
- buttonnode.setAttribute('name','all-checkbox');
- buttonnode.setAttribute('class','projectTableAllButton');
- buttonnode.setAttribute('onClick','buildSelectAll(this)');
- cell.appendChild(buttonnode);
+
+ buildAddBinaryTableCell(id, osArray, projectOsArray, buildAvailable, row);
});
otherProjectList.each(function(){
- var name = $(this).find("ProjectName").text();
+ var id = $(this).find("Id").text();
+ var name = $(this).find("Name").text();
var row = projectTable.insertRow(-1);
var cell = row.insertCell(0);
cell.setAttribute('bgcolor', '#c0c0c0');
cell.innerHTML = name;
- /* add empty cell for status */
- for (i=0;i<osArray.length;i++)
- {
- cell = row.insertCell(-1);
- cell.setAttribute('id', "table"+":"+name+"-"+osArray[i]);
- cell.setAttribute('style', 'text-align: left');
- cell.setAttribute('bgcolor', '#c0c0c0');
- cell.innerHTML = "";
- }
-
- /* add empty cell for all*/
- cell = row.insertCell(-1);
- cell.setAttribute('style', 'text-align: left');
- cell.setAttribute('bgcolor', '#c0c0c0');
- cell.innerHTML = "";
+ buildAddBinaryTableCell(id, osArray, "", false, row);
});
}
-function buildAddBinaryTableRow(binaryProjectList, otherProjectList) {
+function buildAddBinaryTableRow(distributionStatus, binaryProjectList, otherProjectList) {
var binaryProjectTable = document.getElementById("build-binary-table");
var row = binaryProjectTable.insertRow(-1);
var thCell = document.createElement('th');
/* insert binary project in binary project table */
binaryProjectList.each(function(){
- var name = $(this).find("ProjectName").text();
+ var id = $(this).find("Id").text();
+ var name = $(this).find("Name").text();
+ var projectStatus = $(this).find("Status").text();
var packageName = $(this).find("PackageName").text();
var row = '<tr><td bgcolor="#dcddc0" style="text-align:left">'+name+'</td>';
row += '<td bgcolor="#dcddc0" style="text-align:left">' + packageName + '</td>'
- row += '<td bgcolor="#dcddc0" style="text-align:left"><a href="upload.html" onClick="buildUploadBinaryName(\'' +name+'\')" class="binary_project_button" data-role="button" data-ajax="false" data-mini="true">REGISTER</a>';
+ if (distributionStatus == "CLOSE" || projectStatus == "CLOSE") {
+ row += '<td bgcolor="#c0c0c0" style="text-align:left"></td>';
+ } else {
+ row += '<td bgcolor="#dcddc0" style="text-align:left"><a href="upload.html" onClick="buildUploadBinaryName(\'' +id+'\')" class="binary_project_button" data-role="button" data-ajax="false" data-mini="true">REGISTER</a>';
+ }
row += '</tr>'
$("#build-binary-table tr:last").after(row);
});
otherProjectList.each(function(){
- var name = $(this).find("ProjectName").text();
+ var name = $(this).find("Name").text();
var packageName = $(this).find("PackageName").text();
var row = binaryProjectTable.insertRow(-1);
});
}
+function buildAddBinaryTableCell(projectId, osArray, projectOsArray, buildAvailable, row) {
+ for (i=0;i<osArray.length;i++)
+ {
+ var cell = row.insertCell(-1);
+ var osId = osArray[i];
+
+ cell.setAttribute('id', "buildGitProjectTable-"+projectId+"-"+osId);
+ cell.setAttribute('style', 'text-align: center');
+ if (buildAvailable) {
+ /* add cell with build checkbox */
+ cell.setAttribute('bgcolor', '#dcddc0');
+
+ var buttonnode = document.createElement('input');
+ buttonnode.setAttribute('type','checkbox');
+ buttonnode.setAttribute('id','buildGitProjectTable-checkbox-'+projectId+'-'+osId);
+ buttonnode.setAttribute('name','buildGitProjectTable-checkbox-'+projectId);
+ buttonnode.setAttribute('class','projectTableBuildButton');
+ cell.appendChild(buttonnode);
+
+ if(!contains(projectOsArray, osId))
+ {
+ buttonnode.setAttribute('disabled','disabled');
+ }
+ } else {
+ /* add empty cell for status */
+ cell.setAttribute('bgcolor', '#c0c0c0');
+ cell.innerHTML = "";
+ }
+ }
+
+ if (buildAvailable) {
+ /* append all checkbox */
+ var cell = row.insertCell(-1);
+ cell.setAttribute('style', 'text-align: center');
+ cell.setAttribute('bgcolor', '#dcddc0');
+
+ var buttonnode = document.createElement('input');
+ buttonnode.setAttribute('type','checkbox');
+ buttonnode.setAttribute('id','buildGitProjectTable-all-checkbox'+projectId);
+ buttonnode.setAttribute('name','all-checkbox');
+ buttonnode.setAttribute('class','projectTableAllButton');
+ buttonnode.setAttribute('onClick','buildSelectAll(\''+projectId+'\', this.checked)');
+ cell.appendChild(buttonnode);
+ } else {
+ /* add empty cell for all*/
+ cell = row.insertCell(-1);
+ cell.setAttribute('style', 'text-align: left');
+ cell.setAttribute('bgcolor', '#c0c0c0');
+ cell.innerHTML = "";
+ }
+}
+
function buildBuildProject() {
- var distName = $("#build-distribution-select option:selected").val();
+ var distId = $("#build-distribution-select option:selected").val();
+ var checkedBuildButton = $(".projectTableBuildButton:checked");
var buildProjectList = [];
- //var node_list = document.getElementsByTagName('input');
- var node_list = $("#build input")
- for (var i = 0; i < node_list.length; i++) {
- var node = node_list[i];
-
- if (node.getAttribute('type') == "checkbox") {
- if (node.checked == true) {
- if (node.getAttribute('name') != "all-checkbox") {
- var prjName = node.id.split(":")[1];
- var osName = node.id.split(":")[2];
- var buildData = { "distribution":distName, "projectName" : prjName, "os" : osName };
- buildProjectList.push(buildData);
- }
+ checkedBuildButton.each(function(index){
+ var name = $(this).attr("id");
+ var projectId = name.split("-")[2];
+ var osId = name.split("-")[3];
+ var buildData = { "distId":distId, "projectId" : projectId, "osId" : osId};
+ buildProjectList.push(buildData);
+ });
+
+ buildProject(buildProjectList, function (json) {
+ if(json.result != "SUCCESS") {
+ if(json.error != "") {
+ alert(json.message);
+ }
+ else {
+ alert("Build request fail!");
}
}
- }
-
- buildProject(buildProjectList, function () {
- $.mobile.changePage("#jobs");
+ else {
+ $.mobile.changePage("#jobs");
+ }
});
}
-function buildUploadBinaryName(project_name) {
- localStorage.distibutionName = $("#build-distribution-select option:selected").val();
- localStorage.uploadBinaryProjectName = project_name;
+function buildUploadBinaryName(project_id) {
+ localStorage.uploadBinaryProjectId = project_id;
}
function buildBatchFilePathSelector() {
$("#build-git-table").empty();
$("#build-binary-table").empty();
}
+
+function buildSetCookieDistribution(id)
+{
+ saveCookie("build_distribution", id, 7);
+}
+
+function buildGetCookieDistribution()
+{
+ id = getCookie("build_distribution");
+ if(id == "") {
+ id = 0;
+ }
+ return id;
+}
getInfoFromServer(url, successFunction);
}
-// controller : projects
-function buildProject(changeInfoList, successFunction) {
- var url = 'projects/buildProject';
- postForServer(url, changeInfoList, successFunction);
+function queryAllDistribution(successFunction) {
+ var url = 'projects/queryAllDistribution';
+ getInfoFromServer(url, successFunction);
}
-function queryProjectsInDistribution(distName, successFunction) {
- var url = 'projects/queryProjectsInDistribution/' + distName;
+function queryAllProjectInOpenStatus(successFunction) {
+ var url = 'projects/queryAllProjectInOpenStatus';
getInfoFromServer(url, successFunction);
}
-function queryRunningProjectsInfoInDistribution(distName, successFunction) {
- var url = 'projects/queryRunningProjectsInfoInDistribution/' + distName;
+function buildProject(changeInfoList, successFunction) {
+ var url = 'projects/buildProject';
+ postForServer(url, changeInfoList, successFunction);
+}
+
+function queryProjectsInDistribution(distId, successFunction) {
+ var url = 'projects/queryProjectsInDistribution/' + distId;
getInfoFromServer(url, successFunction);
}
-function queryProjectsInfoInDistribution(distName, successFunction) {
- var url = 'projects/queryProjectsInfoInDistribution/' + distName;
+function queryProjectsInfoInDistribution(distId, successFunction) {
+ var url = 'projects/queryProjectsInfoInDistribution/' + distId;
getInfoFromServer(url, successFunction);
}
getInfoFromServer(url, successFunction);
}
-function queryGroupInfo(groupName, successFunction) {
- var url = 'admin_group/queryGroupInfo/' + groupName;
+function queryGroupInfo(groupId, successFunction) {
+ var url = 'admin_group/queryGroupInfo/' + groupId;
getInfoFromServer(url, successFunction);
}
}
// controller : admin_server
-function queryServerInfo(successFunction) {
- var url = 'admin_server/queryServerInfo';
+function queryAllServer(successFunction) {
+ var url = 'admin_server/queryAllServer';
getInfoFromServer(url, successFunction);
}
-function queryAllServer(successFunction) {
- var url = 'admin_server/queryAllServer';
+function queryServerConfig(configId, successFunction) {
+ var url = 'admin_server/queryServerConfig/' + configId;
+ getInfoFromServer(url, successFunction);
+}
+
+function queryRemoteBuildServer(serverId, successFunction) {
+ var url = 'admin_server/queryRemoteBuildServer/' + serverId;
+ getInfoFromServer(url, successFunction);
+}
+
+function querySupportedOS(osId, successFunction) {
+ var url = 'admin_server/querySupportedOS/' + osId;
getInfoFromServer(url, successFunction);
}
}
function addOSCategory(changeInfoList, successFunction) {
- var url = 'admin_server/addOsCategory';
+ var url = 'admin_server/addOSCategory';
postForServer(url, changeInfoList, successFunction);
}
function removeOSCategory(changeInfoList, successFunction) {
- var url = 'admin_server/removeOsCategory';
+ var url = 'admin_server/removeOSCategory';
postForServer(url, changeInfoList, successFunction);
}
function modifyOSCategory(changeInfoList, successFunction) {
- var url = 'admin_server/modifyOsCategory';
+ var url = 'admin_server/modifyOSCategory';
postForServer(url, changeInfoList, successFunction);
}
}
// controller : admin_project
-function queryAllProject(successFunction) {
- var url = 'admin_project/queryAllProject';
- getInfoFromServer(url, successFunction);
-}
-
-function queryProjectsInDistributionForAdmin(distName, successFunction) {
- var url = 'admin_project/queryProjectsInDistributionForAdmin/' + distName;
+function queryProjectsInDistributionForAdmin(distId, successFunction) {
+ var url = 'admin_project/queryProjectsInDistributionForAdmin/' + distId;
getInfoFromServer(url, successFunction);
}
postForServer(url, changeInfoList, successFunction);
}
+function changeAllProjectStatus(changeInfoList, successFunction) {
+ var url = 'admin_project/changeAllProjectStatus';
+ postForServer(url, changeInfoList, successFunction);
+}
+
// controller : admin_distribution
-function queryDistributionInfo(distName, successFunction) {
- var url = 'admin_distribution/queryDistributionInfo/' + distName;
+function queryDistributionInfo(distId, successFunction) {
+ var url = 'admin_distribution/queryDistributionInfo/' + distId;
getInfoFromServer(url, successFunction);
}
postForServer(url, changeInfoList, successFunction);
}
-function fullBuildDistribution(changeInfoList, successFunction) {
- var url = 'admin_distribution/fullBuildDistribution';
- postForServer(url, changeInfoList, successFunction);
-}
-
// controller : admin
function queryAllOS(successFunction) {
var url = 'admin/queryAllOS';
// append "ALL" distribution
$("#jobs-distribution-select").append("<option value='ALL'>ALL</option>");
- $(xml).find("Data").find("DistributionName").each(function(){
- var name = $(this).text();
+ $(xml).find("Data").find("Distribution").each(function(){
+ var id = $(this).find("Id").text();
+ var name = $(this).find("Name").text();
$("#jobs-distribution-select").append("<option value=\'"+name+"\'>"+name+"</option>");
});
var lastJobId = 0;
$(xml).find("JobList").find("Job").each(function(){
var id = $(this).find("Id").text();
- var li = generateHtmlJobList($(this));
+ var jobAttribute = $(this).find("JobAttribute").text();
+ var parentJobId = $(this).find("ParentJobId").text();
+ var li = "";
+ if(jobAttribute == "CHILD")
+ {
+ li = generateHtmlJobList($(this));
+ console.log("add-child-job parent's id:"+parentJobId);
+ $("#jobs-li-"+parentJobId+"-sub-job-area").append(li);
+ $("#jobs-li-"+id).collapsible();
+ $("#jobs-li-"+id+"-sub-job-button").button();
- lastJobId = id;
- $("#jobs-job-list").append(li).listview('refresh');
+ $("#jobs-li-link-"+id).popupWindow({
+ height:900,
+ width:800,
+ top:30,
+ left:50
+ });
+ console.log("add-child-job id:"+id);
+
+ //Display sub-jobs button
+ if($("#jobs-li-"+parentJobId+"-sub-job-button-div").hasClass("ui-screen-hidden") == true) {
+ $("#jobs-li-"+parentJobId+"-sub-job-button-div").removeClass("ui-screen-hidden");
+ }
+ }
+ else
+ {
+ li = generateHtmlJobList($(this));
+
+ lastJobId = id;
+ $("#jobs-job-list").append(li).listview('refresh');
+ $("#jobs-li-"+id+"-sub-job-button").button();
+
+ $("#jobs-li-link-"+id).popupWindow({
+ height:900,
+ width:800,
+ top:30,
+ left:50
+ });
+ }
- $("#jobs-li-link-"+id).popupWindow({
- height:900,
- width:800,
- top:30,
- left:50
- });
});
console.log("last job id :"+lastJobId);
// Add new job list
$(xml).find("JobList").find("Job").each(function(){
var id = $(this).find("Id").text();
+ var jobAttribute = $(this).find("JobAttribute").text();
+ var parentJobId = $(this).find("ParentJobId").text();
var li = generateHtmlJobList($(this));
- $(li).insertBefore(firstLi);
- $("#jobs-job-list").listview('refresh');
- $("#jobs-li-link-"+id).popupWindow({
- height:900,
- width:800,
- top:30,
- left:50
- });
- console.log("ADD List :"+id);
+ if(jobAttribute == "CHILD") {
+ console.log("add-child-job parent's id:"+parentJobId);
+ $("#jobs-li-"+parentJobId+"-sub-job-area").append(li);
+ $("#jobs-li-"+id).collapsible();
+ $("#jobs-li-"+id+"-sub-job-button").button();
+ $("#jobs-job-list").listview('refresh');
+
+ $("#jobs-li-link-"+id).popupWindow({
+ height:900,
+ width:800,
+ top:30,
+ left:50
+ });
+ console.log("add-child-job id:"+id);
+
+ //Display sub-jobs button
+ if($("#jobs-li-"+parentJobId+"-sub-job-button-div").hasClass("ui-screen-hidden") == true) {
+ $("#jobs-li-"+parentJobId+"-sub-job-button-div").removeClass("ui-screen-hidden");
+ }
+ }
+ else {
+ $(li).insertBefore(firstLi);
+ $("#jobs-job-list").listview('refresh');
+ $("#jobs-li-"+id+"-sub-job-button").button();
+ $("#jobs-li-link-"+id).popupWindow({
+ height:900,
+ width:800,
+ top:30,
+ left:50
+ });
+ console.log("ADD List :"+id);
+ }
});
// Update working job list
var job_id = $(this).find("Id").text();
var parent_job_id = $(this).find("ParentJobId").text();
var job_status = $(this).find("Status").text();
+ var job_error_code = $(this).find("ErrorCode").text();
var start_time = $(this).find("StartTime").text();
var end_time = $(this).find("EndTime").text();
var font_color = "black";
switch(job_status)
{
case "ERROR" :
+ if(job_error_code != "") {
+ job_status = job_error_code;
+ }
case "CANCELED" :
font_color = "red";
break;
console.log("UPDATE List :"+job_id);
}
else {
- var next_parent_job_li = $("#jobs-li-"+parent_job_id).nextAll(".jobs-li-header").first();
- console.log(parent_job_id);
- console.log($("#jobs-li-"+parent_job_id));
- console.log(next_parent_job_li);
- console.log(next_parent_job_li.text());
-
+ console.log("add-child-job parent's id:"+parent_job_id);
var li = generateHtmlJobList($(this));
-
- $(li).insertBefore(next_parent_job_li);
+ $("#jobs-li-"+parent_job_id+"-sub-job-area").append(li);
+ $("#jobs-li-"+job_id).collapsible();
+ $("#jobs-li-"+job_id+"-sub-job-button").button();
$("#jobs-job-list").listview('refresh');
+
$("#jobs-li-link-"+job_id).popupWindow({
height:900,
width:800,
top:30,
left:50
});
- console.log("ADD child list :"+job_id);
+ console.log("add-child-job id:"+job_id);
+
+ //Display sub-jobs button
+ if($("#jobs-li-"+parent_job_id+"-sub-job-button-div").hasClass("ui-screen-hidden") == true) {
+ $("#jobs-li-"+parent_job_id+"-sub-job-button-div").removeClass("ui-screen-hidden");
+ }
}
});
});
suggestion_list = [];
if(distribution == "ALL") {
- queryAllProject(function(xml) {
+ queryAllProjectInOpenStatus(function(xml) {
var idx = 0;
$(xml).find("Data").find("Project").each(function(){
clearJobList();
}
+
function generateHtmlJobList(xml) {
var id = xml.find("Id").text();
var distribution = xml.find("Distribution").text();
var jobAttribute = xml.find("JobAttribute").text();
var os = xml.find("Os").text();
var jobStatus = xml.find("Status").text();
+ var jobErrorCode = xml.find("ErrorCode").text();
var userName = xml.find("UserName").text();
var startTime = xml.find("StartTime").text();
var endTime = xml.find("EndTime").text();
+ var projectList = xml.find("ProjectList").text();
var li = "";
var font_color = "black";
switch(jobStatus)
{
case "ERROR" :
+ if(jobErrorCode != "") {
+ jobStatus = jobErrorCode;
+ }
+ console.log(id);
+ console.log(jobErrorCode);
case "CANCELED" :
font_color = "red";
break;
{
li = '<li class="jobs-li-header" data-role="list-divider" title="'+id+'">'
+ '<span>'+id+ ' ' +projectName+ '</span><span style="float: right">'+distribution+'</span></li>'
- + '<li id="jobs-li-'+id+'" class="jobs-list-data" title="'+id+'">'
+ + '<li id="jobs-li-'+id+'" class="jobs-list-data" title="'+id+'" data-icon="false">'
+ '<a href=log.html?jobid='+id+' id="jobs-li-link-'+id+'" class="logWindow" data-ajax="false">'
+ '<h3>' +projectName+ '</h3>'
+ '<p>ID : <strong>' +id+ '</strong></p>'
+ '<p id="jobs-li-time-'+id+'">TIME: <strong>' +startTime+ ' ~ '+endTime+ '</strong></p>';
li = li + '<p id="jobs-li-status-'+id+'" class="ui-li-aside jobs-li-status"><strong><font color="'+font_color+'">'+jobStatus+'</strong></p>';
- li = li + '<div hidden="hidden" class="jobs-li-hidden ui-screen-hidden">'
+ li = li + '</a>';
+ li = li + '<div id="jobs-li-'+id+'-sub-job-button-div" class="ui-screen-hidden" style="position: absolute; top: 95px; right: 20px;"><button id="jobs-li-'+id+'-sub-job-button" data-inline="true" data-mini="true" data-icon="plus" data-iconpos="notext" data-corners="true" onClick="clickSubJobs('+id+')"></button></div>'
+ li = li + '<div class="ui-screen-hidden">'
+ '<p class="jobs-li-hidden-id">'+id+'</p>'
+ '<p class="jobs-li-hidden-attr">'+jobAttribute+'</p>'
+ '</div>';
- li = li + '</a></li>';
+ li = li + '</li>';
+ //For Sub job
+ li = li + '<li id="jobs-li-'+id+'-child" class="ui-screen-hidden">'
+ + '<div id="jobs-li-'+id+'-sub-job-area"></div></li>';
}
else if(jobAttribute == "MULTI")
{
li = '<li class="jobs-li-header" data-role="list-divider" title="'+id+'">'
- + '<span>'+id+ ' ' +jobAttribute+ '</span><span style="float: right">'+distribution+'</span></li>'
- + '<li id="jobs-li-'+id+'" class="jobs-list-data" title="'+id+'">'
- + '<a href=log.html?jobid='+id+' id="jobs-li-link-'+id+'" class="logWindow" data-ajax="false">'
+ + '<span>'+id+ ' ' +jobAttribute+ '</span><span style="float: right">'+distribution+'</span></li>';
+ li = li + '<li id="jobs-li-'+id+'" class="jobs-list-data" title="'+id+'" data-icon="false">';
+ li = li + '<a href=log.html?jobid='+id+' id="jobs-li-link-'+id+'" class="logWindow" data-ajax="false">'
+ + '<h3>' +projectList+ '</h3>'
+ + '<p>ID : <strong>' +id+ '</strong></p>'
+ + '<p>TYPE : <strong>' +jobType+ '</strong></p>'
+ '<p>USER : <strong>' +userName+ '</strong></p>'
+ '<p id="jobs-li-time-'+id+'">TIME: <strong>' +startTime+ ' ~ '+endTime+ '</strong></p>'
- + '<p id="jobs-li-attr-'+id+'" hidden="hidden">'+jobAttribute+'</p>';
- li = li + '<p id="jobs-li-status-'+id+'" class="ui-li-aside jobs-li-status" title="'+id+'"><strong><font color="'+font_color+'">'+jobStatus+'</strong></p>';
- li = li + '<div hidden="hidden" class="jobs-li-hidden ui-screen-hidden">'
- + '<p class="jobs-li-hidden-id">'+id+'</p>'
- + '<p class="jobs-li-hidden-attr">'+jobAttribute+'</p>'
- + '</div>';
- li = li + '</a></li>';
+ li = li + '<p id="jobs-li-status-'+id+'" class="ui-li-aside jobs-li-status" title="'+id+'"><strong><font color="'+font_color+'">'+jobStatus+'</strong></p>';
+ li = li + '</a>';
+ li = li + '<div id="jobs-li-'+id+'-sub-job-button-div" class="ui-screen-hidden" style="position: absolute; top: 80px; right: 20px;"><button id="jobs-li-'+id+'-sub-job-button" data-inline="true" data-mini="true" data-icon="plus" data-iconpos="notext" data-corners="true" onClick="clickSubJobs('+id+')"></button></div>'
+ li = li + '<div class="ui-screen-hidden">'
+ + '<p class="jobs-li-hidden-id">'+id+'</p>'
+ + '<p class="jobs-li-hidden-attr">'+jobAttribute+'</p>'
+ + '</div>';
+ li = li + '</li>';
+ //For Sub job
+ li = li + '<li id="jobs-li-'+id+'-child" class="ui-screen-hidden">'
+ + '<div id="jobs-li-'+id+'-sub-job-area"></div></li>';
}
else if(jobAttribute == "CHILD")
{
- li = '<li id="jobs-li-'+id+'" class="jobs-list-data" title="'+id+'">'
- + '<a href=log.html?jobid='+id+' id="jobs-li-link-'+id+'" class="logWindow" data-ajax="false">'
- + '<h3>' +projectName+ '</h3>'
- + '<p>ID : <strong>' +id+ '</strong></p>'
+ li = '<div id="jobs-li-'+id+'" class="jobs-list-data" title="'+id+'" data-role="collapsible" data-collapsed="true" data-mini="true" data-iconpos="right" style="clear: both;">'
+ + '<h3><span style="width: 80%;">['+id+ '] '+projectName+' - '+os+'</span><span id="jobs-li-status-'+id+'" class="jobs-li-status" style="float: right; font-size: 12px;"><font color="'+font_color+'">'+jobStatus+'</font></span></h3>'
+ + '<a href=log.html?jobid='+id+' id="jobs-li-link-'+id+'" class="logWindow" data-ajax="false" style="text-decoration: none; color: black">'
+ + '<h4>' +projectName+ '</h4>'
+ + '<p class="ui-li-desc">ID : <strong>' +id+ '</strong></p>'
+ '<p>TYPE : <strong>' +jobType+ '</strong></p>'
+ '<p>OS : <strong>' +os+ '</strong></p>'
+ '<p id="jobs-li-time-'+id+'">TIME: <strong>' +startTime+ ' ~ '+endTime+ '</strong></p>'
- + '<p id="jobs-li-attr-'+id+'" hidden="hidden">'+jobAttribute+'</p>';
-
- li = li + '<p id="jobs-li-status-'+id+'" class="ui-li-aside jobs-list-status" title="'+id+'"><strong><font color="'+font_color+'">'+jobStatus+'</strong></p>';
- li = li + '<div hidden="hidden" class="jobs-li-hidden ui-screen-hidden">'
- + '<p class="jobs-li-hidden-id">'+id+'</p>'
- + '<p class="jobs-li-hidden-attr">'+jobAttribute+'</p>'
- + '</div>';
- li = li + '</a></li>';
+ + '</a>';
+ li = li + '<div class="ui-screen-hidden">'
+ + '<p class="jobs-li-hidden-id">'+id+'</p>'
+ + '<p class="jobs-li-hidden-attr">'+jobAttribute+'</p>'
+ + '</div>';
+ li = li + '<div id="jobs-li-'+id+'-sub-job-button-div" class="ui-screen-hidden" style="float: right; position: relative; top: -20px;"><button id="jobs-li-'+id+'-sub-job-button" data-inline="true" data-mini="true" data-icon="minus" data-iconpos="notext" data-corners="true" onClick="clickSubJobs('+id+')"></button></div>';
+ //For Sub job
+ li = li + '<div id="jobs-li-'+id+'-child" style="clear: both; width: 97%; position: relative; left: 30px;">'
+ + '<div id="jobs-li-'+id+'-sub-job-area"></div></div>';
+ li = li + '</div>';
}
return li;
case "WORKING" :
case "REMOTE_WORKING" :
case "WAITING" :
- if(job_attr != "CHILD") {
- working_job_array.push(job_id);
- }
+ working_job_array.push(job_id);
break;
default:
break;
}
}
+function clickSubJobs(job_id) {
+ if($("#jobs-li-"+job_id+"-child").hasClass("ui-screen-hidden") == true) {
+ $("#jobs-li-"+job_id+"-child").removeClass("ui-screen-hidden");
+ $("#jobs-li-"+job_id+"-sub-job-button").buttonMarkup({icon:"minus"});
+ }
+ else {
+ $("#jobs-li-"+job_id+"-child").addClass("ui-screen-hidden");
+ $("#jobs-li-"+job_id+"-sub-job-button").buttonMarkup({icon:"plus"});
+ }
+}
+
}
function autoQueryLog(conti, working_status) {
- if(conti && stop) {
- queryLog();
- }
- else if(working_status == 1 && stop) {
+ if(working_status == 1 && stop) {
console.log("status is working. try request");
- setTimeout(function(){queryLog()}, 3000);
+ setTimeout(function(){queryLog()}, 1000);
+ }
+ else if(conti && stop) {
+ console.log("contiue request");
+ setTimeout(function(){queryLog()}, 100);
}
}
function cancelJob() {
cancelJobsJobid(job_id, function(xml) {
- alert("Reqeusted cancel job : "+job_id);
+ var message = $(xml).find("Data").find("Message").text();
+ alert(message);
});
}
clearFormData('signup-form');
break;
case "login":
- clearFormData('login-form');
+ clearLoginData();
+ getUserId();
break;
case "projects":
generateNavigationBar(id);
case "adminDistributionModify":
adminDistributionModifyPopupInit();
break;
- case "adminUserModify":
- adminUserModifyInit();
- break;
- case "adminProjectModifyBinary":
- adminProjectModifyBinaryProjectInit();
- break;
- case "adminProjectModifyGit":
- adminProjectModifyGitProjectInit();
- break;
case "adminGroupAdd":
adminGroupAddInit();
break;
- case "adminGroupModify":
- adminGroupModifyInit();
- break;
- case "adminServerModifyRemoteBuildServer":
- adminServerModifyRemoteBuildServerInit();
- break;
case "adminProjectAddGit":
adminProjectAddGitInit();
break;
buildClear();
jobsClear();
}
+
+function getCookie(key)
+{
+ var cook = document.cookie + ";";
+ var idx = cook.indexOf(key, 0);
+ var val = "";
+
+ if (idx != -1) {
+ cook = cook.substring(idx, cook.length);
+ begin = cook.indexOf("=", 0) + 1;
+ end = cook.indexOf(";", begin);
+ val = unescape(cook.substring(begin, end));
+ }
+
+ return val;
+}
+
+function saveCookie(key, value, expire_days)
+{
+ var today = new Date();
+ today.setDate(today.getDate() + expire_days);
+ document.cookie = key + "=" + escape(value) + "; path=/; expires=" + today.toGMTString() + ";";
+}
function projectsInit() {
if( $("#projects-distribution-select").children().length == 0 ) {
queryDistribution( function(xml) {
- $(xml).find("Data").find("DistributionName").each(function(){
- var name = $(this).text();
+ $(xml).find("Data").find("Distribution").each(function(){
+ var id = $(this).find("Id").text();
+ var name = $(this).find("Name").text();
- $("#projects-distribution-select").append("<option value=\'"+name+"\'>"+name+"</option>");
+ $("#projects-distribution-select").append("<option value=\'"+id+"\'>"+name+"</option>");
});
/* default distribution selection */
- $("#projects-distribution-select option:eq(0)").attr("selected", "selected");
+ defualt_dist_id = projectsGetCookieDistribution();
+ $("#projects-distribution-select").val(defualt_dist_id);
$("#projects-distribution-select").selectmenu('refresh');
- projectsQueryProjectListType("MY");
$('#projects-type-select input[type="radio"]').attr("checked",false).checkboxradio("refresh");
$('#projects-type-select input[type="radio"]:first').attr("checked",true).checkboxradio("refresh");
+ projectsQueryProjectListType();
});
} else {
- projectsQueryProjectListType("MY");
- $('#projects-type-select input[type="radio"]').attr("checked",false).checkboxradio("refresh");
- $('#projects-type-select input[type="radio"]:first').attr("checked",true).checkboxradio("refresh");
+ projectsQueryProjectListType();
}
}
-function projectsQueryProjectListType(queryType) {
- var distName = $("#projects-distribution-select option:selected").val();
+function projectsQueryProjectListType() {
+ var dist_id = $("#projects-distribution-select option:selected").val();
- queryProjectsInfoInDistribution( distName, function(xml) {
+ projectsSetCookieDistribution(dist_id);
+
+ queryProjectsInfoInDistribution( dist_id, function(xml) {
$("#projects-project-list").empty();
var projectList = document.getElementById("projects-project-list");
+ var projectType = $('#projects-type-select').find("input[type='radio']:checked").val();
$(xml).find("Data").find("ProjectList").find("Project").each(function(){
- switch(queryType) {
+ switch(projectType) {
case "ALL":
projectsAppendProjectList($(this), projectList);
break;
}
function projectsAppendProjectList( project, projectList ) {
+ var id = project.find("Id").text();
var name = project.find("Name").text();
var type = project.find("Type").text();
var groupAccess = project.find("GroupAccess").text();
$("#projects-project-list").empty();
}
+function projectsSetCookieDistribution(id)
+{
+ saveCookie("projects_distribution", id, 7);
+}
+
+function projectsGetCookieDistribution()
+{
+ id = getCookie("projects_distribution");
+ if(id == "") {
+ id = 0;
+ }
+ return id;
+}
sessionStorage.sessionInfoName = name;
sessionStorage.sessionInfoGroup = group;
sessionStorage.sessionInfoAdmin = admin;
+
+ saveUserId(email);
+
$.mobile.changePage("#index");
}
else
{
alert(message);
- }
+ }
});
}
+
+function clearLoginData()
+{
+ $("#login-form-email").val("");
+ $("#login-form-password").val("");
+}
+function getUserId()
+{
+ id = getCookie("user_email");
+ if(id != "") {
+ $("#login-form-email").val(id);
+ }
+}
+
+function saveUserId(id)
+{
+ if($("#login-form-save").attr("checked") == "checked") {
+ if (id != "") {
+ saveCookie("user_email", id, 7);
+ } else {
+ saveCookie("user_email", id, -1);
+ }
+ }
+ else {
+ saveCookie("user_email", id, -1);
+ }
+}
<script>
$('#register').click(function(){
- var dist_name = localStorage.distibutionName;
- var prj_name = localStorage.uploadBinaryProjectName;
+ var prj_id = localStorage.uploadBinaryProjectId;
var formData = new FormData($('form')[0]);
- formData.append("distribution", dist_name);
- formData.append("project", prj_name);
+ formData.append("ProjectId", prj_id);
$('progress').removeAttr("hidden");
+* 2.1.40
+- Fixed some minor bugs
+== Sungmin Kim <dev.sungmin.kim@samsung.com> 2013-06-04
+* 2.1.33
+- Applied "retry count" when downloading files
+- Changed "stop" command format of pkg sver
+- Fixed some minor bugs
+== donghee yang <donghee.yang@samsung.com> 2013-06-04
+* 2.1.32
+- DIBS command should be forcibly enter your email address and password.
+== Taejun ha <taejun.ha@samsung.com> 2013-04-24
+* 2.1.31
+- Fixed a bug that calc for empty room
+- Fixed a bug that local commit id is used for remote build
+- Shows reverse build jobs in DIBS WEB
+- Shows "ERROR CODE" in DIBS WEB
+== donghee yang <donghee.yang@samsung.com> 2013-04-24
+* 2.1.30
+- Fixed a bug that infinite loop of getting source code
+== donghee yang <donghee.yang@samsung.com> 2013-04-19
+* 2.1.29
+- Fixed a bug that migrating DB does not work
+== donghee yang <donghee.yang@samsung.com> 2013-04-19
+* 2.1.28
+- Fixed a bug that upgrade does not work
+== donghee yang <donghee.yang@samsung.com> 2013-04-19
+* 2.1.27
+- Fixed build server failure caused by job number
+== donghee yang <donghee.yang@samsung.com> 2013-04-19
+* 2.1.26
+- Added new user "sync-manager" for package synchronization
+- Changed to insert error code when job is ended with "ERROR"
+- Added time-stamping of job
+- Modified to make child build servers work without DB
+== donghee yang <donghee.yang@samsung.com> 2013-04-19
+* 2.1.25
+- Fixed a bug that remote job is not released from remote server queue
+== donghee yang <donghee.yang@samsung.com> 2013-04-12
+* 2.1.24
+- Fixed a bug that job assignment to child server is wrong
+== donghee yang <donghee.yang@samsung.com> 2013-04-12
+* 2.1.23
+- Modified to make build-server work when max-job is zero
+== donghee yang <donghee.yang@samsung.com> 2013-04-12
+* 2.1.22
+- Fixed not to build redundent jobs
+- Modified to use separate process for file transfering
+== donghee yang <donghee.yang@samsung.com> 2013-04-11
+* 2.1.21
+- Fixed the calculation of file transfer rate
+== donghee yang <donghee.yang@samsung.com> 2013-04-11
+* 2.1.20
+- Separate the process for log monitor
+== donghee yang <donghee.yang@samsung.com> 2013-04-10
+* 2.1.19
+- Fixed a bug that noreverse option is not working
+- Fixed a bug about checking dependency of multi job
+- Modified to continue build process when "git reset fail"
+- Fixed a but that remote job return wrong status
+- Fixed a bug that JOB numbering return 0
+== donghee yang <donghee.yang@samsung.com> 2013-04-05
+* 2.1.18
+- Increase protocol version from 1.8.0 to 1.9.0
+== Sungmin kim <dev.sungmin.kim@samsung.com> 2013-04-04
+* 2.1.17
+- Add command about "pkg-cli changeLog -u url [-s snapshotName1,snapshotName2]"
+- Fixed Multi-job about sub-job add internal job for cancel process
+- Fixed stoping query-log when couldn't search in JOB queue
+- Fixed reverse-job to add int DB first after creation
+== Sungmin kim <dev.sungmin.kim@samsung.com> 2013-04-03
+* 2.1.16
+- Fixed query-log terminated when status is not "FINISHED"
+- Fixed bug about file lock in build-cli
+== Sungmin kim <dev.sungmin.kim@samsung.com> 2013-04-01
+* 2.1.15
+- Fixed some bug about query-log
+- Improve process in web side
+== Sungmin kim <dev.sungmin.kim@samsung.com> 2013-03-29
+* 2.1.14
+- Support query-log command
+- Improve process to receive log
+== Sungmin kim <dev.sungmin.kim@samsung.com> 2013-03-28
+* 2.1.13
+- Fixed a bug that there are too many open files on build-svr
+== donghee yang <donghee.yang@samsung.com> 2013-03-27
+* 2.1.12
+- Project lock Applied with dibs web
+== taejun ha <taejun.ha@samsung.com> 2013-03-26
+* 2.1.11
+- Fixed a bug that "CANCEL" of remote job is not finished
+== donghee yang <donghee.yang@samsung.com> 2013-03-26
+* 2.1.10
+- Added more check points for immediate "CANCEL"
+== donghee yang <donghee.yang@samsung.com> 2013-03-26
+* 2.1.9
+- Fixed a bug that "CANCEL" is not done immediately
+== donghee yang <donghee.yang@samsung.com> 2013-03-26
+* 2.1.8
+- Modified to use hard-link instead of copying
+- Removed "verbose" option in build-cli
+== donghee yang <donghee.yang@samsung.com> 2013-03-25
+* 2.1.7
+- add log for debug
+== hyoun jiil <jiil.hyoun@samsung.com> 2013-03-21
+* 2.1.6
+- Fixed client cache bug
+- Fixed Job numbering bug
+== donghee yang <donghee.yang@samsung.com> 2013-03-20
* 2.1.5
- bug fix : log file remove when job initializing
== hyoun jiil <jiil.hyoun@samsung.com> 2013-03-15
Source : dibs
-Version :2.1.5
+Version :2.1.40
Maintainer : taejun ha<taejun.ha@samsung.com>, jiil hyoun <jiil.hyoun@samsung.com>, donghyuk yang <donghyouk.yang@samsung.com>, donghee yang <donghee.yang@samsung.com>, sungmin kim <dev.sungmin.kim@samsung.com
Package : dibs
# check HOST OS
if not Utils.check_host_OS() then
- puts "Error: Your host OS is not supported!"
- exit 1
+
+ if Utils.is_linux_like_os Utils::HOST_OS then
+ Utils.set_default_linux_host_os
+ puts "Warning: Your host OS is not supported!\nWe assume your host OS as #{Utils::HOST_OS} !!!"
+ else
+ puts "Error: Your host OS is not supported!"
+ exit 1
+ end
end
# if "--os" is not specified, use host os type
# check HOST OS
if not Utils.check_host_OS() then
- puts "Error: Your host OS is not supported!"
- exit 1
+
+ if Utils.is_linux_like_os Utils::HOST_OS then
+ Utils.set_default_linux_host_os
+ puts "Warning: Your host OS is not supported!\nWe assume your host OS as #{Utils::HOST_OS} !!!"
+ else
+ puts "Error: Your host OS is not supported!"
+ exit 1
+ end
end
begin
# check HOST OS
if not Utils.check_host_OS() then
- puts "Error: Your host OS is not supported!"
- exit 1
+
+ if Utils.is_linux_like_os Utils::HOST_OS then
+ Utils.set_default_linux_host_os
+ puts "Warning: Your host OS is not supported!\nWe assume your host OS as #{Utils::HOST_OS} !!!"
+ else
+ puts "Error: Your host OS is not supported!"
+ exit 1
+ end
end
#if "--os" is not specfied, use host os type
if option[:os].nil? then
case option[:cmd]
when "clean" then
- client = Client.new( nil, option[:loc], nil, false )
+ client = Client.create( nil, option[:loc], nil, false )
+ if client.nil? then
+ puts "Error: Cannot create package client!"
+ exit 1
+ end
client.clean(option[:f])
when "download" then
- client = Client.new( option[:url], option[:loc], nil )
+ client = Client.create( option[:url], option[:loc], nil )
+ if client.nil? then
+ puts "Error: Cannot create package client!"
+ exit 1
+ end
file_loc = client.download( option[:pkg], option[:os], option[:t] )
+when "make-img" then
+ client = Client.create( option[:url], option[:loc], nil )
+ if client.nil? then
+ puts "Error: Cannot create package client!"
+ exit 1
+ end
+ client.make_img( option[:os] )
when "install" then
- client = Client.new( option[:url], option[:loc], nil )
+ client = Client.create( option[:url], option[:loc], nil )
+ if client.nil? then
+ puts "Error: Cannot create package client!"
+ exit 1
+ end
client.install( option[:pkg], option[:os], option[:t], option[:f] )
when "install-file" then
if option[:t] then
- client = Client.new( option[:url], option[:loc], nil )
+ client = Client.create( option[:url], option[:loc], nil )
+ if client.nil? then
+ puts "Error: Cannot create package client!"
+ exit 1
+ end
client.install_local_pkg( option[:pkg], option[:t], option[:f] )
else
- client = Client.new( nil, option[:loc], nil, false )
+ client = Client.create( nil, option[:loc], nil, false )
+ if client.nil? then
+ puts "Error: Cannot create package client!"
+ exit 1
+ end
client.install_local_pkg( option[:pkg], option[:t], option[:f] )
end
when "uninstall" then
- client = Client.new( nil, option[:loc], nil, false )
+ client = Client.create( nil, option[:loc], nil, false )
+ if client.nil? then
+ puts "Error: Cannot create package client!"
+ exit 1
+ end
client.uninstall( option[:pkg], option[:t] )
when "upgrade" then
- client = Client.new( option[:url], option[:loc], nil )
+ client = Client.create( option[:url], option[:loc], nil )
+ if client.nil? then
+ puts "Error: Cannot create package client!"
+ exit 1
+ end
client.upgrade( option[:os], option[:t] )
when "check-upgrade" then
- client = Client.new( option[:url], option[:loc], nil )
+ client = Client.create( option[:url], option[:loc], nil )
+ if client.nil? then
+ puts "Error: Cannot create package client!"
+ exit 1
+ end
client.check_upgrade( option[:os] )
when "show-rpkg" then
- client = Client.new( option[:url], nil, nil )
+ client = Client.create( option[:url], nil, nil )
+ if client.nil? then
+ puts "Error: Cannot create package client!"
+ exit 1
+ end
puts client.show_pkg_info( option[:pkg], option[:os] )
when "list-rpkg" then
- client = Client.new( option[:url], nil, nil )
+ client = Client.create( option[:url], nil, nil )
+ if client.nil? then
+ puts "Error: Cannot create package client!"
+ exit 1
+ end
result = client.show_pkg_list( option[:os] )
if not result.nil? and not result.empty? then
result.each do |i|
end
end
when "show-lpkg" then
- client = Client.new( nil, option[:loc], nil, false )
+ client = Client.create( nil, option[:loc], nil, false )
+ if client.nil? then
+ puts "Error: Cannot create package client!"
+ exit 1
+ end
puts client.show_installed_pkg_info( option[:pkg] )
when "list-lpkg" then
- client = Client.new( nil, option[:loc], nil, false )
+ client = Client.create( nil, option[:loc], nil, false )
+ if client.nil? then
+ puts "Error: Cannot create package client!"
+ exit 1
+ end
result = client.show_installed_pkg_list()
if not result.nil? and not result.empty? then
result.each do |i|
puts "Info: There is no any package."
end
when "build-dep" then
- client = Client.new( option[:url], nil, nil )
+ client = Client.create( option[:url], nil, nil )
+ if client.nil? then
+ puts "Error: Cannot create package client!"
+ exit 1
+ end
result = client.get_build_dependent_packages( option[:pkg], option[:os], true )
if result.nil? then
puts "Error: Failed to get remote package list. try update first."
ret[-3..-1] = ""
puts ret
when "install-dep" then
- client = Client.new( option[:url], nil, nil )
+ client = Client.create( option[:url], nil, nil )
+ if client.nil? then
+ puts "Error: Cannot create package client!"
+ exit 1
+ end
result = client.get_install_dependent_packages( option[:pkg], option[:os], true, false )
if result.nil? then
puts "Error: Failed to get remote package list. try update first."
ret[-3..-1] = ""
puts ret
when "register" then
- client = Client.new( nil, nil, nil )
+ client = Client.create( nil, nil, nil )
+ if client.nil? then
+ puts "Error: Cannot create package client!"
+ exit 1
+ end
client.register(option[:address], option[:dist], option[:pkg], option[:passwd])
+when "snapshotlist" then
+ client = Client.create(option[:url],nil,nil);
+ if client.nil? then
+ puts "Error: Cannot create package client!"
+ exit 1
+ end
+ client.printSnapshotList(option[:all]);
+when "changelog" then
+ client = Client.create(option[:url], nil, nil);
+ if client.nil? then
+ puts "Error: Cannot create package client!"
+ exit 1
+ end
+ if option[:snapshot].nil?() then
+ client.printChangeLog();
+ else
+ client.printChangeLog(option[:snapshot][0], option[:snapshot][1]);
+ end
else
raise RuntimeError, "Input is incorrect : #{option[:cmd]}"
end
# initialize
def initialize( name, server, os_list, dist_name, pkg_name = nil )
- super(name, "BINARY", server, os_list, dist_name)
+ super(name, "BINARY", server, os_list, dist_name, "OPEN")
@pkg_name = pkg_name
end
row, prj_os_list, source_info, package_info = load_row(name, dist_name, db)
prj_id = row['id']
prj_name = row['name']
- prj_passwd = row['password']
+ prj_status = row['status']
new_project = BinaryUploadProject.new(prj_name, server, prj_os_list, dist_name)
- if not prj_passwd.empty? then new_project.passwd = prj_passwd end
new_project.set_project_id( prj_id )
new_project.set_source_info( source_info )
new_project.set_package_info( package_info )
+ new_project.set_project_status( prj_status )
row=db.select_one("SELECT * FROM project_bins WHERE project_id=#{prj_id}")
if row.nil? then return nil end
require 'utils'
class BuildClientUsage
- BUILD="build-cli build -N <project name> -d <server address> [-o <os>] [-w <password>] [--async] [-D <distribution name>] [-U user-email] [-V]"
- #RESOLVE="build-cli resolve -N <project name> -d <server address> [-o <os>] [-w <password>] [--async] [-D <distribution name>] [-U user-email] [-V]"
+ BUILD="build-cli build -N <project name> -d <server address> -U <user-id> -w <user-password> [-o <os>] [--async] [-D <distribution name>] [--save]"
QUERY="build-cli query -d <server address>"
QUERY_SYSTEM="build-cli query-system -d <server address>"
QUERY_PROJECT="build-cli query-project -d <server address>"
QUERY_JOB="build-cli query-job -d <server address>"
- CANCEL="build-cli cancel -j <job number> -d <server address> [-w <password>] [-U user-email]"
- REGISTER="build-cli register -P <package file> -d <server address> [-t <ftp server url>] [-w <password>] [-D <distribution name>] [-U user-email]"
+ QUERY_LOG="build-cli query-log -d <server address> -j <job number> [--output <output file path>]"
+ CANCEL="build-cli cancel -j <job number> -d <server address> -U user-id -w <user-password>"
+ REGISTER="build-cli register -P <package file> -d <server address> -U user-id -w <user-password> [-t <ftp server url>] [-D <distribution name>]"
end
when "build" then
if options[:project].nil? or options[:project].empty? or
- options[:domain].nil? or options[:domain].empty? then
+ options[:domain].nil? or options[:domain].empty? or
+ options[:passwd].nil? or options[:passwd].empty? or
+ options[:user].nil? or options[:user].empty? then
raise ArgumentError, "Usage: " + BuildClientUsage::BUILD
end
-# when "resolve" then
-# if options[:project].nil? or options[:project].empty? or
-# options[:domain].nil? or options[:domain].empty? then
-# raise ArgumentError, "Usage: " + BuildClientUsage::RESOLVE
-# end
-#
when "query" then
if options[:domain].nil? or options[:domain].empty? then
raise ArgumentError, "Usage: " + BuildClientUsage::QUERY
raise ArgumentError, "Usage: " + BuildClientUsage::QUERY_JOB
end
+ when "query-log" then
+ if options[:domain].nil? or options[:domain].empty? or
+ options[:job].nil? or options[:job].empty? then
+ raise ArgumentError, "Usage: " + BuildClientUsage::QUERY_LOG
+ end
+
when "cancel" then
if options[:job].nil? or options[:job].empty? or
- options[:domain].nil? or options[:domain].empty? then
+ options[:domain].nil? or options[:domain].empty? or
+ options[:passwd].nil? or options[:passwd].empty? or
+ options[:user].nil? or options[:user].empty? then
raise ArgumentError, "Usage: " + BuildClientUsage::CANCEL
end
when "register" then
if options[:package].nil? or options[:package].empty? or
- options[:domain].nil? or options[:domain].empty? then
+ options[:domain].nil? or options[:domain].empty? or
+ options[:passwd].nil? or options[:passwd].empty? or
+ options[:user].nil? or options[:user].empty? then
raise ArgumentError, "Usage: " + BuildClientUsage::REGISTER
end
+ "\t" + "query-system Query system information about build-server." + "\n" \
+ "\t" + "query-project Query project information about build-server." + "\n" \
+ "\t" + "query-job Query job information about build-server." + "\n" \
+ + "\t" + "query-log Query log contents about job in build-server." + "\n" \
+ "\t" + "cancel Cancel a building project." + "\n" \
+ "\t" + "register Register the package to the build-server." + "\n" \
+ "\n" + "Subcommand usage:" + "\n" \
+ "\t" + BuildClientUsage::QUERY_SYSTEM + "\n" \
+ "\t" + BuildClientUsage::QUERY_PROJECT + "\n" \
+ "\t" + BuildClientUsage::QUERY_JOB + "\n" \
+ + "\t" + BuildClientUsage::QUERY_LOG + "\n" \
+ "\t" + BuildClientUsage::CANCEL + "\n" \
+ "\t" + BuildClientUsage::REGISTER + "\n" \
+ "\n" + "Options:" + "\n"
options[:noreverse] = "YES"
end
+ options[:rebuild] = "NO"
+ opts.on( '--rebuild', 'do not check package version' ) do
+ options[:rebuild] = "YES"
+ end
+
+ options[:save] = false
+ opts.on( '--save', 'save the files built from remote server' ) do
+ options[:save] = true
+ end
+
opts.on( '-j', '--job <job number>', 'job number' ) do|job|
options[:job] = job
end
options[:passwd] = ""
- opts.on( '-w', '--passwd <password>', 'password for managing project' ) do|passwd|
+ opts.on( '-w', '--passwd <user-password>', 'user password' ) do|passwd|
options[:passwd] = passwd
end
options[:fdomain] = domain
end
- options[:user] = "admin@user"
+ options[:user] = ""
opts.on( '-U', '--user <user email>', 'user email infomation' ) do|user|
options[:user] = user
end
- options[:verbose] = "NO"
- opts.on( '-V', '--verbose', 'verbose mode' ) do
- options[:verbose] = "YES"
+ options[:output] = nil
+ opts.on( '--output <output_path>', 'output file path' ) do|path|
+ options[:output] = path
end
opts.on( '-h', '--help', 'display help' ) do
- opts.help.split("\n").each {|op| puts op if not op.include? "--noreverse"}
+ opts.help.split("\n").each {|op| puts op if not op.include? "--noreverse" and not op.include? "--rebuild"}
exit
end
exit
end
+
end
cmd = ARGV[0]
if cmd.eql? "build" or #cmd.eql? "resolve" or
cmd.eql? "query" or cmd.eql? "query-system" or
cmd.eql? "query-project" or cmd.eql? "query-job" or
+ cmd.eql? "query-log" or
cmd.eql? "cancel" or
cmd.eql? "register" or
cmd =~ /(-v)|(--version)/ or
require "Version.rb"
require "Builder.rb"
require "RemoteBuilder.rb"
-require "JobLog.rb"
require "mail.rb"
require "utils.rb"
require "ReverseBuildChecker.rb"
require "CommonJob.rb"
+require "BuildServerException.rb"
class BuildJob < CommonJob
attr_accessor :pkginfo, :source_path
- attr_accessor :pkgsvr_client, :thread
-# attr_accessor :rev_fail_projects, :rev_success_jobs
-# attr_accessor :pending_ancestor
+ attr_accessor :pkgsvr_client
attr_accessor :no_reverse
- attr_accessor :remote_id
+ attr_accessor :remote_id, :remote_status, :remote_error_msg
# initialize
def initialize (project, os, server)
@os = os
@type = "BUILD"
- #@resolve = false
@host_os = Utils::HOST_OS
- if not @server.distmgr.nil? then
+ if not @server.distmgr.nil? and @server.has_db? and
+ not @project.nil? and not @project.is_transferred? then
@pkgsvr_url = @server.distmgr.get_distribution(project.dist_name).pkgsvr_url
@pkgsvr_ip = @server.distmgr.get_distribution(project.dist_name).pkgsvr_ip
@pkgsvr_port = @server.distmgr.get_distribution(project.dist_name).pkgsvr_port
# this item will be initialized on pre-verify
@pkginfo = nil
@pkgsvr_client = nil
- @thread = nil
@log = nil
@parent = nil # for job hierachy
#@pending_ancestor = nil # for cancel pending job
@remote_id = nil # for cancel remote_working job
@build_dep_prjs = nil # for cacnel pending job
+ @remote_status = ""
+ @remote_error_msg = ""
## for resolving build-break
#@rev_fail_projects = [] # list of [project,os]
@is_rev_build_check_job = false
@is_remote_job = false
- # for internal(transferred) job
- @is_internal_job = false
+ # "verified" means that server will not check any rule
+ @is_verified = false
+ # "send_result_back" mean that server will send package file by network
+ @send_result_back = false
@dock_num = "0"
+ @result_files = []
@external_pkgs = []
@force_rebuild = false
end
- def set_internal_job( dock_num )
- @is_internal_job = true
+ def set_verified( value )
+ @is_verified = value
+ end
+
+
+ def set_send_result_back( dock_num )
+ @send_result_back = true
@dock_num = dock_num
end
- ## set option for waiting for resolve
- #def set_resolve_flag()
- # @resolve = true
- #end
+ def is_send_result_back?
+ return @send_result_back
+ end
+
+ def get_result_files()
+ return @result_files
+ end
# set force rebuild
# This make project to build
end
+ # for transferred project, this will overwite URL
+ def set_package_server_url(url)
+ @pkgsvr_url = url
+ end
+
+
#cancel
def cancel()
# kill sub process if exist?
kill_sub_process()
# cancel all its sub jobs
- @sub_jobs.select{|x| x.event == "NONE"}.each do |sub|
+ @sub_jobs.select{|x| x.event == "NONE" and x.status != "FINISHED" and x.status != "ERROR" and x.status != "CANCELED" }.each do |sub|
sub.event = "CANCEL"
end
end
end
- # cancel log print
- if not @log.nil? then
- @log.info( "JOB is canceled by cancel operation !!", Log::LV_USER)
- end
-
- case @status
- when "REMOTE_WORKING" then
+ if @status == "REMOTE_WORKING" then
client = BuildCommClient.create( @remote_server.ip, @remote_server.port, @log )
if not client.nil? then
- client.send "CANCEL|#{@remote_id}|#{self.get_project.passwd}|admin@user"
+ client.send "CANCEL|#{@remote_id}||"
result1 = client.receive_data()
if result1.nil? then
@log.info( "cancel operation failed [connection error] !!", Log::LV_USER)
end
client.terminate
end
- #when "PENDING" then
- # if @pending_ancestor.nil? then
- # #resolve pending job
- # pending_descendants = @server.jobmgr.jobs.select do |j|
- # (not j.pending_ancestor.nil?) and "#{j.pending_ancestor.id}" == "#{@id}"
- # end
- # pending_descendants.each do |pd|
- # pd.cancel_state = "INIT"
- # end
- # else
- # # remove myself from success job if exist
- # # and add myself into rev_fail_project list if not exist
- # @pending_ancestor.remove_rev_success_job(self)
- # @pending_ancestor.add_rev_fail_project( @project, @os )
-
- # # remove the project that depends on me if exist
- # # and add it into rev_fail_project list if not exist
- # p_sub_jobs = @server.jobmgr.jobs.select do |j|
- # ( not j.pending_ancestor.nil? and
- # "#{j.pending_ancestor.id}" == "#{@pending_ancestor.id}" and
- # j.is_build_dependent_project(@project, @os) )
- # end
- # p_sub_jobs.each do |d|
- # @pending_ancestor.remove_rev_success_job(d)
- # @pending_ancestor.add_rev_fail_project( d.get_project, d.os )
-
- # if not d.thread.nil? then d.thread.terminate end
- # d.status = "WAITING"
- # end
- # end
- when "WORKING", "WAITING" , "INITIALIZING" , "JUST_CREATED" then
- #just log
- else # ERROR | FINISHED | RESOLVED
- #do noting
+ end
+
+ # wait for job thread to finish
+ @thread.join if not @thread.nil?
+
+ # cancel log print
+ if not @log.nil? then
+ @log.info( "JOB is canceled by cancel operation !!", Log::LV_USER)
end
end
if @pkginfo.nil? then return false end
@pkginfo.packages.each do |pkg|
- if pkg.os_list.include? @os and pkg.build_host_os.include? host_os then
- return true
+ if not pkg.os_list.include? @os then next end
+ if not pkg.build_host_os.include? host_os then
+ return false
end
end
- return false
+
+ return true
end
end
+ def is_same_with?(wjob)
+ # must have same distribution
+ if get_distribution_name() != wjob.get_distribution_name() then
+ return false
+ end
+
+ if @type != wjob.type then return false end
+
+ prj1 = get_project()
+ prj2 = wjob.get_project()
+
+ # check project name
+ if prj1.nil? or prj2.nil? or
+ prj1.name != prj2.name then
+ return false
+ end
+
+ # check version
+ if @pkginfo.nil? or wjob.pkginfo.nil? or
+ not(Version.new(@pkginfo.get_version()) == Version.new(wjob.pkginfo.get_version())) then
+ return false
+ end
+ end
+
+
def is_compatible_with?(o)
# must have same distribution
if get_distribution_name() != o.get_distribution_name() then
end
- def is_connected?
- return @log.is_connected?
- end
-
-
# return the job is asyncronous job
def is_asynchronous_job?
- if not @log.has_second_out? then
- return true
- else
- return false
- end
+ return true
end
- ## remove job from reverse success job
- #def remove_rev_success_job( job )
- # @rev_success_jobs.delete job if @rev_success_jobs.include? job
- #end
-
-
- ## check [project,os] is in reverse fail project list
- #def is_rev_fail_project( prj, os )
- # # check the project already exist
- # @rev_fail_projects.each do |p|
- # if p[0] == prj and p[1] == os then
- # return true
- # end
- # end
-
- # return false
- #end
-
-
- ## add [project,os] to reverse fail project list
- #def add_rev_fail_project( prj, os )
- # # check the project already exist
- # @rev_fail_projects.each do |p|
- # if p[0] == prj and p[1] == os then
- # return
- # end
- # end
- # # if not, add it
- # @rev_fail_projects.push [prj,os]
- #end
-
-
- ## remove [project,os] from reverse fail project list
- #def remove_rev_fail_project( prj, os )
- # remove_list = []
-
- # # check project and os name
- # @rev_fail_projects.each do |p|
- # if p[0] == prj and p[1] == os then
- # remove_list.push p
- # end
- # end
-
- # # remove
- # remove_list.each do |r|
- # @rev_fail_projects.delete r
- # end
- #end
-
-
# get project that my job is dependent on
def get_build_dependent_projects()
if @build_dep_prjs.nil? then
def get_log_url()
# only when server support log url
if @server.job_log_url.empty? then
- return "",""
+ return ""
end
- url = "#{@server.job_log_url}/#{@id}/log"
- # if remote, the file existence must be checked
- if File.exist? "#{@job_root}/remote_log" then
- return url,"#{@server.job_log_url}/#{@id}/remote_log"
- else
- return url,""
- end
+ return "#{@server.job_log_url}/#{@id}/log"
end
protected
def job_main()
@log.info( "Invoking a thread for building Job #{@id}", Log::LV_USER)
- if @status == "ERROR" then return end
@log.info( "New Job #{@id} is started", Log::LV_USER)
# checking build dependency
- if not @is_remote_job and not @is_internal_job and
- not check_build_dependency() then
- if @is_internal_job then copy_result_files_to_master() end
- @status = "ERROR"
- return false
+ if not @is_remote_job and not @is_verified then
+ check_build_dependency()
end
# clean build
- if not build() then
- if @is_internal_job then copy_result_files_to_master() end
-
- @status = "ERROR"
- return false
- end
+ build()
lock_event
+ if not @parent.nil? and not @is_rev_build_check_job then
+ copy_result_files(@parent.source_path)
+ end
+
# upload
- if not @is_rev_build_check_job and not @is_internal_job and
- @parent.nil? and
- not upload() then
- @status = "ERROR"
- return false
+ if not @is_rev_build_check_job and not @send_result_back and @parent.nil? then
+ upload()
end
# copy result files to transport path
- if @is_internal_job then
+ if @send_result_back and not @is_rev_build_check_job then
copy_result_files_to_master()
- elsif not @parent.nil? and not @is_rev_build_check_job then
- copy_result_files(@parent.source_path)
end
# INFO. don't change this string
@log.info( "Job is completed!", Log::LV_USER)
@status = "FINISHED"
- return true
end
# check if version is same and source_info is different
ver_local = @pkginfo.packages[0].version
old_source_info = @project.get_source_info( ver_local )
- if not old_source_info.nil? and old_source_info != source_info then
- @log.error( "Source code has been changed without increasing version!", Log::LV_USER)
- @log.error( " * Version : #{ver_local}", Log::LV_USER)
- @log.error( " * Before : #{old_source_info}", Log::LV_USER)
- @log.error( " * Current : #{source_info}", Log::LV_USER)
+ if ( not @force_rebuild and
+ not old_source_info.nil? and old_source_info != source_info ) then
- return false
+ raise BuildServerException.new("ERR106"), "#{ver_local}"
end
# compare with package version in package server
if ver_svr.nil? then next end
# compare version
- if Version.new(ver_local) < Version.new(ver_svr) or
- ( not @force_rebuild and Version.new(ver_local) == Version.new(ver_svr) ) then
- @log.error( "Version must be increased : #{ver_local} <= #{ver_svr}", Log::LV_USER)
- return false
+ if ( not @force_rebuild and
+ ( Version.new(ver_local) < Version.new(ver_svr) or
+ Version.new(ver_local) == Version.new(ver_svr) ) ) then
+
+ raise BuildServerException.new("ERR105"), "#{ver_local} <= #{ver_svr}"
end
end
# unmet dependencies found , report the errors
if not unmet_bdeps.empty? or not unmet_ideps.empty? then
- @log.error( "Unmet dependency found!", Log::LV_USER)
+ unmet_pkgs = []
unmet_bdeps.each do |d|
os = (d.target_os_list.empty?) ? @os : d.target_os_list[0]
- @log.error( " * #{d.package_name}(#{os}) for build-dependency", Log::LV_USER)
+ unmet_pkgs.push "#{d.package_name}(#{os})"
end
unmet_ideps.each do |d|
os = (d.target_os_list.empty?) ? @os : d.target_os_list[0]
- @log.error( " * #{d.package_name}(#{os}) for install-dependency", Log::LV_USER)
+ unmet_pkgs.push "#{d.package_name}(#{os})"
end
-
- return false
- else
- return true
+ unmet_pkgs.uniq!
+ raise BuildServerException.new("ERR200"), unmet_pkgs.join(",")
end
end
# build clean
def build()
-
- ## check there are pending packages which wait for me
- ## it will return nil if not exist
- ## this process must be skip if it is sub-job
- #if not @is_rev_build_check_job and not @is_internal_job then
- # @server.cancel_lock.synchronize do
- # @pending_ancestor = get_pending_ancestor_job()
- # end
- #end
-
- #if not @pending_ancestor.nil? then
- # # resolve other pending job
- # resolve()
- #elsif @resolve then
- # # wait for being resolved by other jobs
- # # this condition must be placed after checking pending status
- # wait_resolve()
- #else
- # # build
- # build_normal()
- #end
-
# build
build_normal()
end
- ## return pending job that wait for me
- #def get_pending_ancestor_job()
- # @server.jobmgr.get_pending_jobs.each do |job|
- # # must have same distribution
- # if get_distribution_name() != job.get_distribution_name() then
- # next
- # end
-
- # if job.is_rev_fail_project(@project,@os) then
- # return job
- # end
- # end
-
- # return nil
- #end
-
-
# check whether build this job or not
# if not build, then return its compat pkgs list
def check_compatable_packages
# create builder
if @is_remote_job then
- builder = RemoteBuilder.new("JB#{@id}", @remote_server, @server.ftp_addr, @server.ftp_port, @server.ftp_username, @server.ftp_passwd)
+ builder = RemoteBuilder.create_from_server(@remote_server, @server.ftp_addr, @server.ftp_port, @server.ftp_username, @server.ftp_passwd)
@log.info( "JobBuilder##{@id} is created", Log::LV_USER)
@log.info( " - Remote Server : #{@remote_server.ip}:#{@remote_server.port}" )
if not @server.ftp_addr.nil? then
else
builder = Builder.create( "JB#{@id}", @pkgsvr_url, nil,
"#{@buildroot_dir}", @server.build_cache_dir )
- if builder.nil?
- @log.error( "Creating job builder failed", Log::LV_USER)
- return false
+ if builder.nil? then
+ raise BuildServerException.new("ERR201")
end
@log.info( "JobBuilder##{@id} is created", Log::LV_USER)
@log.info( " - Package Server : #{@pkgsvr_url}" )
base_package_name= File.basename(local_path, "#{cos}#{ext}")
@log.info( "Copying compatible package:#{local_path}", Log::LV_USER)
@log.info( "Creating package file ... #{base_package_name}#{@os}#{ext}", Log::LV_USER)
- FileUtils.cp local_path, "#{@source_path}/#{base_package_name}#{@os}#{ext}"
+ FileUtils.ln local_path, "#{@source_path}/#{base_package_name}#{@os}#{ext}", :force => true
else
@log.info( "Downloading compatible package:#{pkg_name}(#{cos})", Log::LV_USER)
loc = @pkgsvr_client.download(pkg_name, cos, false)
# build
if @is_remote_job then
result = builder.build_job(self, local_pkgs)
+ # if remote build finishes, remove job from remote server
+ get_remote_server().remove_working_job(self)
+ get_remote_server().update_db()
else
result = builder.build_job(self, use_clean, local_pkgs, false )
end
if not result then
- @log.error( "Building job failed", Log::LV_USER)
- write_log_url()
- return false
+ raise BuildServerException.new("ERR202")
end
end
# check reverse dependecy if not sub jobs
+ if not @no_reverse and not @is_rev_build_check_job and not @is_verified and
+ not ReverseBuildChecker.check( self, true ).empty? then
- if not @no_reverse then
- if not @is_rev_build_check_job and not @is_internal_job and
- not ReverseBuildChecker.check( self, true ).empty? then
- @log.error( "Reverse-build-check failed!" )
- return false
- end
+ raise BuildServerException.new("ERR203")
end
-
- return true
end
- ## wait to be resolved by other jobs
- #def wait_resolve()
- # @log.info( "Started to build this job and wait for being resolved...", Log::LV_USER)
-
- # # create builder
- # if @is_remote_job then
- # builder = RemoteBuilder.new("JB#{@id}", @remote_server, @server.ftp_addr, @server.ftp_port, @server.ftp_username, @server.ftp_passwd)
- # @log.info( "JobBuilder##{@id} is created", Log::LV_USER)
- # @log.info( " - Remote Server : #{@remote_server.ip}:#{@remote_server.port}" )
- # if not @server.ftp_addr.nil? then
- # @log.info( " - FTP Server : #{@server.ftp_addr}" )
- # end
- # else
- # builder = Builder.create( "JB#{@id}", @pkgsvr_url, nil,
- # "#{@buildroot_dir}/#{@os}", @server.build_cache_dir )
- # if builder.nil?
- # @log.error( "Creating job builder failed", Log::LV_USER)
- # return false
- # end
- # @log.info( "JobBuilder##{@id} is created", Log::LV_USER)
- # @log.info( " - Package Server : #{@pkgsvr_url}" )
- # @log.info( " - Build Cache Path : #{@server.build_cache_dir}" )
- # end
- # @log.info( " - Log Path : #{@log.path}" )
-
- # # build
- # if @is_remote_job then
- # result = builder.build_job(self, [])
- # else
- # result = builder.build_job(self, true, [], false )
- # end
- # if not result then
- # @log.error( "Building job failed", Log::LV_USER)
- # write_log_url()
- # return false
- # end
-
- # # check reverse dependecy
- # @rev_fail_projects = ReverseBuildChecker.check(self, false)
- # if @rev_fail_projects.empty? then
- # # if no problem?, it OK
- # return true
- # end
-
- # # pending
- # @status = "PENDING"
- # @log.info( "Entered the PENDING state ...", Log::LV_USER)
- # old_msg = ""
- # while @status == "PENDING"
- # new_msg = @rev_fail_projects.map {|p| "#{p[0].name}(#{p[1]})"}.join(", ")
- # if old_msg != new_msg then
- # @log.error( " * Waiting for building next projects: #{new_msg}", Log::LV_USER)
- # old_msg = new_msg
- # end
- # sleep 1
- # end
-
- # return true
- #end
-
-
- ## resolve other pending job
- #def resolve()
-
- # # wait for other build-dependent projects are resolved
- # old_msg = ""
- # wait_prjs = @pending_ancestor.rev_fail_projects.select {|p| is_build_dependent_project(p[0], p[1])}
- # @log.info("Checking build dependency before RESOLVE", Log::LV_USER)
- # while not wait_prjs.empty?
- # @status = "PENDING"
- # new_msg = wait_prjs.map {|p| "#{p[0].name}(#{p[1]})"}.join(", ")
- # if new_msg != old_msg then
- # @log.info(" * Waiting for building next projects: #{new_msg}", Log::LV_USER)
- # old_msg = new_msg
- # end
- # sleep 1
- # wait_prjs = @pending_ancestor.rev_fail_projects.select {|p| is_build_dependent_project(p[0], p[1])}
- # end
-
- # # return back to "WORKING"
- # @status = "WORKING"
-
- # @log.info( "Started to build this job and resolve other pending job...", Log::LV_USER)
-
- # # create builder
- # if @is_remote_job then
- # builder = RemoteBuilder.new("JB#{@id}", @remote_server, @server.ftp_addr, @server.ftp_port, @server.ftp_username, @server.ftp_passwd)
- # @log.info( "JobBuilder##{@id} is created", Log::LV_USER)
- # @log.info( " - Remote Server : #{@remote_server.ip}:#{@remote_server.port}" )
- # if not @server.ftp_addr.nil? then
- # @log.info( " - FTP Server : #{@server.ftp_addr}" )
- # end
- # else
- # builder = Builder.create( "JB#{@id}", @pkgsvr_url, nil,
- # "#{@buildroot_dir}/#{@os}", @server.build_cache_dir )
- # if builder.nil?
- # @log.error( "Creating job builder failed", Log::LV_USER)
- # return false
- # end
- # @log.info( "JobBuilder##{@id} is created", Log::LV_USER)
- # @log.info( " - Package Server : #{@pkgsvr_url}" )
- # @log.info( " - Build Cache Path : #{@server.build_cache_dir}" )
- # end
- # @log.info( " - Log Path : #{@log.path}" )
-
- # # get local packages to overwite
- # # they must be composed of packages of pending jobs and its success list
- # local_pkgs=[]
- # local_pkgs += @external_pkgs
- # src_path = @pending_ancestor.source_path
- # ver = @pending_ancestor.pkginfo.get_version()
- # @pending_ancestor.pkginfo.get_target_packages(@os).each do |pkg|
- # local_pkgs.push "#{src_path}/#{pkg.package_name}_#{ver}_#{@os}.zip"
- # end
- # @pending_ancestor.rev_success_jobs.each do |job|
- # src_path = job.source_path
- # ver = job.pkginfo.get_version()
- # job.pkginfo.get_target_packages(@os).each do |pkg|
- # local_pkgs.push "#{src_path}/#{pkg.package_name}_#{ver}_#{@os}.zip"
- # end
- # end
-
- # # build
- # if @is_remote_job then
- # result = builder.build_job(self, local_pkgs)
- # else
- # result = builder.build_job(self, true, local_pkgs, false )
- # end
- # if not result then
- # @log.error( "Building job failed", Log::LV_USER)
- # write_log_url()
- # return false
- # end
-
- # # check reverse dependecy and update parent rev_fail_project list
- # new_fail_projects = ReverseBuildChecker.check(self, false)
- # new_fail_projects.each do |p|
- # @pending_ancestor.add_rev_fail_project(p[0], p[1])
- # end
-
- # # update the status of pending job
- # @status = "PENDING"
- # @pending_ancestor.remove_rev_fail_project(@project, @os)
- # @pending_ancestor.rev_success_jobs.push self
- # if @pending_ancestor.rev_fail_projects.empty? then
- # @pending_ancestor.status = "RESOLVED"
- # @pending_ancestor.rev_success_jobs.each do |job|
- # job.status = "RESOLVED"
- # end
- # else
- # @log.info( "Entered the PENDING state ...", Log::LV_USER)
- # old_msg = ""
- # while @status == "PENDING"
- # new_msg = @pending_ancestor.rev_fail_projects.map {|p| "#{p[0].name}(#{p[1]})"}.join(", ")
-
- # if new_msg != old_msg then
- # @log.info(" * Waiting for building next projects: #{new_msg}", Log::LV_USER)
- # old_msg = new_msg
- # end
-
- # sleep 1
- # end
- # end
-
- # return true
- #end
-
-
def upload()
- @log.info( "Uploading ...", Log::LV_USER)
+ begin
+ add_timestamp("UPLOAD_START")
+ @log.info( "Uploading ...", Log::LV_USER)
- # get package path list
- binpkg_path_list = Dir.glob("#{@source_path}/*_*_#{@os}.zip")
+ # get package path list
+ binpkg_path_list = Dir.glob("#{@source_path}/*_*_#{@os}.zip")
- # upload
- u_client = Client.new( @pkgsvr_url, nil, @log )
- snapshot = u_client.upload( @pkgsvr_ip, @pkgsvr_port, binpkg_path_list, @server.ftp_addr, @server.ftp_port, @server.ftp_username, @server.ftp_passwd, @pkgsvr_password)
+ # upload
+ u_client = Client.create( @pkgsvr_url, nil, @log )
+ if u_client.nil? then
+ raise BuildServerException.new("ERR023")
+ end
- if snapshot.nil? then
- @log.info( "Upload failed...", Log::LV_USER)
+ snapshot = u_client.upload( @pkgsvr_ip, @pkgsvr_port, binpkg_path_list, @server.ftp_addr, @server.ftp_port, @server.ftp_username, @server.ftp_passwd, @pkgsvr_password)
- return false
- end
+ if snapshot.nil? then
+ raise BuildServerException.new("ERR204")
+ end
- # update local
- @log.info( "Upload succeeded. Sync local pkg-server again...", Log::LV_USER)
- @pkgsvr_client.update
- @log.info("Snapshot: #{snapshot}", Log::LV_USER)
+ # update local
+ @log.info( "Upload succeeded. Sync local pkg-server again...", Log::LV_USER)
+ @pkgsvr_client.update
+ @log.info("Snapshot: #{snapshot}", Log::LV_USER)
- return true
+ ensure
+ add_timestamp("UPLOAD_END")
+ end
end
binpkg_path_list = Dir.glob("#{@source_path}/*_*_#{@os}.zip")
binpkg_path_list.each do |file|
+ @result_files.push File.basename(file)
@log.info( " * #{file}", Log::LV_USER)
- FileUtils.cp(file,"#{dst_path}/")
+ FileUtils.ln(file,"#{dst_path}/", :force => true)
end
-
- return true
end
# copy binary package files and log file to transport dir
def copy_result_files_to_master()
outgoing_dir = "#{@server.transport_path}/#{@dock_num}"
-
- @log.info( "Copying log to #{outgoing_dir}", Log::LV_USER)
- file = "#{@source_path}/../log"
- FileUtils.copy_file(file, "#{outgoing_dir}/remote_log")
-
- # copy result files, if not reverse build
- if not @is_rev_build_check_job then
- return copy_result_files( outgoing_dir )
- else
- return true
+ if not File.exist? outgoing_dir then
+ FileUtils.mkdir_p outgoing_dir
end
+
+ # copy result files
+ copy_result_files( outgoing_dir )
end
end
- # write web url for log
- protected
- def write_log_url()
- url,remote_url = get_log_url()
- if not url.empty? then
- @log.info( " ** Log1: #{url}", Log::LV_USER)
- end
- if not remote_url.empty? then
- @log.info( " ** Log2: #{remote_url}", Log::LV_USER)
- end
- end
-
-
# get target os of dependency
protected
def get_os_of_dependency(dep)
require 'fileutils'
require 'dbi'
require 'thread'
+require 'bcrypt'
+require 'file/tail'
$LOAD_PATH.unshift File.dirname(__FILE__)
$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common"
require "SocketJobRequestListener.rb"
require "ProjectManager.rb"
require "DistributionManager.rb"
require "db_utils.rb"
+require "FileUtil"
class BuildServer
attr_accessor :id, :path, :status, :host_os, :log
attr_accessor :remote_servers
attr_accessor :git_server_url, :git_bin_path
+ attr_accessor :config_port
attr_accessor :allowed_git_branch
attr_accessor :jobmgr
attr_accessor :test_time
def initialize (id, path, ftpsvr_addr, ftpsvr_port, ftpsvr_username, ftpsvr_passwd)
@id = id
@path = path
+ @run_file_path = File.join(BuildServer::CONFIG_ROOT, @id, "run")
@remote_servers = []
@req_listener = []
@finish = false
+ @running_port = nil
+ @config_port = nil
# status
@status = "INITIALIZING"
# host_os
#DB settring
@db = nil
- @db_dsn = "SQLite3:#{BuildServer::CONFIG_ROOT}/#{@id}/server.db"
+ @db_dsn = nil
@db_user = nil
@db_passwd = nil
- @db_version = 2
+ @db_version = 5
@sqlite3_db_mutex = Mutex.new
#DB upgrade SQL command
@db_migrate = []
+
+ @latest_job_id = nil
+ @job_id_mutex = Mutex.new
end
def send_mail
def send_mail=(mail)
get_db_connection() do |db|
- db.do "UPDATE server_configs SET value = '#{mail}' WHERE property = 'send_mail'"
+ db.do "UPDATE server_configs SET value = '#{mail.strip}' WHERE property = 'send_mail'"
end
end
def job_log_url=(url)
get_db_connection() do |db|
- db.do "UPDATE server_configs SET value = '#{url}' WHERE property = 'job_log_url'"
+ db.do "UPDATE server_configs SET value = '#{url.strip}' WHERE property = 'job_log_url'"
end
end
+
def port
- result = nil
+ return @running_port
+ end
+
+
+ def port=(svr_port)
+ @running_port = svr_port
+ if has_db? then
+ get_db_connection() do |db|
+ db.do "UPDATE server_configs SET value = '#{svr_port}' WHERE property = 'port'"
+ end
+ end
+ end
+
+ def save_id_to_db(id)
get_db_connection() do |db|
- result = db.select_one("SELECT value FROM server_configs WHERE property = 'port'")[0]
+ db.do "UPDATE server_configs SET value = '#{id.strip}' WHERE property = 'id'"
end
- return (result.nil?) ? "" : result
end
- def port=(svr_port)
+ def save_path_to_db(path)
get_db_connection() do |db|
- db.do "UPDATE server_configs SET value = '#{svr_port}' WHERE property = 'port'"
+ db.do "UPDATE server_configs SET value = '#{path.strip}' WHERE property = 'path'"
end
end
end
def db_insert_id(db)
- return (@db_dsn =~ /^Mysql/i) ? db.func(:insert_id) : db.select_one("SELECT last_insert_rowid()")[0]
+ return (@db_dsn =~ /^Mysql/i) ? db.func(:insert_id).to_s : db.select_one("SELECT last_insert_rowid()")[0]
+ end
+
+
+ def has_db?()
+ return (not @db_dsn.nil?)
end
+
# start server daemon
def start
# set build cache dir
FileUtils.mkdir_p @build_cache_dir
end
+ # init job directory if needed
+ if not File.exist? "#{@path}/jobs" then FileUtils.mkdir_p "#{@path}/jobs" end
+
# init transport path
if not File.exist? @transport_path then FileUtils.mkdir_p @transport_path end
+
+ #lock the build server. Do not run the same server at the same time
+ if not lockServer() then
+ printErrorMessage("Server \"#{id}\" is already running.")
+ return
+ end
+
+ #check that the port is open
+ if BuildCommServer.port_open? port then
+ printErrorMessage("Port \"#{port}\" is already in use.")
+ return
+ end
# init project mgr
@log.info "Setting Project Manager..."
@cleaner = JobCleaner.new(self)
@cleaner.start
+ # init latest job id
+ if has_db? then
+ @latest_job_id = get_latest_job_id_from_db()
+ else
+ @latest_job_id = get_latest_job_id_from_directory()
+ end
+
# set package server synchrontizer
@log.info "Setting Package Server Synchronizer..."
- @pkg_sync = PackageServerSynchronizer.new(self)
- @pkg_sync.start
-
+ if has_db? then
+ @pkg_sync = PackageServerSynchronizer.new(self)
+ @pkg_sync.start
+ end
+
# update friend server status
@log.info "Initializing Remote Servers..."
- @remote_servers = get_remote_servers()
- @remote_servers.each do |server|
- server.create_system_monitor()
+ if has_db? then
+ @remote_servers = get_remote_servers()
+ @remote_servers.each do |server|
+ server.create_system_monitor()
+ end
end
-
+
# main loop
@log.info "Entering main loop..."
@status = "RUNNING"
row = db.select_one("SELECT distributions.id FROM sync_pkg_servers,distributions WHERE sync_pkg_servers.pkgsvr_url='#{url}' and distributions.name='#{dist}' and sync_pkg_servers.distribution_id = distributions.id")
if not row.nil? then return false end
row = db.select_one("SELECT id FROM distributions WHERE name='#{dist}'")
- dist_id = row['id'];
- db.do "INSERT INTO sync_pkg_servers (pkgsvr_url,period,distribution_id) VALUES('#{url}','#{@pkg_sync_period}',#{dist_id})"
+ dist_id = row['id']
+ db.do "INSERT INTO sync_pkg_servers (pkgsvr_url,period,distribution_id) VALUES('#{url}',600,#{dist_id})"
end
return true
get_db_connection() do |db|
row = db.select_one("SELECT distributions.id FROM sync_pkg_servers,distributions WHERE sync_pkg_servers.pkgsvr_url='#{url}' and distributions.name='#{dist}' and sync_pkg_servers.distribution_id = distributions.id")
if row.nil? then return false end
- dist_id = row['id'];
+ dist_id = row['id']
db.do("DELETE FROM sync_pkg_servers WHERE pkgsvr_url='#{url}' and distribution_id=#{dist_id}")
end
end
# get availables server
- # but, job must not be "REGISTER" and "MULTIBUILD" job
- if job.type != "REGISTER" and job.type != "MULTIBUILD" then
+ if job.type == "MULTIBUILD" or job.type == "REGISTER" then
+ # if max working job is zero, check max-non-build-jobs
+ if @jobmgr.max_working_jobs == 0 and
+ local_empty_rooms >= -1 * @jobmgr.get_max_jobs() then
+ candidates.push self
+ end
+ else
+ # if normal JOB
@remote_servers.each do |server|
if ( server.status == "RUNNING" and server.can_build?( job ) and
not server.has_waiting_jobs and
end
end
- best_server = candidates[0]
- if best_server.nil? or candidates.count == 1 then return best_server end
+ if candidates.count == 0 then return nil end
# get best
# it is better if working jobs count is less
+ best_server = candidates[0]
max_empty_room = best_server.get_number_of_empty_room
candidates.each do |server|
# check whether idle, use it
if @db_dsn =~ /^Mysql/i then
@db_migrate[1]=["ALTER TABLE jobs CHANGE COLUMN id id INTEGER AUTO_INCREMENT NOT NULL",
"ALTER TABLE distributions ADD pkgsvr_password VARCHAR(64)"]
+ @db_migrate[2]=["ALTER TABLE projects ADD COLUMN status VARCHAR(32) NOT NULL DEFAULT 'OPEN'"]
+ @db_migrate[3]=["CREATE TABLE job_timestamps (id INTEGER PRIMARY KEY #{db_inc()}, job_id INTEGER, stamp_name VARCHAR(64), stamp_time DATETIME)#{db_post_fix()}",
+ "ALTER TABLE jobs ADD COLUMN error_code VARCHAR(32)",
+ "INSERT INTO users (name,email,password_hash,password_salt) VALUES ('sync-manager','sync-manager@user','$2a$10$H.w3ssI9KfuvNEXXp1qxD.b3Wm8alJG.HXviUofe4nErDn.TKUAka','$2a$10$H.w3ssI9KfuvNEXXp1qxD.')",
+ "INSERT INTO user_groups (user_id, group_id) SELECT users.id,groups.id FROM users,groups WHERE users.email = 'sync-manager@user' and groups.name = 'admin'",
+ "INSERT INTO server_configs (property,value) VALUES ('max_jobs','4')"]
+ @db_migrate[4]=["ALTER TABLE projects DROP COLUMN password"]
else
@db_migrate[1]=["ALTER TABLE distributions ADD pkgsvr_password VARCHAR(64)"]
+ @db_migrate[2]=["ALTER TABLE projects ADD COLUMN status VARCHAR(32) NOT NULL DEFAULT 'OPEN'"]
+ @db_migrate[3]=["CREATE TABLE job_timestamps (id INTEGER PRIMARY KEY #{db_inc()}, job_id INTEGER, stamp_name VARCHAR(64), stamp_time DATETIME)#{db_post_fix()}",
+ "ALTER TABLE jobs ADD COLUMN error_code VARCHAR(32)",
+ "INSERT INTO users (name,email,password_hash,password_salt) VALUES ('sync-manager','sync-manager@user','$2a$10$H.w3ssI9KfuvNEXXp1qxD.b3Wm8alJG.HXviUofe4nErDn.TKUAka','$2a$10$H.w3ssI9KfuvNEXXp1qxD.')",
+ "INSERT INTO user_groups (user_id, group_id) SELECT users.id,groups.id FROM users,groups WHERE users.email = 'sync-manager@user' and groups.name = 'admin'",
+ "INSERT INTO server_configs (property,value) VALUES ('max_jobs','4')"]
+ @db_migrate[4]=["ALTER TABLE projects DROP COLUMN password"]
end
end
db.do "INSERT INTO server_configs (property,value) VALUES ('db_version','#{@db_version}')"
db.do "INSERT INTO server_configs (property,value) VALUES ('port','2222')"
db.do "INSERT INTO server_configs (property,value) VALUES ('max_working_jobs','2')"
+ db.do "INSERT INTO server_configs (property,value) VALUES ('max_jobs','4')"
db.do "INSERT INTO server_configs (property,value) VALUES ('send_mail','NO')"
db.do "INSERT INTO server_configs (property,value) VALUES ('keep_time','86400')"
db.do "INSERT INTO server_configs (property,value) VALUES ('pkg_sync_period','600')"
CONSTRAINT fk_users_has_groups_groups1 FOREIGN KEY ( group_id ) REFERENCES groups ( id )) #{post_fix}"
db.do "INSERT INTO users (name,email,password_hash,password_salt) VALUES ('administrators','admin@user','$2a$10$H.w3ssI9KfuvNEXXp1qxD.b3Wm8alJG.HXviUofe4nErDn.TKUAka','$2a$10$H.w3ssI9KfuvNEXXp1qxD.')"
+ db.do "INSERT INTO users (name,email,password_hash,password_salt) VALUES ('sync-mananger','sync-manager@user','$2a$10$H.w3ssI9KfuvNEXXp1qxD.b3Wm8alJG.HXviUofe4nErDn.TKUAka','$2a$10$H.w3ssI9KfuvNEXXp1qxD.')"
db.do "INSERT INTO groups (name, admin, description) VALUES ('admin','TRUE','')"
db.do "INSERT INTO user_groups (user_id, group_id) SELECT users.id,groups.id FROM users,groups WHERE users.email = 'admin@user' and groups.name = 'admin'"
+ db.do "INSERT INTO user_groups (user_id, group_id) SELECT users.id,groups.id FROM users,groups WHERE users.email = 'sync-manager@user' and groups.name = 'admin'"
# PROJECTS
CommonProject.create_table(db, inc, post_fix)
def get_db_connection(transaction=true)
begin
- if @db_dsn =~ /^SQLite3:/ then
+ if @db_dsn.nil? then
+ return false
+ elsif @db_dsn =~ /^SQLite3:/ then
@sqlite3_db_mutex.lock
@db = DBI.connect("DBI:#{@db_dsn}", @db_user, @db_passwd)
else
@db = DBI.connect("DBI:#{@db_dsn}", @db_user, @db_passwd)
end
end
- if transaction then
- @db['AutoCommit'] = false
- begin
- @db.transaction do |dbh|
- yield dbh if block_given?
- end
- ensure
- @db['AutoCommit'] = true
- end
- else
- yield @db if block_given?
+
+ @db['AutoCommit'] = false
+ @db.transaction do |dbh|
+ yield dbh if block_given?
end
return true
return -1
end
+ def check_user_password(user_id, passwd)
+ get_db_connection() do |db|
+ row = db.select_one("SELECT * FROM users WHERE id='#{user_id}'")
+ if not row.nil? then
+ if row['password_hash'].eql? passwd
+ # if passwd is encript and that value equal password_hash then return true
+ return 1
+ else
+ return row['password_hash'] == BCrypt::Engine.hash_secret(passwd, row['password_salt'])
+ end
+ else
+ return -1
+ end
+ end
+
+ return -1
+ end
+
def qualify_admin_to_access(prj_id)
# nothing to do, admin can change everything on web admin tool
end
end
end
+
+ def query_job_log(job_number, conn)
+ @log.info "Sending job log : #{job_number}"
+
+ job_status = ""
+ job = @jobmgr.search_job(job_number)
+
+ Thread.new do
+ job_log_path = File.join(@path, "jobs", job_number, "log")
+
+ if File.exist? job_log_path then
+ begin
+ File::Tail::Logfile.open(job_log_path) do |log|
+ log.interval = 0.05
+ # send log file information using file-tail
+ log.tail do |line|
+ BuildCommServer.send(conn, line)
+
+ if not job.nil? then
+ # Send status when changed status
+ if not job.status.eql? job_status then
+ job_status = job.status
+ BuildCommServer.send(conn, "=JOB_STATUS,#{job_status}")
+ end
+
+ if not log.return_if_eof and
+ (job.status.eql? "FINISHED" or job.status.eql? "ERROR" or job.status.eql? "CANCELED") then
+
+ log.return_if_eof = true
+ # this will make a time for finishing log write
+ sleep 2
+ end
+ else
+ if log.eof? then
+ break
+ end
+ end
+ end
+ end
+ if not job.nil? and job.status == "FINISHED" and job.is_send_result_back? then
+ job.get_result_files().each do |file|
+ BuildCommServer.send(conn, "=JOB_FILE,#{file}")
+ end
+ end
+ rescue => e
+ @log.error e.message
+ @log.error e.backtrace.inspect
+ if e.message.eql? "Connection is closed" then
+ BuildCommServer.disconnect(conn)
+ Thread.exit
+ end
+ end
+ else
+ @log.error "Can't find job log file : #{job_log_path}"
+ BuildCommServer.send(conn, "Can't find job log file : #{job_number}")
+ BuildCommServer.send(conn, "=LOG_ERROR")
+ end
+
+ if job.nil? then
+ get_db_connection() do |db|
+ job_status = db.select_one("SELECT status FROM jobs WHERE id = #{job_number}")[0]
+ end
+ BuildCommServer.send(conn, "=JOB_STATUS,#{job_status}")
+ end
+
+ BuildCommServer.send_end(conn)
+ BuildCommServer.disconnect(conn)
+ end
+
+
+ end
+
+
+ public
+ def get_next_job_id()
+ @job_id_mutex.synchronize do
+ tmp_id = @latest_job_id.to_i + 1
+ @latest_job_id = tmp_id.to_s
+
+ return @latest_job_id
+ end
+ end
+
+ #If the 'run' file is already locked, server is already running.
+ #in this case return false
+ private
+ def lockServer
+ return FileUtil.exclusiveLock(@run_file_path)
+ end
+
+ private
+ def printErrorMessage(errMsg)
+ @log.info "Server creation failed"
+ @log.error errMsg
+
+ puts "Server creation failed"
+ puts errMsg
+ end
+
+
+ # get latest id from DB
+ private
+ def get_latest_job_id_from_db()
+ job_id = nil
+ get_db_connection() do |db|
+ row = db.select_one("SELECT MAX(id) as id FROM jobs")
+ job_id = row['id']
+ end
+
+ if not job_id.nil? then
+ return job_id.to_s
+ else
+ return "0"
+ end
+ end
+
+
+ # get id from "jobs" directory
+ private
+ def get_latest_job_id_from_directory()
+ job_directories = Dir.entries("#{@path}/jobs").select { |dir|
+ not dir.start_with? "." and File.directory?("#{@path}/jobs/#{dir}") and dir.to_s =~ /^\d+$/
+ }
+ max_id = 0
+ job_directories.each do |job_id|
+ if job_id.to_i > max_id then
+ max_id = job_id.to_i
+ end
+ end
+
+ return max_id.to_s
+ end
+
end
$LOAD_PATH.unshift File.dirname(__FILE__)
require "BuildServer.rb"
require "BuildComm.rb"
+require "BuildServerException.rb"
class BuildServerController
@@instance_map = {}
# create new instance and return it
@@instance_map[id] = BuildServer.new( id, path, ftpsvr_addr, ftpsvr_port, ftpsvr_username, ftpsvr_passwd)
+
# set default
if Utils.is_windows_like_os(Utils::HOST_OS) then
@@instance_map[id].git_bin_path="/c/Program\\ Files/Git/bin/git.exe"
else
@@instance_map[id].git_bin_path="/usr/bin/git"
end
+
+ # set default server port
+ default_port = 2222
+ @@instance_map[id].port = default_port
# write config
write_server_config( @@instance_map[id] )
@@instance_map[id].log = Log.new( "#{BuildServer::CONFIG_ROOT}/#{id}/log" )
puts "Created new build server: \"#{id}\""
+ puts " - server location : #{path}"
+ puts " - server configure file : #{BuildServer::CONFIG_ROOT}/#{id}/server.cfg"
+ puts " - default server port : #{default_port}"
+
return @@instance_map[id]
end
def self.migrate_server (id, dsn, user, passwd)
# set DB environment
server = get_server(id)
- server.db_dsn = dsn if not dsn.nil?
+ # if dsn is nil, use default dsn
+ if dsn.nil? then
+ dsn = "SQLite3:#{BuildServer::CONFIG_ROOT}/#{id}/server.db"
+ end
+ server.db_dsn = dsn
server.db_user = user if not user.nil?
server.db_passwd = passwd if not passwd.nil?
# start server
- def self.start_server( id, port = 2222 )
+ def self.start_server( id, port )
server = get_server(id)
- migrate_db(server)
- server.jobmgr.cancel_broken_status
- # write run port
+ if server.has_db? then
+ migrate_db(server)
+ server.jobmgr.cancel_broken_status
+ end
+
server_dir = "#{BuildServer::CONFIG_ROOT}/#{server.id}"
- f = File.open( "#{server_dir}/run", "w" )
- f.puts port
- f.close
+
+ # if user input exsist, set user's port number.
+ if (port != "") and (port != nil) then
+ # update server port information
+ original_string = "SERVER_PORT=#{server.config_port}"
+ replacement_string = "SERVER_PORT=#{port}"
+ contents = File.read("#{server_dir}/server.cfg").gsub("#{original_string}", "#{replacement_string}")
+
+ # write to config file
+ File.open("#{server_dir}/server.cfg", "w") { |f| f.puts contents }
+ # update to db
+ server.port = port
+ else # if user input not exsist, set config file's port number.
+ server.port = server.config_port
+ end
+
+ # write run port
+ File.open( "#{server_dir}/run", "w" ) { |f| f.puts server.port }
# start
- server.port = port
+ if server.has_db? then
+ server.save_id_to_db(server.id)
+ server.save_path_to_db(server.path)
+ end
server.start
end
# server
server = get_server(id)
- migrate_db(server)
+
client = BuildCommClient.create( "127.0.0.1", server.port )
if client.nil? then
puts "Server is not running!"
end
# upgrade server
- def self.upgrade_server( id )
+ def self.upgrade_server( id, pkgsvr_url, dist_name )
- # server
server = get_server(id)
- migrate_db(server)
+
+ # distribution check
+ if pkgsvr_url.nil? then
+ if not server.has_db? then
+ puts BuildServerException.get_message("ERR021")
+ return false
+ end
+
+ if dist_name.nil? then
+ dist = server.distmgr.get_first_distribution()
+ if dist.nil? then
+ puts "No distribution exits!"
+ puts "Upgrade Failed!!"
+ return false
+ end
+ else
+ dist = server.distmgr.get_distribution( dist_name )
+ if dist.nil? then
+ puts "Distribution \"#{dist_name}\" is not exits"
+ puts "Upgrade Failed!!"
+ return false
+ end
+ end
+ pkgsvr_url = dist.pkgsvr_url
+ end
+
client = BuildCommClient.create( "127.0.0.1", server.port )
if client.nil? then
puts "Server is not running!"
# send request
upgrade_ok = false
- if client.send "UPGRADE|#{server.password}" then
+ if client.send "UPGRADE|#{server.password}|#{pkgsvr_url}" then
# recevie & print
mismatched = false
result = client.read_lines do |l|
return true
end
- # request upgrade friends build server
- def self.request_upgrade_server( id )
-
- server = get_server(id)
- migrate_db(server)
- server_dir = "#{BuildServer::CONFIG_ROOT}/#{id}"
-
- if File.exist? "#{server_dir}/friends" then
- File.open( "#{server_dir}/friends", "r" ) do |f|
- f.each_line do |l|
- if l.split(",").count < 2 then next end
- ip = l.split(",")[0].strip
- port = l.split(",")[1].strip
-
- client = BuildCommClient.create( ip, port )
- if client.nil? then
- puts "Friend Server #{ip}:#{port} is not running!"
- next
- end
- # send request
- upgrade_ok = false
- if client.send "UPGRADE|#{server.password}" then
- # recevie & print
- mismatched = false
- result = client.read_lines do |l2|
- puts l2
- if l2.include? "Password mismatched!" then
- mismatched = true
- end
- end
- if result and not mismatched then
- upgrade_ok = true
- end
- end
-
- # terminate
- client.terminate
-
- if upgrade_ok then
- puts "Friend Server #{ip}:#{port} upgrade requested!"
- else
- puts "Friend Server #{ip}:#{port} upgrade failed!"
- end
- end
- end
- else
- puts "No Friend Server."
- end
-
- return true
- end
-
# add friend server
def self.add_remote_server( id, ip, port )
server = get_server(id)
+
+ if not server.has_db? then
+ puts BuildServerException.get_message("ERR021")
+ return false
+ end
migrate_db(server)
# add
# remove friend server
def self.remove_remote_server( id, ip, port )
server = get_server(id)
+
+ if not server.has_db? then
+ puts BuildServerException.get_message("ERR021")
+ return false
+ end
migrate_db(server)
# add
# add supported target os
def self.add_target_os( id, os_name )
- # get server
server = get_server(id)
+
+ if not server.has_db? then
+ puts BuildServerException.get_message("ERR021")
+ return false
+ end
migrate_db(server)
# add
# remove supported target os
def self.remove_target_os( id, os_name )
- # get server
server = get_server(id)
+
+ if not server.has_db? then
+ puts BuildServerException.get_message("ERR021")
+ return false
+ end
migrate_db(server)
# add
# add distribution
def self.add_distribution( id, dist_name, pkgsvr_url, pkgsvr_ip, pkgsvr_port, pkgsvr_password )
- # get server
server = get_server(id)
+
+ if not server.has_db? then
+ puts BuildServerException.get_message("ERR021")
+ return false
+ end
migrate_db(server)
# add
# remove distribution
def self.remove_distribution( id, dist_name )
- # get server
server = get_server(id)
+
+ if not server.has_db? then
+ puts BuildServerException.get_message("ERR021")
+ return false
+ end
migrate_db(server)
# remove
# lock distribution
def self.lock_distribution(id, dist_name)
- # get server
server = get_server(id)
+
+ if not server.has_db? then
+ puts BuildServerException.get_message("ERR021")
+ return false
+ end
migrate_db(server)
# remove
# unlock distribution
def self.unlock_distribution(id, dist_name)
- # get server
server = get_server(id)
+
+ if not server.has_db? then
+ puts BuildServerException.get_message("ERR021")
+ return false
+ end
migrate_db(server)
# remove
# add remote package server
def self.add_sync_package_server(id, url, dist_name)
server = get_server(id)
+
+ if not server.has_db? then
+ puts BuildServerException.get_message("ERR021")
+ return false
+ end
migrate_db(server)
# check distribution
# remove remote package server
def self.remove_sync_package_server(id, url, dist_name)
server = get_server(id)
+
+ if not server.has_db? then
+ puts BuildServerException.get_message("ERR021")
+ return false
+ end
migrate_db(server)
# check distribution
# add project
def self.add_project( id, project_name, git_repos, git_branch, remote_server_id,
- passwd, os_string, dist_name )
- # get server
+ os_string, dist_name )
server = get_server(id)
+
+ if not server.has_db? then
+ puts BuildServerException.get_message("ERR021")
+ return false
+ end
migrate_db(server)
# get supported os for project.
dist_name = check_distribution_name(dist_name, server)
if dist_name.nil? then return false end
- result = server.prjmgr.add_git_project( project_name, git_repos, git_branch, passwd, os_list, dist_name )
+ result = server.prjmgr.add_git_project( project_name, git_repos, git_branch, os_list, dist_name )
if result then
puts "Adding project succeeded!"
return true
# add binary project
- def self.add_binary_project( id, project_name, pkg_name, passwd, os_string, dist_name )
- # get server
+ def self.add_binary_project( id, project_name, pkg_name, os_string, dist_name )
server = get_server(id)
+
+ if not server.has_db? then
+ puts BuildServerException.get_message("ERR021")
+ return false
+ end
migrate_db(server)
# get supported os for project.
if dist_name.nil? then return false end
# add
- result = server.prjmgr.add_binary_project( project_name, pkg_name, passwd,
+ result = server.prjmgr.add_binary_project( project_name, pkg_name,
os_list, dist_name )
if result then
puts "Adding project succeeded!"
# remove project
def self.remove_project( id, project_name, dist_name )
- # get server
server = get_server(id)
+
+ if not server.has_db? then
+ puts BuildServerException.get_message("ERR021")
+ return false
+ end
migrate_db(server)
# check distribution
end
- # full build
- def self.build_all_projects( id, dist_name )
-
- # server
+ def self.register_package(id, file_path, dist_name)
server = get_server(id)
- migrate_db(server)
- # check distribution
- dist_name = check_distribution_name(dist_name, server)
- if dist_name.nil? then return false end
-
- client = BuildCommClient.create( "127.0.0.1", server.port )
- if client.nil? then
- puts "Server is not running!"
+ if not server.has_db? then
+ puts BuildServerException.get_message("ERR021")
return false
end
-
- # send request
- fullbuild_ok = false
- if client.send "FULLBUILD|#{server.password}|#{dist_name}" then
- # recevie & print
- mismatched = false
- dist_not_found = false
- result = client.read_lines do |l|
- puts l
- if l.include? "Password mismatched!" then
- mismatched = true
- end
- if l.include? "Distribution not found!" then
- dist_not_found = true
- end
- end
- if result and not mismatched and not dist_not_found then
- fullbuild_ok = true
- end
- end
-
- # terminate
- client.terminate
-
- if not fullbuild_ok then
- puts "Full build failed!"
- end
-
- return true
- end
-
-
- def self.register_package(id, file_path, dist_name)
- # server
- server = get_server(id)
migrate_db(server)
# check distribution
file_path = File.expand_path(file_path)
# send request
- success = false
- client = BuildCommClient.create( "127.0.0.1", server.port )
- if client.nil? then
- puts "Server is not running!"
+ success = true
+ job_id = nil
+ job_status = nil
+ job_error = nil
+ result = false
+ begin
+ client = BuildCommClient.create( "127.0.0.1", server.port )
+ if client.nil? then
+ puts "Server is not running!"
+ return false
+ end
+ if client.send "REGISTER|BINARY-LOCAL|#{file_path}|#{server.password}|#{dist_name}" then
+ # recevie & print
+ result = client.read_lines do |l|
+ if l.strip.start_with?("=JOB_START") then
+ job_id = l.strip.split(",")[1]
+ elsif l.strip.start_with?("=JOB_STATUS") then
+ data = l.strip.split(",")
+ job_status = data[1]
+ job_error = data[2]
+ else
+ puts l
+ end
+ end
+ if not result then
+ puts "Error: Communication failed! #{client.get_error_msg()}"
+ elsif job_id.nil? then
+ puts job_error
+ result = false
+ end
+ end
+ rescue => e
+ puts "ERROR: #{e}"
+ result = false
+ ensure
+ client.terminate if not client.nil?
+ end
+
+ if not result then
+ puts "Registering package failed!"
return false
end
- if client.send "REGISTER|BINARY-LOCAL|#{file_path}|#{server.password}|#{dist_name}" then
- # recevie & print
- mismatched = false
- result = client.read_lines do |l|
- puts l
- if l.include? "Password mismatched!" then
- mismatched = true
+
+ begin
+ result = JobLog.monitor("127.0.0.1", server.port, job_id) do |line,status,errmsg|
+ job_status = status
+ job_error = errmsg
+ if line.nil? then
+ next
+ end
+
+ category, level, contents = JobLog.parse_log(line)
+ if level < Log::LV_USER then next end
+
+ if category == "INFO" then
+ puts "Info: #{contents}"
+ elsif category == "WARN" then
+ puts "Warn: #{contents}"
+ elsif category == "ERROR" then
+ puts "Error: #{contents}"
+ else
+ next
end
end
- if result and not mismatched then
- success = true
- end
+ rescue BuildServerException => e
+ puts e.err_message()
+ result = false
end
- # terminate
- client.terminate
-
- if not success then
- puts "Registering package failed!"
+ # Check job status
+ if not job_status.eql? "FINISHED" then
+ result = false
end
- return true
+ return result
end
# server
def self.query_server( id )
server = get_server(id)
+
+ if not server.has_db? then
+ puts BuildServerException.get_message("ERR021")
+ return false
+ end
migrate_db(server)
server.prjmgr.load()
end
server = get_server(id)
+
+ if not server.has_db? and attr != "GIT_BIN_PATH" and attr != "PASSWORD" and
+ attr != "FTP_ADDR" and attr != "FTP_PORT" and
+ attr != "FTP_USERNAME" and attr != "FTP_PASSWD" and
+ attr != "DB_DSN" and attr != "DB_USER" and
+ attr != "DB_PASSWD" and attr != "PASSWORD" and
+ attr != "MAX_WORKING_JOBS" and attr != "MAX_JOBS" then
+
+ puts BuildServerException.get_message("ERR021")
+ return false
+ end
+
case attr
when "GIT_BIN_PATH"
server.git_bin_path = value
when "MAX_WORKING_JOBS"
server.jobmgr.max_working_jobs = value.to_i
+ when "MAX_JOBS"
+ server.jobmgr.set_max_jobs(value.to_i)
when "JOB_LOG_URL"
server.job_log_url = value
when "SEND_MAIL"
end
server = get_server(id)
+ if not server.has_db? and attr != "GIT_BIN_PATH" and attr != "PASSWORD" and
+ attr != "FTP_ADDR" and attr != "FTP_PORT" and
+ attr != "FTP_USERNAME" and attr != "FTP_PASSWD" and
+ attr != "DB_DSN" and attr != "DB_USER" and
+ attr != "DB_PASSWD" and attr != "PASSWORD" and
+ attr != "MAX_WORKING_JOBS" and attr != "MAX_JOBS" then
+
+ puts BuildServerException.get_message("ERR021")
+ return false
+ end
+
case attr
when "GIT_BIN_PATH"
puts server.git_bin_path
when "MAX_WORKING_JOBS"
puts server.jobmgr.max_working_jobs
+ when "MAX_JOBS"
+ puts server.jobmgr.get_max_jobs()
when "JOB_LOG_URL"
puts server.job_log_url
when "SEND_MAIL"
f.puts "ID=#{server.id}"
f.puts "PATH=#{server.path}"
f.puts "GIT_BIN_PATH=#{server.git_bin_path}"
+ f.puts "SERVER_PORT=#{server.port}"
f.puts "TEST_TIME=#{server.test_time}" if server.test_time > 0
f.puts "PASSWORD=#{server.test_time}" if server.password != "0000"
if not server.ftp_addr.nil? then
f.puts "DB_DSN=#{server.db_dsn}"
f.puts "DB_USER=#{server.db_user}"
f.puts "DB_PASSWORD=#{server.db_passwd}"
+ if not server.has_db? then
+ f.puts "MAX_WORKING_JOBS=#{server.jobmgr.max_working_jobs}"
+ f.puts "MAX_JOBS=#{server.jobmgr.get_max_jobs()}"
+ end
end
end
def self.read_server_config( id )
path=""
git_bin_path="/usr/bin/git"
+ running_port=nil
+ config_port=nil
test_time=0
password="0000"
ftp_addr=nil
ftp_port=nil
ftp_username=nil
ftp_passwd=nil
- db_dsn="SQLite3:#{BuildServer::CONFIG_ROOT}/#{id}/server.db"
+ db_dsn=nil
db_user=nil
db_passwd=nil
+ max_working_jobs=2
+ max_jobs=4
# read configuration
server_dir = "#{BuildServer::CONFIG_ROOT}/#{id}"
path = l[idx,length].strip
elsif l.start_with?("GIT_BIN_PATH=")
git_bin_path = l[idx,length].strip
+ elsif l.start_with?("SERVER_PORT=")
+ config_port = l[idx,length].strip.to_i
elsif l.start_with?("TEST_TIME=")
test_time = l[idx,length].strip.to_i
elsif l.start_with?("PASSWORD=")
when /^Mysql:(.*)/i then
db_dsn = "Mysql:#{$1}"
else
- db_dsn = "SQLite3:#{BuildServer::CONFIG_ROOT}/#{id}/server.db"
+ db_dsn = nil
end
elsif l.start_with?("DB_USER=")
db_user = l[idx,length].strip if not l[idx,length].strip.empty?
elsif l.start_with?("DB_PASSWORD=")
db_passwd = l[idx,length].strip if not l[idx,length].strip.empty?
+ elsif l.start_with?("ID=")
+ if not l[idx,length].strip.eql? id then
+ raise RuntimeError, "Server configuration FAILED: #{server_dir}/server.cfg: ID must be \"#{id}\""
+ end
+ elsif l.start_with?("MAX_WORKING_JOBS=")
+ max_working_jobs = l[idx,length].strip.to_i
+ elsif l.start_with?("MAX_JOBS=")
+ max_jobs = l[idx,length].strip.to_i
else
next
end
# create server object
obj = BuildServer.new( id, path, ftp_addr, ftp_port, ftp_username, ftp_passwd )
- # check running port
+ # get running port
if File.exist? "#{server_dir}/run" then
f = File.open( "#{server_dir}/run", "r" )
l = f.gets
- obj.port = l.strip.to_i
+ running_port = l.strip.to_i
f.close
end
+ # set port information
+ obj.port = running_port if (running_port != nil)
+ obj.config_port = config_port
+
# set git binary path
obj.git_bin_path = git_bin_path
obj.db_user = db_user
obj.db_passwd = db_passwd
+ # max working jobs
+ if not obj.has_db? then
+ obj.jobmgr.max_working_jobs = max_working_jobs
+ obj.jobmgr.set_max_jobs(max_jobs)
+ end
+
# save config
#write_server_config( obj )
class BuildServerException < Exception
+ attr_accessor :err_code
+
@@err_msgs = {
"ERR001" => "Invalid request format is used!",
"ERR002" => "Distribution not found!",
"ERR008" => "Distribution locked!",
"ERR009" => "Project not found!",
"ERR010" => "Build operation not allowed on this project type!",
- "ERR011" => "Project password required!",
- "ERR012" => "Project password not matched!",
+ "ERR011" => "User password not matched!",
+
"ERR013" => "Project from file-name/distribution not found!",
"ERR014" => "Job cancel failed!",
"ERR015" => "Server password not matched!",
"ERR016" => "Can't received register file!",
+ "ERR017" => "Project locked!",
+
+ "ERR018" => "Connection failed!",
+ "ERR019" => "Receiving data failed!",
+ "ERR020" => "Sending data failed!",
+
+ "ERR021" => "No DB exists and create(migrate) DB first!",
+ "ERR022" => "There already exists same job.",
+ "ERR023" => "Cannot create package client!",
+
+ "ERR100" => "Package info file(\"package/pkginfo.manifest\") does not exist!",
+ "ERR101" => "Parsing package info file failed!",
+ "ERR102" => "Parsing change-log file failed!",
+ "ERR103" => "Change log not found!",
+ "ERR104" => "No servers supports the \"Host-OS\"!",
+ "ERR105" => "Version must be increased!",
+ "ERR106" => "Source code has been changed without increasing version!",
+ "ERR107" => "Package file not found!",
+ "ERR108" => "Unsupported OS used in package file name!",
+ "ERR109" => "Extracting package file failed!",
+ "ERR110" => "Initializing sub jobs failed!",
+ "ERR111" => "Git clone failed!!",
+ "ERR112" => "Git checkout failed!!",
+
+ "ERR200" => "Unmet dependency found!",
+ "ERR201" => "Creating job builder failed!",
+ "ERR202" => "Building job failed!",
+ "ERR203" => "Reverse-build-check failed!",
+ "ERR204" => "Uploading package file(s) failed!",
+ "ERR205" => "Job stopped by failure of its sub job!",
"ERR900" => "Cancel event received!",
"ERR901" => "Job already upload status. Cancel failed!"
@err_code = code
end
- def err_message()
- if not message().nil? and not message().empty? then
- return "Error: #{@@err_msgs[@err_code]}: #{message()}"
+ def err_message(prefix = "Error: ")
+ if not message().nil? and not message().empty? and
+ message() != "BuildServerException" then
+
+ return "#{prefix}#{@@err_msgs[@err_code]}: #{message()}"
else
- return "Error: #{@@err_msgs[@err_code]}"
+ return "#{prefix}#{@@err_msgs[@err_code]}"
end
end
+
+
+ def self.get_message(err_code, prefix = "Error: ")
+ return "#{prefix}#{@@err_msgs[err_code]}"
+ end
end
CREATE="build-svr create -n <server name> [-t <ftp server url>]"
REMOVE="build-svr remove -n <server name>"
MIGRATE="build-svr migrate -n <server name> [--dsn <db dsn> [--dbuser <db_user> --dbpassword <db_password>] ]"
- START="build-svr start -n <server name> -p <port>"
+ START="build-svr start -n <server name> [-p <port>]"
STOP="build-svr stop -n <server name>"
- UPGRADE="build-svr upgrade -n <server name> [-D <distribution name>]"
+ UPGRADE="build-svr upgrade -n <server name> [-D <distribution name>] [-u <package server url>]"
ADD_SVR="build-svr add-svr -n <server name> -d <friend server address>"
REMOVE_SVR= "build-svr remove-svr -n <server name> -d <friend server address>"
ADD_OS= "build-svr add-os -n <server name> -o <os>"
UNLOCK_DIST="build-svr unlock-dist -n <server name> -D <distribution name>"
ADD_SYNC="build-svr add-sync -n <server name> -u <remote pkg server url> [--dist <distribution>]"
REMOVE_SYNC="build-svr remove-sync -n <server name> -u <remote pkg server url> [--dist <distribution>]"
- ADD_PRJ="build-svr add-prj -n <server name> -N <project name> (-g <git repository> -b <git branch>|-P <package name>) [-w <password>] [-o <os list>] [--dist <distribution>]"
+ ADD_PRJ="build-svr add-prj -n <server name> -N <project name> (-g <git repository> -b <git branch>|-P <package name>) [-o <os list>] [--dist <distribution>]"
REMOVE_PRJ="build-svr remove-prj -n <server name> -N <project name> [--dist <distribution>]"
- FULLBUILD="build-svr fullbuild -n <server name> [--dist <distribution>]"
REGISTER="build-svr register -n <server name> -P <package file> [--dist <distribution>]"
QUERY="build-svr query -n <server name>"
SET_ATTR="build-svr set-attr -n <server name> -A <attribute> -V <value>"
end
when "start"
- if options[:name].nil? or options[:name].empty? or
- options[:port].nil? then
+ if options[:name].nil? or options[:name].empty? then
raise ArgumentError, "Usage: " + BuildServerUsage::START
end
raise ArgumentError, "Usage: " + BuildServerUsage::REMOVE_PRJ
end
- when "fullbuild"
- if options[:name].nil? or options[:name].empty? then
- raise ArgumentError, "Usage: " + BuildServerUsage::FULLBUILD
- end
-
when "register"
if options[:name].nil? or options[:name].empty? or
options[:package].nil? or options[:package].empty? then
+ "\t" + "add-prj Add project to build." + "\n" \
+ "\t" + "remove-prj Remove project." + "\n" \
+ "\t" + "register Register the package to the build-server." + "\n" \
- + "\t" + "fullbuild Build all your projects and upload them to package server." + "\n" \
+ "\t" + "query Show build server configuration." + "\n" \
+ "\t" + "set-attr Set build server atribute." + "\n" \
+ "\t" + "get-attr Get build server atribute." + "\n" \
+ "\t" + BuildServerUsage::REMOVE_SYNC + "\n" \
+ "\t" + BuildServerUsage::ADD_PRJ + "\n" \
+ "\t" + BuildServerUsage::REMOVE_PRJ + "\n" \
- + "\t" + BuildServerUsage::FULLBUILD + "\n" \
+ "\t" + BuildServerUsage::REGISTER + "\n" \
+ "\t" + BuildServerUsage::QUERY + "\n" \
+ "\t" + BuildServerUsage::SET_ATTR + "\n" \
options[:domain] = domain
end
- options[:port] = 2222
+ options[:port] = nil
opts.on( '-p', '--port <port>', 'server port number: 2224' ) do|port|
options[:port] = port.strip.to_i
end
cmd.eql? "lock-dist" or cmd.eql? "unlock-dist" or
cmd.eql? "add-sync" or cmd.eql? "remove-sync" or
cmd.eql? "add-prj" or cmd.eql? "remove-prj" or
- cmd.eql? "fullbuild" or cmd.eql? "register" or
+ cmd.eql? "register" or
cmd.eql? "query" or
cmd.eql? "set-attr" or cmd.eql? "get-attr" or
cmd =~ /(-v)|(--version)/ or
$LOAD_PATH.unshift File.dirname(__FILE__)
$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common"
require "utils.rb"
+require "JobLog.rb"
+require "BuildServerException.rb"
+
class CommonJob
attr_accessor :id, :server, :log, :status, :priority
- attr_accessor :os, :type, :pre_jobs, :user_id, :event, :sub_jobs
+ attr_accessor :os, :type, :pre_jobs, :user_id, :event, :sub_jobs, :thread, :error
USER_JOB_PRIORITY = 100
AUTO_JOB_PRIORITY = 0
@locked = false
@log = nil
- @start_time = Time.now
+ @start_time = nil
@end_time = nil
+ @thread = nil
@sub_pid = 0
+
+ @error = nil
end
# event check
# create logger
public
- def create_logger( second_out, verbose = false )
- @log = JobLog.new( self, second_out, verbose )
+ def create_logger( verbose = false )
+ @log = JobLog.new( self, verbose )
return @log
end
@project = project
end
+
+ public
+ def is_transferred?
+ if not @project.nil? then
+ return @project.is_transferred?
+ else
+ return false
+ end
+ end
+
public
def get_user_email
return @server.get_email_using_user_id(@user_id)
@thread = Thread.new do
begin
job_main()
-
- # parent job will call sub job's terminate method
- if not is_sub_job? then terminate() end
rescue BuildServerException => e
- @log.error e.message
- if @status == "WORKING" then @status = "ERROR" end
+ @log.error( e.err_message, Log::LV_USER )
+ # "CANCEL" operation(ERR900) must be excluded
+ if e.err_code != "ERR900" then
+ @status = "ERROR"
+ @error = e
+ end
rescue => e
@log.error e.message
@log.error e.backtrace.inspect
- if @status == "WORKING" then @status = "ERROR" end
+ @status = "ERROR"
ensure
+ # parent job will call sub job's terminate method
+ # if "WORKING"(canceled) and "ERROR", must call "terminate" here
+ if not is_sub_job? and (@status == "ERROR" or @status == "FINISHED") then
+ terminate()
+ end
@thread = nil
end
end
#cancel
public
def cancel()
+ kill_sub_process
+
+ @sub_jobs.select{|x| x.event == "NONE" and x.status != "FINISHED" and x.status != "ERROR" and x.status != "CANCELED" }.each do |sub|
+ sub.event = "CANCEL"
+ end
+ # wait for job thread to finish
+ @thread.join if not @thread.nil?
+
if not @log.nil? then
@log.info( "JOB is canceled by cancel operation !!", Log::LV_USER)
end
# create process to execute command
public
def execute_command(cmd)
+ # if canceled, must prevent invoking more process
+ check_event
+
# execute
pid, status = Utils.execute_shell_with_log(cmd, @log.path, false)
@sub_pid = pid
end
@sub_pid = 0
+ # if canceled, must exit job thread
check_event
+
# return
return pid, status
end
status VARCHAR(32) NOT NULL DEFAULT 'JUST_CREATED',
start_time DATETIME,
end_time DATETIME,
+ error_code VARCHAR(32),
CONSTRAINT fk_jobs_projects1 FOREIGN KEY ( project_id ) REFERENCES projects ( id ),
CONSTRAINT fk_jobs_users1 FOREIGN KEY ( user_id ) REFERENCES users ( id ),
CONSTRAINT fk_jobs_supported_os1 FOREIGN KEY ( supported_os_id ) REFERENCES supported_os ( id ),
CONSTRAINT fk_jobs_jobs1 FOREIGN KEY ( parent_job_id ) REFERENCES jobs ( id ),
CONSTRAINT fk_jobs_sources1 FOREIGN KEY ( source_id ) REFERENCES sources ( id ),
CONSTRAINT fk_jobs_remote_build_servers1 FOREIGN KEY ( remote_build_server_id ) REFERENCES remote_build_servers ( id ) )#{post_fix}"
+ db.do "CREATE TABLE job_timestamps (
+ id INTEGER PRIMARY KEY #{inc},
+ job_id INTEGER,
+ stamp_name VARCHAR(64),
+ stamp_time DATETIME)#{post_fix}"
end
# save to db
public
- def save(db, now)
-
+ def save(db)
+ now = @server.db_now
prj_id = @project.nil? ? "NULL" : @project.get_project_id()
if @id.nil? then
- start_time = @start_time.strftime("%F %T")
+ @start_time = Time.now
os_id = BuildServer.get_supported_os_id(db, @os)
dist_id = PackageDistribution.get_distribution_id(db, get_distribution_name())
parent_id = @parent.nil? ? "NULL" : @parent.id
- db.do "INSERT INTO jobs(project_id,user_id,supported_os_id, distribution_id, parent_job_id,jtype,status,start_time)
- VALUES (#{prj_id},#{@user_id},#{os_id},#{dist_id},#{parent_id},'#{@type}','#{@status}',#{now})"
- @id = @server.db_insert_id(db)
+ @id = @server.get_next_job_id()
+ db.do "INSERT INTO jobs(id,project_id,user_id,supported_os_id, distribution_id, parent_job_id,jtype,status,start_time)
+ VALUES (#{@id},#{prj_id},#{@user_id},#{os_id},#{dist_id},#{parent_id},'#{@type}','#{@status}',#{now})"
else
remote_bs_id = (@type == "BUILD" and not get_remote_server().nil?) ?
get_remote_server().id : "NULL"
db.do "UPDATE jobs SET source_id=#{source_id} WHERE id=#{@id}"
end
db.do "UPDATE jobs SET status='#{@status}',remote_build_server_id=#{remote_bs_id} WHERE id=#{@id}"
- if @status == "FINISHED" or @status == "ERROR" or @status == "CANCELED" then
- @end_time = Time.now.strftime("%F %T")
+ if @end_time.nil? and
+ @status == "FINISHED" or @status == "ERROR" or @status == "CANCELED" then
+
+ @end_time = Time.now
db.do "UPDATE jobs SET end_time=#{now} WHERE id=#{@id}"
+ if @status == "ERROR" and not @error.nil? then
+ db.do "UPDATE jobs SET error_code='#{@error.err_code}' WHERE id=#{@id}"
+ end
end
end
end
+ public
+ def add_timestamp(name)
+ if not @server.has_db? then return end
+
+ now = @server.db_now()
+ @server.get_db_connection() do |db|
+ db.do "INSERT INTO job_timestamps(job_id,stamp_name,stamp_time)
+ VALUES (#{@id},'#{name}',#{now})"
+ end
+ end
+
+
def kill_sub_process()
if @sub_pid != 0 then
if not @log.nil? then
$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common"
class CommonProject
- attr_accessor :name, :type, :passwd, :os_list, :dist_name, :path
+ attr_accessor :name, :type, :os_list, :dist_name, :path, :status
# initialize
- def initialize( name, type, server, os_list, dist_name="BASE" )
+ def initialize( name, type, server, os_list, dist_name="BASE", status="OPEN" )
@prj_id = -1
- @name = name
+ if name.nil? then
+ @name = "TRANSFERRED"
+ else
+ @name = name
+ end
@type = type
- @passwd = ""
@os_list = os_list
@server = server
@dist_name = dist_name
+ @status = status
@source_info = {}
@package_info = {}
if @dist_name == "BASE" then
end
- #return passwd
- def is_passwd_set?()
- return ( not @passwd.empty? )
- end
-
-
- def passwd_match?(word)
- if not is_passwd_set? then return true end
-
- if word.eql? @passwd then
- return true
- else
- return false
- end
+ def is_transferred?
+ return @name == "TRANSFERRED"
end
return @prj_id
end
+ def set_project_status(status)
+ @status = status
+ end
+
+ def get_project_status()
+ return @status
+ end
+
def self.create_table(db, inc, post_fix)
db.do "CREATE TABLE projects (
id INTEGER PRIMARY KEY #{inc},
user_id INTEGER,
name VARCHAR(32) NOT NULL,
ptype VARCHAR(32) NOT NULL,
- password VARCHAR(32),
+ status VARCHAR(32) NOT NULL DEFAULT 'OPEN',
CONSTRAINT fk_projects_users1 FOREIGN KEY ( user_id ) REFERENCES users ( id ),
CONSTRAINT fk_projects_distributions1 FOREIGN KEY ( distribution_id ) REFERENCES distributions ( id ) )#{post_fix}"
if @prj_id == -1 then
row = db.select_one("SELECT * FROM distributions WHERE name='#{@dist_name}'")
dist_id = row['id']
- db.do "INSERT INTO projects (distribution_id,name,ptype,password)
- VALUES (#{dist_id},'#{@name}','#{@type}','#{@passwd}')"
+ db.do "INSERT INTO projects (distribution_id,name,ptype,status)
+ VALUES (#{dist_id},'#{@name}','#{@type}','#{@status}')"
case @server.db_dsn
when /^SQLite3:/ then @prj_id = db.select_one("select last_insert_rowid()")[0]
when /^Mysql:/ then @prj_id = db.func(:insert_id)
else
row = db.select_one("SELECT * FROM distributions WHERE name='#{@dist_name}'")
dist_id = row['id']
- db.do "UPDATE projects SET ptype='#{@type}',password='#{@passwd}' WHERE name='#{@name}' and distribution_id=#{dist_id})"
+ db.do "UPDATE projects SET ptype='#{@type}',status='#{@status}' WHERE name='#{@name}' and distribution_id=#{dist_id})"
db.do "DELETE FROM project_os WHERE project_id=#{@prj_id}"
@os_list.each do |os|
row = db.select_one("SELECT * FROM supported_os WHERE name='#{os}'")
if row1.nil? then
db.do "INSERT INTO sources(project_id, pkg_ver,location)
VALUES(#{@prj_id},'#{src_ver}','#{info}')"
+ else
+ db.do "UPDATE sources SET location='#{info}' "+
+ "WHERE project_id=#{@prj_id} and pkg_ver='#{src_ver}'"
end
end
public
def self.get_project_from_pkg_name_row(pkg_name, dist_name, db)
- return db.select_one("SELECT projects.id,projects.distribution_id,projects.name,projects.ptype,projects.password
+ return db.select_one("SELECT projects.id,projects.distribution_id,projects.name,projects.ptype
FROM distributions,projects,project_bins
WHERE distributions.name='#{dist_name}' and
distributions.id = projects.distribution_id and
$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common"
require "BuildJob.rb"
require "utils.rb"
+require "BuildServerException.rb"
$git_mutex = Mutex.new
# if succeeded, register source info and copy pkginfo.manifest
@log.info( "Updating the source info for project \"#{@project.name}\"" , Log::LV_USER)
- @project.save_source_info( @pkginfo.get_version(), @git_commit)
- @project.save_package_info_from_manifest( @pkginfo.get_version(),
- "#{@source_path}/package/pkginfo.manifest", @os)
+ if not is_transferred? then
+ @project.save_source_info( @pkginfo.get_version(), @git_commit)
+ @project.save_package_info_from_manifest( @pkginfo.get_version(),
+ "#{@source_path}/package/pkginfo.manifest", @os)
+ end
@server.jobmgr.save_job_status(self)
# clean up
@server.cleaner.clean(@id)
# create logger
if @log.nil? then
- @log = JobLog.new(self, nil )
+ @log = JobLog.new(self)
end
@log.info( "Initializing job...", Log::LV_USER)
# if internal job, copy external_pkgs
- if @is_internal_job then
+ if not @external_pkgs.empty? then
@log.info( "Copying external dependent pkgs...", Log::LV_USER)
ext_pkgs_dir = "#{@job_root}/external_pkgs"
# download source code
@git_commit = get_source_code()
- if @git_commit.nil? then
- @status = "ERROR"
- return false
- end
# check pkginfo.manifest
- if not File.exist? "#{@source_path}/package/pkginfo.manifest"
- @log.error( "package/pkginfo.manifest does not exist", Log::LV_USER)
- @status = "ERROR"
- return false
+ if not File.exist? "#{@source_path}/package/pkginfo.manifest" then
+ raise BuildServerException.new("ERR100")
end
# set up pkg info
begin
@pkginfo = PackageManifest.new("#{@source_path}/package/pkginfo.manifest")
rescue => e
- @log.error( e.message, Log::LV_USER)
- return false
+ raise BuildServerException.new("ERR101"), e.message
end
# set up pkgsvr_client
- @pkgsvr_client = Client.new(@pkgsvr_url, @job_working_dir, @log)
+ @pkgsvr_client = Client.create(@pkgsvr_url, @job_working_dir, @log)
+ if @pkgsvr_client.nil? then
+ raise BuildServerException.new("ERR023")
+ end
# checking version if not reverse-build job or not internal-job
- if not @is_rev_build_check_job and not @is_internal_job then
+ if not @is_rev_build_check_job and not @is_verified then
#check change log
change_log = {}
begin
change_log = Parser.read_changelog "#{@source_path}/package/changelog" if File.exist? "#{@source_path}/package/changelog"
rescue => e
- @log.error( e.message, Log::LV_USER)
- return false
+ raise BuildServerException.new("ERR102"), e.message
end
if not change_log.empty? and @pkginfo.packages[0].change_log.empty? then
end
if @server.changelog_check and not @pkginfo.packages[0].does_change_exist? then
- @log.error( "change log not found", Log::LV_USER )
- return false
+ raise BuildServerException.new("ERR103"), @pkginfo.packages[0].version
end
# check availabiltiy
if not @server.check_job_availability( self ) then
- @log.error( "No servers that are able to build your packages.", Log::LV_USER)
- @log.error( "Host-OS (#{@os}) is not supported in build server.", Log::LV_USER)
- @status = "ERROR"
- @server.log.info "Adding the job \"#{@id}\" is canceled"
- return false
+ raise BuildServerException.new("ERR104"), "#{@os}"
end
- if not check_package_version(@git_commit) then
- @status = "ERROR"
- return false
- end
+ check_package_version(@git_commit)
+ end
+
+ return true
+ end
+
+
+ def is_same_with?(wjob)
+ # must have same distribution
+ if get_distribution_name() != wjob.get_distribution_name() then
+ return false
end
+ if @type != wjob.type then return false end
+
+ prj1 = @project
+ prj2 = wjob.get_project()
+
+ # check project name
+ if prj1.nil? or prj2.nil? or
+ prj1.name != prj2.name then
+ return false
+ end
+
+ # check version
+ if @pkginfo.nil? or wjob.pkginfo.nil? or
+ not(Version.new(@pkginfo.get_version()) == Version.new(wjob.pkginfo.get_version())) then
+ return false
+ end
+
+ if @git_commit != wjob.git_commit then return false end
+
+ # check compat os
+ wjob.pkginfo.get_target_packages(wjob.os).each do |p|
+ if not p.os_list.include?(@os) then return false end
+ end
+
return true
end
protected
def get_source_code_internal()
# check git directory
- git_path = "#{@project.path}/cache/git"
cache_path = "#{@project.path}/cache"
if not File.exist? cache_path then
FileUtils.mkdir_p cache_path
end
+ git_path = "#{cache_path}/#{File.basename(@git_repos)}"
# verify git & check branch name
if File.exist? git_path then
end
end
+ # git reset origin operation
+ if File.exist? git_path and not git_cmd("reset --hard origin/#{@git_branch}", git_path,@log) then
+ @log.warn( "Failed on \"git reset --hard origin/#{@git_branch}\"", Log::LV_USER)
+ FileUtils.rm_rf git_path
+ end
+
# git pull operation
if File.exist? git_path and not git_cmd("pull", git_path,@log) then
@log.warn( "Failed on \"git pull\"", Log::LV_USER)
# if no git, clone it
if not File.exist? git_path then
# if "git pull" failed, try to "git clone"
- if not git_cmd("clone #{@git_repos} git", cache_path, @log) then
- @log.error( "Failed on \"git clone #{@git_repos}\"", Log::LV_USER)
- return nil
+ if not git_cmd("clone #{@git_repos}", cache_path, @log) then
+ raise BuildServerException.new("ERR111"), "git clone #{@git_repos}"
end
# git checkout
if not git_cmd("checkout #{@git_branch}", git_path, @log) then
- @log.error( "Failed on \"git checkout #{@git_branch}\"", Log::LV_USER)
- return nil
+ raise BuildServerException.new("ERR112"), "git checkout #{@git_branch}"
end
end
else
# git reset
if not git_cmd("reset --hard #{@git_commit}", git_path, @log) then
- @log.error( "Failed on \"git reset --hard #{@git_commit}\"", Log::LV_USER)
- return nil
+ @log.warn( "Failed on \"git reset --hard #{@git_commit}\"", Log::LV_USER)
+ FileUtils.rm_rf git_path
+ @git_commit = nil
+ @git_commit = get_source_code_internal()
end
end
# initialize
def initialize( name, server, os_list, dist_name, repos = nil, branch = nil )
- super(name, "GIT", server, os_list, dist_name)
+ super(name, "GIT", server, os_list, dist_name, "OPEN")
@repository = repos
@branch = branch
end
prj_id = row['id']
prj_name = row['name']
- prj_passwd = row['password']
+ prj_status = row['status']
new_project = GitBuildProject.new(prj_name, server, prj_os_list, dist_name)
- if not prj_passwd.empty? then new_project.passwd = prj_passwd end
new_project.set_project_id( prj_id )
new_project.set_source_info( source_info )
new_project.set_package_info( package_info )
+ new_project.set_project_status( prj_status )
row=db.select_one("SELECT * FROM project_gits WHERE project_id=#{prj_id}")
if row.nil? then return nil end
require "log"
require "logger"
require "BuildComm.rb"
+require "BuildServerException.rb"
+
class JobLog < Log
- def initialize(job, stream_out, verbose = false)
+ def initialize(job, verbose = false)
log_level = (verbose) ? Log::LV_NORMAL : Log::LV_USER
if job.nil? then
super(nil)
super("#{job.server.path}/jobs/#{job.id}/log",log_level)
end
@parent_job=job
- @second_out = stream_out
end
- def set_second_out( out )
- @second_out = out
- end
-
-
- def close
- # close communication
- if not @second_out.nil? then
- begin
- if not @second_out.closed? then
- BuildCommServer.send_end(@second_out)
- end
- rescue
- end
- BuildCommServer.disconnect(@second_out)
+ def JobLog.parse_log(line)
+ data = line.sub(/(^[a-zA-Z], \[[^\]]*\][ \t]*)/,"")
+ if $1.nil? then
+ return "UNKNOWN", 1, line
end
- @second_out = nil
- end
-
-
- def is_connected?
- if @second_out.nil? or @second_out.closed? then
- return false
- else
- return true
+ data_tok = data.split(" -- : ")
+ if data_tok.nil? then
+ return "UNKNOWN", 1, line
+ elsif data_tok.count != 2 then
+ return "INFO", 1, ""
end
- end
+ category = data_tok[0]
+ sub_data = data_tok[1]
+ level = sub_data[1..1].to_i
+ contents = sub_data[4..-1]
- def has_second_out?
- if @second_out.nil? then
- return false
- else
- return true
+ if contents.nil? then
+ contents = ""
end
+
+ return category, level, contents
end
- protected
+ def JobLog.monitor(ip, port, job_id)
- # overide
- def output_extra(msg)
+ result = true
+ job_status = ""
begin
- if not @second_out.nil? then
- BuildCommServer.send( @second_out, msg )
+ client = BuildCommClient.create( ip, port, nil, 0 )
+ if client.nil? then
+ raise BuildServerException.new("ERR018"), "#{ip}:#{port}"
end
- rescue
- # close second_out
- @second_out.close
- @second_out = nil
- error "Connection closed by remote client"
+ client.send "LOG|#{job_id}"
+ result = client.read_lines do |line|
+ if line.strip.start_with?("=JOB_STATUS") then
+ data = line.strip.split(",")
+ job_status = data[1]
+ job_error = data[2]
+
+ if block_given? then
+ yield nil,job_status,job_error
+ end
+ else
+ if block_given? then
+ yield line.strip,job_status,job_error
+ else
+ puts line.strip
+ end
+ end
+ end
- # cancel parent job
- if not @parent_job.nil? and @parent_job.event == "NONE" then
- @parent_job.event = "CANCEL"
+ if not result then
+ raise BuildServerException.new("ERR019"), "#{client.get_error_msg()}"
end
+
+ ensure
+ client.terminate if not client.nil?
end
- end
+ return result
+ end
end
require "SocketJobRequestListener.rb"
require "RegisterPackageJob.rb"
require "packageServer.rb"
-
+require "BuildServerException.rb"
class JobManager
attr_accessor :jobs, :internal_jobs, :reverse_build_jobs
@new_job_index = 0
@internal_job_schedule = Mutex.new
@latest_job_touch = Mutex.new
+ @max_build_jobs = 2
+ @max_jobs = 4
end
def cancel_broken_status
end
def max_working_jobs
- result = nil
- @server.get_db_connection() do |db|
- result = db.select_one("SELECT value FROM server_configs WHERE property = 'max_working_jobs'")[0]
+ if @server.has_db? then
+ result = nil
+ @server.get_db_connection() do |db|
+ result = db.select_one("SELECT value FROM server_configs WHERE property = 'max_working_jobs'")[0]
+ end
+ @max_build_jobs = result.to_i if not result.nil?
end
- return (result.nil?) ? 2 : result.to_i
+
+ return @max_build_jobs
end
def max_working_jobs=(job_cnt)
- @server.get_db_connection() do |db|
- db.do "UPDATE server_configs SET value = '#{job_cnt}' WHERE property = 'max_working_jobs'"
+ @max_build_jobs = job_cnt
+ if @max_jobs < @max_build_jobs then
+ @max_jobs = @max_build_jobs
+ end
+
+ if @server.has_db? then
+ @server.get_db_connection() do |db|
+ db.do "UPDATE server_configs SET value = '#{@max_build_jobs}' WHERE property = 'max_working_jobs'"
+ db.do "UPDATE server_configs SET value = '#{@max_jobs}' WHERE property = 'max_jobs'"
+ end
end
end
+
+ def get_max_jobs()
+ if @server.has_db? then
+ result = nil
+ @server.get_db_connection() do |db|
+ result = db.select_one("SELECT value FROM server_configs WHERE property = 'max_jobs'")[0]
+ end
+ @max_jobs = result.to_i if not result.nil?
+ end
+
+ if @max_jobs < @max_build_jobs then
+ @max_jobs = @max_build_jobs
+ end
+
+ return @max_jobs
+ end
+
+
+ def set_max_jobs(cnt)
+ if cnt > @max_build_jobs then
+ @max_jobs = cnt
+ else
+ @max_jobs = @max_build_jobs
+ end
+
+ if @server.has_db? then
+ @server.get_db_connection() do |db|
+ db.do "UPDATE server_configs SET value = '#{@max_jobs}' WHERE property = 'max_jobs'"
+ end
+ end
+ end
+
+
# initialize
def init()
# load latest job idx if exist
def initialize_job ( job )
job.status = "INITIALIZING"
job.thread = Thread.new do
- save_job_status(job)
begin
+ save_job_status(job)
+ job.add_timestamp("INIT_START")
+
# init
- if not job.init or job.status == "ERROR" then
- if job.event == "NONE" then job.status = "ERROR" end
- @server.log.info "Adding the job \"#{job.id}\" is canceled"
- job.terminate()
- save_job_status(job)
- Thread.current.exit
- end
+ job.init
job.check_event
if job.status == "INITIALIZING" then
job.status = "WAITING"
save_job_status(job)
+ job.add_timestamp("INIT_END")
end
@server.log.info "Checking the job \"#{job.id}\" was finished!"
rescue BuildServerException => e
- @server.log.error e.message
+ @server.log.info "Initializig the job \"#{job.id}\" failed!"
+ if e.err_code != "ERR900" then
+ job.status = "ERROR"
+ end
+ if not job.log.nil? then
+ job.log.error(e.err_message(""), Log::LV_USER)
+ else
+ @server.log.error e.message
+ end
+ if job.status == "ERROR" then
+ job.error = e
+ job.terminate()
+ save_job_status(job)
+ end
rescue => e
@server.log.error e.message
@server.log.error e.backtrace.inspect
+ job.status = "ERROR"
ensure
job.thread = nil
end
def execute(job)
job.status = "WORKING"
save_job_status(job)
+ job.add_timestamp("WORK_START")
# start build
job.execute
# start build
set_remote(job, rserver)
+
+ # status change & job control
+ job.status = "REMOTE_WORKING"
+ save_job_status(job)
+ job.add_timestamp("WORK_START")
+
if job.execute() then
- # status change & job control
- job.status = "REMOTE_WORKING"
- save_job_status(job)
@server.log.info "Moved the job \"#{job.id}\" to remote job list"
else
@server.log.info "Moving the job \"#{job.id}\" to remote failed"
@server.log.info "Creating thread for canceling the job \"#{job.id}\""
Thread.new do
begin
- job.kill_sub_process
-
- job.sub_jobs.select{|x| x.event == "NONE" and x.status != "FINISHED" and x.status != "ERROR" and x.status != "CANCELED" }.each do |sub|
- sub.event = "CANCEL"
- end
- job.thread.join if not job.thread.nil?
-
- # job cacncel
+ # job cancel
job.cancel
# cancel finished
if job.status == "JUST_CREATED" then
initialize_job( job )
end
-
- # check the connection if job is not asynchronous job
- if ( job.status == "WAITING" or job.status == "REMOTE_WORKING" ) and #or job.status == "PENDING") and
- not job.is_asynchronous_job? and
- not job.is_connected? then
-
- job.status = "ERROR"
- save_job_status(job)
- dispose_job( job )
- @server.log.info "Job \"#{job.id}\" is disconnected by user. Removed!"
- end
end
+ # remove duplicated jobs
+ remove_duplicated_jobs()
+
# reverse build job -> internal job -> normal job
job = get_available_job
def dispose_job(job)
- # if remote job, remove it from remote server's queue
- if job.type == "BUILD" and job.is_remote_job then
+ # update remote server state if needed
+ if job.type == "BUILD" and job.is_remote_job then
job.get_remote_server.remove_working_job(job)
job.get_remote_server.update_db()
- end
+ end
# remove from queue
@jobs.delete_if {|j| j.id == job.id}
@reverse_build_jobs.delete_if {|j| j.id == job.id}
end
+
+ # will remove redundent jobs
+ def remove_duplicated_jobs()
+ @jobs.reverse.each do |j1|
+ if j1.status != "WAITING" then next end
+
+ @jobs.each do |j2|
+ if j1.id == j2.id then next end
+ if j2.status != "WAITING" and j2.status != "WORKING" and
+ j2.status != "REMOTE_WORKING" then
+ next
+ end
+
+ if j1.is_same_with?(j2) then
+ begin
+ raise BuildServerException.new("ERR022"), "(#{j2.id})"
+ rescue BuildServerException => e
+ j1.error = e
+ j1.log.error(e.err_message(""), Log::LV_USER)
+ j1.status = "ERROR"
+ end
+ break
+ end
+ end
+ end
+ end
+
+
# select the job whith no build-dependency problem
def get_available_job
# select reverse build job with round-robin method
(@jobs + @internal_jobs + @reverse_build_jobs).each do |job|
if job.status == "WORKING" then
working_cnt = working_cnt + 1
+ else
+ next
end
# must exclude parent job
end
- #def get_pending_jobs
- # result = []
- # @jobs.each do |job|
- # if job.status == "PENDING" then
- # result.push job
- # end
- # end
-
- # return result
- #end
-
+ # Additionally, "commit" option will assign job number
def commit_job(job)
- result = save_job_status(job)
+ if @server.has_db? and not job.is_transferred? then
+ result = save_job_status(job)
+ else
+ job.id = @server.get_next_job_id()
+ result = true
+ end
return result
end
+
def save_job_status(job)
- now = @server.db_now
+ # if transferred job, no need to save
+ if job.is_transferred? then return true end
+
result = @server.get_db_connection() do |db|
- job.save(db, now)
+ job.save(db)
job.sub_jobs.each do |j|
- j.save(db, now)
+ j.save(db)
end
end
return result
end
-
+ def search_job (job_id)
+ (@jobs + @internal_jobs + @reverse_build_jobs).each do |job|
+ if job.id == job_id then
+ return job
+ end
+ job.sub_jobs.each do |job|
+ if job.id == job_id then
+ return job
+ end
+ end
+ end
+ return nil
+ end
+
protected
# select the job whith no build-dependency problem
# if "check_dep_wait" is true, it will check the build dependency
if (cjob.status == "WORKING" or cjob.status == "REMOTE_WORKING" ) and
(job.has_build_dependency?( cjob ) or job.is_compatible_with?( cjob)) then
pre_jobs.push cjob
- # # In case that "PENDING" job is depends on me (not depended )
- # elsif cjob.status == "PENDING" and (not job.does_depend_on? cjob) and
- # (job.has_build_dependency?( cjob ) or job.is_compatible_with?( cjob)) then
- # pre_jobs.push cjob
elsif check_dep_wait and cjob.status == "WAITING" and
(job.does_depend_on? cjob or
(job.id > cjob.id and job.is_compatible_with? cjob) ) then
class MultiBuildJob < CommonJob
attr_accessor :source_path
- attr_accessor :pkgsvr_client, :thread
+ attr_accessor :pkgsvr_client
# initialize
def initialize (server)
@pkgsvr_ip = nil
@pkgsvr_port = nil
@pkgsvr_password = nil
+
+ # "send_result_back" mean that server will send package file by network
+ @send_result_back = false
+ @dock_num = "0"
+ @result_files = []
end
end
+ # This make project to build
+ # even though there is a package of same version on pkg-server
+ def set_force_rebuild(value)
+ @sub_jobs.each do |sub|
+ sub.set_force_rebuild(value)
+ end
+ end
+
+
+ def set_send_result_back( dock_num )
+ @send_result_back = true
+ @dock_num = dock_num
+ end
+
+
+ def is_send_result_back?
+ return @send_result_back
+ end
+
+
+ def get_result_files()
+ return @result_files
+ end
+
+
#
def init
@job_root = "#{@server.path}/jobs/#{@id}"
# create logger
if @log.nil? then
- @log = JobLog.new(self, nil )
+ @log = JobLog.new(self)
end
@log.info( "Initializing job...", Log::LV_USER)
# initialize all sub jobs and add them to "internal_jobs"
tstatus = @status
@sub_jobs.each do |job|
- # initialize job
- if not job.init or job.status == "ERROR" then
- job.status = "ERROR"
- @log.info( "Failed to initialize sub-job \"#{job.get_project().name}\" for #{job.os}. (#{job.id})", Log::LV_USER)
- job.terminate()
- end
+ begin
+ job.status = "INITIALIZING"
+ @log.info( "Initializing sub-job(#{job.id})...", Log::LV_USER)
- if job.status != "ERROR" then
- job.status = "WAITING"
- else
- job.status = "ERROR"
+ job.add_timestamp("INIT_START")
+
+ # initialize job
+ job.init
+ if job.status == "INITIALIZING" then
+ job.status = "WAITING"
+ job.add_timestamp("INIT_END")
+ end
+ rescue BuildServerException => e
+ if e.err_code != "ERR900" then
+ job.error = e
+ job.status = "ERROR"
+ end
+ @log.error( "Failed to initialize sub-job \"#{job.get_project().name}\" for #{job.os}. (#{job.id})", Log::LV_USER)
+ @log.error( " * #{e.err_message("")}", Log::LV_USER)
tstatus = "ERROR"
end
end
+
if tstatus == "ERROR" then
# Changed the status of initialized sub-jobs if parent is in ERROR status
@sub_jobs.each do |job|
if job.status == "WAITING" then
+ job.event = "CANCEL"
job.status = "CANCELED"
end
+ # Add internal job for cancel,error process
+ @server.jobmgr.add_internal_job(job)
end
- @status = tstatus
- return false
+
+ raise BuildServerException.new("ERR110")
end
@pkgsvr_ip = @server.distmgr.get_distribution(first_project.dist_name).pkgsvr_ip
@pkgsvr_port = @server.distmgr.get_distribution(first_project.dist_name).pkgsvr_port
@pkgsvr_password = @server.distmgr.get_distribution(first_project.dist_name).pkgsvr_password
- @pkgsvr_client = Client.new(@pkgsvr_url, @job_working_dir, @log)
+ @pkgsvr_client = Client.create(@pkgsvr_url, @job_working_dir, @log)
+ if @pkgsvr_client.nil? then
+ raise BuildServerException.new("ERR023")
+ end
return true
end
end
+ def is_same_with?(o)
+ return false
+ end
+
+
def is_compatible_with?(o)
return false
end
def has_same_packages?( wjob )
- # must have same distribution
- if get_distribution_name() != wjob.get_distribution_name() then
- return false
- end
-
- # same package must have same os
- if not @os.eql? wjob.os then
- return false
- end
-
- # check package name
- get_packages.each do |pkg|
- wjob.get_packages().each do |wpkg|
- if pkg.package_name == wpkg.package_name then
- #puts "Removed from candiated... A == B"
- return true
+ @sub_jobs.each do |job2|
+ if wjob.type == "MULTIBUILD" then
+ wjob.sub_jobs.each do |wjob2|
+ if job2.has_same_packages?( wjob2 ) then return true end
end
- end
+ else
+ if job2.has_same_packages?( wjob ) then return true end
+ end
end
return false
end
- def is_connected?
- return true
- end
-
-
# return the job is asyncronous job
def is_asynchronous_job?
return false
def get_log_url()
# only when server support log url
if @server.job_log_url.empty? then
- return "",""
+ return ""
end
- return "#{@server.job_log_url}/#{@id}/log",""
+ return "#{@server.job_log_url}/#{@id}/log"
end
#
protected
def job_main()
@log.info( "Invoking a thread for MULTI-BUILD Job #{@id}", Log::LV_USER)
- if @status == "ERROR" then return end
@log.info( "New Job #{@id} is started", Log::LV_USER)
# initialize status map
@server.jobmgr.add_internal_job(job)
@log.info( "Added new job \"#{job.get_project().name}\" for #{job.os}! (#{job.id})",
Log::LV_USER)
- if not @server.job_log_url.empty? then
- @log.info( " * Log URL : #{@server.job_log_url}/#{job.id}/log", Log::LV_USER)
- end
end
end
while not all_jobs_finished
all_jobs_finished = true
@sub_jobs.each do |job|
+ job_status = job.status
# check status chanaged, if then print
- if job_status_map[ job.id ] != job.status then
- @log.info(" * Sub-Job \"#{job.get_project().name}(#{job.os})\" has entered \"#{job.status}\" state. (#{job.id})", Log::LV_USER)
- job_status_map[ job.id ] = job.status
+ if job_status_map[ job.id ] != job_status then
+ @log.info(" * Sub-Job \"#{job.get_project().name}(#{job.os})\" has entered \"#{job_status}\" state. (#{job.id})", Log::LV_USER)
+ job_status_map[ job.id ] = job_status
end
# check all jobs are finished
- if job.status != "ERROR" and job.status != "FINISHED" and job.status != "CANCELED" then
+ if job_status != "ERROR" and job_status != "FINISHED" and job_status != "CANCELED" then
all_jobs_finished = false
end
# check there is some error or cancel
if stop_status == "FINISHED" and
- (job.status == "ERROR" or job.status == "CANCELED") then
- # write url
- write_log_url(job)
+ (job_status == "ERROR" or job_status == "CANCELED") then
# cancel all other un-finished jobs
@sub_jobs.each do |sub|
- if sub.status != "ERROR" and sub.status != "FINISHED" and
- sub.status != "CANCELED" and sub.event == "NONE" then
+ sub_status = sub.status
+ if sub_status != "ERROR" and sub_status != "FINISHED" and
+ sub_status != "CANCELED" and sub.event == "NONE" then
@log.info(" * Sub-Job \"#{sub.get_project().name}(#{sub.os})\" has entered \"CANCELING\" state. (#{sub.id})", Log::LV_USER)
sub.event = "CANCEL"
end
end
- stop_status = job.status
+ stop_status = job_status
break
end
end
check_event
+ sleep 1
end
- if stop_status == "ERROR" or stop_status == "CANCELED" then
- @status = stop_status
- return
+ if stop_status == "ERROR" then
+ raise BuildServerException.new("ERR205")
+ elsif stop_status == "CANCELED" then
+ @event = "CANCEL" if @event == "NONE"
+ raise BuildServerException.new("ERR205")
end
lock_event
# upload
- if not upload() then
- @status = "ERROR"
- return
+ if not @send_result_back then
+ upload()
+ end
+
+ # copy result files to transport path
+ if @send_result_back then
+ copy_result_files_to_master()
end
# INFO. don't change this string
binpkg_path_list = Dir.glob("#{@source_path}/*_*_*.zip")
# upload
- u_client = Client.new( @pkgsvr_url, nil, @log )
+ u_client = Client.create( @pkgsvr_url, nil, @log )
+ if u_client.nil? then
+ raise BuildServerException.new("ERR023")
+ end
+
snapshot = u_client.upload( @pkgsvr_ip, @pkgsvr_port, binpkg_path_list, @server.ftp_addr, @server.ftp_port, @server.ftp_username, @server.ftp_passwd, @pkgsvr_password)
if snapshot.nil? then
- @log.info( "Upload failed...", Log::LV_USER)
-
- return false
+ raise BuildServerException.new("ERR204")
end
# update local
@log.info( "Upload succeeded. Sync local pkg-server again...", Log::LV_USER)
@pkgsvr_client.update
@log.info("Snapshot: #{snapshot}", Log::LV_USER)
-
- return true
end
- # write web url for log
+ # copy binary package files and log file to transport dir
private
- def write_log_url(job)
- url,remote_url = job.get_log_url()
- if not url.empty? then
- @log.info( " ** Log1: #{url}", Log::LV_USER)
+ def copy_result_files_to_master()
+ outgoing_dir = "#{@server.transport_path}/#{@dock_num}"
+ if not File.exist? outgoing_dir then
+ FileUtils.mkdir_p outgoing_dir
end
- if not remote_url.empty? then
- @log.info( " ** Log2: #{remote_url}", Log::LV_USER)
+
+ # copy result files
+ copy_result_files( outgoing_dir )
+ end
+
+
+ private
+ def copy_result_files(dst_path)
+ @log.info( "Copying result files to #{dst_path}", Log::LV_USER)
+
+ # get package path list
+ binpkg_path_list = Dir.glob("#{@source_path}/*_*_*.zip")
+
+ binpkg_path_list.each do |file|
+ @result_files.push File.basename(file)
+ @log.info( " * #{file}", Log::LV_USER)
+ FileUtils.ln(file,"#{dst_path}/", :force => true)
end
end
$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common"
require "Action.rb"
require "ScheduledActionHandler.rb"
+require "BuildServerException.rb"
class PackageSyncAction < Action
@sync_root = "#{@server.path}/sync/#{my_id}"
@download_path = "#{@sync_root}/remote"
@original_path = "#{@sync_root}/main"
+ @user_id = nil
end
FileUtils.mkdir_p @original_path
# create client
- @pkgsvr_client = Client.new( @pkgsvr_url, @download_path, @server.log )
+ @pkgsvr_client = Client.create( @pkgsvr_url, @download_path, @server.log )
+ if @pkgsvr_client.nil? then
+ raise BuildServerException.new("ERR023")
+ end
main_url = @server.distmgr.get_distribution(@dist_name).pkgsvr_url
- @main_client = Client.new( main_url, @original_path, @server.log )
+ @main_client = Client.create( main_url, @original_path, @server.log )
+ if @main_client.nil? then
+ raise BuildServerException.new("ERR023")
+ end
+
+ @user_id = @server.check_user_id_from_email("sync-manager@user")
end
next
end
new_job.priority = CommonJob::AUTO_JOB_PRIORITY
+ new_job.user_id = @user_id if @user_id != -1
# add job
@server.jobmgr.commit_job(new_job)
# create logger, this step must be done after 'commit'
- new_job.create_logger( nil )
+ new_job.create_logger()
@server.jobmgr.add_job( new_job )
registered_jobs.push new_job
end
if not exist then
new_time = Time.new + 10
- @handler.register( PackageSyncAction.new(new_time, url, dist_name, @server) )
- @server.log.info "Registered package-sync action!: #{dist_name} <= \"#{url}\""
+ begin
+ @handler.register( PackageSyncAction.new(new_time, url, dist_name, @server) )
+ @server.log.info "Registered package-sync action!: #{dist_name} <= \"#{url}\""
+ rescue BuildServerException => e
+ @server.log.error e.message
+ @server.log.error "Registering package-sync action failed!: #{dist_name} <= \"#{url}\""
+ end
end
end
end
- def add_git_project(name, repos, branch, passwd, os_list, dist_name)
+ def add_git_project(name, repos, branch, os_list, dist_name)
new_prj = nil
result = @server.get_db_connection() do |db|
prj = get_project_internal(name, dist_name, db)
# create new object
new_prj = GitBuildProject.new(name, @server, os_list, dist_name, repos, branch)
- if not passwd.nil? and not passwd.empty? then
- new_prj.passwd = passwd
- end
# save to db
new_prj.save(db)
end
- def add_binary_project(name, pkg_name, passwd, os_list, dist_name)
+ def add_binary_project(name, pkg_name, os_list, dist_name)
new_prj = nil
result = @server.get_db_connection() do |db|
prj = get_project_internal(name, dist_name, db)
# create new object
new_prj = BinaryUploadProject.new(name, @server, os_list, dist_name, pkg_name)
- if not passwd.nil? and not passwd.empty? then
- new_prj.passwd = passwd
- end
# save to db
new_prj.save(db)
end
- # create new full job
- def create_new_full_build_job(dist_name="BASE")
- # create multi job
- result = MultiBuildJob.new( @server )
-
- # create sub jobs
- get_all_projects().each do |prj|
- if prj.type != "GIT" then next end
- if prj.dist_name != dist_name then next end
-
- prj.os_list.each do |os|
- if not @server.supported_os_list.include? os then next end
-
- new_job = create_new_job( prj.name, os, dist_name )
- if new_job.nil? then next end
-
- # This make project to build
- # even though there is a package of same version on pkg-server
- new_job.set_force_rebuild(true)
-
- # add to multi job
- result.add_sub_job( new_job )
- end
- end
-
- return result
- end
-
-
# get project that includes specified pkg name and os
# will return [project,os,ver] list
def get_projects_from_pkgs(pkgs, dist_name="BASE")
end
- def create_unnamed_git_project(repos, dist_name)
- name = "UNNAMED_PRJ_#{get_all_projects().count}"
- branch = "master"
- passwd = nil
- os_list = Utils.get_all_OSs()
- os_list.each do |os|
- @server.add_supported_os(os)
- end
- # add
- add_git_project(name , repos, branch, passwd, os_list, dist_name)
- # get
- return get_project(name, dist_name)
+ # this project will not be saved on DB
+ def create_transferred_git_project(repos, dist_name, os)
+ return GitBuildProject.new(nil, @server, [os], dist_name, repos, "master")
end
require "client.rb"
require "PackageManifest.rb"
require "Version.rb"
-require "JobLog.rb"
require "mail.rb"
require "utils.rb"
require "ReverseBuildChecker.rb"
require "CommonJob.rb"
+require "JobLog.rb"
+require "BuildServerException.rb"
class RegisterPackageJob < CommonJob
attr_accessor :source_path
- attr_accessor :pkgsvr_client, :thread, :pkg_type
- attr_accessor :pkg_name, :pkginfo
+ attr_accessor :pkgsvr_client, :pkg_type
+ attr_accessor :pkg_name, :pkginfo, :pkg_version
attr_accessor :no_reverse
else
@pkg_type = "ARCHIVE"
@pkg_name = @filename
+ @pkg_version = "0"
end
@pkginfo = nil #This info is valid only for BINARY package
@project = project
@no_reverse = true
end
+
+ def set_send_result_back( dock_num )
+ # do nothing
+ end
+
+
+ def is_send_result_back?
+ return false
+ end
+
+
def execute_shell(cmd)
+ # if canceled, must prevent invoking more process
+ check_event
ret = Utils.execute_shell(cmd)
+ # if canceled, must exit job thread
check_event
return ret
end
# create logger
if @log.nil? then
- @log = JobLog.new(self, nil )
+ @log = JobLog.new(self)
end
@log.info( "Initializing job...", Log::LV_USER)
# copy package file to source path
@file_path = "#{@source_path}/#{File.basename(@local_path)}"
if not File.exist? @local_path then
- @log.error( "File not found!", Log::LV_USER)
- @status = "ERROR"
- return false
+ raise BuildServerException.new("ERR107"), @local_path
+ end
+
+ if @auto_remove then
+ # if remote upload remove file and its directory
+ FileUtils.mv(@local_path, @file_path)
+ FileUtils.rm_rf("#{File.dirname(@local_path)}")
else
- if @auto_remove then
- # if remote upload remove file and its directory
- FileUtils.mv(@local_path, @file_path)
- FileUtils.rm_rf("#{File.dirname(@local_path)}")
- else
- FileUtils.cp(@local_path, @file_path)
- end
+ FileUtils.ln(@local_path, @file_path, :force => true)
end
# set up pkgsvr_client
- @pkgsvr_client = Client.new(@pkgsvr_url, @job_working_dir, @log)
+ @pkgsvr_client = Client.create(@pkgsvr_url, @job_working_dir, @log)
+ if @pkgsvr_client.nil? then
+ raise BuildServerException.new("ERR023")
+ end
# check if the os is supported by build server
if @pkg_type == "BINARY" and
not @server.supported_os_list.include? @os then
- @log.error( "Unsupported OS \"#{@os}\" is used!", Log::LV_USER)
- @status = "ERROR"
- return false
+
+ raise BuildServerException.new("ERR108"), @os
end
# checking version if not reverse-build job
# extrac pkg file
cmd = "cd \"#{@source_path}\";unzip #{@file_path}"
if not execute_shell(cmd) then
- @log.error( "Extracting package file failed!", Log::LV_USER)
- @status = "ERROR"
- return false
+ raise BuildServerException.new("ERR109"), @file_path
+ end
+
+ # check pkginfo.manifest
+ if not File.exist? "#{@source_path}/pkginfo.manifest" then
+ raise BuildServerException.new("ERR100")
end
# set up pkg info
begin
@pkginfo = PackageManifest.new("#{@source_path}/pkginfo.manifest")
rescue => e
- @log.error( e.message, Log::LV_USER)
- @status = "ERROR"
- return false
+ raise BuildServerException.new("ERR101"), e.message
end
- #if @server.changelog_check and not @pkginfo.packages[0].does_change_exist? then
- # @log.error( "change log not found", Log::LV_USER )
- # return false
- #end
+ # TODO: need to check change log file
- if not check_package_version() then
- @status = "ERROR"
- return false
- end
+ check_package_version()
end
return true
end
- #cancel
- def cancel()
- if not @log.nil? then
- @log.info( "JOB is canceled by cancel operation !!", Log::LV_USER)
- end
- end
-
-
# check building is possible
def can_be_built_on?(host_os)
return true
end
+ def is_same_with?(wjob)
+ # must have same distribution
+ if get_distribution_name() != wjob.get_distribution_name() then
+ return false
+ end
+
+ if @type != wjob.type then return false end
+
+ case @pkg_type
+ when "BINARY"
+ if @pkg_name == wjob.pkg_name and
+ @pkg_version == wjob.pkg_version and
+ wjob.pkginfo.packages.count == 1 and
+ wjob.pkginfo.packages[0].os_list.include?(@os) then
+ return true
+ end
+ when "ARCHIVE"
+ if @pkg_name == wjob.pkg_name then return true end
+ end
+
+ return false
+ end
+
+
def is_compatible_with?(o)
return false
end
end
- def is_connected?
- return true
- end
-
-
# return the job is asyncronous job
def is_asynchronous_job?
return false
def get_log_url()
# only when server support log url
if @server.job_log_url.empty? then
- return "",""
+ return ""
end
- return "#{@server.job_log_url}/#{@id}/log",""
+ return "#{@server.job_log_url}/#{@id}/log"
end
#
protected
def job_main()
@log.info( "Invoking a thread for REGISTER Job #{@id}", Log::LV_USER)
- if @status == "ERROR" then return end
@log.info( "New Job #{@id} is started", Log::LV_USER)
# clean build
if not ReverseBuildChecker.check( self, true ).empty? then
- @status = "ERROR"
- @log.error( "Reverse-build-check failed!" )
- return
+ raise BuildServerException.new("ERR203")
end
# if this package has compatible OS, check
# make new package file for compatible OS
newfile = "#{@pkg_name}_#{@pkg_version}_#{os}.zip"
@log.info( "Copying #{@filename} to #{newfile}" )
- FileUtils.cp(@file_path,"#{@source_path}/#{newfile}")
+ FileUtils.ln(@file_path,"#{@source_path}/#{newfile}",:force => true)
# reverse check
if not @no_reverse then
if not ReverseBuildChecker.check( self, true, os ) then
- @status = "ERROR"
- @log.error( "Reverse-build-check failed!" )
- return
+ raise BuildServerException.new("ERR203")
end
end
end
lock_event
# upload
- if not upload() then
- @status = "ERROR"
- return
- end
+ upload()
# INFO. don't change this string
@log.info( "Job is completed!", Log::LV_USER)
end
# upload
- u_client = Client.new( @pkgsvr_url, nil, @log )
+ u_client = Client.create( @pkgsvr_url, nil, @log )
+ if u_client.nil? then
+ raise BuildServerException.new("ERR023")
+ end
+
snapshot = u_client.upload( @pkgsvr_ip, @pkgsvr_port, binpkg_path_list, @server.ftp_addr, @server.ftp_port, @server.ftp_username, @server.ftp_passwd, @pkgsvr_password)
if snapshot.nil? then
- @log.info( "Upload failed...", Log::LV_USER)
-
- return false
+ raise BuildServerException.new("ERR204")
end
# update local
@log.info( "Upload succeeded. Sync local pkg-server again...", Log::LV_USER)
@pkgsvr_client.update
@log.info("Snapshot: #{snapshot}", Log::LV_USER)
-
- return true
end
#ver_svr = @pkgsvr_client.get_package_version( pkg.package_name, @os )
ver_svr = @pkgsvr_client.get_attr_from_pkg( pkg.package_name, @os, "version")
if not ver_svr.nil? and Version.new(ver_local) <= Version.new(ver_svr) then
- @log.error( "Version must be increased : #{ver_local} <= #{ver_svr}", Log::LV_USER)
- return false
+ raise BuildServerException.new("ERR105"), "#{ver_local} <= #{ver_svr}"
end
end
require "log"
require "FileTransferViaFTP"
require "FileTransferViaDirect"
+require "BuildServerException.rb"
+
class RemoteBuilder
- attr_accessor :id, :log
+ attr_accessor :log
# initialize
- def initialize( id, server,ftp_addr, ftp_port, ftp_username, ftp_passwd)
- @id = id
- @server = server
- @addr = server.ip
- @port = server.port
+ def initialize( addr, port ,ftp_addr, ftp_port, ftp_username, ftp_passwd)
+ @addr = addr
+ @port = port
@ftp_addr = ftp_addr
@ftp_port = ftp_port
@ftp_username = ftp_username
@ftp_passwd = ftp_passwd
- @log = DummyLog.new
+
+ @log = StandardOutLogPrinter.new
@job = nil
end
+ def RemoteBuilder.create_from_server(rserver, ftp_addr, ftp_port, ftp_username, ftp_passwd)
+
+ return RemoteBuilder.new(rserver.ip, rserver.port, ftp_addr, ftp_port, ftp_username, ftp_passwd)
+ end
+
+
# build_job
def build_job( job, local_pkgs )
# set job
@log = job.log
# build
- ret = build(@job.get_project().repository, @job.source_path, @job.os,
- @job.is_rev_build_check_job(), @job.git_commit, @job.no_reverse,
- local_pkgs, @job.get_project().dist_name,"admin@user" )
+ options = RemoteBuilder.init_options()
+ options[:git_repos] = @job.get_project().repository
+ options[:git_commit] = @job.git_commit
+ options[:src_path] = @job.source_path
+ options[:os] = @job.os
+ options[:noreverse] = @job.no_reverse
+ options[:local_pkgs] = local_pkgs
+ options[:dist] = @job.get_project().dist_name
+ options[:user] = "admin@user"
+ options[:is_rev_build] = @job.is_rev_build_check_job()
+ options[:dock] = Utils.create_uniq_name()
+ options[:save] = @job.is_rev_build_check_job() ? false : true
+ options[:pkgsvr_url] = @job.server.distmgr.get_distribution(options[:dist]).pkgsvr_url
+ ret = build( options )
# reset job
@job = nil
# build
- def build( git_repos, source_path, os, is_rev_build, srcinfo, no_reverse, local_pkgs, dist_name, user_email )
- @log.info( "Start to build on remote server...", Log::LV_USER )
-
- # create unique dock number
- dock = Utils.create_uniq_name()
-
- # send local packages
- begin
- @server.add_file_transfer()
- local_pkgs.each do |pkg_path|
- @log.info( "Sending file... : #{pkg_path}", Log::LV_USER )
- result = send_file_to_remote( pkg_path, dock )
- if not result then
- @log.error( "File transfering failed!", Log::LV_USER )
- @server.remove_file_transfer()
- return false
+ def build( options )
+ @log.info( "Start to build on remote server...", Log::LV_USER ) if not @job.nil?
+
+ # send local packages if build is invoked from JOB
+ if not @job.nil? and not options[:local_pkgs].empty? then
+ begin
+ @job.add_timestamp("REMOTE_UPLOAD_START")
+ @job.get_remote_server().add_file_transfer()
+ options[:local_pkgs].each do |pkg_path|
+ @log.info( "Sending file... : #{pkg_path}", Log::LV_USER )
+ if Utils.is_unix_like_os(Utils::HOST_OS) then
+ result = send_file_to_remote2( pkg_path, options[:dock] )
+ else
+ result = send_file_to_remote( pkg_path, options[:dock] )
+ end
+ if not result then
+ @log.error( "File transfering failed!", Log::LV_USER )
+ @job.get_remote_server().remove_file_transfer()
+ return false
+ end
end
+ ensure
+ @job.get_remote_server().remove_file_transfer()
+ @job.add_timestamp("REMOTE_UPLOAD_END")
end
- ensure
- @server.remove_file_transfer()
end
# send build request
- @log.info( "Sending build request to remote server...", Log::LV_USER )
- result, result_files = send_build_request(git_repos, os, is_rev_build,
- srcinfo, no_reverse, local_pkgs, dock, dist_name, user_email, @log.is_verbose)
+ @log.info( "Sending build request to remote server...", Log::LV_USER ) if not @job.nil?
- @log.info( "Receiving log file from remote server...", Log::LV_USER )
- if not receive_file_from_remote( "#{source_path}/../remote_log", dock ) then
- @log.warn( "File transfering failed! : remote_log", Log::LV_USER )
+ result, job_id, job_error = send_build_request( options )
+ if not result then
+ @log.error( job_error, Log::LV_USER ) if not job_error.nil?
+ @log.error( "Building job request on remote server failed!", Log::LV_USER ) if not @job.nil?
+ return false
+ end
+
+ if options[:async] then return result end
+
+ result_files = []
+ if Utils.is_unix_like_os(Utils::HOST_OS) then
+ result, result_files = send_monitor_request2(job_id, options[:monitor_level])
+ else
+ result, result_files = send_monitor_request(job_id, options[:monitor_level])
end
if not result then
@log.error( "Building job on remote server failed!", Log::LV_USER )
+
+ #Cancel remote job
+ if not @job.nil? then
+ begin
+ client = BuildCommClient.create( @addr, @port, @log )
+ if not client.nil? then
+ client.send "CANCEL|#{@job.remote_id}|#{@job.get_project.passwd}|admin@user"
+ client.receive_data()
+ client.terminate
+ end
+ rescue e
+ @log.error(e, Log::LV_USER)
+ end
+ end
return false
end
- # receive binary package
- result_files.each do |file_name|
- @log.info( "Receiving file from remote server : #{file_name}", Log::LV_USER )
- result = receive_file_from_remote( "#{source_path}/#{file_name}", dock )
- if not result then
- @log.error( "File transfering failed! : #{file_name}", Log::LV_USER )
- return false
+ # receive binary package if not reverse build
+ if options[:save] then
+ @job.add_timestamp("REMOTE_DOWNLOAD_START") if not @job.nil?
+ result_files.each do |file_name|
+ @log.info( "Receiving file from remote server : #{file_name}", Log::LV_USER )
+ if Utils.is_unix_like_os(Utils::HOST_OS) then
+ result = receive_file_from_remote2( "#{options[:src_path]}/#{file_name}", options[:dock] )
+ else
+ result = receive_file_from_remote( "#{options[:src_path]}/#{file_name}", options[:dock] )
+ end
+ if not result then
+ @log.error( "File transfering failed! : #{file_name}", Log::LV_USER )
+ return false
+ end
end
+ @job.add_timestamp("REMOTE_DOWNLOAD_END") if not @job.nil?
end
return true
end
+ protected
+ def RemoteBuilder.init_options()
+ options = {}
+ options[:projects] = nil
+ options[:passwd] = nil
+ options[:git_repos] = nil
+ options[:git_commit] = nil
+ options[:src_path] = nil
+ options[:os] = nil
+ options[:noreverse] = false
+ options[:local_pkgs] = []
+ options[:dist] = nil
+ options[:user] = nil
+ options[:is_rev_build] = false
+ options[:rebuild] = false
+ options[:save] = false
+ options[:async] = false
+ options[:monitor_level] = Log::LV_NORMAL
+ options[:pkgsvr_url] = nil
+
+ return options
+ end
+
+
# upload binary packages that is need to be overwrite
# before remote package
protected
end
- # send build request
protected
- def send_build_request(git_repos, os, is_rev_build, commit, no_reverse, local_pkgs, dock, dist_name, user_email, verbose)
- result_files = []
+ def send_file_to_remote2(file_path, dock = "0")
+ result = true
- client = BuildCommClient.create( @addr, @port, @log )
- if client.nil? then
- @log.error( "Creating communication client failed!", Log::LV_USER)
- return false, result_files
+ ruby_path=File.join(Config::CONFIG["bindir"],
+ Config::CONFIG["RUBY_INSTALL_NAME"] +
+ Config::CONFIG["EXEEXT"])
+
+ if @ftp_addr.nil? then
+ ftp_addr = "0"
+ ftp_port = "0"
+ ftp_username = "0"
+ ftp_passwd = "0"
+ else
+ ftp_addr = @ftp_addr
+ ftp_port = @ftp_port
+ ftp_username = @ftp_username
+ ftp_passwd = @ftp_passwd
end
- # get local package names
- local_pkg_names = local_pkgs.map { |path| File.basename(path) }
+ if @log.path.nil? then
+ cmd = "#{ruby_path} \"#{File.expand_path(File.dirname(__FILE__))}/send_file.rb\" #{@addr} #{@port} #{dock} \"#{file_path}\" #{ftp_addr} #{ftp_port} #{ftp_username} #{ftp_passwd}"
+ else
+ cmd = "#{ruby_path} \"#{File.expand_path(File.dirname(__FILE__))}/send_file.rb\" #{@addr} #{@port} #{dock} \"#{file_path}\" #{ftp_addr} #{ftp_port} #{ftp_username} #{ftp_passwd} \"#{@log.path}\""
+ end
- # send
- # 0 | 1 | 2 | 3 | 4| 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
- # format: BUILD|GIT|repository|passwd|os|async|no_reverse|dist_name|user_email|verbose|internal|rev-build|commit|pkgs|dock_num
- # value : BUILD|GIT|repository| |os|NO |no_reverse|dist_name|user_email|verbose|YES |rev-build|commit|pkgs|dock_num
- result = true
- commit = commit.nil? ? "":commit
- pkg_list = local_pkg_names.join(",")
- rev = is_rev_build ? "YES":"NO"
- msg = "BUILD|GIT|#{git_repos}||#{os}|NO|#{no_reverse}|#{dist_name}|#{user_email}|#{verbose}|YES|#{rev}|#{commit}|#{pkg_list}|#{dock}"
- result = client.send( msg )
- if not result then
- @log.error( "Communication failed! #{client.get_error_msg()}", Log::LV_USER)
- return false, result_files
+ cmd = Utils.generate_shell_command( cmd )
+ IO.popen("#{cmd} 2>&1") do |io|
+ if @log.path.nil? then
+ io.each do |l|
+ if l.start_with?("=TRANSFER_END") then
+ break
+ else
+ puts l
+ end
+ end
+ end
+ result = Marshal.load(io.read)
end
- r_job_number = Regexp.new('Added new job "([^"]*)"')
- error = false
- result = client.read_lines do |l|
- # write log first
- @log.output( l.strip, Log::LV_USER)
+ return result
+ end
+
+
+ # send build request
+ protected
+ def send_build_request( options )
+ result = true
+ job_id = nil
+ job_status = ""
+ job_error = nil
- # set remote job id
- if not @job.nil? and @job.remote_id.nil? and l =~ r_job_number then
- @job.remote_id = $1
+ begin
+ client = BuildCommClient.create( @addr, @port, @log )
+ if client.nil? then
+ raise BuildServerException.new("ERR018"), "#{@addr}:#{@port}"
+ end
+
+ if not options[:git_repos].nil? then
+ commit = options[:git_commit].nil? ? "" : options[:git_commit]
+ pkg_list = options[:local_pkgs].map { |path| File.basename(path) }.join(",")
+ # format: BUILD|GIT|repository|passwd|os|async|
+ # no_reverse|dist_name|
+ # user_email|rebuild|internal|rev-build|
+ # commit|pkgs|dock_num|pkgsvr_url
+ msg = "BUILD|GIT|#{options[:git_repos]}||#{options[:os]}|NO|"+
+ "#{options[:noreverse] ? "YES" : "NO"}|#{options[:dist]}|"+
+ "#{options[:user]}|NO|YES|#{options[:is_rev_build] ? "YES":"NO"}|"+
+ "#{commit}|#{pkg_list}|#{options[:dock]}|#{options[:pkgsvr_url]}"
+ else
+ # format: BUILD|GIT|project_list|passwd|
+ # os|async|
+ # no_reverse|dist_name|
+ # user_email|rebuild
+ # internal|rev-build|commit|pkgs|dock_num
+ msg = "BUILD|GIT|#{options[:projects]}|#{options[:passwd]}|"+
+ "#{options[:os]}|"+
+ "#{options[:async] ? "YES" : "NO"}|"+
+ "#{options[:noreverse] ? "YES" : "NO"}|#{options[:dist]}|"+
+ "#{options[:user]}|#{options[:rebuild] ? "YES" : "NO"}|"+
+ "NO||||#{options[:dock].nil? ? "" : options[:dock]}"
end
- # check build result
- if l.include? "Job is stopped by ERROR" or
- l.include? "Error:" then
- error = true
+ if not client.send( msg ) then
+ raise BuildServerException.new("ERR020"), "#{client.get_error_msg()}"
end
- # gather result files if not reverse build
- if not is_rev_build and l =~ /Creating package file \.\.\. (.*)/ then
- file_name = $1
- result_files.push file_name
+ result = client.read_lines do |line|
+ if line.strip.start_with?("=JOB_START") then
+ job_id = line.strip.split(",")[1]
+ elsif line.strip.start_with?("=JOB_STATUS") then
+ data = line.strip.split(",")
+ job_status = data[1]
+ job_error = data[2]
+ else
+ @log.output( line.strip, Log::LV_USER)
+ end
end
+
+ if not result then
+ raise BuildServerException.new("ERR019"), "#{client.get_error_msg()}"
+ end
+ if job_id.nil? then
+ result = false
+ end
+
+ @job.remote_id = job_id if not @job.nil?
+ @job.remote_status = job_status if not @job.nil?
+ @job.remote_error_msg = job_error if not @job.nil?
+ rescue BuildServerException => e
+ @log.error( e.err_message(""), Log::LV_USER )
+ result = false
+ rescue => e
+ @log.error( "#{e.message()}", Log::LV_USER )
+ result = false
+ ensure
+ client.terminate if not client.nil?
end
- if not result then
- @log.error( "Communication failed! #{client.get_error_msg()}", Log::LV_USER)
+
+ return result, job_id, job_error
+ end
+
+
+ # send monitor request
+ protected
+ def send_monitor_request(job_id, min_level)
+ result_files = []
+ result = true
+ job_status = "JUST_CREATED"
+
+ begin
+ result = JobLog.monitor(@addr, @port, job_id) do |line,status,errmsg|
+ job_status = status
+ @job.remote_status = status if not @job.nil?
+ @job.remote_error_msg = errmsg if not @job.nil?
+ if line.nil? then
+ next
+ end
+ if line.strip.start_with?("=JOB_FILE") then
+ result_files.push( line.strip.split(",")[1] )
+ end
+
+ category, level, contents = JobLog.parse_log(line)
+ if level < min_level then next end
+ if category == "INFO" then
+ @log.info( contents, level )
+ elsif category == "WARN" then
+ @log.warn( contents, level )
+ elsif category == "ERROR" then
+ @log.error( contents, level )
+ else
+ next
+ end
+ end
+
+ rescue BuildServerException => e
+ @log.error( e.err_message(""), Log::LV_USER )
+ result = false
+ rescue => e
+ @log.error( "#{e.message()}", Log::LV_USER )
+ result = false
end
- if error then result=false end
- # close socket
- client.terminate
+ if job_status != "FINISHED" then
+ if not @job.nil? then
+ @log.error( "Remote job is finished with \"#{@job.remote_status}\"! #{@job.remote_error_msg}", Log::LV_USER)
+ end
+ result = false
+ end
+
+ return result, result_files
+ end
+
+
+ protected
+ def send_monitor_request2(job_id, min_level)
+ result_files = []
+ result = true
+ job_status = "JUST_CREATED"
+ job_errmsg = ""
+
+ ruby_path=File.join(Config::CONFIG["bindir"],
+ Config::CONFIG["RUBY_INSTALL_NAME"] +
+ Config::CONFIG["EXEEXT"])
+
+ if @log.path.nil? then
+ cmd = "#{ruby_path} \"#{File.expand_path(File.dirname(__FILE__))}/monitor_log.rb\" #{@addr} #{@port} #{job_id} #{min_level}"
+ else
+ cmd = "#{ruby_path} \"#{File.expand_path(File.dirname(__FILE__))}/monitor_log.rb\" #{@addr} #{@port} #{job_id} #{min_level} \"#{@log.path}\""
+ end
+ cmd = Utils.generate_shell_command( cmd )
+ IO.popen("#{cmd} 2>&1") do |io|
+ if @log.path.nil? then
+ io.each do |l|
+ if l.start_with?("=LOG_END") then
+ break
+ else
+ puts l
+ end
+ end
+ end
+ result, job_status, job_errmsg, result_files = Marshal.load(io.read)
+ end
+ if job_status != "FINISHED" then
+ if not @job.nil? then
+ @log.error( "Remote job is finished with \"#{job_status}\"! #{job_errmsg}", Log::LV_USER)
+ end
+ result = false
+ end
return result, result_files
end
return result
end
+
+
+ protected
+ def receive_file_from_remote2(file_path, dock = "0")
+ result = true
+
+ ruby_path=File.join(Config::CONFIG["bindir"],
+ Config::CONFIG["RUBY_INSTALL_NAME"] +
+ Config::CONFIG["EXEEXT"])
+
+ if @ftp_addr.nil? then
+ ftp_addr = "0"
+ ftp_port = "0"
+ ftp_username = "0"
+ ftp_passwd = "0"
+ else
+ ftp_addr = @ftp_addr
+ ftp_port = @ftp_port
+ ftp_username = @ftp_username
+ ftp_passwd = @ftp_passwd
+ end
+
+ if @log.path.nil? then
+ cmd = "#{ruby_path} \"#{File.expand_path(File.dirname(__FILE__))}/receive_file.rb\" #{@addr} #{@port} #{dock} \"#{file_path}\" #{ftp_addr} #{ftp_port} #{ftp_username} #{ftp_passwd}"
+ else
+ cmd = "#{ruby_path} \"#{File.expand_path(File.dirname(__FILE__))}/receive_file.rb\" #{@addr} #{@port} #{dock} \"#{file_path}\" #{ftp_addr} #{ftp_port} #{ftp_username} #{ftp_passwd} \"#{@log.path}\""
+ end
+ cmd = Utils.generate_shell_command( cmd )
+ IO.popen("#{cmd} 2>&1") do |io|
+ if @log.path.nil? then
+ io.each do |l|
+ if l.start_with?("=TRANSFER_END") then
+ break
+ else
+ puts l
+ end
+ end
+ end
+ result = Marshal.load(io.read)
+ end
+
+ return result
+ end
end
$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/pkg_server"
require "utils.rb"
require "client.rb"
-require "JobLog.rb"
require "PackageManifest.rb"
class ReverseBuildChecker
if rev_prj.type != "GIT" then next end
found = false
- ## if job on resolve process, its unresolved project
- ##of pending ancestor must be excluded.
- #if job.type == "BUILD" and not job.pending_ancestor.nil? then
- # found = false
- # job.pending_ancestor.rev_fail_projects.each do |fp|
- # f_prj = fp[0]
- # f_os = fp[1]
-
- # if rev_prj == f_prj and rev_os == f_os then
- # found = true
- # break
- # end
- # end
- # if found then next end
- #end
-
# if this is sub job, all other sibling job must be excluded
if job.is_sub_job? then
job.get_parent_job().get_sub_jobs().each do |sub_job|
# set user id
new_job.user_id = job.user_id
+ # commit to DB
+ job.server.jobmgr.commit_job(new_job)
+
rev_build_jobs.push new_job
end
if not is_project_included?(failure_list, rev_prj, rev_os) then
log.info( " * Reverse-build FAIL ... #{rev_prj.name}(#{rev_os}) (#{rev_job.id})", Log::LV_USER)
failure_list.push [ rev_prj, rev_os ]
- write_log_url(log, rev_job)
end
# if "exist on error" cancel all other jobs
return false
end
-
-
- # write web url for log
- private
- def self.write_log_url(log, job)
- url,remote_url = job.get_log_url()
- if not url.empty? then
- log.info( " ** Log1: #{url}", Log::LV_USER)
- end
- if not remote_url.empty? then
- log.info( " ** Log2: #{remote_url}", Log::LV_USER)
- end
- end
end
=end
$LOAD_PATH.unshift File.dirname(__FILE__)
-require "JobLog.rb"
require "BuildComm.rb"
require "BuildServerException.rb"
case cmd
when "BUILD"
handle_cmd_build( req_line, req )
- #when "RESOLVE"
- # handle_cmd_resolve( req_line, req )
when "QUERY"
handle_cmd_query( req_line, req )
when "CANCEL"
handle_cmd_stop( req_line, req )
when "UPGRADE"
handle_cmd_upgrade( req_line, req )
- when "FULLBUILD"
- handle_cmd_fullbuild( req_line, req )
when "REGISTER"
handle_cmd_register( req_line, req )
when "MONITOR"
handle_cmd_monitor( req_line, req )
+ when "LOG"
+ handle_cmd_log( req_line, req )
when "DOWNLOAD"
Thread.new do
begin
handle_cmd_build_internal( line, req )
rescue BuildServerException => e
@log.error(e.message)
- BuildCommServer.send(req, e.err_message())
+ BuildCommServer.send(req, "=JOB_STATUS,ERROR,#{e.err_message()}")
BuildCommServer.send_end(req)
BuildCommServer.disconnect(req)
end
end
# 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
- # Case1. BUILD|GIT|project_name|passwd|os_list|async|no_reverse|dist_name|user_email|verbose
- # Case2. BUILD|GIT|git_repos | |os |async|no_reverse|dist_name|user_email|verbose|internal|rev_build|commit|pkgs|dock_num
+ # Case1. BUILD|GIT|project_name|passwd|os_list|async|no_reverse|dist_name|user_email|rebuild
+ # Case2. BUILD|GIT|git_repos | |os |async|no_reverse|dist_name|user_email|rebuild|internal|rev_build|commit|pkgs|dock_num
# parse
project_name_list = tok[2].split(",")
- passwd_list = tok[3].split(",")
- passwd = passwd_list[0]
+ passwd = tok[3]
os_list = tok[4].split(",")
async = tok[5].eql? "YES"
no_reverse = tok[6].eql? "YES"
dist_name = (not tok[7].nil? and not tok[7].empty?) ? tok[7].strip : ""
user_email = (not tok[8].nil? and not tok[8].empty?) ? tok[8].strip : ""
- verbose = tok[9].eql? "YES"
+ rebuild = tok[9].eql? "YES"
is_internal = tok[10].eql? "YES"
rev_job = tok[11].eql? "YES"
git_commit = (not tok[12].nil? and not tok[12].empty?) ? tok[12] : nil
pkg_files = (not tok[13].nil? and not tok[13].empty?) ? tok[13].split(",") : []
dock_num = (not tok[14].nil? and not tok[14].empty?) ? tok[14].strip : "0"
+ pkgsvr_url = (not tok[15].nil? and not tok[15].empty?) ? tok[15].strip : nil
if (dist_name.nil? or dist_name.empty?) then
dist_name = @parent_server.distmgr.get_default_distribution_name()
end
# check distribution
- check_distribution(dist_name, req)
+ if not is_internal then
+ check_distribution(dist_name, req)
+ end
# check supported os if not internal job
if not is_internal then
end
# check user email
- user_id = @parent_server.check_user_id_from_email( user_email )
- if user_id == -1 then
- raise BuildServerException.new("ERR004"), user_email
+ if not is_internal then
+ user_id = @parent_server.check_user_id_from_email( user_email )
+ if user_id == -1 then
+ raise BuildServerException.new("ERR004"), user_email
+ end
+ end
+
+ # check user psssword
+ if not is_internal and not @parent_server.check_user_password(user_id, passwd) then
+ raise BuildServerException.new("ERR011"), "Email : #{user_email} && Password : #{passwd}"
end
new_job_list = []
i = 0
project_name_list.each do |pname|
- if not passwd_list[i].nil? then passwd = passwd_list[i]
- else passwd = passwd_list[0] end
- check_build_project(pname,passwd,dist_name,req)
+ check_build_project(pname,dist_name,req)
if not check_project_user_id(pname,dist_name,user_id) then
raise BuildServerException.new("ERR005"), "#{user_email} -> #{pname}"
end
raise BuildServerException.new("ERR006"),"No valid sub jobs in Multi-Build job"
end
- # transfered job
+ # transferred job
elsif is_internal then
git_repos = project_name_list[0]
os = os_list[0]
- new_job = create_new_internal_job(git_repos, os, git_commit, pkg_files, dock_num, dist_name )
+ new_job = create_new_transferred_job(git_repos, os, git_commit, pkg_files, dock_num, dist_name, pkgsvr_url )
if new_job.nil? then
raise BuildServerException.new("ERR006"),"Transfered-Build job"
else
pname = project_name_list[0]
os = os_list[0]
- check_build_project(pname,passwd,dist_name,req)
+ check_build_project(pname,dist_name,req)
if not check_project_user_id(pname,dist_name,user_id) then
raise BuildServerException.new("ERR005"), "#{user_email} -> #{pname}"
end
# check reverse build
if no_reverse then new_job.set_no_reverse end
+ # set force rebuild if needed
+ if rebuild then new_job.set_force_rebuild(true) end
+
+ # set send result back
+ if dock_num != "0" and not is_internal then
+ new_job.set_send_result_back( dock_num )
+ end
+
@parent_server.jobmgr.commit_job(new_job)
- # create logger and set
+ # create logger and disconnect client
+ logger = new_job.create_logger(false)
+ BuildCommServer.send(req, "=JOB_START,#{new_job.id}")
+ logger.info("Added new job \"#{new_job.id}\" for #{new_job.os}!", Log::LV_USER)
+ if not @parent_server.job_log_url.empty? then
+ logger.info(" * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log", Log::LV_USER)
+ end
+
if async then
- new_job.create_logger( nil, verbose)
BuildCommServer.send(req,"Info: Added new job \"#{new_job.id}\" for #{new_job.os}!")
- if not @parent_server.job_log_url.empty? then
- BuildCommServer.send(req,"Info: * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log")
- end
BuildCommServer.send(req,"Info: Above job(s) will be processed asynchronously!")
- BuildCommServer.send_end(req)
- BuildCommServer.disconnect(req)
- else
- logger = new_job.create_logger( req, verbose)
- logger.info( "Added new job \"#{new_job.id}\" for #{new_job.os}!", Log::LV_USER)
- if not @parent_server.job_log_url.empty? then
- logger.info( " * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log", Log::LV_USER)
- end
end
+ BuildCommServer.send_end(req)
+ BuildCommServer.disconnect(req)
# add to job queue
if new_job.is_rev_build_check_job() then
end
- def check_build_project(prj_name, passwd, dist_name, req)
+ def check_build_project(prj_name, dist_name, req)
# check project
prj = check_project_exist(prj_name, dist_name, req)
- # check passwd
- check_project_password(prj, passwd, req)
-
+ # check project status
+ if prj.status != "OPEN" then
+ raise BuildServerException.new("ERR017"), "#{prj_name} on #{dist_name}. project is [[#{prj.status}]]"
+ end
+
# check project type
if prj.type == "BINARY" then
raise BuildServerException.new("ERR010"), prj.type
end
- ## "RESOLVE"
- #def handle_cmd_resolve( line, req )
- # @log.info "Received REQ: #{line}"
-
- # begin
- # handle_cmd_resolve_internal( line, req )
- # rescue BuildServerException => e
- # @log.error(e.message)
- # BuildCommServer.send(req, e.err_message())
- # BuildCommServer.send_end(req)
- # BuildCommServer.disconnect(req)
- # end
-
- # @log.info "Handled REQ: #{line}"
- #end
-
-
- #def handle_cmd_resolve_internal( line ,req)
- # tok = line.split("|").map { |x| x.strip }
- # if tok.count < 3 then
- # raise BuildServerException.new("ERR001"), line
- # end
-
- # case tok[1]
- # # RESOLVE|GIT|project_name|passwd|os|async|dist_name|user_email|verbose
- # when "GIT"
-
- # # parse
- # project_name=tok[2]
- # passwd=tok[3]
- # os=tok[4]
- # async = tok[5].eql? "YES"
- # dist_name = tok[6]
- # user_email = (not tok[7].nil? and not tok[7].empty?) ? tok[7].strip : ""
- # verbose = tok[8].eql? "YES"
- # if (dist_name.nil? or dist_name.empty?) then
- # dist_name = @parent_server.distmgr.get_default_distribution_name()
- # end
-
- # # check distribution
- # check_distribution(dist_name, req)
-
- # # check project
- # prj = check_project_exist(project_name, dist_name, req)
-
- # # check passwd
- # check_project_password(prj, passwd, req)
-
- # # check os
- # os_list = check_supported_os( [os] , req )
- # os = os_list[0]
-
- # # check user email
- # user_id = @parent_server.check_user_id_from_email( user_email )
- # if user_id == -1 then
- # raise BuildServerException.new("ERR004"), user_email
- # end
-
- # # check user accessable
- # if not check_project_user_id(project_name,dist_name,user_id) then
- # raise BuildServerException.new("ERR005"), "#{user_email} -> #{project_name}"
- # end
-
- # # create new job
- # new_job = create_new_job( project_name, os, dist_name )
- # if new_job.nil? then
- # raise BuildServerException.new("ERR006"), "Resolve job #{project_name} #{os}"
- # end
- # @log.info "Received a request for resolving this project : #{project_name}, #{os}"
-
- # new_job.user_id = user_id
-
- # # resolve
- # new_job.set_resolve_flag()
-
- # # create logger and set
- # if async then
- # new_job.create_logger( nil, verbose)
- # BuildCommServer.send(req,"Info: Added new job \"#{new_job.id}\" for #{new_job.os}!")
- # if not @parent_server.job_log_url.empty? then
- # BuildCommServer.send(req,"Info: * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log")
- # end
- # BuildCommServer.send(req,"Info: Above job(s) will be processed asynchronously!")
- # BuildCommServer.send_end(req)
- # BuildCommServer.disconnect(req)
- # else
- # logger = new_job.create_logger( req, verbose)
- # logger.info( "Added new job \"#{new_job.id}\" for #{new_job.os}!", Log::LV_USER)
- # if not @parent_server.job_log_url.empty? then
- # logger.info( " * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log", Log::LV_USER)
- # end
- # end
-
- # @parent_server.jobmgr.add_job( new_job )
- # else
- # raise BuildServerException.new("ERR001"), line
- # end
- #end
-
-
# "QUERY"
def handle_cmd_query( line, req )
begin
def handle_cmd_cancel_internal( line, req )
tok = line.split("|").map { |x| x.strip }
- if tok.count < 2 then
+ if tok.count < 4 then
raise BuildServerException.new("ERR001"), line
end
cancel_job = nil
- # check user email
- user_id = @parent_server.check_user_id_from_email( tok[3] )
- if user_id == -1 then
- raise BuildServerException.new("ERR004"), tok[3]
- end
+ job_number = tok[1]
+ user_password = tok[2]
+ user_email = tok[3]
#CANCEL, JOB
(@parent_server.jobmgr.jobs + @parent_server.jobmgr.internal_jobs + @parent_server.jobmgr.reverse_build_jobs).each do |j|
- if "#{j.id}" == "#{tok[1]}" then
+ if "#{j.id}" == "#{job_number}" then
cancel_job = j
break
end
end
if cancel_job.nil? then
- raise BuildServerException.new("ERR014"), "Job #{tok[1]} not found."
+ raise BuildServerException.new("ERR014"), "Job #{job_number} not found."
end
if cancel_job.event != "NONE" then
raise BuildServerException.new("ERR014"), "Job already canceled."
end
- # check passwd
- if not @parent_server.jobmgr.is_user_accessable(cancel_job,user_id) then
- raise BuildServerException.new("ERR014"), "Access denied #{tok[3]}"
- end
+ if not cancel_job.is_transferred? then
+ # check user email
+ user_id = @parent_server.check_user_id_from_email(user_email)
+ if user_id == -1 then
+ raise BuildServerException.new("ERR004"), user_email
+ end
+
+ # check user psssword
+ if not @parent_server.check_user_password(user_id, user_password) then
+ raise BuildServerException.new("ERR011"), "Email : #{user_email} && Password : #{passwd}"
+ end
- if cancel_job.type == "MULTIBUILD" then
- cancel_job.get_sub_jobs().select{|x| x.event == "NONE" }.each do |sub|
- check_project_password( sub.get_project, tok[2], req)
+ # check project accessable
+ if not @parent_server.jobmgr.is_user_accessable(cancel_job,user_id) then
+ raise BuildServerException.new("ERR014"), "Access denied #{user_email}"
end
+ end
+ if cancel_job.type == "MULTIBUILD" then
+ sub_projects = cancel_job.get_sub_jobs().map{|sub| sub.get_project }
BuildCommServer.send(req, "\"#{cancel_job.id}, #{cancel_job.get_sub_jobs().map{|x| x.id}.join(", ")}\" will be canceled")
else
raise BuildServerException.new("ERR014"), "No project infomation"
end
- check_project_password( prj, tok[2], req)
-
BuildCommServer.send(req, "\"#{cancel_job.id}\" will be canceled")
end
def handle_cmd_upgrade_internal( line, req )
tok = line.split("|").map { |x| x.strip }
- if tok.count < 2 then
+ if tok.count < 3 then
raise BuildServerException.new("ERR001"), line
end
+ password = tok[1]
+ pkgsvr_url = tok[2]
- if tok[1] != @parent_server.password then
+ # write package server url
+ File.open("#{BuildServer::CONFIG_ROOT}/#{@parent_server.id}/upgrade_dist","w") do |f|
+ f.puts pkgsvr_url
+ end
+
+ if password != @parent_server.password then
raise BuildServerException.new("ERR015"), ""
else
BuildCommServer.send(req,"Server will be upgraded!")
BuildCommServer.send_end(req)
BuildCommServer.disconnect(req)
end
- if tok[1] == @parent_server.password then
- @parent_server.finish = true
- @parent_server.upgrade = true
- end
- end
-
-
- # "FULLBUILD"
- def handle_cmd_fullbuild( line, req )
- @log.info "Received REQ: #{line}"
-
- begin
- handle_cmd_fullbuild_internal( line, req )
- rescue BuildServerException => e
- @log.error(e.message)
- BuildCommServer.send(req, e.err_message())
- BuildCommServer.send_end(req)
- BuildCommServer.disconnect(req)
- end
- @log.info "Handled REQ: #{line}"
- end
-
-
- def handle_cmd_fullbuild_internal( line, req )
- tok = line.split("|").map { |x| x.strip }
- if tok.count < 2 then
- raise BuildServerException.new("ERR001"), line
- end
-
- server_passwd = tok[1]
- dist_name = tok[2]
- if (dist_name.nil? or dist_name.empty?) then
- dist_name = @parent_server.distmgr.get_default_distribution_name()
- end
-
- # check distribution
- check_distribution(dist_name, req, true)
-
- # check server password
- if server_passwd != @parent_server.password then
- raise BuildServerException.new("ERR015"), ""
- end
-
- # create full build job
- new_job = @parent_server.prjmgr.create_new_full_build_job(dist_name)
-
- @parent_server.jobmgr.commit_job(new_job)
-
- # set logger
- new_job.create_logger( req )
-
- # add to job
- @parent_server.jobmgr.add_job( new_job )
+ # set flag for quit message loop
+ @parent_server.finish = true
+ @parent_server.upgrade = true
end
handle_cmd_register_internal( line, req )
rescue BuildServerException => e
@log.error(e.message)
- BuildCommServer.send(req, e.err_message())
+ BuildCommServer.send(req, "=JOB_STATUS,ERROR,#{e.err_message()}")
BuildCommServer.send_end(req)
BuildCommServer.disconnect(req)
rescue => e
# check distribution
check_distribution(dist_name, req)
+ # check project
+ file_name = File.basename(file_path)
+ prj = check_project_for_package_file_name(file_name, dist_name, req)
+ # check project status
+ if prj.status != "OPEN" then
+ raise BuildServerException.new("ERR017"), "#{prj.name} on #{dist_name}. project is [[#{prj.status}]]"
+ end
+
new_job = @parent_server.jobmgr.create_new_register_job( file_path, dist_name )
- new_job.create_logger( req )
+
+ @parent_server.jobmgr.commit_job(new_job)
+ logger = new_job.create_logger()
+
+ # notify that job has been received
+ BuildCommServer.send(req, "=JOB_START,#{new_job.id}")
+ logger.info( "Added new job \"#{new_job.id}\" for #{new_job.os}!", Log::LV_USER)
+ if not @parent_server.job_log_url.empty? then
+ logger.info( " * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log", Log::LV_USER)
+ end
+
+ BuildCommServer.send_end(req)
+ BuildCommServer.disconnect(req)
# add
@parent_server.jobmgr.add_job( new_job )
# check project
prj = check_project_for_package_file_name(filename, dist_name, req)
+ # check project status
+ if prj.status != "OPEN" then
+ raise BuildServerException.new("ERR017"), "#{prj.name} on #{dist_name}. project is [[#{prj.status}]]"
+ end
+
# check user email
user_id = @parent_server.check_user_id_from_email( user_email )
if user_id == -1 then
raise BuildServerException.new("ERR004"), user_email
end
+ # check user psssword
+ if not @parent_server.check_user_password(user_id, passwd) then
+ raise BuildServerException.new("ERR011"), "Email : #{user_email} && Password : #{passwd}"
+ end
+
if not check_project_pkg_name_user_id(filename, dist_name, user_id) then
raise BuildServerException.new("ERR005"), "#{user_email} -> #{prj.name}"
end
- # check passwd
- check_project_password(prj, passwd, req)
-
# save thread and wait uplaod
BuildCommServer.send(req, "WAITFORUPLOAD")
req_line = req.gets
# create new job
@log.info "Received a request for uploading binaries : #{filename}"
- new_job = create_new_upload_job( prj.name, filename, dock, dist_name, req )
+ new_job = create_new_upload_job( prj.name, filename, dock, dist_name )
if new_job.nil? then
raise BuildServerException.new("ERR006"), "Register-job #{filename}, #{prj.name}, #{dist_name}"
end
@parent_server.jobmgr.commit_job(new_job)
# create logger and set
- logger = new_job.create_logger(req)
+ logger = new_job.create_logger()
# notify that job has been received
+ BuildCommServer.send(req, "=JOB_START,#{new_job.id}")
logger.info( "Added new job \"#{new_job.id}\" for #{new_job.os}!", Log::LV_USER)
if not @parent_server.job_log_url.empty? then
logger.info( " * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log", Log::LV_USER)
end
+ BuildCommServer.send_end(req)
+ BuildCommServer.disconnect(req)
+
# add
@parent_server.jobmgr.add_job( new_job )
else
end
+ # "LOG"
+ def handle_cmd_log( line, req )
+ @log.info "Received REQ: #{line.strip}"
+
+ begin
+ handle_cmd_log_internal( line, req )
+ rescue BuildServerException => e
+ @log.error(e.message)
+ BuildCommServer.send(req, e.err_message())
+ BuildCommServer.send_end(req)
+ BuildCommServer.disconnect(req)
+ end
+
+ @log.info "Handled REQ: #{line.strip}"
+ end
+
+
def handle_cmd_monitor_internal( line, req )
tok = line.split("|").map { |x| x.strip }
if tok.count < 2 then
end
+ def handle_cmd_log_internal( line, req )
+ tok = line.split("|").map { |x| x.strip }
+ if tok.count < 2 then
+ raise BuildServerException.new("ERR001"), line
+ end
+
+ job_number = tok[1]
+ @parent_server.query_job_log(job_number, req)
+ end
+
+
# "UPLOAD"
def handle_cmd_upload( line, req )
@log.info "Received File transfer REQ : #{line}"
# get package name
new_name = filename.sub(/(.*)_(.*)_(.*)\.zip/,'\1,\2,\3')
pkg_name = new_name.split(",")[0]
-
prj = @parent_server.prjmgr.get_project_from_package_name(pkg_name, dist_name)
if prj.nil? then
raise BuildServerException.new("ERR013"), "#{pkg_name} #{dist_name}"
return prj
end
-
- private
- def check_project_password(prj, passwd, req)
-
- if prj.is_passwd_set? then
- if passwd.nil? or passwd.empty? then
- raise BuildServerException.new("ERR011"), "Use -w option to input your project password"
- end
-
- if not prj.passwd_match?(passwd) then
- raise BuildServerException.new("ERR012"), ""
- end
- end
- end
-
-
private
def check_distribution(dist_name, req, only_exist = false)
dist = @parent_server.distmgr.get_distribution(dist_name)
end
end
-
private
def check_supported_os(os_list, req)
elsif @parent_server.supported_os_list.include?(os) then
result.push os
else
- msgs = "#{os}\n\tSupported OS list.\n"
- @parent_server.supported_os_list.each do |os_name|
- msgs += "\t * #{os_name}\n"
- end
+ msgs = "#{os}... Use a name in (" +
+ @parent_server.supported_os_list.join("|") + ")"
raise BuildServerException.new("ERR003"),msgs
end
end
private
- def create_new_upload_job( project_name, filename, dock, dist_name, req)
+ def create_new_upload_job( project_name, filename, dock, dist_name)
return @parent_server.prjmgr.get_project(project_name, dist_name).create_new_job(filename, dock)
end
private
- def create_new_internal_job( git_repos, os, git_commit, pkg_files, dock_num, dist_name )
- prj = @parent_server.prjmgr.get_git_project( git_repos, dist_name )
- if prj.nil? then
- prj = @parent_server.prjmgr.create_unnamed_git_project( git_repos, dist_name )
- end
+ def create_new_transferred_job( git_repos, os, git_commit, pkg_files, dock_num, dist_name, pkgsvr_url )
+ prj = @parent_server.prjmgr.create_transferred_git_project( git_repos, dist_name, os )
new_job = prj.create_new_job(os)
- new_job.set_internal_job( dock_num )
+ new_job.set_package_server_url(pkgsvr_url)
+ new_job.set_verified( true )
+ new_job.set_send_result_back( dock_num )
new_job.git_commit = git_commit
- incoming_dir = "#{@parent_server.transport_path}/#{dock_num}"
pkg_files.each do |file|
new_job.add_external_package( file )
end
--- /dev/null
+#!/usr/bin/ruby
+=begin
+
+ monitor_log.rb
+
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+Contact:
+Taejun Ha <taejun.ha@samsung.com>
+Jiil Hyoun <jiil.hyoun@samsung.com>
+Donghyuk Yang <donghyuk.yang@samsung.com>
+DongHee Yang <donghee.yang@samsung.com>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+- S-Core Co., Ltd
+=end
+
+require 'logger'
+$LOAD_PATH.unshift File.dirname(__FILE__)
+$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__)) + "/common"
+require 'JobLog'
+require 'log.rb'
+require 'utils.rb'
+
+# parse arguments
+addr = ARGV[0]
+port = ARGV[1]
+job_id = ARGV[2]
+min_level = ARGV[3].to_i
+log_path = ARGV[4]
+if log_path.nil? then
+ log = StandardOutLogPrinter.new
+else
+ log = Log.new(log_path)
+end
+result_files = []
+result = true
+job_status = "JUST_CREATED"
+job_errmsg = ""
+begin
+ result = JobLog.monitor(addr, port, job_id) do |line,status,errmsg|
+ job_status = status
+ job_errmsg = errmsg
+ if line.nil? then
+ next
+ end
+ if line.strip.start_with?("=JOB_FILE") then
+ result_files.push( line.strip.split(",")[1] )
+ end
+
+ category, level, contents = JobLog.parse_log(line)
+ if level < min_level then next end
+ if category == "INFO" then
+ log.info( contents, level )
+ STDOUT.flush
+ elsif category == "WARN" then
+ log.warn( contents, level )
+ STDOUT.flush
+ elsif category == "ERROR" then
+ log.error( contents, level )
+ STDOUT.flush
+ else
+ next
+ end
+ end
+
+rescue BuildServerException => e
+ log.error( e.err_message("") )
+ result = false
+rescue => e
+ log.error( "#{e.message()}" )
+ result = false
+end
+if log_path.nil? then
+ puts "=LOG_END"
+ STDOUT.flush
+end
+Marshal.dump([result, job_status, job_errmsg, result_files], $stdout)
--- /dev/null
+#!/usr/bin/ruby
+=begin
+
+ send_file.rb
+
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+Contact:
+Taejun Ha <taejun.ha@samsung.com>
+Jiil Hyoun <jiil.hyoun@samsung.com>
+Donghyuk Yang <donghyuk.yang@samsung.com>
+DongHee Yang <donghee.yang@samsung.com>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+- S-Core Co., Ltd
+=end
+
+require 'logger'
+$LOAD_PATH.unshift File.dirname(__FILE__)
+$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__)) + "/common"
+require 'JobLog'
+require 'log.rb'
+require 'utils.rb'
+require "FileTransferViaFTP"
+require "FileTransferViaDirect"
+
+# parse arguments
+addr = ARGV[0]
+port = ARGV[1]
+dock = ARGV[2]
+file_path = ARGV[3]
+file_path = ARGV[3]
+ftp_addr = ARGV[4]
+ftp_port = ARGV[5]
+ftp_username = ARGV[6]
+ftp_passwd = ARGV[7]
+log_path = ARGV[8]
+if log_path.nil? then
+ log = StandardOutLogPrinter.new
+else
+ log = Log.new(log_path)
+end
+
+begin
+ result = false
+
+ # create client
+ client = BuildCommClient.create( addr, port, log )
+ if client.nil? then
+ log.error( "Creating communication client failed!", Log::LV_USER)
+ exit(1)
+ end
+
+ # download file
+ file_name = file_path.split("/")[-1]
+ msg = "DOWNLOAD|#{dock}|#{file_name}"
+ if client.send( msg ) then
+ if ftp_addr != "0" then
+ transporter=FileTransferFTP.new(log, ftp_addr, ftp_port, ftp_username, ftp_passwd)
+ else
+ transporter=FileTransferDirect.new(log)
+ end
+ result=client.receive_file(file_path, transporter)
+ if not result then
+ log.error( "File downloading failed...#{file_name}", Log::LV_USER)
+ end
+ end
+rescue => e
+ log.error( "#{e.message()}" )
+ result = false
+ensure
+ #close connections
+ client.terminate if not client.nil?
+
+ # send result
+ if log_path.nil? then
+ puts "=TRANSFER_END"
+ STDOUT.flush
+ end
+ Marshal.dump(result, $stdout)
+end
+
--- /dev/null
+#!/usr/bin/ruby
+=begin
+
+ send_file.rb
+
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+Contact:
+Taejun Ha <taejun.ha@samsung.com>
+Jiil Hyoun <jiil.hyoun@samsung.com>
+Donghyuk Yang <donghyuk.yang@samsung.com>
+DongHee Yang <donghee.yang@samsung.com>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+- S-Core Co., Ltd
+=end
+
+require 'logger'
+$LOAD_PATH.unshift File.dirname(__FILE__)
+$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__)) + "/common"
+require 'JobLog'
+require 'log.rb'
+require 'utils.rb'
+require "FileTransferViaFTP"
+require "FileTransferViaDirect"
+
+
+# parse arguments
+addr = ARGV[0]
+port = ARGV[1]
+dock = ARGV[2]
+file_path = ARGV[3]
+ftp_addr = ARGV[4]
+ftp_port = ARGV[5]
+ftp_username = ARGV[6]
+ftp_passwd = ARGV[7]
+log_path = ARGV[8]
+if log_path.nil? then
+ log = StandardOutLogPrinter.new
+else
+ log = Log.new(log_path)
+end
+
+begin
+ result = false
+
+ # create client
+ client = BuildCommClient.create( addr, port, log )
+ if client.nil? then
+ log.error( "Creating communication client failed!", Log::LV_USER)
+ exit(1)
+ end
+
+ # upload file
+ file_name = file_path.split("/")[-1]
+ msg = "UPLOAD|#{dock}"
+ if client.send( msg ) then
+ if ftp_addr != "0" then
+ transporter=FileTransferFTP.new(log, ftp_addr, ftp_port, ftp_username, ftp_passwd)
+ else
+ transporter=FileTransferDirect.new(log)
+ end
+
+ result=client.send_file( file_path, transporter )
+ if not result then
+ log.error( "File uploading failed...#{file_name}", Log::LV_USER)
+ end
+ end
+
+rescue => e
+ log.error( "#{e.message()}" )
+ result = false
+ensure
+ #close connections
+ client.terminate if not client.nil?
+
+ # send result
+ if log_path.nil? then
+ puts "=TRANSFER_END"
+ STDOUT.flush
+ end
+ Marshal.dump(result, $stdout)
+end
+
# create client
@log.info( "Downloding client is initializing...", Log::LV_USER)
- cl = Client.new(@pkgserver_url, build_root_dir, @log)
+ cl = Client.create(@pkgserver_url, build_root_dir, @log)
+ if cl.nil? then
+ @log.error( "Cannot create package client!", Log::LV_USER )
+ return false
+ end
if clean then
cl.clean(true)
end
# install build dependencies
@log.info( "Installing dependent packages...", Log::LV_USER)
pkginfo.get_build_dependencies( os ).each do |dep|
+ # if job, check "CANCEL"
+ if not @job.nil? then @job.check_event() end
+
if dep.target_os_list.count != 0 then
dep_target_os = dep.target_os_list[0]
else
return true
end
- FileUtils.cp(src, tar)
+ FileUtils.ln(src, tar,:force => true)
end
return true
return true
end
- FileUtils.cp(src, tar)
+ FileUtils.ln(src, tar,:force => true)
end
return true
end
-require "socket"
-
=begin
BuildComm.rb
$LOAD_PATH.unshift File.dirname(__FILE__)
require "log"
+require "socket"
require 'timeout'
require "net/ftp"
require 'thread'
ATTEMPTS = ["first", "second", "third"]
class BuildCommServer
- VERSION = "1.8.0"
+ VERSION = "1.9.0"
private_class_method :new
# if hit , touch and copy
FileUtils.touch cache_file
- FileUtils.copy_file(cache_file, dst_file)
+ FileUtils.ln(cache_file, dst_file, :force => true)
found = true
end
cache_file = "#{@cache_dir}/#{file_name}"
@download_cache_mutex.synchronize do
# copy & touch
- FileUtils.copy_file(dst_file, cache_file)
+ FileUtils.ln(dst_file, cache_file, :force => true)
FileUtils.touch cache_file
end
end
class BuildCommClient
- VERSION = "1.8.0"
+ VERSION = "1.9.0"
FIRST_RESPONSE_TIMEOUT = 120
private_class_method :new
def initialize(socket, log)
+ @job_id = nil
+ @job_status = ""
+ @job_error = ""
@log = log
@socket = socket
@error_msg = ""
# create
# if sec 0 or nil then not set timeout. it's timeout spec
- def self.create(ip, port, log = nil, sec = 5)
- # open socket
- socket = nil
- begin
- timeout(sec) do
- socket = TCPSocket.open( ip, port )
+ def self.create(ip, port, log = nil, sec = 10, retries = 3)
+ # open socket
+ socket = nil
+ for i in 1..retries
+ begin
+ timeout(sec) do
+ socket = TCPSocket.open( ip, port )
+ end
+ rescue Timeout::Error
+ log.warn("Connection Timed Out!") if not log.nil?
+ socket = nil
+ rescue => e # unknown exception
+ log.warn("TCPSocket Error: #{e.message}") if not log.nil?
+ socket = nil
end
- rescue Timeout::Error
- return nil
- rescue
- # unknown exception
- return nil
- end
+ if not socket.nil? then break end
+ log.warn("Retrying...") if not log.nil? and i < retries
+ end
# refused
if socket.nil? then
return new(socket, log)
end
-
def get_error_msg()
return @error_msg
end
+ def get_job_id
+ return @job_id
+ end
+
+ def get_job_status
+ return @job_status
+ end
+
+ def get_job_error
+ return @job_status
+ end
def set_error_msg( msg )
@error_msg = msg
@error_msg = "Connection is not available!"
return false
end
-
- @socket.puts( msg )
- return true
- end
-
-
- def print_stream
-
begin
- l = nil
- timeout(FIRST_RESPONSE_TIMEOUT) do
- l = @socket.gets()
- end
-
- if l.nil? then
- @error_msg = "Connection closed or no more message"
- return false
- end
-
- # check protocol
- if not protocol_matched? l.strip then
- @error_msg = "Comm. Protocol version is mismatched! #{VERSION}. Upgrade your DIBS client!"
- return false
- end
-
- # get contents
- while line = @socket.gets()
- if line.strip == "=END" then break end
- if line.strip == "=CHK" then next end
- # print
- puts line.strip
- end
- rescue Timeout::Error
- @error_msg = "Connection timed out!"
- return false
-
+ @socket.puts( msg )
rescue => e
@error_msg = e.message
return false
# handle
def read_lines(begin_timeout = nil, data_timeout = nil)
+ result = true
begin
# get first line
l = nil
end
# get contents
- result = true
while true
line = nil
if not data_timeout.nil? then
else
line = @socket.gets()
end
- if line.nil? then break end
- if line.strip == "=END" then break end
- if line.strip == "=CHK" then next end
+
+ if line.nil? then
+ @error_msg = "Disconnected by remote server!"
+ result = false
+ break
+ elsif line.strip == "=END" then
+ break
+ elsif line.strip == "=CHK" then
+ next
+ end
# execute
yield line.strip if block_given?
end
rescue Timeout::Error
@error_msg = "Connection timed out!"
- return false
+ result = false
rescue => e
@error_msg = e.message
- return false
+ result = false
end
- return true
+ return result
end
old_progress = 0
# read file contents
# send via tcp/ip
+ trBegin = Time.now()
File.open(src_file, "rb") do |io|
while size > 0
buf = io.read(size > 1024*1024 ? 1024*1024 : size)
end
end
end
-
- @log.info "Upload is succeeded!"
+ trEnd = Time.now()
+ trRate = (full_size / (trEnd - trBegin) / 1000).to_i
+ @log.info "Upload is succeeded! #{trRate}KByte/s"
conn.puts "SEND_OK"
# wait for download result
@log.info "Received file info from remote site"
filename = tok[1].strip
size = tok[2].strip.to_i
+ full_size = size
checksum = tok[3].strip
if File.directory? dst_file then
dst_file = File.join(dst_file, filename)
end
+ trBegin = Time.now()
File.open( dst_file, "wb" ) do |io|
while size > 0
buf = conn.read(size > 1024*1024 ? 1024*1024 : size)
size -= buf.length
end
end
+ trEnd = Time.now()
+ trRate = (full_size / (trEnd - trBegin) / 1000).to_i
+ @log.info "Download is succeeded! #{trRate}KByte/s"
conn.puts "RECEIVE_OK"
--- /dev/null
+require "fileutils"
+
+class FileUtil
+ public
+ def FileUtil.getFileNameFromURL(url)
+ fileName = url.split('/')[-1]
+ return fileName
+ end
+
+ public
+ def FileUtil.getFlatURL(url)
+ if url.nil? or url.empty? then
+ return ""
+ end
+
+ return url.delete(".:/@")
+ end
+
+ public
+ def FileUtil.exclusiveLock(filePath)
+ if (not File.exist?(filePath))
+ FileUtils.mkdir_p(filePath)
+ end
+
+ file = File.new(filePath)
+ if (file.flock(File::LOCK_EX | File::LOCK_NB))
+ return true;
+ else
+ return false
+ end
+ end
+
+end
\ No newline at end of file
--- /dev/null
+#$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common/model"
+require 'model/Property'
+
+class PropertyParser
+ attr_accessor :seperate
+ def initialize(seperate)
+ if seperate.nil? then
+ @seperate = ":";
+ else
+ @seperate = seperate;
+ end
+ end
+
+ public
+ def parseFile(filePath)
+ propertySection = Array.new;
+ properties = Array.new;
+
+ f = File.open(filePath,"r");
+ f.each_line do |line|
+ if line.empty? || line.eql?("\n") then
+ if not properties.empty?() then
+ propertySection.push(properties);
+ properties = Array.new
+ end
+ else
+ sepLine = line.split(@seperate);
+ properties.push(Property.new(sepLine[0].strip, sepLine[1].strip))
+ end
+
+ end
+
+ if (not properties.empty?) then
+ propertySection.push(properties);
+ end
+
+ return propertySection;
+ end
+end
# execute and write log
IO.popen("#{cmd} 2>&1") do |io|
io.each do |line|
- log.info line
+ log.info "{1} #{line}"
end
end
class Log
- attr_accessor :path, :cnt
+ attr_accessor :path, :cnt, :logger
# Log LEVEL
LV_NORMAL = 1
def initialize(path, lv=LV_USER)
@cnt = 0
@path = path
+ @level = lv
+ @closed = false
if @path.nil? then
@logger = Logger.new(STDOUT)
else
@logger = Logger.new(path, "monthly")
end
- # if log level is bigger/equal to second out level
- # , we will send the log to second-out
- @second_out_level = lv
- @second_out = nil
+
# diable logger format
@default_formatter = @logger.formatter
@no_prefix_formatter = proc do |severity, datetime, progname, msg|
def info(msg, lv=LV_NORMAL)
- if @path.nil? and not @second_out.nil? then puts "Info: #{msg}"
- else @logger.info msg end
- if not @second_out.nil? and lv >= @second_out_level then
- output_extra "Info: " + msg
- end
+ if @path.nil? then puts "Info: #{msg}" else @logger.info "{#{lv}} #{msg}" end
+ output_extra("Info: " + msg, lv)
@cnt = @cnt + 1
end
def warn(msg, lv=LV_NORMAL)
- if @path.nil? and not @second_out.nil? then puts "Warn: #{msg}"
- else @logger.warn msg end
- if not @second_out.nil? and lv >= @second_out_level then
- output_extra "Warn: " + msg
- end
+ if @path.nil? then puts "Warn: #{msg}" else @logger.warn "{#{lv}} #{msg}" end
+ output_extra("Warn: " + msg, lv)
@cnt = @cnt + 1
end
def error(msg, lv=LV_NORMAL)
- if @path.nil? and not @second_out.nil? then puts "Error: #{msg}"
- else @logger.error msg end
- if not @second_out.nil? and lv >= @second_out_level then
- output_extra "Error: " + msg
- end
+ if @path.nil? then puts "Error: #{msg}" else @logger.error "{#{lv}} #{msg}" end
+ output_extra("Error: " + msg, lv)
@cnt = @cnt + 1
end
def output(msg, lv=LV_NORMAL)
- if @path.nil? and not @second_out.nil? then puts msg
- else @logger.info msg end
- if not @second_out.nil? and lv >= @second_out_level then
- output_extra msg
- end
+ if @path.nil? then puts msg else @logger.info "{#{lv}} #{msg}" end
+ output_extra(msg, lv)
@cnt = @cnt + 1
end
def close
- @second_out= nil
+ @closed = true
end
- def is_verbose
- return @second_out_level.eql? Log::LV_NORMAL
- end
+ def is_closed?
+ return @closed
+ end
protected
- def output_extra(msg)
+ def output_extra(msg, lv)
#do nothing
end
end
end
end
+
class StandardOutLog < Log
def initialize(path)
super(path)
- @second_out = $stdout
end
protected
- def output_extra(msg)
- @second_out.puts msg
+ def output_extra(msg, lv)
+ if lv >= @level then
+ $stdout.puts msg
+ end
+ end
+end
+
+
+class StandardOutLogPrinter < Log
+
+ def initialize()
+ super(nil)
+ end
+
+ def info(msg, lv=LV_NORMAL)
+ if lv >= @level then
+ puts "Info: #{msg}"
+ @cnt = @cnt + 1
+ end
+ end
+
+ def warn(msg, lv=LV_NORMAL)
+ if lv >= @level then
+ puts "Warn: #{msg}"
+ @cnt = @cnt + 1
+ end
+ end
+
+
+ def error(msg, lv=LV_NORMAL)
+ if lv >= @level then
+ puts "Error: #{msg}"
+ @cnt = @cnt + 1
+ end
+ end
+
+
+ def output(msg, lv=LV_NORMAL)
+ if lv >= @level then
+ puts msg
+ @cnt = @cnt + 1
+ end
end
end
--- /dev/null
+class Property
+ attr_accessor(:key, :value)
+
+ def initialize(key, value)
+ @key = key;
+ @value = value;
+ end
+end
\ No newline at end of file
end
def does_change_exist?
- if not @change_log.empty? and not @change_log[@version].nil? then
+ if not @change_log[@version].nil? then
return true
end
return false
case `uname -s`.strip
when "Linux"
+ arch = `getconf LONG_BIT`.strip
+ arch = "unknown" if arch.length != 2
if File.exist? "/etc/debian_version" then
- arch = (`uname -i`.strip == "x86_64") ? "64" : "32"
os = "ubuntu-#{arch}"
elsif File.exist? "/etc/redhat-release" then
- os = "redhat-unknown"
+ os = "redhat-#{arch}"
elsif File.exist? "/etc/SuSE-release" then
- arch = (`uname -i`.strip == "x86_64") ? "64" : "32"
os = "opensuse-#{arch}"
elsif File.exist? "/etc/mandrake-release" then
- os = "mandrake-unknown"
+ os = "mandrake-#{arch}"
+ else
+ os = "unknownlinux-#{arch}"
end
when "MINGW32_NT-5.1"
progfile_path = Utils.execute_shell_return("echo $PROGRAMFILES","windows")[0].strip
return os
end
+ def Utils.set_default_linux_host_os()
+ HOST_OS.sub!(/.*-/,"ubuntu-")
+ end
def Utils.check_host_OS()
if Utils.get_all_OSs().include? HOST_OS then
def Utils.get_all_OSs()
- return ["ubuntu-32","ubuntu-64","windows-32","windows-64","macos-64","opensuse-32", "opensuse-64"]
+ return ["ubuntu-32","ubuntu-64","windows-32","windows-64","macos-64"]
end
end
- def Utils.create_process(command,redirStdout="", redirStderr="")
-
- if redirStdout.length > 0
- tmpfile = File.new(redirStdout,"w")
- save_stdout = $stdout.clone
- $stdout.reopen(tmpfile)
- end
-
- if redirStderr.length > 0
- tmpfile = File.new(redirStderr,"w")
- save_stderr = $stderr.clone
- $stderr.reopen(tmpfile)
- end
+ def Utils.create_process(command)
params = [
'L', # IN LPCSTR lpApplicationName
createProcess.call(0, command, 0, 0, 0, NORMAL_PRIORITY_CLASS, 0, 0, startupInfo, processInfo)
- if redirStdout.length > 0
- $stdout.reopen(save_stdout)
- end
-
- save_stdout.close if save_stdout
-
- if redirStderr.length > 0
- $stderr.reopen(save_stderr)
- end
-
- save_stderr.close if save_stderr
-
($0 == __FILE__ ) ? processInfo : processInfo.unpack("LLLL")[2]
end
# check if the os is unix-like
def Utils.is_unix_like_os(os_name)
- if os_name.start_with? "ubuntu-" or
- os_name.start_with? "opensuse-" or
+ if Utils.is_linux_like_os os_name or
os_name.start_with?"macos-" then
return true
else
# check if the os is linux-like
def Utils.is_linux_like_os(os_name)
if os_name.start_with? "ubuntu-" or
- os_name.start_with? "opensuse-" then
+ os_name.start_with? "redhat-" or
+ os_name.start_with? "opensuse-" or
+ os_name.start_with? "mandrake-" or
+ os_name.start_with? "unknownlinux-" then
return true
else
return false
def Utils.get_os_category(os_name)
- if os_name.start_with? "ubuntu-" or os_name.start_with? "opensuse-" then
+ if is_linux_like_os os_name then
return "linux"
- elsif os_name.start_with?"macos-" then
+ elsif is_macos_like_os os_name then
return "macos"
- elsif os_name.start_with? "windows-" then
+ elsif is_windows_like_os os_name then
return "windows"
else
return os_name
def Utils.checksum(file_path)
if File.exist? file_path then
- return Utils.execute_shell_return("shasum -a 256 \"#{file_path}\"")[0].split(" ")[0]
+ return execute_shell_return("shasum -a 256 \"#{file_path}\"")[0].split(" ")[0]
else
return nil
end
end
+ def Utils.validatePkgFile(filepath, orig_checksum, orig_size)
+ checksum = checksum(filepath)
+ size = File.size filepath
+ if checksum.eql? orig_checksum and size.to_s.eql? orig_size then
+ return true
+ else
+ return false
+ end
+ end
+
def Utils.get_version()
version_file = "#{File.dirname(__FILE__)}/../../VERSION"
Find.find(path) do |dep_path|
if (File.exist?(dep_path) and not File.directory? dep_path)
fsize = File.size(dep_path)
- ctime = File.new(dep_path).ctime
- mtime = File.new(dep_path).mtime
+ ctime = File.ctime(dep_path)
+ mtime = File.mtime(dep_path)
list.push [dep_path,fsize,ctime,mtime]
end
end
Dir.chdir WORKING_DIR
end
-
end
--- /dev/null
+require "SnapshotController"
+require "PackageServerConstants"
+require "fileutils"
+
+$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common"
+require "FileUtil"
+
+class ChangeLogController
+ def initialize(serverURL, ssController)
+ @serverUrl = serverURL
+ @ssController = ssController
+ end
+
+ ##Get
+ public
+ def getLatestChangeLog()
+ recentSnapshotName = @ssController.getLatestSnapshot().getName();
+ return getChangeLog(recentSnapshotName)
+ end
+
+ public
+ def getChangeLog(snapshotName)
+ logPath = downloadChangeLog(snapshotName)
+
+ if (logPath.nil?() || !File.exist?(logPath)) then
+ return;
+ end
+
+
+ return loadChangeLog(logPath);
+ end
+
+ public
+ def getTotalChangeLog(startSnapshotName, endSnapshotName)
+ if (endSnapshotName.nil?())
+ return;
+ elsif (endSnapshotName.nil?())
+ return getChangeLog(startSnapshot);
+ else
+ changeLog = String.new
+
+ totalSnapshotList = @ssController.getTotalSnapshotName(startSnapshotName,endSnapshotName)
+ totalSnapshotList.each() do |snapshotName|
+ changeLog = changeLog + getChangeLog(snapshotName) + "\n"
+ end
+
+ return changeLog
+ end
+ end
+
+ private
+ def downloadChangeLog(snapshotName)
+ changeLogURLPath = getChangeLogURLPath(snapshotName)
+
+ localPath = getChangeLogPath()
+
+ FileUtils.mkdir_p(localPath)
+
+ logger = DummyLog.new()
+
+ if (FileDownLoader.download(changeLogURLPath,localPath,logger)) then
+ return File.join(localPath, getChangeLogFile(snapshotName))
+ else
+ return nil
+ end
+ end
+
+ private
+ def getChangeLogPath()
+ flatServerName = FileUtil.getFlatURL(@serverUrl)
+ return File.join(PackageServerConfig::CONFIG_PATH, flatServerName, PackageServerConstants::CHANGE_LOG_DIRECTORY_NAME)
+ end
+
+ private
+ def getChangeLogURLPath(snapshotName)
+ changeLogURLPath = File.join(@serverUrl, PackageServerConstants::CHANGE_LOG_DIRECTORY_NAME, getChangeLogFile(snapshotName));
+
+ return changeLogURLPath
+ end
+
+ private
+ def getChangeLogFile(snapshotName)
+ if (snapshotName.nil?() || snapshotName.empty?())
+ return ""
+ end
+ return snapshotName + PackageServerConstants::CHANGE_LOG_FILE_EXTENSION
+ end
+
+ private
+ def loadChangeLog(logPath)
+ changeLog = String.new
+
+ file = File.open(logPath,"r")
+ file.each_line do |line|
+ changeLog = changeLog + line
+ end
+
+ return changeLog
+ end
+end
\ No newline at end of file
--- /dev/null
+class PackageServerConstants
+ #changelog information
+ CHANGE_LOG_DIRECTORY_NAME = "changes"
+ CHANGE_LOG_FILE_EXTENSION = ".log"
+
+ #distribution information
+ DISTRIBUTION_INFO_FILE_NAME = "distribution.info"
+
+ #snapshot information
+ SNAPSHOT_INFO_FILE_NAME = "snapshot.info"
+ SNAPSHOT_NAME_FIELD = "name"
+ SNAPSHOT_TIME_FIELD = "time"
+ SNAPSHOT_TYPE_FIELD = "type"
+ SNAPSHOT_PATH_FIELD = "path"
+ SNAPSHOT_MANUAL_TYPE_VALUE = "manual"
+end
\ No newline at end of file
--- /dev/null
+$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common"
+require "PropertyParser"
+require "PackageServerConstants"
+require 'model/snapshot'
+
+class SnapshotController
+ attr_accessor :snapshotList
+ def initialize(snapshotFilePath)
+ @snapshotList = Array.new
+
+ if (File.directory? snapshotFilePath) then
+ snapshotFilePath = File.join(snapshotFilePath, PackageServerConstants::SNAPSHOT_INFO_FILE_NAME)
+ end
+
+ loadSnapshot(snapshotFilePath)
+ end
+
+ public
+ def getAllSnapshotList
+ return @snapshotList
+ end
+
+ public
+ def getManualSnapshotList
+ manualSnapshotList = Array.new
+
+ @snapshotList.each() do |snapshot|
+ if (snapshot.getType().eql?(PackageServerConstants::SNAPSHOT_MANUAL_TYPE_VALUE)) then
+ manualSnapshotList.push(snapshot[name])
+ end
+ end
+
+ return manualSnapshotList
+ end
+
+ public
+ def getLatestSnapshot
+ return @snapshotList.pop()
+ end
+
+ public
+ def getTotalSnapshotName(startSnapshotName, endSnapshotName)
+ totalSnapshotList = Array.new
+
+ @snapshotList.each() do |snapshot|
+ snapshotName = snapshot.getName()
+ if (snapshotName.eql?(startSnapshotName) || snapshotName.eql?(endSnapshotName)) then
+ if (totalSnapshotList.empty?) then
+ totalSnapshotList.push(snapshotName)
+ else
+ break
+ end
+ end
+
+ if (not totalSnapshotList.empty?) then
+ totalSnapshotList.push(snapshotName)
+ end
+ end
+
+ return totalSnapshotList
+ end
+
+ private
+ def loadSnapshot(snapshotPath)
+ if not File.exist?(snapshotPath) then
+ return;
+ end
+
+ parser = PropertyParser.new(nil)
+ propertySection = parser.parseFile(snapshotPath);
+
+ propertySection.each() do |properties|
+ snapshot = Snapshot.new(properties)
+ @snapshotList.push(snapshot);
+ end
+
+ end
+end
\ No newline at end of file
require "FileTransferViaFTP"
require "FileTransferViaDirect"
require 'digest'
+require "SnapshotController"
+require "ChangeLogController"
+require 'PackageServerConstants'
+
$update_mutex = Mutex.new
ARCHIVE_PKG_LIST_FILE = "archive_pkg_list"
attr_accessor :server_addr, :location, :pkg_hash_os, :is_server_remote, :installed_pkg_hash_loc, :archive_pkg_list, :all_dep_list, :log, :support_os_list, :config_dist_path, :download_path, :tmp_path, :snapshot_path, :snapshots_path, :snapshot_url
+ private_class_method :new
public
# initialize
if not server_addr.nil? then
# chop server address, if end with "/"
if server_addr.strip.end_with? "/" then server_addr = server_addr.chop end
+ server_addr.strip!
if is_snapshot_url(server_addr) then
@snapshot_url = true
if not File.exist? @snapshots_path then FileUtils.mkdir_p "#{@snapshots_path}" end
if not File.exist? @tmp_path then FileUtils.mkdir_p "#{@tmp_path}" end
end
+ end
+
+ @configs = {}
+ #default cache size = 8G
+ @configs[:CACHE_SIZE] = "8000"
+ end
+
+
+ public
+ def self.create(server_addr, location, logger, access_svr = true)
+ new_client = new(server_addr, location, logger, access_svr )
+ if new_client.init(access_svr) then
+ return new_client
+ else
+ return nil
+ end
+ end
+
+ public
+ def init(access_svr)
+ if access_svr then
# read remote pkg list, and hash list
@log.info "Update remote package list and supported os list.."
if update() then
- @log.info "Initialize - #{server_addr}, #{location}"
+ @log.info "Initialize - #{@server_addr}, #{@location}"
else
- @log.error "Failed to update remote package list."
+ @log.error "Failed to update remote package list."
+ return false
end
end
@log.info "Update local package list.. [#{@location}]"
read_installed_pkg_list()
- @configs = {}
- #default cache size = 4G
- @configs[:CACHE_SIZE] = "4000"
+ return true
end
if not remove_list.empty? then
@log.info "Removed oldest package files.. (Now not fully caching)"
@log.info " * #{remove_list.map{|path| File.basename(path)}.join(", ")}"
- $cache_mutex.synchronize do
- FileUtils.rm_rf remove_list
- end
+ FileUtils.rm_rf remove_list
end
end
private
def get_config_max_cache_size
- return (@configs[:CACHE_SIZE] =~ /^([0-9][0-9]*)$/i)? ($1.to_i * 1024 * 1024) : (4 * 1024 * 1024 * 1024) #default size 4G : unit = MB
+ return (@configs[:CACHE_SIZE] =~ /^([0-9][0-9]*)$/i)? ($1.to_i * 1024 * 1024) : (8 * 1024 * 1024 * 1024) #default size 4G : unit = MB
end
private
file_path = get_file_from_cache(filename, pkg_checksum, pkg_size, loc)
if file_path.nil? then
- if not FileDownLoader.download(url, loc, @log) then
+ file_path = File.join(loc, filename)
+
+ result = FileDownLoader.download(url, loc, @log)
+ if not result or not File.exist? file_path then
@log.error "File Download Failed!!"
@log.error "* #{url} -> #{loc}"
return nil
end
- file_path = File.join(loc, filename)
- if validatePkgFile(file_path, pkg_checksum, pkg_size) then
+ if Utils.validatePkgFile(file_path, pkg_checksum, pkg_size) then
add_file_to_cache(file_path)
else
@log.error "File Validation Failed!!"
- return nil
- end
+ @log.info "Valiate : file path : #{file_path}, shasum : #{pkg_checksum}, size : #{pkg_size}", Log::LV_USER
+ return nil
+ end
else
@log.info "Cached #{pkg_name} package file.. OK"
end
return file_local_path
end
- private
- def validatePkgFile(filepath, orig_checksum, orig_size)
- checksum = Digest::SHA256.file(filepath).hexdigest
- size = File.size filepath
- if checksum.to_s.eql? orig_checksum and size.to_s.eql? orig_size then
- return true
- else
- return false
- end
- end
+ public
+ # make sdk image
+ def make_img(os)
+ # get package list
+ all_pkg_list = @pkg_hash_os[os].values
+
+ # select meta and install-type packages
+ img_pkg_list = []
+ all_pkg_list.each { |pkg|
+ attr = get_attr_from_pkg(pkg.package_name, os, "attribute")
+ if attr.nil? or attr.empty? then next end
+ if attr[0].strip.upcase.eql? "ROOT" or attr[0].strip.upcase.eql? "INSTALL" then
+ dependent_pkg_list = get_install_dependent_packages(pkg.package_name, os, true, true)
+ img_pkg_list = img_pkg_list + dependent_pkg_list
+ end
+ }
+ img_pkg_list.uniq!
+
+ # init workspace
+ workspace = @location+"/temp_for_tizen_sdk_imgs_#{os}"
+ if File.directory? workspace then FileUtils.remove_dir(workspace, true) end
+
+ # download packages
+ img_pkg_list.each do |pkg| download(pkg, os, false, "#{workspace}/binary") end
+
+ # write pkg_list_os file
+ FileUtils.cp("#{get_pkglist_path}/pkg_list_#{os}", "#{workspace}")
+
+ # write os_info file
+ File.open("#{workspace}/#{OS_INFO_FILE}", 'w') do |f| f.puts os end
+
+ # compress files
+ snapshot = snapshot_path.split('/')[-1]
+ img_name = "TIZNE-SDK-IMG_#{snapshot}_#{os}.zip"
+ cmd = "cd #{workspace}; zip -q -r #{@location}/TIZNE-SDK-IMG_#{snapshot_path.split('/')[-1]}_#{os}.zip *;"
+ Utils.execute_shell_with_log(cmd, @log.path)
+
+ # clean workspace
+ FileUtils.remove_dir(workspace, true)
+ @log.info "<< SDK-Image Info. >>"
+ @log.info " - server addr : #{@server_addr}"
+ @log.info " - snapshot : #{snapshot}"
+ @log.info " - os : #{os}"
+ @log.info " - location : #{location}/"
+ @log.info " - name : #{img_name}"
+
+ return
+ end
private
def get_file_from_cache(filename, pkg_checksum, pkg_size, location)
+ if not File.directory? location then return nil end
downloaded_file_path = nil
- $cache_mutex.synchronize do
+ @log.info "Wait for cache sync",Log::LV_USER
+ begin
+ lock = Utils.file_lock(File.join(CONFIG_PATH,".cache_lock"))
+ @log.info "Entering cache sync",Log::LV_USER
cached_filepath = get_cached_filepath(filename, pkg_checksum, pkg_size)
- if not cached_filepath.nil? then
- FileUtils.cp(cached_filepath, location)
+ if not cached_filepath.nil? and File.exist? cached_filepath then
+ FileUtils.ln(cached_filepath, location, :force => true)
downloaded_file_path = File.join(location, File.basename(cached_filepath))
end
+ ensure
+ Utils.file_unlock(lock) if not lock.nil?
end
+ @log.info "Cache sync done",Log::LV_USER
if not downloaded_file_path.nil? and not File.exist? downloaded_file_path then
downloaded_file_path = nil
end
private
def add_file_to_cache(filepath)
- if filepath.nil? or filepath.empty? then return end
- if not File.exist? @download_path then FileUtils.mkdir_p "#{download_path}" end
+ if filepath.nil? or filepath.empty? or not File.exist? filepath then return end
+ if not File.exist? @download_path then FileUtils.mkdir_p "#{@download_path}" end
filename = File.basename(filepath)
cachefile = File.join(@download_path, filename)
@log.info " [path: #{@download_path}]"
if not File.exist? cachefile then
- FileUtils.cp(filepath, @download_path)
+ FileUtils.ln(filepath, @download_path, :force => true)
end
if not File.exist? cachefile then
@log.info "Failed to move [#{filename}] to "
- @log.info " [#{download_path}]"
+ @log.info " [#{@download_path}]"
+ end
+
+ begin
+ lock = Utils.file_lock(File.join(CONFIG_PATH,".cache_lock"))
+
+ remove_old_files_in_cache
+ ensure
+ Utils.file_unlock(lock) if not lock.nil?
end
- remove_old_files_in_cache
end
private
def get_cached_filepath(pkg_filename, pkg_checksum, pkg_size)
cached_filepath = "#{@download_path}/#{pkg_filename}"
if File.exist? cached_filepath then
- if validatePkgFile(cached_filepath, pkg_checksum, pkg_size) then
+ if Utils.validatePkgFile(cached_filepath, pkg_checksum, pkg_size) then
FileUtils.touch cached_filepath
return cached_filepath
else
# install package
#download
- tmp_location = File.join(@tmp_path,Utils.create_uniq_name)
- filepath = download(pkg_name, os, false, tmp_location)
- if filepath.nil? or filepath[0].nil? then
- return false
- end
+ tmp_location = nil
+ begin
+ tmp_location = File.join(@tmp_path,Utils.create_uniq_name)
+ filepath = download(pkg_name, os, false, tmp_location)
+ if filepath.nil? or filepath[0].nil? then
+ return false
+ end
- #install
- ret = FileInstaller.install(pkg_name, filepath[0], type, @location, @log)
+ #install
+ ret = FileInstaller.install(pkg_name, filepath[0], type, @location, @log)
+ ensure
+ #remove garbage
+ FileUtils.rm_rf tmp_location if not tmp_location.nil? and File.exist? tmp_location
+ end
- #remove garbage
- FileUtils.rm_rf tmp_location
return ret
end
file_url = File.join(@server_addr, ssinfo_file)
if from_server then
if not FileDownLoader.download(file_url, @config_dist_path, @log) then
- @log.warn "Server does not have \"#{ssinfo_file}\" file. This error can be ignored."
+ @log.error "Server does not have \"#{ssinfo_file}\" file."
+ return nil
end
else
- if File.exist? file_url then FileUtils.cp(file_url, @config_dist_path)
- else @log.warn "Server does not have \"#{ssinfo_file}\" file. This error can be ignored." end
+ if File.exist? file_url then
+ FileUtils.cp(file_url, @config_dist_path)
+ else
+ @log.error "Server does not have \"#{ssinfo_file}\" file."
+ return nil
+ end
end
file_path = File.join(@config_dist_path, ssinfo_file)
if addr.nil? then addr = @server_addr end
addr_arr = addr.split('/')
if addr_arr[-2].eql? "snapshots" then
- return addr_arr[0..-3].join("/"), addr_arr[-2..-1].join("/")
+ return addr_arr[0..-3].join("/"), "/"+addr_arr[-2..-1].join("/")
else
return nil
end
attr = get_attr_from_pkg(pkg_name, os, "attribute")
if attr.nil? or attr.empty? then return false end
- if attr[0].strip.upcase.eql? "META" then return true
+ if attr[0].strip.upcase.eql? "ROOT" then return true
else return false end
end
if ret then @log.info "Snapshot is generated : #{ret}" end
end
+
+ ##Print change log to console.
+ public
+ def printChangeLog(snapshot1 = nil, snapshot2 = nil)
+ snapshotPath = File.join(@config_dist_path, PackageServerConstants::SNAPSHOT_INFO_FILE_NAME)
+ @log.info("Read information of snapshot from " + snapshotPath);
+
+ ssController = SnapshotController.new(snapshotPath);
+ changeLogController = ChangeLogController.new(@server_addr, ssController)
+
+ if (snapshot1.nil?()) then
+ changeLog = changeLogController.getLatestChangeLog();
+ elsif snapshot2.nil?() then
+ changeLog = changeLogController.getChangeLog(snapshot1);
+ else
+ changeLog = changeLogController.getTotalChangeLog(snapshot1, snapshot2);
+ end
+
+ puts changeLog
+ end
+
+ ##Print snapshot list to console.
+ public
+ def printSnapshotList(showAll=false)
+ snapshotPath = File.join(@config_dist_path, PackageServerConstants::SNAPSHOT_INFO_FILE_NAME)
+ @log.info("Read information of snapshot from " + snapshotPath);
+
+ ssController = SnapshotController.new(snapshotPath);
+ if showAll then
+ result = ssController.getAllSnapshotList;
+ else
+ result = ssController.getManualSnapshotList ;
+ end
+
+ result.each() do |snapshot|
+ puts PackageServerConstants::SNAPSHOT_NAME_FIELD + ": " + snapshot.getName()
+ puts PackageServerConstants::SNAPSHOT_TIME_FIELD + ": " + snapshot.getTime()
+ puts
+ end
+
+ end
end
if options[:t].nil? then options[:t] = false end
if options[:f].nil? then options[:f] = false end
if options[:v].nil? then options[:v] = false end
+ if options[:all].nil? then options[:all] = false end
end
def option_error_check( options )
options[:url].nil? or options[:url].empty? then
raise ArgumentError, "Usage: pkg-cli download -P <package name> -u <package server url> [-o <os>] [-l <location>] [--trace]"
end
-
+ when "make-img" then
+ if options[:url].nil? or options[:url].empty? then
+ raise ArgumentError, "Usage: pkg-cli make-img -u <package server url> [-o <os>]"
+ end
when "install" then
if options[:pkg].nil? or options[:pkg].empty? or
options[:url].nil? or options[:url].empty? then
options[:dist].nil? or options[:dist].empty? then
raise ArgumentError, "Usage: pkg-cli register -P <package file path> -a <server address> -d <distribution name> -w <password>"
end
+ when "snapshotlist"
+ if options[:url].nil? or options[:url].empty? then
+ raise ArgumentError, "Usage: pkg-cli install-dep -P <package name> -u <package server url> [-o <os>]"
+ end
+ when "changelog"
else
raise ArgumentError, "Input is incorrect : #{options[:cmd]}"
+ "\n" + "Subcommands:" + "\n" \
+ "\t" + "clean Delete the package in your SDK environment." + "\n" \
+ "\t" + "download Download the package in your SDK environment." + "\n" \
+ + "\t" + "make-img Make SDK-Image." + "\n" \
+ "\t" + "install Download the package from package-server and install the package in your SDK environment." + "\n" \
+ "\t" + "install-file Install the package in your SDK environment." + "\n" \
+ "\t" + "uninstall Uninstall the package in your SDK environment." + "\n" \
+ "\t" + "list-rpkg Show the all packages in the package-server." + "\n" \
+ "\t" + "show-lpkg Show the package in your SDK environment." + "\n" \
+ "\t" + "list-lpkg Show the all packages in your SDK environment." + "\n" \
+ + "\t" + "snapshotlist Show the snapshot list in your SDK environment." + "\n" \
+ + "\t" + "changelog Show the change log in your SDK environment." + "\n" \
+ "\t" + "build-dep Show build-dependency packages" + "\n" \
+ "\t" + "install-dep Show install-dependency packages" + "\n" \
+ "\n" + "Subcommand usage:" + "\n" \
+ "\t" + "pkg-cli clean [-l <location>] [--force]" + "\n" \
+ "\t" + "pkg-cli download -P <package name> -u <package server url> [-o <os>] [-l <location>] [--trace]" + "\n" \
+ + "\t" + "pkg-cli make-img -u <package server url> [-o <os>]" + "\n" \
+ "\t" + "pkg-cli install -P <package name> -u <package server url> [-o <os>] [-l <location>] [--trace] [--force]" + "\n" \
+ "\t" + "pkg-cli install-file -P <package file> [-l <location>] [-u <package server url>] [--trace] [--force]" + "\n" \
+ "\t" + "pkg-cli uninstall -P <package name> [-l <location>] [--trace]" + "\n" \
+ "\t" + "pkg-cli list-rpkg -u <package server url> [-o <os>]" + "\n" \
+ "\t" + "pkg-cli show-lpkg -P <package name> [-l <location>]" + "\n" \
+ "\t" + "pkg-cli list-lpkg [-l <location>]" + "\n" \
+ + "\t" + "pkg-cli snapshotlist -u <package server url> [--all]" + "\n" \
+ + "\t" + "pkg-cli changelog -u <package server url> [-snapshot <snapshot name,snapshot name>]" + "\n" \
+ "\t" + "pkg-cli build-dep -P <package name> -u <package server url> [-o <os>]" + "\n" \
+ "\t" + "pkg-cli install-dep -P <package name> -u <package server url> [-o <os>]" + "\n" \
+ "\t" + "pkg-cli register -P <package file path> -a <server address> -d <distribution name> -w <password>" + "\n" \
optparse = OptionParser.new(nil, 32, ' '*8) do|opts|
# Set a banner, displayed at the top
# of the help screen.
+
opts.banner = banner
puts "DIBS(Distributed Intelligent Build System) version " + Utils.get_version()
exit
end
+
+ opts.on('--all', 'show all information') do
+ options[:all] = true
+ end
+
+ opts.on('-s', '--snapshot snapshotName1,snapshotName2', Array, 'snapshot name') do |snapshotName|
+ puts snapshotName[0], snapshotName[1]
+ options[:snapshot] = snapshotName
+ end
end
cmd = ARGV[0]
- if cmd.eql? "download" or
+ if cmd.eql? "download" or cmd.eql? "make-img" or
cmd.eql? "install" or cmd.eql? "show-rpkg" or
cmd.eql? "list-rpkg" or
cmd.eql? "uninstall" or cmd.eql? "show-lpkg" or
cmd.eql? "upgrade" or cmd.eql? "check-upgrade" or
cmd.eql? "build-dep" or cmd.eql? "install-dep" or
cmd.eql? "register" or
+ cmd.eql?("changelog") or
+ cmd.eql?("snapshotlist") or
cmd =~ /(-v)|(--version)/ or
cmd =~ /(help)|(-h)|(--help)/ then
else
server_url = "#{@server_url}/snapshots/#{snapshot}"
end
- client = Client.new( server_url, "#{@location}/binary", @log )
+ client = Client.create( server_url, "#{@location}/binary", @log )
+ if client.nil? then
+ raise RuntimeError, "Cannot create package client."
+ end
# parents package server check
if client.pkg_hash_os.keys.empty? then
end
def sync_archive_pkg
- client = Client.new( @server_url, "#{@location}/source", @log )
+ client = Client.create( @server_url, "#{@location}/source", @log )
+ if client.nil? then
+ raise RuntimeError, "Cannot create package client."
+ end
download_list = client.archive_pkg_list - @archive_pkg_list
logger.info "Downloading #{url}"
if is_remote then
if logger.path.nil? or logger.path.empty? then
- ret = system "wget #{url} -O #{fullpath} -nv --tries=3"
+ ret = system "wget #{url} -O #{fullpath} -nv --tries=3 --connect-timeout=10"
else
- pid,status = Utils.execute_shell_with_log( "wget #{url} -O #{fullpath} -nv --tries=3", logger.path )
+ pid,status = Utils.execute_shell_with_log( "wget #{url} -O #{fullpath} -nv --tries=3 --connect-timeout=10", logger.path )
if not status.nil? then
ret = (status.exitstatus != 0) ? false : true
end
if ret then
logger.info "Downloaded #{filename}.. OK"
else
- logger.info "Failed to download #{filename}"
- logger.info " [dist: #{path}]"
+ logger.error "Failed to download #{filename}"
+ logger.error " [dist: #{path}]"
end
return ret
end
--- /dev/null
+
+class Distribution
+ attr_accessor :name, :time
+
+ def initialize(name, time)
+ @name = name
+ @time = time
+ end
+end
\ No newline at end of file
--- /dev/null
+
+
+class Snapshot
+ attr_accessor :properties
+
+ def initialize(properties)
+ @properties = properties;
+ end
+
+ private
+ def getValue(key)
+ properties.each() do |property|
+ if property.key().eql?(key) then
+ return property.value()
+ end
+ end
+
+ return nil;
+ end
+
+ public
+ def getName
+ return getValue(PackageServerConstants::SNAPSHOT_NAME_FIELD)
+ end
+
+ public
+ def getTime
+ return getValue(PackageServerConstants::SNAPSHOT_TIME_FIELD)
+ end
+
+ public
+ def getType
+ return getValue(PackageServerConstants::SNAPSHOT_TYPE_FIELD)
+ end
+
+ public
+ def getPath
+ return getValue(PackageServerConstants::SNAPSHOT_PATH_FIELD)
+ end
+end
\ No newline at end of file
$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common"
$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/build_server"
require "BuildComm"
-require "packageServerLog"
require "packageServerConfig"
require "distribution"
require "SocketRegisterListener"
require "client"
require "utils"
+require "FileUtil"
require "mail"
require "DistSync"
+require "log"
class PackageServer
attr_accessor :id, :location, :log, :integrity
if not File.exist?( SERVER_ROOT )
FileUtils.mkdir_p( SERVER_ROOT )
end
- @log = PackageServerLog.new( @log_file_path )
+ @log = StandardOutLog.new( @log_file_path )
server_information_initialize()
end
f.puts "integrity check : #{@integrity}"
f.puts "auto sync : #{@auto_sync_flag}"
f.puts "sync interval : #{@sync_interval}"
+ f.puts "server port : #{@port}"
f.puts "server_url : #{dist_name} -> #{server_url}"
end
Utils.file_unlock(lock_file)
@log.output( "package server [#{@id}] created successfully", Log::LV_USER )
+ @log.output( " - server location : #{@location}", Log::LV_USER )
+ @log.output( " - server configure file : #{@config_file_path}", Log::LV_USER )
+ @log.output( " - default server port : #{@port}", Log::LV_USER )
end
def register( file_path_list, dist_name, snapshot, test_flag, internal_flag = false )
# move file to package server
binary_pkg_file_path_list.each do |l|
if test_flag then
- FileUtils.copy_file( l, "#{distribution.location}/temp/#{File.basename(l)}" )
+ FileUtils.ln( l, "#{distribution.location}/temp/#{File.basename(l)}", :force => true )
else
- FileUtils.copy_file( l, "#{distribution.location}/binary/#{File.basename(l)}" )
+ FileUtils.ln( l, "#{distribution.location}/binary/#{File.basename(l)}", :force => true )
end
end
# if snapshot mode is true then generate snapshot
if snapshot or test_flag then
@log.info "generaging snapshot"
- snapshot_name = distribution.generate_snapshot("", "", false, "Changed package: \n" + registed_package_list.map{|x|"- #{x.package_name}"}.join("\n") + "\n\n" + get_changelog_string(registed_package_list) )
+ snapshot_name = distribution.generate_snapshot("", "", false, "Changed packages: \n" + registed_package_list.map{|x|"- #{x.package_name}"}.uniq.sort.join("\n") + "\n\n" + get_changelog_string(registed_package_list) )
end
Utils.file_unlock(@lock_file)
# start server daemon
def start( port, passwd )
@log.info "Package server Start..."
- # set port number. default port is 3333
- @port = port
-
- # write package server port
- File.open(@run_file_path, "w") do |f|
- f.puts @port
+ # if user input exsist, set port number.
+ if (port != "") then
+ # update server port information
+ # config file
+ original_string = "server port : #{@port}"
+ replacement_string = "server port : #{port}"
+ contents = File.read(@config_file_path).gsub("#{original_string}", "#{replacement_string}")
+ File.open(@config_file_path, "w") { |f| f.puts contents }
+
+ # global variable
+ @port = port
+ end
+
+ # write package server port for server lock
+ File.open(@run_file_path, "w") { |f| f.puts @port }
+
+ #lock the package server. Do not run the same server at the same time
+ if (not lockServer()) then
+ printErrorMessage("Server \"#{id}\" is already running.")
+ return
end
-
+
+ #check that the port is open
+ if BuildCommServer.port_open? port then
+ printErrorMessage("Port \"#{port}\" is already in use.")
+ return
+ end
+
# set job request listener
@log.info "Setting listener..."
listener = SocketRegisterListener.new(self)
end
def self.list_id
- @@log = PackageServerLog.new("#{SERVER_ROOT}/.log")
+ @@log = StandardOutLog.new("#{SERVER_ROOT}/.log")
d = Dir.new( SERVER_ROOT )
s = d.select {|f| not f.start_with?(".") }
end
def self.list_dist( id )
- @@log = PackageServerLog.new( "#{SERVER_ROOT}/.log" )
+ @@log = StandardOutLog.new( "#{SERVER_ROOT}/.log" )
@@log.output( "=== ID [#{id}]'s distribution list ===", Log::LV_USER)
@auto_sync_flag = l.split(" :")[1].strip.upcase
elsif l.start_with?( "sync interval :" ) then
@sync_interval = l.split(" :")[1].strip.to_i
+ elsif l.start_with?( "server port :" ) then
+ @port = l.split(" :")[1].strip.to_i
elsif l.start_with?( "server_url :" ) then
info = l.split(" :")[1].split("->")
@dist_to_server_url[info[0].strip] = info[1].strip
@incoming_path = "#{@config_dir}/incoming"
@server_lock_file_path = "#{@config_dir}/.server_lock"
end
+
+ #If the 'run' file is already locked, Package server is already running.
+ #in this case return false
+ private
+ def lockServer
+ return FileUtil.exclusiveLock(@run_file_path)
+ end
+
+ private
+ def printErrorMessage(errMsg)
+ @log.info "Server creation failed"
+ @log.error errMsg
+
+ puts "Server creation failed"
+ puts errMsg
+ end
end
require "utils"
class PackageServerConfig
+
CONFIG_ROOT = "#{Utils::HOME}/.build_tools"
+ CONFIG_PATH = "#{PackageServerConfig::CONFIG_ROOT}/client"
+
end
+++ /dev/null
-=begin
-
- packageServerLog.rb
-
-Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-
-Contact:
-Taejun Ha <taejun.ha@samsung.com>
-Jiil Hyoun <jiil.hyoun@samsung.com>
-Donghyuk Yang <donghyuk.yang@samsung.com>
-DongHee Yang <donghee.yang@samsung.com>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Contributors:
-- S-Core Co., Ltd
-=end
-
-$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__)) + "/common"
-require "log"
-require "logger"
-
-class PackageServerLog < Log
-
- def initialize(path)
- super(path)
- @second_out = $stdout
- end
-
- protected
- def output_extra(msg)
- @second_out.puts msg
- end
-
-
-end
options[:pkgs] = []
options[:snaps] = []
options[:bsnap] = ""
- options[:port] = "3333"
+ options[:port] = ""
options[:gensnap] = true
options[:force] = false
options[:test] = false
raise ArgumentError, "Usage: pkg-svr gen-snapshot -n <server name> -d <distribution> -s <snapshot name> [-b <base snapshot name>]"
end
when "start"
- if options[:port].empty? then
- raise ArgumentError, "Usage: pkg-svr start -n <server name> -p <port> [-w <password>]"
- end
when "stop"
when "sync"
when "list"
+ "\t" + "pkg-svr sync -n <server name> -d <distribution> -s <snapshot_name> [--force] " + "\n" \
+ "\t" + "pkg-svr clean -n <server name> -d <distribution> [-s <snapshot list>] " + "\n" \
+ "\t" + "pkg-svr start -n <server name> -p <port> [-w <password>]" + "\n" \
- + "\t" + "pkg-svr stop -n <server name> " + "\n" \
+ + "\t" + "pkg-svr stop -n <server name> [-w <password>]" + "\n" \
+ "\t" + "pkg-svr list [-n <server name>] " + "\n" \
+ "\n" + "Options:" + "\n"
query-system Query system information about build-server.
query-project Query project information about build-server.
query-job Query job information about build-server.
+query-log Query log contents about job in build-server.
cancel Cancel a building project.
register Register the package to the build-server.
Subcommand usage:
-build-cli build -N <project name> -d <server address> [-o <os>] [-w <password>] [--async] [-D <distribution name>] [-U user-email] [-V]
+build-cli build -N <project name> -d <server address> -U <user-id> -w <user-password> [-o <os>] [--async] [-D <distribution name>] [--save]
build-cli query -d <server address>
build-cli query-system -d <server address>
build-cli query-project -d <server address>
build-cli query-job -d <server address>
-build-cli cancel -j <job number> -d <server address> [-w <password>]
-build-cli register -P <package file> -d <server address> [-t <ftp server url>] [-w <password>] [-D <distribution name>] [-U user-email]
+build-cli query-log -d <server address> -j <job number> [--output <output file path>]
+build-cli cancel -j <job number> -d <server address> -U user-id -w <user-password>
+build-cli register -P <package file> -d <server address> -U user-id -w <user-password> [-t <ftp server url>] [-D <distribution name>]
Options:
-N, --project <project name> project name
-d, --address <server address> build server address: 127.0.0.1:2224
-o, --os <operating system> target operating system: ubuntu-32/ubuntu-64/windows-32/windows-64/macos-64
--async asynchronous job
+--save save the files built from remote server
-j, --job <job number> job number
--w, --passwd <password> password for managing project
+-w, --passwd <user-password> user password
-P, --pkg <package file> package file path
-D, --dist <distribution name> distribution name
-t, --ftp <ftp server url> ftp server url: ftp://dibsftp:dibsftp@127.0.0.1
--U, --user <user email> user email infomation
--V, --verbose verbose mode
+-U, --user <user email> user email
+--output <output_path> output file path
-h, --help display help
-v, --version display version
#PRE-EXEC
#EXEC
-../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32
+../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32 -u admin@user -w 1234
#POST-EXEC
#EXPECT
Info: Added new job
#PRE-EXEC
#EXEC
-../../build-cli build -N non_exist_project -d 127.0.0.1:2223 -o ubuntu-32
+../../build-cli build -N non_exist_project -d 127.0.0.1:2223 -o ubuntu-32 -U admin@user -w 1234
#POST-EXEC
#EXPECT
-Error: Project not found!: non_exist_project on BASE
+Error: Project not found!: non_exist_project on unstable
#PRE-EXEC
#EXEC
-../../build-cli build -N testa -d 127.0.0.1:11113 -o ubuntu-32
+../../build-cli build -N testa -d 127.0.0.1:11113 -o ubuntu-32 -U admin@user -w 1234
#POST-EXEC
#EXPECT
-Connection to server failed!
+Error: Connection failed!: 127.0.0.1:11113
#PRE-EXEC
#EXEC
-../../build-cli build -N testa -d 111.11q.111.111:1111 -o ubuntu-32
+../../build-cli build -N testa -d 111.11q.111.111:1111 -o ubuntu-32 -U admin@user -w 1234
#POST-EXEC
#EXPECT
-Connection to server failed!
+Error: Connection failed!: 111.11q.111.111:1111
#PRE-EXEC
echo "testa project is already built and uploaded in previeous testcase"
#EXEC
-../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32
+../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32 -U admin@user -w 1234
#POST-EXEC
#EXPECT
Info: Added new job
Info: Initializing job...
Info: Checking package version ...
-Error: Version must be increased :
+Error: Version must be increased!: 0.0.1 <= 0.0.1
Error: Job is stopped by ERROR
+Error: Building job on remote server failed!
#PRE-EXEC
echo "Assume testa project is already built and uploaded in previeous testcase"
#EXEC
-../../build-cli build -N testb -d 127.0.0.1:2223 -o ubuntu-32
+../../build-cli build -N testb -d 127.0.0.1:2223 -o ubuntu-32 -U admin@user -w 1234
#POST-EXEC
#EXPECT
Info: Added new job
Info: Downloding client is initializing...
Info: Installing dependent packages...
Info: * a
+Info: Wait for cache sync
+Info: Entering cache sync
+Info: Cache sync done
Info: Downloading dependent source packages...
Info: Make clean...
Info: Make build...
../../pkg-svr remove-pkg -n pkgsvr01 -d unstable -P b
../../pkg-svr remove-pkg -n pkgsvr01 -d unstable -P a
#EXEC
-../../build-cli build -N testb -d 127.0.0.1:2223 -o ubuntu-32
+../../build-cli build -N testb -d 127.0.0.1:2223 -o ubuntu-32 -U admin@user -w 1234
#POST-EXEC
#EXPECT
Info: Added new job
Info: New Job
Info: Checking build dependency ...
Info: Checking install dependency ...
-Error: Unmet dependency found!
-Error: * a(ubuntu-32) for build-dependency
+Error: Error: Unmet dependency found!: a(ubuntu-32)
Error: Job is stopped by ERROR
+Error: Building job on remote server failed!
echo "This is the test case for omitting os"
../../pkg-svr remove-pkg -n pkgsvr01 -d unstable -P a
#EXEC
-../../build-cli build -N testa -d 127.0.0.1:2223
+../../build-cli build -N testa -d 127.0.0.1:2223 -U admin@user -w 1234
#POST-EXEC
#EXPECT
Info: Added new job
#PRE-EXEC
echo "if there doe not exist server to build, error"
#EXEC
-../../build-cli build -N testa -d 127.0.0.1:2223 -o windows-32
+../../build-cli build -N testa -d 127.0.0.1:2223 -o windows-32 -U admin@user -w 1234
#POST-EXEC
#EXPECT
Info: Added new job
Info: Initializing job...
-Error: No servers that are able to build your packages.
-Error: Host-OS (windows-32) is not supported in build server.
+Error: No servers supports the "Host-OS"!: windows-32
Error: Job is stopped by ERROR
+Error: Building job on remote server failed!
echo "wrong os name in build command"
../../pkg-svr remove-pkg -n pkgsvr01 -d unstable -P a
#EXEC
-../../build-cli build -N testa -d 127.0.0.1:2223 -o wrong_os_name
+../../build-cli build -N testa -d 127.0.0.1:2223 -o wrong_os_name -U admin@user -w 1234
#POST-EXEC
#EXPECT
-Error: Unsupported OS name used!: wrong_os_name
-Supported OS list.
-* ubuntu-32
-* windows-32
+Error: Unsupported OS name used!: wrong_os_name... Use a name in (ubuntu-32|windows-32)
#PRE-EXEC
echo "wrong os name in resolve command"
#EXEC
-../../build-cli resolve -N testa -d 127.0.0.1:2223 -o wrong_os_name
+../../build-cli resolve -N testa -d 127.0.0.1:2223 -o wrong_os_name -U admin@user -w 1234
#POST-EXEC
#EXPECT
Error: Unsupported OS name used!: wrong_os_name
echo "Assume that testa,testb which are depended by testc are built and uploaded"
echo "For, work around solution, removed cache"
rm -rf buildsvr01/projects/testa/cache
-../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32
-../../build-cli build -N testb -d 127.0.0.1:2223 -o ubuntu-32
+../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32 -U admin@user -w 1234
+../../build-cli build -N testb -d 127.0.0.1:2223 -o ubuntu-32 -U admin@user -w 1234
#EXEC
-../../build-cli build -N testc -d 127.0.0.1:2223 -w 1111 -o ubuntu-32
+../../build-cli build -N testc -d 127.0.0.1:2223 -w 1111 -o ubuntu-32 -U admin@user -w 1234
#POST-EXEC
#EXPECT
Info: Added new job
Info: Downloding client is initializing...
Info: Installing dependent packages...
Info: * a
+Info: Wait for cache sync
+Info: Entering cache sync
+Info: Cache sync done
Info: * b
+Info: Wait for cache sync
+Info: Entering cache sync
+Info: Cache sync done
Info: Downloading dependent source packages...
Info: Make clean...
Info: Make build...
echo "Assume that testc project has the password (1111)"
echo "Assume that testa,testb which are depended by testc are built and uploaded"
#EXEC
-../../build-cli build -N testc -d 127.0.0.1:2223 -o ubuntu-32
+../../build-cli build -N testc -d 127.0.0.1:2223 -o ubuntu-32 -U admin@user
#POST-EXEC
#EXPECT
-Error: Project password required!: Use -w option to input your project password
+Usage: build-cli build -N <project name> -d <server address> -U <user-id> -w <user-password> [-o <os>] [--async] [-D <distribution name>] [--save]
echo "Assume that testc project has the password (1111)"
echo "Assume that testa,testb which are depended by testc are built and uploaded"
#EXEC
-../../build-cli build -N testc -d 127.0.0.1:2223 -w 2222 -o ubuntu-32
+../../build-cli build -N testc -d 127.0.0.1:2223 -w 2222 -o ubuntu-32 -U admin@user -w 1111
#POST-EXEC
#EXPECT
-Error: Project password not matched!
+Error: User password not matched!: Email : admin@user && Password : 1111
#PRE-EXEC
../pkg-svr remove-pkg -n pkgsvr01 -d unstable -P c
#EXEC
-../../build-cli build -N testc -d 127.0.0.1:2223 -w 1111 --async -o ubuntu-32
+../../build-cli build -N testc -d 127.0.0.1:2223 -w 1111 --async -o ubuntu-32 -U admin@user -w 1234
#POST-EXEC
#EXPECT
Info: Added new job
../../pkg-svr remove-pkg -n pkgsvr01 -d unstable -P b
../../pkg-svr remove-pkg -n pkgsvr01 -d unstable -P a
#EXEC
-../../build-cli build -N testa -d 127.0.0.1:2223 --async -o ubuntu-32
+../../build-cli build -N testa -d 127.0.0.1:2223 --async -o ubuntu-32 -U admin@user -w 1234
sleep 1
-../../build-cli build -N testb -d 127.0.0.1:2223 -o ubuntu-32
+../../build-cli build -N testb -d 127.0.0.1:2223 -o ubuntu-32 -U admin@user -w 1234
#POST-EXEC
#EXPECT
Info: Added new job
Info: Downloding client is initializing...
Info: Installing dependent packages...
Info: * a
+Info: Wait for cache sync
+Info: Entering cache sync
+Info: Cache sync done
Info: Downloading dependent source packages...
Info: Make clean...
Info: Make build...
#EXEC
rm -rf git01/a
cd git01;tar xf a_v2.tar.gz
-../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32
+../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32 -U admin@user -w 1234
#POST-EXEC
#EXPECT
Info: Added new job
Info: Zipping...
Info: Creating package file ... a_0.0.2_ubuntu-32.zip
Info: Checking reverse build dependency ...
-Info: * Will check reverse-build for projects: testb(ubuntu-32)
-Info: * Added new job for reverse-build ... testb(ubuntu-32)
-Info: * Reverse-build FAIL ... testb(ubuntu-32)
+Info: * Will check reverse-build for projects:
+Info: * Added new job for reverse-build ... testb
+Info: * Reverse-build FAIL ... testb
+Error: Error: Reverse-build-check failed!
Error: Job is stopped by ERROR
+Error: Building job on remote server failed!
rm -rf git01/c
cd git01;tar xf c_v1_1.tar.gz
#EXEC
-../../build-cli build -N testc -d 127.0.0.1:2223 -o ubuntu-32 -w 1111
+../../build-cli build -N testc -d 127.0.0.1:2223 -o ubuntu-32 -w 1111 -U admin@user -w 1234
#POST-EXEC
#EXPECT
Info: Added new job
Info: Initializing job...
Info: Checking package version ...
-Error: Source code has been changed without increasing version!
-Error: * Version :
-Error: * Before :
-Error: * Current :
+Error: Source code has been changed without increasing version!: 0.0.1
Error: Job is stopped by ERROR
+Error: Building job on remote server failed!
cd git01;tar xf b_v2.tar.gz
cd git01;tar xf c_v2.tar.gz
#EXEC
-../../build-cli build -N testa,testb,testc -d 127.0.0.1:2223 -o ubuntu-32 -w 1111
+../../build-cli build -N testa,testb,testc -d 127.0.0.1:2223 -o ubuntu-32 -U admin@user -w 1234
#POST-EXEC
#EXPECT
Info: Added new job
Info: Initializing job...
+Info: Initializing sub-job
+Info: Initializing sub-job
+Info: Initializing sub-job
Info: Invoking a thread for MULTI-BUILD Job
Info: New Job
Info: Added new job "testa" for ubuntu-32!
#PRE-EXEC
echo "This test case must be execute right after testcase 22"
#EXEC
-../../build-cli build -N testa,testb,testc -d 127.0.0.1:2223 -o ubuntu-32 -w 1111
+../../build-cli build -N testa,testb,testc -d 127.0.0.1:2223 -o ubuntu-32 -U admin@user -w 1234
#POST-EXEC
#EXPECT
Info: Added new job
Info: Initializing job...
-Info: Failed to initialize sub-job
-Info: Failed to initialize sub-job
-Info: Failed to initialize sub-job
+Info: Initializing sub-job
+Error: Failed to initialize sub-job "testa" for
+Error: * Version must be increased!:
+Info: Initializing sub-job
+Error: Failed to initialize sub-job "testb" for
+Error: * Version must be increased!:
+Info: Initializing sub-job
+Error: Failed to initialize sub-job "testc" for
+Error: * Version must be increased!:
+Error: Initializing sub jobs failed!
Error: Job is stopped by ERROR
+Error: Building job on remote server failed!
#PRE-EXEC
cd git01;tar xf a_v3.tar.gz
#EXEC
-../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32,windows-32
+../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32,windows-32 -U admin@user -w 1234
#POST-EXEC
#EXPECT
Info: Added new job
Info: Initializing job...
+Info: Initializing sub-job
+Info: Initializing sub-job
Info: Invoking a thread for MULTI-BUILD Job
Info: New Job
Info: Added new job "testa" for ubuntu-32!
cd git01;tar xf b_v4.tar.gz
cd git01;tar xf c_v4.tar.gz
#EXEC
-../../build-svr fullbuild -n testserver3
+../../build-cli build -N testa,testb,testc,testa1,testd -o all --rebuild -d 127.0.0.1:2223 -U admin@user -w 1234
#POST-EXEC
#EXPECT
+Info: Added new job
Info: Initializing job...
+Info: Initializing sub-job
+Info: Initializing sub-job
+Info: Initializing sub-job
+Info: Initializing sub-job
+Info: Initializing sub-job
+Info: Initializing sub-job
+Info: Initializing sub-job
+Info: Initializing sub-job
+Info: Initializing sub-job
Info: Invoking a thread for MULTI-BUILD Job
Info: New Job
Info: Added new job
#PRE-EXEC
cd git01;tar xf c_v5.tar.gz
#EXEC
-../../build-cli build -N testc -d 127.0.0.1:2223 -o li_* -w 1111
+../../build-cli build -N testc -d 127.0.0.1:2223 -o li_* -U admin@user -w 1234
#POST-EXEC
#EXPECT
Error: Unsupported OS name used!: There is no OS name matched.
#PRE-EXEC
echo "wild card"
#EXEC
-../../build-cli build -N testc -d 127.0.0.1:2223 -o ubuntu-* -w 1111
+../../build-cli build -N testc -d 127.0.0.1:2223 -o ubuntu-* -U admin@user -w 1234
#POST-EXEC
#EXPECT
Info: Added new job
Info: Downloding client is initializing...
Info: Installing dependent packages...
Info: * a
+Info: Wait for cache sync
+Info: Entering cache sync
+Info: Cache sync done
Info: * b
+Info: Wait for cache sync
+Info: Entering cache sync
+Info: Cache sync done
Info: Downloading dependent source packages...
Info: Make clean...
Info: Make build...
#EXEC
rm -rf git01/a
cd git01;tar xf a_v5.tar.gz
-../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32
+../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32 -U admin@user -w 1234
#POST-EXEC
#EXPECT
Info: Added new job
#PRE-EXEC
echo "user check"
#EXEC
-../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32 -U xxuser@user
+../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32 -U xxuser@user -w 1234
#POST-EXEC
#EXPECT
Error: User account not found!: xxuser@user
--- /dev/null
+#PRE-EXEC
+echo "query-log"
+#EXEC
+../../build-cli query-log -d 127.0.0.1:2223 -j 1 | grep {2} | cut -d '}' -f2
+#POST-EXEC
+#EXPECT
+Added new job
+Initializing job...
+Checking package version ...
+Invoking a thread for building Job
+New Job
+hecking build dependency ...
+Checking install dependency ...
+Started to build this job...
+JobBuilder
+ownloding client is initializing...
+Installing dependent packages...
+Downloading dependent source packages...
+Make clean...
+Make build...
+Make install...
+eneratiing pkginfo.manifest...
+Zipping...
+Creating package file ... a_0.0.1_ubuntu-32.zip
+Checking reverse build dependency ...
+Uploading ...
+Upload succeeded. Sync local pkg-server again...
+Snapshot:
+Job is completed!
+Job is FINISHED successfully!
+Updating the source info for project "testa"
--- /dev/null
+#PRE-EXEC
+echo "query-log"
+rm -rf a.txt
+#EXEC
+../../build-cli query-log -d 127.0.0.1:2223 -j 1 --output a.txt
+#POST-EXEC
+rm -rf a.txt
+#EXPECT
+Started query log, writing to the file "a.txt"
+End query log, check file "a.txt"
--- /dev/null
+#PRE-EXEC
+echo "This case will test --save option"
+#EXEC
+../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32 --save --rebuild -U admin@user -w 1234
+#POST-EXEC
+#EXPECT
+Info: Added new job
+Info: Initializing job...
+Info: Checking package version ...
+Info: Invoking a thread for building Job
+Info: New Job
+Info: Checking build dependency ...
+Info: Checking install dependency ...
+Info: Started to build this job...
+Info: JobBuilder
+Info: Downloding client is initializing...
+Info: Installing dependent packages...
+Info: Downloading dependent source packages...
+Info: Make clean...
+Info: Make build...
+Info: Make install...
+Info: Generatiing pkginfo.manifest...
+Info: Zipping...
+Info: Creating package file ...
+Info: Checking reverse build dependency ...
+Info: * Will check reverse-build for projects: testb(ubuntu-32), testc(ubuntu-32)
+Info: * Added new job for reverse-build ... testb(ubuntu-32)
+Info: * Added new job for reverse-build ... testc(ubuntu-32)
+Info: * Reverse-build OK ...
+Info: * Reverse-build OK ...
+Info: Copying result files to
+Info: *
+Info: Job is completed!
+Info: Job is FINISHED successfully!
+Info: Updating the source info for project "testa"
+Info: Receiving file from remote server :
--- /dev/null
+#PRE-EXEC
+echo "This case will test --save option for MULTI build job"
+#EXEC
+../../build-cli build -N testa,testb -d 127.0.0.1:2223 -o ubuntu-32 --save --rebuild -U admin@user -w 1234
+#POST-EXEC
+#EXPECT
+Info: Added new job
+Info: Initializing job...
+Info: Initializing sub-job
+Info: Initializing sub-job
+Info: Invoking a thread for MULTI-BUILD Job
+Info: New Job
+Info: Added new job "testa" for ubuntu-32!
+Info: Added new job "testb" for ubuntu-32!
+Info: * Sub-Job
+Info: * Sub-Job
+Info: * Sub-Job
+Info: * Sub-Job
+Info: Copying result files to
+Info: *
+Info: *
+Info: Job is completed!
+Info: Receiving file from remote server :
+Info: Receiving file from remote server :
--- /dev/null
+#PRE-EXEC
+echo "This case will test --noreverse option"
+#EXEC
+../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32 --rebuild --noreverse -U admin@user -w 1234
+#POST-EXEC
+#EXPECT
+Info: Added new job
+Info: Initializing job...
+Info: Checking package version ...
+Info: Invoking a thread for building Job
+Info: New Job
+Info: Checking build dependency ...
+Info: Checking install dependency ...
+Info: Started to build this job...
+Info: JobBuilder
+Info: Downloding client is initializing...
+Info: Installing dependent packages...
+Info: Downloading dependent source packages...
+Info: Make clean...
+Info: Make build...
+Info: Make install...
+Info: Generatiing pkginfo.manifest...
+Info: Zipping...
+Info: Creating package file ...
+Info: Uploading ...
+Info: Upload succeeded. Sync local pkg-server again...
+Info: Snapshot:
+Info: Job is completed!
+Info: Job is FINISHED successfully!
+Info: Updating the source info for project "testa"
--- /dev/null
+#PRE-EXEC
+echo "This case will check redundent job"
+../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32 --rebuild -U admin@user -w 1234 &
+#EXEC
+sleep 2
+../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32 --rebuild -U admin@user -w 1234
+#POST-EXEC
+#EXPECT
+Info: Added new job
+Info: Initializing job...
+Info: Checking package version ...
+Error: There already exists same job.
+Error: Building job on remote server failed!
--- /dev/null
+#PRE-EXEC
+echo "error case when wrong git repository setted"
+../../build-svr add-prj -n testserver3 -N testaErr -g `pwd`/git01/aErr -b master
+#EXEC
+../../build-cli build -N testaErr -d 127.0.0.1:2223 -o ubuntu-32 -U admin@user -w 1234
+#POST-EXEC
+#EXPECT
+Info: Added new job
+Info: Initializing job...
+Error: Git clone failed!!: git clone
+Error: Job is stopped by ERROR
+Error: Building job on remote server failed!
--- /dev/null
+#PRE-EXEC
+echo "error case when wrong git branch setted"
+../../build-svr add-prj -n testserver3 -N testbErr -g `pwd`/git01/b -b testError
+#EXEC
+../../build-cli build -N testbErr -d 127.0.0.1:2223 -o ubuntu-32 -U admin@user -w 1234
+#POST-EXEC
+#EXPECT
+Info: Added new job
+Info: Initializing job...
+Error: Git checkout failed!!: git checkout
+Error: Job is stopped by ERROR
+Error: Building job on remote server failed!
${RUBY} ../../../build-svr migrate -n testserver3 --dsn Mysql:testserver3:localhost --dbuser root --dbpassword $DB_PASSWD
rm -f a
cd ..
-${RUBY} ../../build-svr add-dist -n testserver3 -D BASE -u `pwd`/pkgsvr01/unstable -d 127.0.0.1:3333 -w score
+${RUBY} ../../build-svr add-dist -n testserver3 -D unstable -u `pwd`/pkgsvr01/unstable -d 127.0.0.1:3333 -w score
${RUBY} ../../build-svr add-svr -n testserver3 -d 127.0.0.1:2224
${RUBY} ../../build-svr add-os -n testserver3 -o ubuntu-32
${RUBY} ../../build-svr add-os -n testserver3 -o windows-32
${RUBY} ../../build-svr add-prj -n testserver3 -N testa -g `pwd`/git01/a -b master
${RUBY} ../../build-svr add-prj -n testserver3 -N testb -g `pwd`/git01/b -b master
-${RUBY} ../../build-svr add-prj -n testserver3 -N testc -g `pwd`/git01/c -b master -w 1111
+${RUBY} ../../build-svr add-prj -n testserver3 -N testc -g `pwd`/git01/c -b master
${RUBY} ../../build-svr add-prj -n testserver3 -N testd -g `pwd`/git01/d -b master -o ubuntu-32
${RUBY} ../../build-svr add-prj -n testserver3 -N teste -P bin
${RUBY} ../../build-svr add-prj -n testserver3 -N testa1 -g `pwd`/git01/a1 -b master
build-cli-28.testcase
build-cli-29.testcase
build-cli-30.testcase
+build-cli-31.testcase
+build-cli-32.testcase
+build-cli-33.testcase
+build-cli-34.testcase
+build-cli-35.testcase
+build-cli-36.testcase
+build-cli-37.testcase
+build-cli-38.testcase
add-prj Add project to build.
remove-prj Remove project.
register Register the package to the build-server.
-fullbuild Build all your projects and upload them to package server.
query Show build server configuration.
set-attr Set build server atribute.
get-attr Get build server atribute.
build-svr create -n <server name> [-t <ftp server url>]
build-svr remove -n <server name>
build-svr migrate -n <server name> [--dsn <db dsn> [--dbuser <db_user> --dbpassword <db_password>] ]
-build-svr start -n <server name> -p <port>
+build-svr start -n <server name> [-p <port>]
build-svr stop -n <server name>
build-svr upgrade -n <server name>
build-svr add-svr -n <server name> -d <friend server address>
build-svr remove-sync -n <server name> -u <remote pkg server url> [--dist <distribution>]
build-svr add-prj -n <server name> -N <project name> (-g <git repository> -b <git branch>|-P <package name>) [-w <password>] [-o <os list>] [--dist <distribution>]
build-svr remove-prj -n <server name> -N <project name> [--dist <distribution>]
-build-svr fullbuild -n <server name> [--dist <distribution>]
build-svr register -n <server name> -P <package file> [--dist <distribution>]
build-svr query -n <server name>
build-svr set-attr -n <server name> -A <attribute> -V <value>
rm -rf buildsvr01
mkdir buildsvr01
cd buildsvr01; ../../../build-svr create -n testserver3 -t ftp://dibsftp:coreps2@172.21.111.132
+cd buildsvr01; ../../../build-svr migrate -n testserver3 --dsn SQLite3:`pwd`/server.db
cd buildsvr01; ../../../build-svr add-dist -n testserver3 -D BASE -u `pwd`/../pkgsvr01/unstable -d 127.0.0.1:3333
#EXEC
../../build-svr add-svr -n testserver3 -d 127.0.0.1:2223
mkdir buildsvr01
rm -rf ~/.build_tools/build_server/testserver3
cd buildsvr01; ../../../build-svr create -n testserver3 -t ftp://dibsftp:coreps2@172.21.111.132
+cd buildsvr01; ../../../build-svr migrate -n testserver3 --dsn SQLite3:`pwd`/server.db
cd buildsvr01; ../../../build-svr add-dist -n testserver3 -D BASE -u `pwd`/../pkgsvr01/unstable -d 127.0.0.1:3333
../../build-svr start -n testserver3 -p 2223 &
#EXEC
#PRE-EXEC
mkdir buildsvr01
cd buildsvr01; ../../../build-svr create -n testserver3 -u `pwd`/../pkgsvr01/unstable -d 127.0.0.1:3333 -t ftp://dibsftp:coreps2@172.21.111.132
+cd buildsvr01; ../../../build-svr migrate -n testserver3 --dsn SQLite3:`pwd`/server.db
#EXEC
../../build-svr stop -n testserver3
#POST-EXEC
../../build-svr remove -n testserver3
rm -rf buildsvr01
#EXPECT
-generating
Server is not running!
rm -rf buildsvr01
mkdir buildsvr01
cd buildsvr01; ../../../build-svr create -n testserver3 -t ftp://dibsftp:coreps2@172.21.111.132
+cd buildsvr01; ../../../build-svr migrate -n testserver3 --dsn SQLite3:`pwd`/server.db
cd buildsvr01; ../../../build-svr add-dist -n testserver3 -D BASE -u `pwd`/../pkgsvr01/unstable -d 127.0.0.1:3333
../../build-svr add-os -n testserver3 -o ubuntu-32
#EXEC
rm -rf buildsvr01
mkdir buildsvr01
cd buildsvr01; ../../../build-svr create -n testserver3 -t ftp://dibsftp:coreps2@172.21.111.132
+cd buildsvr01; ../../../build-svr migrate -n testserver3 --dsn SQLite3:`pwd`/server.db
cd buildsvr01; ../../../build-svr add-dist -n testserver3 -D BASE -u `pwd`/../pkgsvr01/unstable -d 127.0.0.1:3333
#EXEC
../../build-svr add-prj -n testserver3 -N testa -g test_git -b test_branch -w 1111
rm -rf ~/.build_tools/build_server/testserver3
mkdir buildsvr01
cd buildsvr01; ../../../build-svr create -n testserver3 -t ftp://ftpuser:ftpuser@127.0.0.1
+cd buildsvr01; ../../../build-svr migrate -n testserver3 --dsn SQLite3:`pwd`/server.db
cd buildsvr01; ../../../build-svr add-dist -n testserver3 -D BASE -u `pwd`/../pkgsvr01/unstable -d 127.0.0.1:3333
../../build-svr add-os -n testserver3 -o ubuntu-32
#EXEC
rm -rf buildsvr01
mkdir buildsvr01
cd buildsvr01; ../../../build-svr create -n testserver3 -t ftp://dibsftp:coreps2@172.21.111.132
+cd buildsvr01; ../../../build-svr migrate -n testserver3 --dsn SQLite3:`pwd`/server.db
cd buildsvr01; ../../../build-svr add-dist -n testserver3 -D BASE -u `pwd`/../pkgsvr01/unstable -d 127.0.0.1:3333
#EXEC
../../build-svr add-os -n testserver3 -o ubuntu-32
rm -rf buildsvr01
mkdir buildsvr01
cd buildsvr01; ../../../build-svr create -n testserver3 -u `pwd`/../pkgsvr01/unstable -d 127.0.0.1:3333 -t ftp://dibsftp:coreps2@172.21.111.132
+cd buildsvr01; ../../../build-svr migrate -n testserver3 --dsn SQLite3:`pwd`/server.db
#EXEC
../../build-svr add-os -n testserver3 -o ubuntu-32
../../build-svr add-os -n testserver3 -o ubuntu-32
../../build-svr remove -n testserver3
rm -rf buildsvr01
#EXPECT
-generating
Target OS is added successfully!
Target OS already exists in list!
rm -rf buildsvr01
mkdir buildsvr01
cd buildsvr01; ../../../build-svr create -n testserver3 -u `pwd`/../pkgsvr01/unstable -d 127.0.0.1:3333 -t ftp://dibsftp:coreps2@172.21.111.132
+cd buildsvr01; ../../../build-svr migrate -n testserver3 --dsn SQLite3:`pwd`/server.db
../../build-svr add-os -n testserver3 -o ubuntu-32
../../build-svr add-os -n testserver3 -o windows-32
#EXEC
rm -rf buildsvr01
mkdir buildsvr01
cd buildsvr01; ../../../build-svr create -n testserver3 -t ftp://ftpuser:ftpuser@172.21.111.124
+cd buildsvr01; ../../../build-svr migrate -n testserver3 --dsn SQLite3:`pwd`/server.db
cd buildsvr01; ../../../build-svr add-dist -n testserver3 -D BASE -u `pwd`/../pkgsvr01/unstable -d 127.0.0.1:3333
../../build-svr add-os -n testserver3 -o ubuntu-32
+../../build-svr add-prj -n testserver3 -N bin -P bin -o ubuntu-32
mkdir -p bin
cp ../bin/bin_0.0.0_ubuntu-32.zip bin/bin_0.0.0_wrongosname.zip
../../build-svr start -n testserver3 -p 2223 &
rm -rf buildsvr01
rm -rf bin/bin/bin_0.0.0_wrongosname.zip
#EXPECT
+Info: Added new job
Info: Initializing job...
-Error: Unsupported OS "wrongosname" is used!
+Error: Unsupported OS used in package file name!: wrongosname
Error: Job is stopped by ERROR
rm -rf buildsvr01
mkdir buildsvr01
cd buildsvr01; ../../../build-svr create -n testserver3 -u `pwd`/../pkgsvr01/unstable -d 127.0.0.1:3333 -t ftp://ftpuser:ftpuser@172.21.111.124
-cd buildsvr01; ../../../build-svr migrate -n testserver3
+cd buildsvr01; ../../../build-svr migrate -n testserver3 --dsn SQLite3:`pwd`/server.db
#EXEC
../../build-svr set-attr -n testserver3 -A MAX_WORKING_JOBS -V 3
../../build-svr get-attr -n testserver3 -A MAX_WORKING_JOBS
--- /dev/null
+#PRE-EXEC
+rm -rf buildsvr01
+mkdir buildsvr01
+cd buildsvr01; ../../../build-svr create -n testserver3 -u `pwd`/../pkgsvr01/unstable -d 127.0.0.1:3333 -t ftp://ftpuser:ftpuser@172.21.111.124
+#EXEC
+../../build-svr add-dist -n testserver3 -D BASE -u `pwd`/../pkgsvr01/unstable -d 127.0.0.1:3333
+../../build-svr remove-dist -n testserver3 -D BASE
+../../build-svr query -n testserver3
+../../build-svr add-svr -n testserver3 -d 127.0.0.1:2223
+../../build-svr remove-svr -n testserver3 -d 127.0.0.1:2223
+../../build-svr add-os -n testserver3 -o ubuntu-32
+../../build-svr remove-os -n testserver3 -o ubuntu-32
+../../build-svr lock-dist -n testserver3 -D BASE
+../../build-svr unlock-dist -n testserver3 -D BASE
+../../build-svr add-sync -n testserver3 -u `pwd`/../pkgsvr01/unstable
+../../build-svr remove-sync -n testserver3 -u `pwd`/../pkgsvr01/unstable
+../../build-svr add-prj -n testserver3 -N testx -g test_git -b test_branch -o ubuntu-32
+../../build-svr remove-prj -n testserver3 -N testx
+../../build-svr register -n testserver3 -P bin/bin_0.0.0_ubuntu-32.zip
+../../build-svr set-attr -n testserver3 -A MAX_WORKING_JOBS -V 3
+../../build-svr get-attr -n testserver3 -A MAX_WORKING_JOBS
+#POST-EXEC
+../../build-svr remove -n testserver3
+rm -rf buildsvr01
+#EXPECT
+Error: No DB exists and create(migrate) DB first!
+Error: No DB exists and create(migrate) DB first!
+Error: No DB exists and create(migrate) DB first!
+Error: No DB exists and create(migrate) DB first!
+Error: No DB exists and create(migrate) DB first!
+Error: No DB exists and create(migrate) DB first!
+Error: No DB exists and create(migrate) DB first!
+Error: No DB exists and create(migrate) DB first!
+Error: No DB exists and create(migrate) DB first!
+Error: No DB exists and create(migrate) DB first!
+Error: No DB exists and create(migrate) DB first!
+Error: No DB exists and create(migrate) DB first!
+Error: No DB exists and create(migrate) DB first!
+Error: No DB exists and create(migrate) DB first!
+Error: No DB exists and create(migrate) DB first!
+Error: No DB exists and create(migrate) DB first!
--- /dev/null
+#PRE-EXEC
+rm -rf buildsvr01
+mkdir buildsvr01
+cd buildsvr01; ../../../build-svr create -n testserver3 -u `pwd`/../pkgsvr01/unstable -d 127.0.0.1:3333 -t ftp://ftpuser:ftpuser@172.21.111.124
+#EXEC
+../../build-svr set-attr -n testserver3 -A MAX_WORKING_JOBS -V 3
+../../build-svr get-attr -n testserver3 -A MAX_WORKING_JOBS
+#POST-EXEC
+../../build-svr remove -n testserver3
+rm -rf buildsvr01
+#EXPECT
+3
--- /dev/null
+#PRE-EXEC
+../../build-svr remove -n testserver3
+rm -rf buildsvr01
+mkdir buildsvr01
+cd buildsvr01; ../../../build-svr create -n testserver3 -u `pwd`/../pkgsvr01/unstable -d 127.0.0.1:3333 -t ftp://ftpuser:ftpuser@172.21.111.124
+#EXEC
+../../build-svr get-attr -n testserver3 -A MAX_JOBS
+../../build-svr set-attr -n testserver3 -A MAX_JOBS -V 3
+../../build-svr get-attr -n testserver3 -A MAX_JOBS
+#POST-EXEC
+../../build-svr remove -n testserver3
+rm -rf buildsvr01
+#EXPECT
+4
+3
build-svr-19.testcase
build-svr-20.testcase
build-svr-21.testcase
+build-svr-23.testcase
+build-svr-24.testcase
+build-svr-25.testcase
#PRE-EXEC
#EXEC
-../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32 -D unstable
+../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32 -D unstable -U admin@user -w 1234
#POST-EXEC
#EXPECT
Info: Added new job
Info: Sending build request to remote server...
Info: Added new job
Info: Initializing job...
-Info: Copying external dependent pkgs...
Info: Invoking a thread for building Job
Info: New Job
Info: Started to build this job...
Info: Generatiing pkginfo.manifest...
Info: Zipping...
Info: Creating package file ... a_0.0.1_ubuntu-32.zip
-Info: Copying log to
Info: Copying result files to
Info: *
Info: Job is completed!
Info: Job is FINISHED successfully!
-Info: Updating the source info for project "UNNAMED
-Info: Receiving log file from remote server...
+Info: Updating the source info for project "TRANSFERRED"
Info: Receiving file from remote server : a_0.0.1_ubuntu-32.zip
Info: Checking reverse build dependency ...
Info: Uploading ...
#PRE-EXEC
#EXEC
-../../build-cli build -N testb -d 127.0.0.1:2223 -o ubuntu-32 -D unstable
+../../build-cli build -N testb -d 127.0.0.1:2223 -o ubuntu-32 -D unstable -U admin@user -w 1234
#POST-EXEC
#EXPECT
Info: Added new job
Info: Sending build request to remote server...
Info: Added new job
Info: Initializing job...
-Info: Copying external dependent pkgs...
Info: Invoking a thread for building Job
Info: New Job
Info: Started to build this job...
Info: Downloding client is initializing...
Info: Installing dependent packages...
Info: * a
+Info: Wait for cache sync
+Info: Entering cache sync
+Info: Cache sync done
Info: Downloading dependent source packages...
Info: Make clean...
Info: Make build...
Info: Generatiing pkginfo.manifest...
Info: Zipping...
Info: Creating package file ... b_0.0.1_ubuntu-32.zip
-Info: Copying log to
Info: Copying result files to
Info: *
Info: Job is completed!
Info: Job is FINISHED successfully!
-Info: Updating the source info for project "UNNAMED
-Info: Receiving log file from remote server...
+Info: Updating the source info for project "TRANSFERRED"
Info: Receiving file from remote server : b_0.0.1_ubuntu-32.zip
Info: Checking reverse build dependency ...
Info: Uploading ...
--- /dev/null
+#PRE-EXEC
+#EXEC
+../../build-cli build -N testa,testb -d 127.0.0.1:2223 -o ubuntu-32 -D unstable --rebuild -U admin@user -w 1234
+#POST-EXEC
+#EXPECT
+Info: Added new job
+Info: Initializing job...
+Info: Initializing sub-job
+Info: Initializing sub-job
+Info: Invoking a thread for MULTI-BUILD Job
+Info: New Job
+Info: Added new job "testa" for ubuntu-32!
+Info: Added new job "testb" for ubuntu-32!
+Info: * Sub-Job "testa(ubuntu-32)" has entered "REMOTE_WORKING" state.
+Info: * Sub-Job "testa(ubuntu-32)" has entered "FINISHED" state.
+Info: * Sub-Job "testb(ubuntu-32)" has entered "REMOTE_WORKING" state.
+Info: * Sub-Job "testb(ubuntu-32)" has entered "FINISHED" state.
+Info: Uploading ...
+Info: Upload succeeded. Sync local pkg-server again...
+Info: Snapshot:
+Info: Job is completed!
RUBY="ruby -d"
fi
-if [ ! "$DB_PASSWD" ] ; then
- read -p "Insert DB password: " input
- export DB_PASSWD=$input
-else
- echo $DB_PASSWD
-fi
-
rm -rf buildsvr02
../../build-svr remove -n testserver4
mkdir buildsvr02
cd buildsvr02
${RUBY} ../../../build-svr create -n testserver4
-echo "DROP DATABASE testserver4;" > a
-mysql -u root -p --password=$DB_PASSWD -h localhost < a
-${RUBY} ../../../build-svr migrate -n testserver4 --dsn Mysql:testserver4:localhost --dbuser root --dbpassword $DB_PASSWD
-rm -f a
cd ..
-${RUBY} ../../build-svr add-dist -n testserver4 -D unstable -u `pwd`/pkgsvr01/unstable -d 127.0.0.1:3333
+#${RUBY} ../../build-svr add-dist -n testserver4 -D unstable -u `pwd`/pkgsvr01/unstable -d 127.0.0.1:3333
${RUBY} ../../build-svr start -n testserver4 -p 2224 --CHILD
01.testcase
02.testcase
+03.testcase
rm -rf ~/.build_tools/build_server/testserver3
mkdir buildsvr01
cd buildsvr01;../../../build-svr create -n testserver3 -t ftp://ftpuser:ftpuser@127.0.0.1
+cd buildsvr01; ../../../build-svr migrate -n testserver3 --dsn SQLite3:`pwd`/server.db
../../build-svr add-os -n testserver3 -o ubuntu-32
../../build-svr add-os -n testserver3 -o ubuntu-64
#EXEC
#PRE-EXEC
#EXEC
-../../build-svr register -n testserver3 -D unstable -P bin/bin_0.0.0_ubuntu-32.zip
+../../build-svr register -n testserver3 -D unstable -P bin/bin_0.0.0_ubuntu-32.zip
#POST-EXEC
#EXPECT
+Info: Added new job
Info: Initializing job...
Info: Checking package version ...
Info: Invoking a thread for REGISTER Job
Info: Upload succeeded. Sync local pkg-server again...
Info: Snapshot:
Info: Job is completed!
+Info: Job is FINISHED successfully!
#PRE-EXEC
#EXEC
-../../build-cli build -N testa -d 127.0.0.1:2223 -D unstable
-../../build-cli build -N testa -d 127.0.0.1:2223 -D unstable2
+../../build-cli build -N testa -d 127.0.0.1:2223 -D unstable -U admin@user -w 1234
+../../build-cli build -N testa -d 127.0.0.1:2223 -D unstable2 -U admin@user -w 1234
#POST-EXEC
#EXPECT
Info: Added new job
#PRE-EXEC
#EXEC
-../../build-cli register -d 127.0.0.1:2223 -P bin/bin_0.0.0_ubuntu-32.zip -D unstable2 #-t ftp://ftpuser:ftpuser@127.0.0.1
+../../build-cli register -d 127.0.0.1:2223 -P bin/bin_0.0.0_ubuntu-32.zip -D unstable2 -U admin@user -w 1234 #-t ftp://ftpuser:ftpuser@127.0.0.1
#POST-EXEC
#EXPECT
I, [
I, [
I, [
I, [
+I, [
Info: Added new job
Info: Initializing job...
Info: Checking package version ...
Info: Upload succeeded. Sync local pkg-server again...
Info: Snapshot:
Info: Job is completed!
+Info: Job is FINISHED successfully!
+Info: Updating the source info for project "testbin"
#PRE-EXEC
#EXEC
-../../build-svr fullbuild -n testserver3 -D unstable2
+../../build-cli build -d 127.0.0.1:2223 -N testa,testb -o all -D unstable2 --rebuild -U admin@user -w 1234
#POST-EXEC
#EXPECT
+Info: Added new job
Info: Initializing job...
+Info: Initializing sub-job
+Info: Initializing sub-job
Info: Invoking a thread for MULTI-BUILD Job
Info: New Job
Info: Added new job "testa" for ubuntu-32!
echo "=="
../../build-svr lock-dist -n testserver3 -D unstable2
echo "=="
-../../build-cli build -N testb -d 127.0.0.1:2223 -D unstable2
+../../build-cli build -N testb -d 127.0.0.1:2223 -D unstable2 -U admin@user -w 1234
echo "=="
../../build-svr unlock-dist -n testserver3 -D unstable2
echo "=="
-../../build-cli build -N testb -d 127.0.0.1:2223 -D unstable2
+../../build-cli build -N testb -d 127.0.0.1:2223 -D unstable2 -U admin@user -w 1234
#POST-EXEC
#EXPECT
==
Info: Downloding client is initializing...
Info: Installing dependent packages...
Info: * a
+Info: Wait for cache sync
+Info: Entering cache sync
+Info: Cache sync done
Info: Downloading dependent source packages...
Info: Make clean...
Info: Make build...
--- /dev/null
+#PRE-EXEC
+echo "Will check duplicated registration"
+../../build-svr register -n testserver3 -D unstable -P bin/bin_0.0.1_ubuntu-32.zip &
+#EXEC
+sleep 1
+../../build-svr register -n testserver3 -D unstable -P bin/bin_0.0.1_ubuntu-32.zip
+#POST-EXEC
+#EXPECT
+Info: Added new job
+Info: Initializing job...
+Info: Checking package version ...
+Error: There already exists same job.
build-svr3-03.testcase
build-svr3-04.testcase
build-svr3-05.testcase
+build-svr3-06.testcase
require File.dirname(__FILE__) + "/../src/pkg_server/client"
require File.dirname(__FILE__) + "/../src/pkg_server/serverConfig"
-### Client.new("server","dist","snapshot","location")
+### Client.create("server","dist","snapshot","location")
# local server
-#cl = Client.new("/home/yangttak/test-packageserver")
+#cl = Client.create("/home/yangttak/test-packageserver")
# remote server
-cl = Client.new("http://172.21.111.132/pkgserver/unstable", "/home/yangttak/build_root")
+cl = Client.create("http://172.21.111.132/pkgserver/unstable", "/home/yangttak/build_root")
#cl.update()
result = cl.get_install_dependent_packages("cross-arm-gcc-4.5", "linux", true)
puts "----"
#cl.install_local_pkg("/home/yangttak/test0208/sdk-build/smart-build-interface_0.20.0_linux.zip", "linux")
#cl.show_pkg_info("tizen-ide", "linux")
-#cl = Client.new("http://172.21.111.132/pkgserver/unstable/snapshot/snapshot3-linux", "/tmp/client-test")
+#cl = Client.create("http://172.21.111.132/pkgserver/unstable/snapshot/snapshot3-linux", "/tmp/client-test")
#cl.update()
#result = cl.get_install_dependent_packages("smart-build-interface", "linux")
#puts result
# if location is nil
-#cl = Client.new("http://172.21.111.132/pkgserver/unstable", nil)
+#cl = Client.create("http://172.21.111.132/pkgserver/unstable", nil)
# if server addr is nil
-#cl = Client.new(nil, "/tmp/client-test")
+#cl = Client.create(nil, "/tmp/client-test")
# install package list
#cl.download("base-toolchain", "windows")
# test install different veriosn package
-#cl = Client.new("http://172.21.111.132/pkgserver/unstable/snapshot/snapshot2-linux", "/tmp/client-test")
+#cl = Client.create("http://172.21.111.132/pkgserver/unstable/snapshot/snapshot2-linux", "/tmp/client-test")
#cl.install("tizen-ide", "linux")
#cl.install("smart-build-interface", "linux")
-#cl = Client.new("http://172.21.111.132/pkgserver/unstable", "/tmp/client-test")
+#cl = Client.create("http://172.21.111.132/pkgserver/unstable", "/tmp/client-test")
#result = cl.get_build_dependent_packages("mpfr", "linux")
#puts result
#result = cl.get_install_dependent_packages("arm-linux-gnueabi-gdb-7.2", "linux")
UPGRADE_CMD = "#{PREV_VER_PATH}/upgrade"
BUILD_CONFIG_ROOT = "#{Utils::HOME}/.build_tools/build_server/#{svr_name}"
- if not svr_dist.nil? then
+ if pkg_svr_url.nil? and not svr_dist.nil? then
build_server = BuildServerController.get_server(svr_name)
- dist = build_server.distmgr.get_distribution(svr_dist)
+ if build_server.has_db? then
+ dist = build_server.distmgr.get_distribution(svr_dist)
+ else
+ dist = nil
+ end
if dist.nil? then
log.error "Upgrade failed : No distribution name \"#{svr_dist}\" exist!", Log::LV_USER
cmd = Utils.generate_shell_command("#{dibs_path}/build-svr start -n #{svr_name} -p #{svr_port}")
Utils.spawn(cmd)
exit 1
end
+ pkg_svr_url = dist.pkgsvr_url
end
if not File.exist? BACKUP_ROOT then FileUtils.mkdir_p(BACKUP_ROOT) end
# Run Upgrade
if start_opt and svr_type.eql? "BUILDSERVER" then
cmd = "#{UPGRADE_CMD} -I -l #{dibs_path} -S -t #{svr_type} -n #{svr_name} -p #{svr_port}"
+ else
+ cmd = "#{UPGRADE_CMD} -I -l #{dibs_path}"
+ end
- if not (pkg_svr_url.nil? or pkg_svr_url.empty?) then
- cmd += " -u #{pkg_svr_url}"
- end
-
- if not (svr_dist.nil? or svr_dist.empty?) then
- cmd += " -D #{svr_dist}"
- end
-
+ if not (pkg_svr_url.nil? or pkg_svr_url.empty?) then
+ cmd += " -u #{pkg_svr_url}"
else
- cmd = "#{UPGRADE_CMD} -I -l #{dibs_path} -u #{pkg_svr_url}"
+ log.error "Upgrade failed : No package server URL!", Log::LV_USER
+ exit 1
end
cmd = Utils.generate_shell_command(cmd)
else
# Get SERVER INFORMATION
- if start_opt and svr_type.eql? "BUILDSERVER" then
- # only when acesss build server controller
- build_server = BuildServerController.get_server(svr_name)
- if pkg_svr_url.nil? or pkg_svr_url.empty? then
- if svr_dist.nil? or svr_dist.empty? then
- pkg_svr_url = build_server.distmgr.get_default_pkgsvr_url()
- else
- dist = build_server.distmgr.get_distribution(svr_dist)
- if not dist.nil? then
- pkg_svr_url = dist.pkgsvr_url
- else
- log.error "Upgrade failed : No distribution name \"#{svr_dist}\" exist!", Log::LV_USER
- exit 1
- end
- end
- end
+ if svr_type.eql? "BUILDSERVER" then
log.info("Build server : [#{svr_name}][#{svr_port}]", Log::LV_USER)
end
log.info("Package Server : [#{pkg_svr_url}]", Log::LV_USER)
log.info("DIBS Path : [#{dibs_path}]", Log::LV_USER)
# Download DIBS Package
- client = Client.new( pkg_svr_url, NEW_VER_PATH, log)
+ client = Client.create( pkg_svr_url, NEW_VER_PATH, log)
+ if client.nil? then
+ log.error("Cannot create package client!", Log::LV_USER)
+ exit(1)
+ end
client.update()
client.install( DIBS_PKG_NAME, Utils::HOST_OS, true, true)
+ if not File.exist? "#{NEW_VER_PATH}/tools/dibs" then
+ log.error("Not installed package error.", Log::LV_USER)
+ exit(1)
+ end
# Copy Current path
if File.exist? "#{dibs_path}" then
FileUtils.rm_rf("#{dibs_path}")
#FileUtils.mkdir_p("#{dibs_path}")
end
- if File.exist? "#{NEW_VER_PATH}/tools/dibs" then
- FileUtils.cp_r("#{NEW_VER_PATH}/tools/dibs/.", "#{dibs_path}", :preserve => true)
- else
- log.error("Not installed package error.", Log::LV_USER)
- exit(1)
- end
+
+ FileUtils.cp_r("#{NEW_VER_PATH}/tools/dibs/.", "#{dibs_path}", :preserve => true)
# Execute start command
- if start_opt
- if not build_server.nil? and svr_type.eql? "BUILDSERVER" then
+ if start_opt then
+ if svr_type.eql? "BUILDSERVER" then
# get friends server information
- build_server.get_remote_servers().each do |svr|
- ip = svr.ip
- port = svr.port
-
- build_client = BuildCommClient.create( ip, port )
- if build_client.nil? then
- log.info("Friend Server #{ip}:#{port} is not running!", Log::LV_USER)
- next
- end
+ build_server = BuildServerController.get_server(svr_name)
+ if build_server.has_db? then
+ build_server.get_remote_servers().each do |svr|
+ ip = svr.ip
+ port = svr.port
+
+ build_client = BuildCommClient.create( ip, port )
+ if build_client.nil? then
+ log.info("Friend Server #{ip}:#{port} is not running!", Log::LV_USER)
+ next
+ end
- # send request
- log.info("Upgrading Friend Server #{ip}:#{port}...", Log::LV_USER)
- if build_client.send "UPGRADE|#{build_server.password}" then
- # recevie & print
- mismatched = false
- result = build_client.read_lines do |l|
- log.info(l, Log::LV_USER)
- if l.include? "Password mismatched!" then
- mismatched = true
+ # send request
+ log.info("Upgrading Friend Server #{ip}:#{port}...", Log::LV_USER)
+ if build_client.send "UPGRADE|#{build_server.password}|#{pkg_svr_url}" then
+ # recevie & print
+ mismatched = false
+ result = build_client.read_lines do |l|
+ log.info(l, Log::LV_USER)
+ if l.include? "Password mismatched!" then
+ mismatched = true
+ end
end
- end
- if not result then
+ if not result then
+ log.info("Upgrading failed! #{build_client.get_error_msg()}", Log::LV_USER)
+ elsif mismatched then
+ log.info("Upgrading failed! Password mismatched!", Log::LV_USER)
+ end
+ else
log.info("Upgrading failed! #{build_client.get_error_msg()}", Log::LV_USER)
- elsif mismatched then
- log.info("Upgrading failed! Password mismatched!", Log::LV_USER)
+ next
end
- else
- log.info("Upgrading failed! #{build_client.get_error_msg()}", Log::LV_USER)
- next
- end
- # terminate
- build_client.terminate
+ # terminate
+ build_client.terminate
+ end
end
# Start Build server