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 "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.new(option[:url],nil,nil);
- client.printSnapshotList(option[:all]);
+ 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.new(option[:url], nil, nil);
- if option[:snapshot].nil?() then
- client.printChangeLog();
- else
- client.printChangeLog(option[:snapshot][0], option[:snapshot][1]);
- end
+ 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
binpkg_path_list = Dir.glob("#{@source_path}/*_*_#{@os}.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
"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!",
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_verified then
@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
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
$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common"
require "Action.rb"
require "ScheduledActionHandler.rb"
+require "BuildServerException.rb"
class PackageSyncAction < Action
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
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
# 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
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
# 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
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 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 = 8G
- @configs[:CACHE_SIZE] = "8000"
+ return true
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)
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
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")
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