when "register" then
client = Client.new( nil, nil, nil )
client.register(option[:address], option[:dist], option[:pkg], option[:passwd])
+when "snapshotlist" then
+ client = Client.new(option[:url],nil,nil);
+ client.printSnapshotList(option[:all]);
+when "changelog" then
+ client = Client.new(option[:url], nil, nil);
+ client.printChangeLog();
else
raise RuntimeError, "Input is incorrect : #{option[:cmd]}"
end
--- /dev/null
+#$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common/model"
+require 'model/Property'
+
+class PropertyParser
+ attr_accessor (:seperate)
+ def initialize(seperate)
+ if (seperate.nil?())
+ @seperate = ":";
+ else
+ @seperate = seperate;
+ end
+ end
+
+ public
+ def parseFile(filePath)
+ propertySection = Array.new;
+ properties = Array.new;
+
+ f = File.open(filePath,"r");
+ f.each_line do |line|
+ if (line.empty? || line.eql?("\n")) then
+ if not properties.empty?() then
+ propertySection.push(properties);
+ properties = Array.new
+ end
+ else
+ sepLine = line.split(@seperate);
+ properties.push(Property.new(sepLine[0].strip, sepLine[1].strip))
+ end
+
+ end
+
+ if (not properties.empty?) then
+ propertySection.push(properties);
+ end
+
+ return propertySection;
+ end
+end
\ No newline at end of file
--- /dev/null
+class Property
+ attr_accessor(:key, :value)
+
+ def initialize(key, value)
+ @key = key;
+ @value = value;
+ end
+end
\ No newline at end of file
--- /dev/null
+class ChangeLogController
+end
\ No newline at end of file
--- /dev/null
+class PackageServerConstants
+ CHANGE_LOG_PATH_FROM_DISTRIBUTION = "changes"
+ DISTRIBUTION_INFO_FILE_NAME = "distribution.info"
+
+ #snapshot information
+ SNAPSHOT_INFO_FILE_NAME = "snapshot.info"
+ SNAPSHOT_NAME_FIELD = "name"
+ SNAPSHOT_TIME_FIELD = "time"
+ SNAPSHOT_TYPE_FIELD = "type"
+ SNAPSHOT_PATH_FIELD = "path"
+ SNAPSHOT_MANUAL_TYPE_VALUE = "manual"
+end
\ No newline at end of file
--- /dev/null
+$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common"
+require "PropertyParser"
+require "PackageServerConstants"
+require 'model/snapshot'
+
+class SnapshotController
+ attr_accessor :snapshotList
+ def initialize(snapshotFilePath)
+ @snapshotList = Array.new
+
+ loadSnapshot(snapshotFilePath)
+ end
+
+ public
+ def getAllSnapshotList
+ return @snapshotList
+ end
+
+ public
+ def getManualSnapshotList
+ manualSnapshotList = Array.new
+
+ @snapshotList.each() do |snapshot|
+ if (snapshot.getValue(PackageServerConstants::SNAPSHOT_TYPE_FIELD).eql?(PackageServerConstants::SNAPSHOT_MANUAL_TYPE_VALUE)) then
+ manualSnapshotList.push(snapshot[name])
+ end
+ end
+
+ return manualSnapshotList
+ end
+
+ private
+ def loadSnapshot(snapshotPath)
+ parser = PropertyParser.new(nil)
+ propertySection = parser.parseFile(snapshotPath);
+
+ propertySection.each() do |properties|
+ snapshot = Snapshot.new(properties)
+ @snapshotList.push(snapshot);
+ end
+
+ end
+end
\ No newline at end of file
require "FileTransferViaFTP"
require "FileTransferViaDirect"
require 'digest'
+require "SnapshotController"
+require 'PackageServerConstants'
$update_mutex = Mutex.new
if ret then @log.info "Snapshot is generated : #{ret}" end
end
-
+
+ ##Print change log to console.
+ public
+ def printChangeLog(snapshot1 = nil, snapshot2 = nil)
+ changeLogController = ChangeLogController.new()
+ if (snapshot1.nil?()) then
+ changeLogController.getRecentLog();
+ elsif snapshot2.nil?() then
+ changeLogController.getLog(snapshot1);
+ else
+ changeLogController.getLog(snapshot1, snapshot2);
+ end
+
+ end
+
+ ##Print snapshot list to console.
+ public
+ def printSnapshotList(showAll=false)
+ snapshotPath = File.join(@config_dist_path, PackageServerConstants::SNAPSHOT_INFO_FILE_NAME)
+ @log.info("Read information of snapshot from " + snapshotPath);
+
+ ssController = SnapshotController.new(snapshotPath);
+ if showAll then
+ result = ssController.getAllSnapshotList;
+ else
+ result = ssController.getManualSnapshotList ;
+ end
+
+ result.each() do |snapshot|
+ puts PackageServerConstants::SNAPSHOT_NAME_FIELD + ": " + snapshot.getValue(PackageServerConstants::SNAPSHOT_NAME_FIELD)
+ puts PackageServerConstants::SNAPSHOT_TIME_FIELD + ": " + snapshot.getValue(PackageServerConstants::SNAPSHOT_TIME_FIELD)
+ puts
+ end
+
+ end
end
if options[:t].nil? then options[:t] = false end
if options[:f].nil? then options[:f] = false end
if options[:v].nil? then options[:v] = false end
+ if options[:all].nil? then options[:all] = false end
end
def option_error_check( options )
options[:dist].nil? or options[:dist].empty? then
raise ArgumentError, "Usage: pkg-cli register -P <package file path> -a <server address> -d <distribution name> -w <password>"
end
+ when "snapshotlist"
+ if options[:url].nil? or options[:url].empty? then
+ raise ArgumentError, "Usage: pkg-cli install-dep -P <package name> -u <package server url> [-o <os>]"
+ end
+ when "changelog"
else
raise ArgumentError, "Input is incorrect : #{options[:cmd]}"
puts "DIBS(Distributed Intelligent Build System) version " + Utils.get_version()
exit
end
+
+ opts.on('--all', 'show all information') do
+ options[:all] = true
+ end
end
cmd.eql? "upgrade" or cmd.eql? "check-upgrade" or
cmd.eql? "build-dep" or cmd.eql? "install-dep" or
cmd.eql? "register" or
+ cmd.eql?("changelog") or
+ cmd.eql?("snapshotlist") or
cmd =~ /(-v)|(--version)/ or
cmd =~ /(help)|(-h)|(--help)/ then
--- /dev/null
+
+class Distribution
+ attr_accessor :name, :time
+
+ def initialize(name, time)
+ @name = name
+ @time = time
+ end
+end
\ No newline at end of file
--- /dev/null
+
+
+class Snapshot
+ attr_accessor :properties
+
+ def initialize(properties)
+ @properties = properties;
+ end
+
+ public
+ def getValue(key)
+ properties.each() do |property|
+ if property.key().eql?(key) then
+ return property.value()
+ end
+ end
+
+ return nil;
+ end
+end
\ No newline at end of file