# chop server address, if end with "/"
if server_addr.strip.end_with? "/" then server_addr = server_addr.chop end
+ @snapshot_path = nil
if is_snapshot_url(server_addr) then
@server_addr, @snapshot_path = split_addr_and_snapshot(server_addr)
else
@log = logger
end
- $get_snapshot_mutex.synchronize {
- @snapshot_path = get_lastest_snapshot(@is_server_remote)
- }
- @log.info "The lastest snapshot : #{@snapshot_path}"
- if @snapshot_path.nil? then
- @log.warn "Failed to get the lastest package list"
- @snapshot_path = ""
- end
-
# read installed pkg list, and create hash
- if not File.exist? @location then FileUtils.mkdir_p "#{@location}" end
+ if not File.exist? @location then FileUtils.mkdir_p "#{@location}" end
+ @log.info "Update local package list.. [#{@location}]"
read_installed_pkg_list()
# read remote pkg list, and hash list
+ @log.info "Update remote package list and supported os list.."
update()
@log.info "Initialize - #{server_addr}, #{location}"
end
public
# update package list from server
def update()
+
+ if @snapshot_path.nil? then
+ $get_snapshot_mutex.synchronize {
+ @snapshot_path = get_lastest_snapshot(@is_server_remote)
+ }
+ end
+ @log.info "The lastest snapshot : #{@snapshot_path}"
+ if @snapshot_path.nil? then
+ @log.warn "Failed to get the lastest package list"
+ @snapshot_path = ""
+ end
+
exists_snapshot = false
if is_snapshot_exist(@snapshot_path) then
@log.info "Snapshot information is already cached [#{get_pkglist_path()}]"
return false
end
+ clean_list()
+
if exists_snapshot then
read_supported_os_list(list_path)
read_remote_pkg_list(list_path)
return true
end
+ private
+ def clean_list()
+ @pkg_hash_os.clear
+ @archive_pkg_list.clear
+ @support_os_list.clear
+ @log.info "Cleard package list, supported os list.. OK"
+ end
+
public
# download package
def download(pkg_name, os, trace, loc = nil)
cached_filepath = get_cached_filepath(filename, pkg_checksum, pkg_size, os)
end
if not cached_filepath.nil? then
- @log.info "Install #{pkg_name} using cached file"
+ @log.info "\"#{pkg_name}\" will be installed using cached file"
ret = FileInstaller.install(pkg_name, cached_filepath, type, @location, @log)
else
filepath = download(pkg_name, os, false, @download_path)