From: hataejun Date: Wed, 22 Aug 2012 14:50:09 +0000 (+0900) Subject: [Title] package server config location move X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8c4db19dc6c2f09ea1990bc8e53890127744adbc;p=sdk%2Ftools%2Fsdk-build.git [Title] package server config location move [Type] [Module] [Priority] [Jira#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- diff --git a/src/pkg_server/packageServer.rb b/src/pkg_server/packageServer.rb index 6279648..2a675db 100644 --- a/src/pkg_server/packageServer.rb +++ b/src/pkg_server/packageServer.rb @@ -47,6 +47,11 @@ class PackageServer attr_accessor :distribution_list attr_accessor :sync_interval, :passwd + # constant + SERVER_ROOT = "#{PackageServerConfig::CONFIG_ROOT}/pkg_server" + LOCK_FILE = "#{SERVER_ROOT}/.server_loc" + AUTO_SYNC_CHK_FILE = "#{SERVER_ROOT}/auto_sync" + # initialize def initialize (id) @location = "" @@ -64,8 +69,8 @@ class PackageServer update_config_information(id) - if not File.exist?( PackageServerConfig::SERVER_ROOT ) - FileUtils.mkdir_p( PackageServerConfig::SERVER_ROOT ) + if not File.exist?( SERVER_ROOT ) + FileUtils.mkdir_p( SERVER_ROOT ) end @log = PackageServerLog.new( @log_file_path ) @@ -93,7 +98,7 @@ class PackageServer end # create locking file - @lock_file = Utils.file_lock(PackageServerConfig::LOCK_FILE) + @lock_file = Utils.file_lock(LOCK_FILE) # create server config directory FileUtils.mkdir_p @config_dir @@ -281,7 +286,7 @@ class PackageServer end def add_distribution( dist_name, server_url, clone ) - @lock_file = Utils.file_lock(PackageServerConfig::LOCK_FILE) + @lock_file = Utils.file_lock(LOCK_FILE) # error check : check for already exist in server directory if @dist_to_server_url.keys.include? dist_name.strip then @@ -332,7 +337,7 @@ class PackageServer def remove_server() @log.info( "Package server [#{@id}] will be removed and all server information delete", Log::LV_USER) - @lock_file = Utils.file_lock(PackageServerConfig::LOCK_FILE) + @lock_file = Utils.file_lock(LOCK_FILE) if File.exist? @config_file_path then File.open @config_file_path do |f| f.each_line do |l| @@ -358,7 +363,7 @@ class PackageServer @log.info "remove distribution in server" distribution = get_distribution( dist_name ) - @lock_file = Utils.file_lock(PackageServerConfig::LOCK_FILE) + @lock_file = Utils.file_lock(LOCK_FILE) # modify config file config_file = File.readlines(@config_file_path) @@ -402,7 +407,7 @@ class PackageServer @log.info "package remove in server" distribution = get_distribution( dist_name ) - @lock_file = Utils.file_lock(PackageServerConfig::LOCK_FILE) + @lock_file = Utils.file_lock(LOCK_FILE) distribution.remove_pkg(pkg_name_list, os, recursive) @@ -418,7 +423,7 @@ class PackageServer @log.info "remove snapshot in server" distribution = get_distribution( dist_name ) - @lock_file = Utils.file_lock(PackageServerConfig::LOCK_FILE) + @lock_file = Utils.file_lock(LOCK_FILE) distribution.remove_snapshot(snapshot_list) @@ -429,7 +434,7 @@ class PackageServer @log.info "pakcage server clean" distribution = get_distribution( dist_name ) - @lock_file = Utils.file_lock(PackageServerConfig::LOCK_FILE) + @lock_file = Utils.file_lock(LOCK_FILE) distribution.clean( snapshot_list ) @@ -502,9 +507,9 @@ class PackageServer end def self.list_id - @@log = PackageServerLog.new( "#{PackageServerConfig::SERVER_ROOT}/.log" ) + @@log = PackageServerLog.new( "#{SERVER_ROOT}/.log" ) - d = Dir.new( PackageServerConfig::SERVER_ROOT ) + d = Dir.new( SERVER_ROOT ) s = d.select {|f| not f.start_with?(".") } s.sort! @@ -517,12 +522,12 @@ class PackageServer end def self.list_dist( id ) - @@log = PackageServerLog.new( "#{PackageServerConfig::SERVER_ROOT}/.log" ) + @@log = PackageServerLog.new( "#{SERVER_ROOT}/.log" ) @@log.output( "=== ID [#{id}]'s distribution list ===", Log::LV_USER) # read package id information - config_file_path = "#{PackageServerConfig::SERVER_ROOT}/#{id}/config" + config_file_path = "#{SERVER_ROOT}/#{id}/config" if not File.exist? config_file_path raise RuntimeError, "[#{id}] is not server ID" end @@ -545,7 +550,7 @@ class PackageServer def reload_dist_package() # create locking file - @lock_file = Utils.file_lock(PackageServerConfig::LOCK_FILE) + @lock_file = Utils.file_lock(LOCK_FILE) @distribution_list.each do |dist| dist.initialize_pkg_list end @@ -564,7 +569,7 @@ class PackageServer def server_information_initialize # if id is nil or empty then find default id if @id.nil? or @id.empty? - d = Dir.new( PackageServerConfig::SERVER_ROOT ) + d = Dir.new( SERVER_ROOT ) s = d.select {|f| not f.start_with?(".") } if s.length.eql? 1 then @log.info "using default server ID [#{s[0]}]" @@ -700,8 +705,8 @@ class PackageServer def update_config_information(id) @id = id - @config_dir = "#{PackageServerConfig::SERVER_ROOT}/#{@id}" - @log_file_path = "#{PackageServerConfig::SERVER_ROOT}/#{@id}.log" + @config_dir = "#{SERVER_ROOT}/#{@id}" + @log_file_path = "#{SERVER_ROOT}/#{@id}.log" @config_file_path = "#{@config_dir}/config" @incoming_path = "#{@config_dir}/incoming" end diff --git a/src/pkg_server/packageServerConfig.rb b/src/pkg_server/packageServerConfig.rb index 7e19000..b2b447a 100644 --- a/src/pkg_server/packageServerConfig.rb +++ b/src/pkg_server/packageServerConfig.rb @@ -31,6 +31,4 @@ require "utils" class PackageServerConfig CONFIG_ROOT = "#{Utils::HOME}/.build_tools" - SERVER_ROOT = "#{PackageServerConfig::CONFIG_ROOT}/pkg_server" - LOCK_FILE = "#{PackageServerConfig::SERVER_ROOT}/.server_loc" end