upload tizen1.0 source
[sdk/tools/sdk-build.git] / pkg-build
1 #!/usr/bin/ruby 
2
3 =begin
4  
5  pkg-build
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 $LOAD_PATH.unshift File.dirname(__FILE__)+"/src/common"
32 $LOAD_PATH.unshift File.dirname(__FILE__)+"/src/pkg_server"
33 $LOAD_PATH.unshift File.dirname(__FILE__)+"/src/builder"
34 require "utils"
35 require "packageServer"
36 require "Builder"
37 require "optionparser"
38
39 option = parse
40
41 #generate server when local package server is not set
42
43 # if "--os" is not specified, use host os type
44 if option[:os].nil? then
45         option[:os] = Utils::HOST_OS
46 else 
47     if not option[:os] =~ /^(linux|windows|darwin)$/ then 
48         puts "We have no plan to Buld OS \"#{option[:os]}\" \n please check your option OS "
49         exit 1
50     end
51 end
52
53 path = Dir.pwd
54 if not File.exist? "package" then 
55     puts "current dirctory \"#{path}\" is not package root directory"
56     exit 1
57 end 
58
59 # if url specified
60 if not option[:url].nil? then
61         begin
62         builder = Builder.get("default") 
63                 if builder.pkgserver_url != option[:url] then
64                         puts "Package server URL has been changed! Creating new builder..."
65                 builder = Builder.create("default", option[:url], nil)  
66                 end
67         rescue
68                 puts "Default builder does not exist! Creating new builder..."
69         builder = Builder.create("default", option[:url], nil)  
70         end
71 else # if url is not specified
72         begin 
73         builder = Builder.get("default")  
74         rescue
75                 puts "Default builder does not exist! Creating new builder..."
76         builder = Builder.create("default", "http://172.21.111.132/pkgserver/unstable",nil)  
77         end
78 end 
79
80 #build project
81 if not builder.build( Utils::WORKING_DIR, option[:os], option[:clean], option[:rev], [], []) then
82         puts "Build Failed!"
83 else
84         puts "Build Succeeded!"
85 end
86