#!/usr/bin/ruby =begin pkg-svr Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. Contact: Taejun Ha Jiil Hyoun Donghyuk Yang DongHee Yang Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Contributors: - S-Core Co., Ltd =end require 'fileutils' $LOAD_PATH.unshift File.dirname(__FILE__)+"/src/common" $LOAD_PATH.unshift File.dirname(__FILE__)+"/src/pkg_server" require "utils" require "packageServer" require "serverOptParser" #option parsing begin option = option_parse rescue => e puts "\n=============== Error occured ==============================" puts e.message puts e.backtrace.inspect puts "=============================================================\n" exit 0 end begin if option[:cmd].eql? "list" then if option[:id].empty? then PackageServer.list_id else PackageServer.list_dist option[:id] end exit end server = PackageServer.new( option[:id] ) if server.nil? raise RuntimeError, "server class creation fail" end case option[:cmd] when "create" server.create( option[:id], option[:dist], option[:url], option[:loc] ) when "register" server.register( option[:spkgs], option[:bpkgs], option[:dist], option[:gensnap], option[:test] ) when "gen-snapshot" server.generate_snapshot( option[:snap], option[:dist], option[:bsnap], option[:bpkgs] ) when "sync" server.sync( option[:dist], option[:force] ) when "add-dist" server.add_distribution( option[:dist], option[:url], option[:clone] ) when "spkg-path" server.find_source_package_path( option[:dist], option[:spkgs] ) when "remove" if not option[:force] then puts "Do you want to really? then input \"YES\"" input = $stdin.gets.strip if input.eql? "YES" then puts "Remove server!" else puts "Remove is canceled by user input" exit(0) end end server.remove_server( option[:id] ) when "remove-pkg" server.remove_pkg( option[:id], option[:dist], option[:bpkgs], option[:os] ) else raise RuntimeError, "input option incorrect : #{option[:cmd]}" end rescue => e puts "\n=============== Error occured ==============================" puts e.message puts e.backtrace.inspect puts "=============================================================\n" end