upload tizen1.0 source
[sdk/tools/sdk-build.git] / pkg-svr
1 #!/usr/bin/ruby 
2
3 =begin
4  
5  pkg-svr
6
7 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
8
9 Contact:
10 Taejun Ha <taejun.ha@samsung.com>
11 Jiil Hyoun <jiil.hyoun@samsung.com>
12 Donghyuk Yang <donghyuk.yang@samsung.com>
13 DongHee Yang <donghee.yang@samsung.com>
14
15 Licensed under the Apache License, Version 2.0 (the "License");
16 you may not use this file except in compliance with the License.
17 You may obtain a copy of the License at
18
19 http://www.apache.org/licenses/LICENSE-2.0
20
21 Unless required by applicable law or agreed to in writing, software
22 distributed under the License is distributed on an "AS IS" BASIS,
23 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 See the License for the specific language governing permissions and
25 limitations under the License.
26
27 Contributors:
28 - S-Core Co., Ltd
29 =end
30
31 require 'fileutils'
32 $LOAD_PATH.unshift File.dirname(__FILE__)+"/src/common"
33 $LOAD_PATH.unshift File.dirname(__FILE__)+"/src/pkg_server"
34 require "utils"
35 require "packageServer"
36 require "serverOptParser"
37
38 #option parsing 
39 begin
40         option = option_parse
41 rescue => e
42         puts "\n=============== Error occured =============================="
43         puts e.message
44         puts e.backtrace.inspect
45         puts "=============================================================\n"
46         exit 0
47 end
48
49 begin 
50         if option[:cmd].eql? "list" then
51                 if option[:id].empty? then
52                         PackageServer.list_id 
53                 else
54                         PackageServer.list_dist option[:id]
55                 end 
56                 exit 
57         end 
58
59         server = PackageServer.new( option[:id] )
60
61         if server.nil? 
62                 raise RuntimeError, "server class creation fail"
63         end
64
65         case option[:cmd] 
66         when "create"  
67                 server.create( option[:id], option[:dist], option[:url], option[:loc] )
68         when "register"
69                 server.register( option[:spkgs], option[:bpkgs], option[:dist], option[:gensnap], option[:test] ) 
70         when "gen-snapshot"
71                 server.generate_snapshot( option[:snap], option[:dist], option[:bsnap], option[:bpkgs] ) 
72         when "sync"
73                 server.sync( option[:dist], option[:force] )
74         when "add-dist"
75                 server.add_distribution( option[:dist], option[:url], option[:clone] )
76         when "spkg-path" 
77                 server.find_source_package_path( option[:dist], option[:spkgs] )
78         when "remove"
79                 if not option[:force] then
80                         puts  "Do you want to really? then input \"YES\""
81                         input = $stdin.gets.strip
82                         if input.eql? "YES" then   
83                                 puts "Remove server!"
84                         else
85                                 puts "Remove is canceled by user input"
86                                 exit(0)
87                         end
88                 end
89
90                 server.remove_server( option[:id] )
91         when "remove-pkg"
92                 server.remove_pkg( option[:id], option[:dist], option[:bpkgs], option[:os] )
93         else
94                 raise RuntimeError, "input option incorrect : #{option[:cmd]}"
95         end
96 rescue => e 
97         puts "\n=============== Error occured =============================="
98         puts e.message
99         puts e.backtrace.inspect
100         puts "=============================================================\n"
101 end
102
103