return pkg_all_list.sort
end
+ public
+ # check_syncable_server?
+ # from_server : if true, update from server
+ def check_syncable_server?()
+ ssinfo_file = "snapshot.info"
+ file_url = File.join(@server_addr, ssinfo_file)
+ if @is_server_remote then
+ if not FileDownLoader.download(file_url, @config_dist_path, @log) then
+ @log.error "Server does not have \"#{ssinfo_file}\" file."
+ return false
+ end
+ else
+ if File.exist? file_url then
+ FileUtils.cp(file_url, @config_dist_path)
+ else
+ @log.error "Server does not have \"#{ssinfo_file}\" file."
+ return false
+ end
+ end
+
+ file_path = File.join(@config_dist_path, ssinfo_file)
+ if not File.exist? file_path then return false end
+
+ contents = File.open(file_path, "r").read
+
+ _list = contents.split("\n\n")
+ snapshot_list = _list.map {|x| x.split("\n").first.split(":")[1].strip }
+
+ return (snapshot_list.index{|x| /sync_.*/ =~ x}.nil?)
+ end
+
private
def get_build_dependency_arr(pkg_name, os, n)
pkg_hash = @pkg_hash_os[os]
create_distribution_struct( dist_name, server_url )
Utils.file_unlock(lock_file)
+ # remote server check
+ if (not server_url.empty?) then
+ client = Client.create(server_url.strip, "#{@location}/binary", @log);
+ if client.nil? or not client.check_syncable_server? then
+ # remove configs
+ FileUtils.rm_rf @location
+ FileUtils.rm_rf @config_dir
+ @log.error( "#{server_url} is invalid or not synchronizable package server",Log::LV_USER)
+ return nil
+ end
+ end
+
@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 )
return
end
- begin
- update, snapshot = distribution.sync(mode, snapshot)
- if update then
- distribution.generate_snapshot("sync_#{snapshot}", "", false, distribution.last_sync_changes)
- end
-
- @log.output( "package server [#{@id}]'s distribution [#{dist_name}] has been synchronized.", Log::LV_USER )
- rescue => e
- @log.error( e.message, Log::LV_USER)
- end
- end
+ client = Client.create(distribution.server_url, "#{@location}/binary", @log);
+ if client.nil? or not client.check_syncable_server? then
+ @log.error( "#{distribution.server_url} is invalid or not synchronizable package server", Log::LV_USER)
+ else
+ begin
+ update, snapshot = distribution.sync(mode, snapshot)
+ if update then
+ distribution.generate_snapshot("sync_#{snapshot}", "", false, distribution.last_sync_changes)
+ end
+
+ @log.output( "package server [#{@id}]'s distribution [#{dist_name}] has been synchronized.", Log::LV_USER )
+ rescue => e
+ @log.error( e.message, Log::LV_USER)
+ end
+ end
+ end
def add_distribution( dist_name, server_url, clone )
lock_file = Utils.file_lock(@server_lock_file_path)