def Parser.read_multy_pkginfo_from (file, only_common = false)
pkglist = []
package = nil
+ common_source = ""
+ common_version = ""
+ common_maintainer = ""
+ change_log = {}
+ multi_line = nil
+ change_version = nil
+ change_contents = ""
#file check
File.open file,"r" do |f|
#variable initialize
state = "INIT"
- common_source = ""
- common_version = ""
- common_maintainer = ""
f.each_line do |l|
- # separator
- if l.strip.empty? then
- #make package and initialize
- if state == "PACKAGE" then
- if not package.package_name.empty? then
- pkglist.push package
- else
- raise RuntimeError, "#{file} format is not valid"
- end
- end
- state = "INIT"
- package = nil
- next
- end
- # commant
- if l.strip.start_with? "#" then next end
- #contents
- dsic_on = false
- case l.strip.split(':')[0].strip
- when /^Package/i then
- if only_common then return [common_source, common_version, common_maintainer] end
- # state control
- case state
- when "INIT" then state = "PACKAGE"
- when "COMMON" then state = "PACKAGE"
- when "PACKAGE" then
- if not package.package_name.empty? then
- pkglist.push package
- else
- raise RuntimeError, "Package name is not set in \"#{file}\" file"
- end
- else raise RuntimeError, "UNKNOWN parser state : #{state}"
- end
+ # commant
+ if l.strip.start_with? "#" then next end
- package_name = l.sub(/^[ \t]*Package[ \t]*:[ \t]*/i,"").strip
- if not package_name.empty? then
- package = Package.new(package_name)
- package.source = common_source
- package.version = common_version
- package.maintainer = common_maintainer
- else
- raise RuntimeError, "Package name is not set in \"#{file}\" file"
- end
- disc_on=false
- when /^Label/i then
- case state
- when "INIT" then raise RuntimeError, "\"Package :\" string must be infront of Package section in \"#{file}\" file"
- when "COMMON" then raise RuntimeError, "Not support Label field in Common section in \"#{file}\" file"
- when "PACKAGE" then package.label = l.sub(/^[ \t]*Label[ \t]*:[ \t]*/i,"").strip
- else raise RuntimeError, "UNKNOWN parser state : #{state}"
- end
- disc_on=false
- when /^Version/i then
- case state
- when "INIT" , "COMMON" then
- if common_version.empty? then
- common_version = l.sub(/^[ \t]*Version[ \t]*:[ \t]*/i,"").strip
- else
- raise RuntimeError, "Version information is conflict in \"#{file}\" file\nIf use Version field in Common section then Package section can't contain Version field"
- end
- when "PACKAGE" then
- if common_version.empty? then
- package.version = l.sub(/^[ \t]*Version[ \t]*:[ \t]*/i,"").strip
- else
- raise RuntimeError, "Version information is conflict in \"#{file}\" file\nIf use Version field in Common section then Package section can't contain Version field"
- end
- else raise RuntimeError, "UNKNOWN parser state : #{state}"
- end
- disc_on=false
- when /^OS/i then
- case state
- when "INIT" then raise RuntimeError, "\"Package :\" string must be infront of Package section in \"#{file}\" file"
- when "COMMON" then raise RuntimeError, "Not support OS field in Common section in \"#{file}\" file"
- when "PACKAGE" then
- package.os_list = l.sub(/^[ \t]*OS[ \t]*:[ \t]*/i,"").tr(" \t\n\r", "").split(",")
- package.os = package.os_list[0]
- else raise RuntimeError, "UNKNOWN parser state : #{state}"
- end
- disc_on=false
- when /^Build-host-os/i then
- case state
- when "INIT" then raise RuntimeError, "\"Package :\" string must be infront of Package section in \"#{file}\" file"
- when "COMMON" then raise RuntimeError, "Not support Build-host-os field in Common section in \"#{file}\" file"
- when "PACKAGE" then package.build_host_os = l.sub(/^[ \t]*Build-host-os[ \t]*:[ \t]*/i,"").tr(" \t\n\r", "").split(",")
- else raise RuntimeError, "UNKNOWN parser state : #{state}"
- end
- disc_on=false
- when /^Maintainer/i then
- case state
- when "INIT" , "COMMON" then
- if common_maintainer.empty? then
- common_maintainer = l.sub(/^[ \t]*Maintainer[ \t]*:[ \t]*/i,"").strip
- else
- raise RuntimeError, "Maintainer information is conflict in \"#{file}\" file\nIf use Maintainer field in Common section then Package section can't contain Maintainer field"
+ field_name = l.split(':')[0].strip
+
+ case state
+ when "INIT" then
+ case field_name
+ when /^$/ then next
+ when /^Source$/i then
+ state = "COMMON"
+ if common_source.empty? then common_source = l.sub(/^[ \t]*Source[ \t]*:[ \t]*/i,"").strip
+ else raise RuntimeError, "#{field_name} information is conflict in \"#{file}\" file\nIf use #{field_name} field in Common section then Package section can't contain #{field_name} field"
end
- when "PACKAGE" then
- if common_maintainer.empty? then
- package.maintainer = l.sub(/^[ \t]*Maintainer[ \t]*:[ \t]*/i,"").strip
- else
- raise RuntimeError, "Maintainer information is conflict in \"#{file}\" file\nIf use Maintainer field in Common section then Package section can't contain Maintainer field"
+ when /^Version$/i then
+ state = "COMMON"
+ if common_version.empty? then common_version = l.sub(/^[ \t]*Version[ \t]*:[ \t]*/i,"").strip
+ else raise RuntimeError, "#{field_name} information is conflict in \"#{file}\" file\nIf use #{field_name} field in Common section then Package section can't contain #{field_name} field"
end
- else raise RuntimeError, "UNKNOWN parser state : #{state}"
- end
- disc_on=false
- when /^Attribute/i then
- case state
- when "INIT" then raise RuntimeError, "\"Package :\" string must be infront of Package section in \"#{file}\" file"
- when "COMMON" then raise RuntimeError, "Not support Attribute field in Common section in \"#{file}\" file"
- when "PACKAGE" then package.attribute = l.sub(/^[ \t]*Attribute[ \t]*:[ \t]*/i,"").tr(" \t\n\r","").split("|")
- else raise RuntimeError, "UNKNOWN parser state : #{state}"
- end
- disc_on=false
- when /^Install-dependency/i then
- case state
- when "INIT" then raise RuntimeError, "\"Package :\" string must be infront of Package section in \"#{file}\" file"
- when "COMMON" then raise RuntimeError, "Not support Install-dependency field in Common section in \"#{file}\" file"
- when "PACKAGE" then package.install_dep_list = dep_parser l.sub(/^[ \t]*Install-dependency[ \t]*:[ \t]*/i,"").split(',')
- else raise RuntimeError, "UNKNOWN parser state : #{state}"
- end
- disc_on=false
- when /^Build-dependency/i then
- case state
- when "INIT" then raise RuntimeError, "\"Package :\" string must be infront of Package section in \"#{file}\" file"
- when "COMMON" then raise RuntimeError, "Not support Build-dependency field in Common section in \"#{file}\" file"
- when "PACKAGE" then package.build_dep_list = dep_parser l.sub(/^[ \t]*Build-dependency[ \t]*:[ \t]*/i,"").split(',')
- else raise RuntimeError, "UNKNOWN parser state : #{state}"
- end
- disc_on=false
- when /^Source-dependency/i then
- case state
- when "INIT" then raise RuntimeError, "\"Package :\" string must be infront of Package section in \"#{file}\" file"
- when "COMMON" then raise RuntimeError, "Not support Source-dependency field in Common section in \"#{file}\" file"
- when "PACKAGE" then package.source_dep_list = dep_parser l.sub(/^[ \t]*Source-dependency[ \t]*:[ \t]*/i,"").split(',')
- else raise RuntimeError, "UNKNOWN parser state : #{state}"
- end
- disc_on=false
- when /^Conflicts/i then
- case state
- when "INIT" then raise RuntimeError, "\"Package :\" string must be infront of Package section in \"#{file}\" file"
- when "COMMON" then raise RuntimeError, "Not support Conflicts field in Common section in \"#{file}\" file"
- when "PACKAGE" then package.conflicts = dep_parser l.sub(/^[ \t]*Conflicts[ \t]*:[ \t]*/i,"").split(',')
- else raise RuntimeError, "UNKNOWN parser state : #{state}"
- end
- disc_on=false
- when /^Source/i then
- case state
- when "INIT" , "COMMON" then
+ when /^Maintainer$/i then
state = "COMMON"
- if common_source.empty? then
- common_source = l.sub(/^[ \t]*Source[ \t]*:[ \t]*/i,"").strip
- else
- raise RuntimeError, "Source information is conflict in \"#{file}\" file\nIf use Source field in Common section then Package section can't contain Source field"
+ if common_maintainer.empty? then common_maintainer = l.sub(/^[ \t]*Maintainer[ \t]*:[ \t]*/i,"").strip
+ else raise RuntimeError, "#{field_name} information is conflict in \"#{file}\" file\nIf use #{field_name} field in Common section then Package section can't contain #{field_name} field"
end
- when "PACKAGE" then
- if common_source.empty? then
- package.source = l.sub(/^[ \t]*Source[ \t]*:[ \t]*/i,"").strip
+ when /^Package$/i then
+ state = "PACKAGE"
+ package_name = l.sub(/^[ \t]*Package[ \t]*:[ \t]*/i,"").strip
+ if not package_name.empty? then
+ package = Package.new(package_name)
+ package.source = common_source
+ package.version = common_version
+ package.maintainer = common_maintainer
else
- raise RuntimeError, "Source information is conflict in \"#{file}\" file\nIf use Source field in Common section then Package section can't contain Source field"
+ raise RuntimeError, "Package name is not set in \"#{file}\" file"
end
- else raise RuntimeError, "UNKNOWN parser state : #{state}"
- end
- disc_on=false
- when /^Src-path/i then
- case state
- when "INIT" then raise RuntimeError, "\"Package :\" string must be infront of Package section in \"#{file}\" file"
- when "COMMON" then raise RuntimeError, "Not support Src-path field in Common section in \"#{file}\" file"
- when "PACKAGE" then
- package.src_path = l.sub(/^[ \t]*Src-path[ \t]*:[ \t]*/i,"").strip
- else raise RuntimeError, "UNKNOWN parser state : #{state}"
- end
- disc_on=false
- when /^ORIGIN/ then
- #for compatable
- next
- when /^Include/i then
- case state
- when "INIT", "COMMON" then
+ when /^\*[ \t]*([0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*)[ \t]*$/ then
+ state = "CHANGELOG"
+ change_log[change_version] = change_contents.strip if not change_version.nil?
+ change_version = $1
+ change_contents = ""
+ when /^Include$/i then
pfile = File.dirname(file) + "/" + l.sub(/^[ \t]*Include[ \t]*:[ \t]*/i,"").strip
if File.exist? pfile then
- pkglist = Parser.read_multy_pkginfo_from pfile
+ pkglist = pkglist + (Parser.read_multy_pkginfo_from pfile)
list = Parser.read_multy_pkginfo_from(pfile, true)
- common_source = list[0]
- common_version = list[1]
- common_maintainer = list[2]
+ common_source = list[0] if common_source.empty?
+ common_version = list[1] if common_version.empty?
+ common_maintainer = list[2] if common_maintainer.empty?
+ change_log = list[3] if change_log.empty?
else
raise RuntimeError, "Not exist \"#{pfile}\""
end
- when "PACKAGE" then raise RuntimeError, "Not support Include field in Common section in \"#{file}\" file"
- else raise RuntimeError, "UNKNOWN parser state : #{state}"
- end
- disc_on=false
- when /^Path/i then
- case state
- when "INIT" then raise RuntimeError, "\"Package :\" string must be infront of Package section in \"#{file}\" file"
- when "COMMON" then raise RuntimeError, "Not support Path field in Common section in \"#{file}\" file"
- when "PACKAGE" then package.path = l.sub(/^[ \t]*Path[ \t]*:[ \t]*/i,"").strip
- else raise RuntimeError, "UNKNOWN parser state : #{state}"
- end
- disc_on=false
- when /^Origin/i then
- case state
- when "INIT" then raise RuntimeError, "\"Package :\" string must be infront of Package section in \"#{file}\" file"
- when "COMMON" then raise RuntimeError, "Not support Origin field in Common section in \"#{file}\" file"
- when "PACKAGE" then package.origin = l.sub(/^[ \t]*Origin[ \t]*:[ \t]*/i,"").strip
- else raise RuntimeError, "UNKNOWN parser state : #{state}"
- end
- disc_on=false
- when /^SHA256/i then
- case state
- when "INIT" then raise RuntimeError, "\"Package :\" string must be infront of Package section in \"#{file}\" file"
- when "COMMON" then raise RuntimeError, "Not support SHA256 field in Common section in \"#{file}\" file"
- when "PACKAGE" then package.checksum = l.sub(/^[ \t]*SHA256[ \t]*:[ \t]*/i,"").strip
- else raise RuntimeError, "UNKNOWN parser state : #{state}"
+ else raise RuntimeError, "Can't parse below line in \"#{file}\" file \n\t#{l}"
end
- disc_on=false
- when /^Size/i then
- case state
- when "INIT" then raise RuntimeError, "\"Package :\" string must be infront of Package section in \"#{file}\" file"
- when "COMMON" then raise RuntimeError, "Not support Size field in Common section in \"#{file}\" file"
- when "PACKAGE" then package.size = l.sub(/^[ \t]*Size[ \t]*:[ \t]*/i,"").strip
- else raise RuntimeError, "UNKNOWN parser state : #{state}"
- end
- disc_on=false
- when /^Description/i then
- case state
- when "INIT" then raise RuntimeError, "\"Package :\" string must be infront of Package section in \"#{file}\" file"
- when "COMMON" then raise RuntimeError, "Not support Description field in Common section in \"#{file}\" file"
- when "PACKAGE" then package.description = l.sub(/^[ \t]*Description[ \t]*:[ \t]*/i,"")
- else raise RuntimeError, "UNKNOWN parser state : #{state}"
+ when "COMMON" then
+ case field_name
+ when /^$/ then state = "INIT"
+ when /^Source$/i then
+ state = "COMMON"
+ if common_source.empty? then common_source = l.sub(/^[ \t]*Source[ \t]*:[ \t]*/i,"").strip
+ else raise RuntimeError, "#{field_name} information is conflict in \"#{file}\" file\nIf use #{field_name} field in Common section then Package section can't contain #{field_name} field"
+ end
+ when /^Version$/i then
+ state = "COMMON"
+ if common_version.empty? then common_version = l.sub(/^[ \t]*Version[ \t]*:[ \t]*/i,"").strip
+ else raise RuntimeError, "#{field_name} information is conflict in \"#{file}\" file\nIf use #{field_name} field in Common section then Package section can't contain #{field_name} field"
+ end
+ when /^Maintainer$/i then
+ state = "COMMON"
+ if common_maintainer.empty? then common_maintainer = l.sub(/^[ \t]*Maintainer[ \t]*:[ \t]*/i,"").strip
+ else raise RuntimeError, "#{field_name} information is conflict in \"#{file}\" file\nIf use #{field_name} field in Common section then Package section can't contain #{field_name} field"
+ end
+ else raise RuntimeError, "Can't parse below line in \"#{file}\" file \n\t#{l}"
end
- disc_on=true
- when /^C-/ then
- #custom field
- case state
- when "INIT" then raise RuntimeError, "\"Package :\" string must be infront of Package section in \"#{file}\" file"
- when "COMMON" then raise RuntimeError, "Not support Description field in Common section in \"#{file}\" file"
- when "PACKAGE" then
- if package.custom.empty? then
- package.custom = l.strip
- else
- package.custom = package.custom + "\n" + l.strip
+ when "PACKAGE" then
+ case field_name
+ when /^$/ then
+ state = "INIT"
+ if not package.package_name.empty? then
+ pkglist.push package
+ package = nil
+ else raise RuntimeError, "Package name is not set in \"#{file}\" file"
+ end
+ multi_line = nil
+ when /^Source$/i then
+ if common_source.empty? and package.source.empty? then package.source = l.sub(/^[ \t]*Source[ \t]*:[ \t]*/i,"").strip
+ else raise RuntimeError, "#{field_name} information is conflict in \"#{file}\" file\nIf use #{field_name} field in Common section then Package section can't contain #{field_name} field"
+ end
+ multi_line = nil
+ when /^Version$/i then
+ if common_version.empty? and package.version.empty? then package.version = l.sub(/^[ \t]*Version[ \t]*:[ \t]*/i,"").strip
+ else raise RuntimeError, "#{field_name} information is conflict in \"#{file}\" file\nIf use #{field_name} field in Common section then Package section can't contain #{field_name} field"
+ end
+ multi_line = nil
+ when /^Maintainer$/i then
+ if common_maintainer.empty? and package.maintainer.empty? then package.maintainer = l.sub(/^[ \t]*Maintainer[ \t]*:[ \t]*/i,"").strip
+ else raise RuntimeError, "#{field_name} information is conflict in \"#{file}\" file\nIf use #{field_name} field in Common section then Package section can't contain #{field_name} field"
+ end
+ multi_line = nil
+ when /^OS$/i then
+ package.os_list = l.sub(/^[ \t]*OS[ \t]*:[ \t]*/i,"").tr(" \t\n\r", "").split(",")
+ package.os = package.os_list[0]
+ multi_line = nil
+ when /^Label$/i then
+ package.label = l.sub(/^[ \t]*Label[ \t]*:[ \t]*/i,"").strip
+ multi_line = nil
+ when /^Build-host-os$/i then
+ package.build_host_os = l.sub(/^[ \t]*Build-host-os[ \t]*:[ \t]*/i,"").tr(" \t\n\r", "").split(",")
+ multi_line = nil
+ when /^Attribute$/i then
+ package.attribute = l.sub(/^[ \t]*Attribute[ \t]*:[ \t]*/i,"").tr(" \t\n\r","").split("|")
+ multi_line = nil
+ when /^Install-dependency$/i then
+ package.install_dep_list = dep_parser l.sub(/^[ \t]*Install-dependency[ \t]*:[ \t]*/i,"").split(',')
+ multi_line = nil
+ when /^Build-dependency$/i then
+ package.build_dep_list = dep_parser l.sub(/^[ \t]*Build-dependency[ \t]*:[ \t]*/i,"").split(',')
+ multi_line = nil
+ when /^Source-dependency$/i then
+ package.source_dep_list = dep_parser l.sub(/^[ \t]*Source-dependency[ \t]*:[ \t]*/i,"").split(',')
+ multi_line = nil
+ when /^Conflicts$/i then
+ package.conflicts = dep_parser l.sub(/^[ \t]*Conflicts[ \t]*:[ \t]*/i,"").split(',')
+ multi_line = nil
+ when /^Src-path$/i then
+ package.src_path = l.sub(/^[ \t]*Src-path[ \t]*:[ \t]*/i,"").strip
+ multi_line = nil
+ when /^Path$/i then
+ package.path = l.sub(/^[ \t]*Path[ \t]*:[ \t]*/i,"").strip
+ multi_line = nil
+ when /^Origin$/i then
+ package.origin = l.sub(/^[ \t]*Origin[ \t]*:[ \t]*/i,"").strip
+ multi_line = nil
+ when /^SHA256$/i then
+ package.checksum = l.sub(/^[ \t]*SHA256[ \t]*:[ \t]*/i,"").strip
+ multi_line = nil
+ when /^Size$/i then
+ package.size = l.sub(/^[ \t]*Size[ \t]*:[ \t]*/i,"").strip
+ multi_line = nil
+ when /^Description$/i then
+ package.description = l.sub(/^[ \t]*Description[ \t]*:[ \t]*/i,"").strip
+ multi_line = "Description"
+ when /^ORIGIN$/ then #for compatable
+ multi_line = nil
+ next
+ when /^C-/ then
+ if package.custom.empty? then package.custom = l.rstrip
+ else package.custom = package.custom + "\n" + l.rstrip
+ end
+ multi_line = nil
+ else
+ if multi_line.nil? then raise RuntimeError, "Can't parse below line in \"#{file}\" file \n\t#{l}" end
+ case multi_line
+ when "Description" then package.description = package.description + "\n" + l.rstrip
+ else raise RuntimeError, "Can't parse below line in \"#{file}\" file \n\t#{l}"
end
- else raise RuntimeError, "UNKNOWN parser state : #{state}"
end
- disc_on=false
- else
- if disc_on and state == "PACKAGE" then
- package.description = package.description + l
+ when "CHANGELOG" then
+ case field_name
+ when /^$/ then
+ state = "INIT"
+ if not change_version.nil? then
+ if change_log[change_version].nil? then change_log[change_version] = change_contents.strip
+ else raise RuntimeError, "change log version is duplicated in \"#{file}\" file \n\t#{l}"
+ end
+ end
+ change_version = nil
+ change_contents = ""
+ when /^\*[ \t]*([0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*)[ \t]*$/ then
+ if not change_version.nil? then
+ if change_log[change_version].nil? then change_log[change_version] = change_contents.strip
+ else raise RuntimeError, "change log version is duplicated in \"#{file}\" file \n\t#{l}"
+ end
+ end
+ change_version = $1
+ change_contents = ""
else
- raise RuntimeError, "Can't parse below line in \"#{file}\" file \n\t#{l}"
+ change_contents = change_contents + "\n" + l.rstrip
end
+ else raise RuntimeError, "UNKNOWN state #{field_name}"
end
end
- if only_common then return [common_source, common_version, common_maintainer] end
-
- # check last package
- if state == "PACKAGE" then
- if not package.package_name.empty? then
- pkglist.push package
- else
- raise RuntimeError, "Package name is not set in \"#{file}\" file"
+ # check last package
+ if not package.nil? then pkglist.push package end
+ if not change_version.nil? then
+ if change_log[change_version].nil? then change_log[change_version] = change_contents.strip
+ else raise RuntimeError, "change log version is duplicated in \"#{file}\" file \n\t#{l}"
end
end
+ pkglist.each {|pkg| pkg.change_log = change_log }
end
+ if only_common then return [common_source, common_version, common_maintainer, change_log] end
return pkglist
end
+ def Parser.read_changelog(file)
+ return read_multy_pkginfo_from(file,true)[3]
+ end
+
def Parser.read_single_pkginfo_from (file)
return read_multy_pkginfo_from(file)[0]
end
=begin
-
- distribution.rb
+
+ distribution.rb
Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
require "installer"
class Distribution
- attr_accessor :name, :location, :server_url, :lock_file_path
+ attr_accessor :name, :location, :server_url, :lock_file_path, :last_sync_changes
# constant
- PKG_LIST_FILE_PREFIX = "pkg_list_"
+ PKG_LIST_FILE_PREFIX = "pkg_list_"
ARCHIVE_PKG_FILE = "archive_pkg_list"
OS_INFO_FILE = "os_info"
SNAPSHOT_INFO_FILE = "snapshot.info"
@log = pkg_server.log
@integrity = pkg_server.integrity
@lock_file_path = "#{location}/#{LOCK_FILE}"
- @pkg_hash_os = {}
- @archive_pkg_list = []
- @snapshot_hash = []
+ @pkg_hash_os = {}
+ @archive_pkg_list = []
+ @snapshot_hash = []
@support_os_list = []
+ @last_sync_changes = ""
@log.info "Distribution class[#{name}] initialize "
end
end
- def generate_snapshot(name, base_snapshot, from_cmd)
+ def generate_snapshot(name, base_snapshot, from_cmd, change_log_string)
# if name is nil or empty then create uniq name
if name.nil? or name.empty? then
name = Utils.create_uniq_name
end
FileUtils.mkdir "#{@location}/snapshots/#{name}"
-
+ FileUtils.mkdir "#{@location}/changes" if not File.exists? "#{@location}/changes"
+ File.open( "#{@location}/changes/#{name}.log","w") { |f| f.puts change_log_string }
+
# base_snapshot_path
if base_snapshot.empty? then
snapshot_path = @location
pkg_list_update_flag = false
archive_update_flag = false
distribution_update_flag = false
+ changes = []
# reload pkg list from newest pkg list file
reload_distribution_information()
add_os_list = client.support_os_list - @support_os_list
add_os_list.each do |os|
add_os(os)
+ changes.push "Add OS #{os}"
pkg_list_update_flag = true
end
remove_os_list = @support_os_list - client.support_os_list
remove_os_list.each do |os|
remove_os(os)
+ changes.push "Remove OS #{os}"
pkg_list_update_flag = true
end
end
end
end
- # sync archive package
+ # sync archive package
update_archive_list = sync_archive_pkg()
# lock
case update_option
when "ADD"
local_pkg = @pkg_hash_os[os][pkg.package_name]
-
+
if (not force) and (not local_pkg.nil?) then
# if updated package 'local' package then skip
- if local_pkg.origin.eql? "local" then
+ if local_pkg.origin.eql? "local" then
next
end
next
end
end
-
+
@pkg_hash_os[os][pkg.package_name] = pkg
- when "REMOVE"
+ changes.push pkg.get_changes if pkg.does_change_exist?
+ when "REMOVE"
if not force then
if @pkg_hash_os[os][pkg.package_name].origin.eql? "local" then
next
end
@pkg_hash_os[os].delete(pkg.package_name)
+ changes.push "#{pkg.package_name} #{os} removed"
else
@log.error("Unsupportd update option : #{update_option}", Log::LV_USER)
next
update_archive_list.each do |pkg|
if not @archive_pkg_list.include? pkg then
@archive_pkg_list.push pkg
+ changes.push "Add archive package #{pkg.package_name}"
archive_update_flag = true
end
end
# update archive list file
if archive_update_flag then
- write_archive_pkg_list()
+ write_archive_pkg_list()
distribution_update_flag = true
end
- # unlock
+ # unlock
Utils.file_unlock(lock_file)
+ if not changes.empty? then
+ @last_sync_changes = "SYSTEM: sync parents server \n#{changes.join("\n")}"
+ end
+
return distribution_update_flag
end
require 'fileutils'
$LOAD_PATH.unshift File.dirname(__FILE__)
$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common"
-$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/build_server"
+$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/build_server"
require "BuildComm"
require "packageServerLog"
require "packageServerConfig"
# email just remote package server
# Mail.send_package_registe_mail( msg_list, @id )
end
-
- # if snapshot mode is true then generate snapshot
+
+ # if snapshot mode is true then generate snapshot
if snapshot or test_flag then
@log.info "generaging snapshot"
- snapshot_name = distribution.generate_snapshot("", "", false)
- end
-
+ snapshot_name = distribution.generate_snapshot("", "", false, get_changelog_string(registed_package_list) )
+ end
+
Utils.file_unlock(@lock_file)
@log.output( "package registed successfully", Log::LV_USER)
return snapshot_name
end
+ def get_changelog_string( package_list )
+ log_list = []
+ package_list.each do |pkg|
+ if pkg.does_change_exist? then log_list.push pkg.get_changes end
+ end
+ return log_list.uniq.join("\n")
+ end
+
def generate_snapshot( snpashot_name, dist_name, base_snapshot )
@log.info "generating snapshot"
distribution = get_distribution( dist_name )
@lock_file = Utils.file_lock(distribution.lock_file_path)
- snapshot_name = distribution.generate_snapshot( snpashot_name, base_snapshot, true)
-
+ snapshot_name = distribution.generate_snapshot( snpashot_name, base_snapshot, true, "SYSTEM:")
+
Utils.file_unlock(@lock_file)
return snapshot_name
if distribution.server_url.empty? then
@log.error( "This distribution has not remote server", Log::LV_USER)
return
- end
+ end
ret = distribution.sync(mode)
- if ret then
- distribution.generate_snapshot("", "", false)
+ if ret then
+ distribution.generate_snapshot("", "", false, distribution.last_sync_changes)
end
-
+
@log.output( "package server [#{@id}]'s distribution [#{dist_name}] has been synchronized.", Log::LV_USER )
end
dist.add_os(os)
@log.info "generaging snapshot"
- dist.generate_snapshot("", "", false)
+ dist.generate_snapshot("", "", false, "Add #{os} Package server")
Utils.file_unlock(@lock_file)
@log.output( "package server add os [#{os}] successfully", Log::LV_USER )
# generate snapshot
@log.info "generaging snapshot"
- distribution.generate_snapshot("", "", false)
+ distribution.generate_snapshot("", "", false, "SYSTEM: Package \"#{pkg_name_list.join(", ")}\" is(are) removed in #{os} server")
Utils.file_unlock(lock_file)
@log.output( "package removed successfully", Log::LV_USER )
end
distribution.sync(false)
- distribution.generate_snapshot("", "", false)
+ distribution.generate_snapshot("", "", false, distribution.last_sync_changes)
else
@log.info "generate package server do not using remote package server"