Automated checkin: version bump remove "pre" from version number for firefox 4.0b4...
[mozilla-central.git] / testing / sisyphus / bin / test-setup.sh
blobf26ef89345deaaf85d195e6a8ca5371838b1e03d
1 #!/bin/bash -e
2 # -*- Mode: Shell-script; tab-width: 4; indent-tabs-mode: nil; -*-
3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
14 # License.
16 # The Original Code is mozilla.org code.
18 # The Initial Developer of the Original Code is
19 # Mozilla Corporation.
20 # Portions created by the Initial Developer are Copyright (C) 2006.
21 # the Initial Developer. All Rights Reserved.
23 # Contributor(s):
24 # Bob Clary <bob@bclary.com>
26 # Alternatively, the contents of this file may be used under the terms of
27 # either the GNU General Public License Version 2 or later (the "GPL"), or
28 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 # in which case the provisions of the GPL or the LGPL are applicable instead
30 # of those above. If you wish to allow use of your version of this file only
31 # under the terms of either the GPL or the LGPL, and not to allow others to
32 # use your version of this file under the terms of the MPL, indicate your
33 # decision by deleting the provisions above and replace them with the notice
34 # and other provisions required by the GPL or the LGPL. If you do not delete
35 # the provisions above, a recipient may use your version of this file under
36 # the terms of any one of the MPL, the GPL or the LGPL.
38 # ***** END LICENSE BLOCK *****
40 source $TEST_DIR/bin/library.sh
43 # options processing
45 options="p:b:u:f:c:B:T:x:N:D:L:U:E:d:"
46 function usage()
48 cat<<EOF
49 usage:
50 $SCRIPT -p product -b branch
51 [-u url [-f filepath] [-c credentials]]
52 [-B buildcommands -T buildtype]
53 [-x executablepath]
54 [-N profilename [-D profiledirectory [-L profiletemplate
55 [-U userpreferences]]]]
56 [-E extensiondir]
57 [-d datafiles]
59 variable description
60 =============== ===========================================================
61 -p product required. one of js firefox.
62 -b branch required. supported branch. see library.sh
63 -u url optional. url where to download build
64 -f filepath optional. location to save downloaded build or to find
65 previously downloaded build. If not specified, the
66 default will be the basename of the url saved to the
67 /tmp directory. If there is no basename, then the
68 filepath will be /tmp/\$product-\$branch-file.
69 -B buildcommands optional. one or more of clean checkout build
70 -T buildtype optional. one of opt debug
71 -x executablepath optional. directory tree containing executable with same
72 name as product. If the build is downloaded and executable
73 path is not specified, it will be defaulted to
74 /tmp/\$product-\$branch.
75 For cvs builds it will be defaulted to the appropriate
76 directory in
77 ${BUILDDIR}/\$branch/mozilla/\$product-\$buildtype/
78 -N profilename optional. profilename. profilename is required if
79 profiledirectory or extensiondir are specified.
80 -D profiledirectory optional. If profiledirectory is specified, a new profile
81 will be created in the directory.
82 -L profiletemplate optional. If a new profile is created, profiletemplate is
83 the path to an existing profile which will be copied over
84 the new profile.
85 -U userpreferences optional. If a new profile is created, userpreferences is
86 the path to a user.js file to be copied into the new
87 profile.
88 If userpreferences is not specified when a new profile is
89 created, it is defaulted to
90 ${TEST_DIR}/prefs/test-user.js
91 -E extensiondir optional. path to directory tree containing extensions to
92 be installed.
93 -d datafiles optional. one or more filenames of files containing
94 environment variable definitions to be included.
96 note that the environment variables should have the same
97 names as in the "variable" column.
99 EOF
100 exit 1
103 unset product branch url filepath credentials buildcommands buildtype executablepath profilename profiledirectory profiletemplate userpreferences extenstiondir datafiles
105 while getopts $options optname ;
107 case $optname in
108 p) product="$OPTARG";;
109 b) branch="$OPTARG";;
111 u) url="$OPTARG";;
112 f) filepath="$OPTARG";;
113 c) credentials="$OPTARG";;
115 B) buildcommands="$OPTARG";;
116 T) buildtype="$OPTARG";;
118 x) executablepath="$OPTARG";;
120 N) profilename="$OPTARG";;
121 D) profiledirectory="$OPTARG";;
122 L) profiletemplate="$OPTARG";;
123 U) userpreferences="$OPTARG";;
125 E) extensiondir="$OPTARG";;
127 d) datafiles="$OPTARG";;
128 esac
129 done
131 # include environment variables
132 loaddata $datafiles
134 TEST_PRODUCT=$product
135 TEST_BRANCH=$branch
136 TEST_BUILDCOMMANDS=$buildcommands
137 TEST_BUILDTYPE=$buildtype
138 TEST_EXECUTABLEPATH=$executablepath
139 if [[ -n "$profilename" ]]; then
140 TEST_PROFILENAME=$profilename
142 if [[ -n "$profiletemplate" ]];then
143 TEST_PROFILETEMPLATE=$profiletemplate
145 if [[ -n "$userpreferences" ]]; then
146 TEST_USERPREFERENCES=$userpreferences
148 if [[ -n "$extensiondir" ]]; then
149 TEST_EXTENSIONDIR=$extensiondir
151 TEST_DATAFILES=$datafiles
153 dumpenvironment
154 dumphardware
156 if [[ -z "$product" || -z "$branch" ]]; then
157 echo "product and branch are required"
158 usage
161 checkProductBranch $product $branch
163 if [[ ( -n "$url" || -n "$filepath" ) && ( -n "$buildcommands" ) ]]; then
164 echo "you can not both download and build cvs builds at the same time"
165 usage
168 if [[ -n "$buildcommands" && -n "$executablepath" ]]; then
169 echo "You can not specify the executable path and build cvs builds at the same time"
170 usage
173 if [[ (-n "$profiledirectory" || -n "$extensiondir" ) && -z "$profilename" ]]; then
174 echo "You must specify a profilename if you specify a profiledirectory or extensiondir"
175 usage
178 # if the url is specified but not the filepath
179 # generate a default path where to save the
180 # downloaded build.
181 if [[ -n "$url" && -z "$filepath" ]]; then
182 filepath=`basename $url`
183 if [[ -z "$filepath" ]]; then
184 filepath="$product-$branch-file"
186 filepath="/tmp/$filepath"
189 if [[ -n "$url" ]]; then
190 download.sh -u "$url" -c "$credentials" -f "$filepath" -t "$TEST_DOWNLOAD_TIMEOUT"
193 # install the build at the specified filepath
194 if [[ -n "$filepath" ]]; then
195 if [[ -z "$executablepath" ]]; then
196 executablepath="/tmp/$product-$branch"
198 install-build.sh -p $product -b $branch -x $executablepath -f $filepath
201 if [[ -n "$buildcommands" ]]; then
203 if [[ -z "$buildtype" ]]; then
204 echo "You must specify a buildtype if you are building from cvs"
205 usage
206 elif [[ "$buildtype" != "opt" && "$buildtype" != "debug" ]]; then
207 echo "buildtype must be one of opt debug"
208 usage
211 case "$OSID" in
212 mac)
213 if [[ "$product" == "firefox" ]]; then
214 App=Firefox
216 if [[ "$buildtype" == "debug" ]]; then
217 AppType=Debug
219 executablepath="${BUILDDIR}/$branch/mozilla/$product-$buildtype/dist/$App$AppType.app/Contents/MacOS"
222 executablepath="${BUILDDIR}/$branch/mozilla/$product/$buildtype/dist/bin"
223 esac
225 if echo "$buildcommands" | grep -iq clean; then
226 clean.sh -p $product -b $branch -t $buildtype
229 if echo "$buildcommands" | grep -iq checkout; then
230 checkout.sh -p $product -b $branch -t $buildtype
233 if echo "$buildcommands" | grep -iq build; then
234 build.sh -p $product -b $branch -t $buildtype
239 if [[ -n "$profiledirectory" ]]; then
241 if [[ -z "$userpreferences" ]]; then
242 userpreferences=${TEST_DIR}/prefs/test-user.js
245 unset optargs
246 if [[ -n "$profiletemplate" ]]; then
247 optargs="$optargs -L $profiletemplate"
249 if [[ -n "$userpreferences" ]]; then
250 optargs="$optargs -U $userpreferences"
253 create-profile.sh -p $product -b $branch \
254 -x $executablepath -D $profiledirectory -N $profilename \
255 $optargs
258 if [[ -n "$extensiondir" ]]; then
260 install-extensions.sh -p $product -b $branch \
261 -x $executablepath -N $profilename -E $extensiondir
263 check-spider.sh -p $product -b $branch \
264 -x $executablepath -N $profilename