# constant
PKG_LIST_FILE_PREFIX = "pkg_list_"
ARCHIVE_PKG_FILE = "archive_pkg_list"
+ OS_INFO_FILE = "os_info"
+ SNAPSHOT_INFO_FILE = "snapshot.info"
def initialize( name, location, server_url, pkg_server )
@log = pkg_server.log
@integrity = pkg_server.integrity
@lock_file_name = "#{location}/.lock_file"
- @os_info_file_path = "#{location}/os_info"
- @snapshot_info_file_path = "#{location}/snapshot.info"
@pkg_hash_os = {}
@archive_pkg_list = []
@snapshot_hash = []
raise "snapshot temp file name already exist"
end
- FileUtils.copy_file( @snapshot_info_file_path, tmp_file_name )
+ FileUtils.copy_file( "#{@location}/#{SNAPSHOT_INFO_FILE}", tmp_file_name )
File.open( tmp_file_name, "a" ) do |f|
f.puts "name : #{name}"
f.puts "time : #{Time.now.strftime("%Y%m%d%H%M%S")}"
f.puts "path : /snapshots/#{name}"
f.puts
end
- FileUtils.mv( tmp_file_name, @snapshot_info_file_path, :force => true )
+ FileUtils.mv( tmp_file_name, "#{@location}/#{SNAPSHOT_INFO_FILE}", :force => true )
# snapshot is generated
@log.output( "snapshot is generated : #{@location}/snapshots/#{name}", Log::LV_USER)
# update os information
@support_os_list.push os
@pkg_hash_os[os] = {}
- File.open(@os_info_file_path, "a") do |f|
+ File.open("#{@location}/#{OS_INFO_FILE}", "a") do |f|
f.puts os
end
end
# modify info file
- info_file = File.readlines(@snapshot_info_file_path)
- File.open(@snapshot_info_file_path, 'w') do |f|
+ info_file = File.readlines("#{@location}/#{SNAPSHOT_INFO_FILE}")
+ File.open("#{@location}/#{SNAPSHOT_INFO_FILE}", 'w') do |f|
remove_flag = false
info_file.each { |line|
if line =~ /name :/ then
end
def initialize_pkg_list
- if not File.exist? @os_info_file_path then
+ if not File.exist? "#{@location}/#{OS_INFO_FILE}" then
return
end
# get support_os_list
- File.open( @os_info_file_path, "r" ) do |f|
+ File.open( "#{@location}/#{OS_INFO_FILE}", "r" ) do |f|
f.each_line do |l|
@support_os_list.push l.strip
end
end
def clean_snapshot_info_file(snapshot_list)
- if not File.exist? @snapshot_info_file_path
+ if not File.exist? "#{@location}/#{SNAPSHOT_INFO_FILE}"
@log.error "Can not find snapshot info file"
return
end
# modify snapshot info File
- f = File.open(@snapshot_info_file_path, "r")
+ f = File.open("#{@location}/#{SNAPSHOT_INFO_FILE}", "r")
info_lines = []
save_flag = false
f.each_line do |l|
end
f.close
- f = File.open(@snapshot_info_file_path, "w")
+ f = File.open("#{@location}/#{SNAPSHOT_INFO_FILE}", "w")
info_lines.each do |i|
f.puts i
end