Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / testing / sisyphus / bin / uninstall-build.sh
blobbc1229123b56f01b9b12b6550b9f002f91023e6e
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:x:d:"
46 function usage()
48 cat <<EOF
49 usage:
50 $SCRIPT -p product -b branch -x executablepath [-d datafiles]
52 variable description
53 =============== ============================================================
54 -p product required. firefox, thunderbird or fennec
55 -b branch required. 1.8.0|1.8.1|1.9.0|1.9.1
56 -x executablepath required. directory where build is installed
57 -d datafiles optional. one or more filenames of files containing
58 environment variable definitions to be included.
60 note that the environment variables should have the same names as in the
61 "variable" column.
63 Uninstalls build located in directory-tree 'executablepath'
64 then removes the directory upon completion.
66 EOF
67 exit 1
70 unset product branch executablepath datafiles
72 while getopts $options optname ;
73 do
74 case $optname in
75 p) product=$OPTARG;;
76 b) branch=$OPTARG;;
77 x) executablepath=$OPTARG;;
78 d) datafiles=$OPTARG;;
79 esac
80 done
82 # include environment variables
83 loaddata $datafiles
85 if [[ -z "$product" || -z "$branch" || -z "$executablepath" ]]
86 then
87 usage
91 if [[ ! ls "$executablepath/*" 2> /dev/null ]]; then
92 exit 0
95 executable=`get_executable $product $branch $executablepath`
97 executabledir=`dirname $executable`
99 if [[ $OSID == "nt" ]]; then
100 # see http://nsis.sourceforge.net/Docs/Chapter3.html
102 # if the directory already exists, attempt to uninstall
103 # any existing installation.
105 if [[ -d "$executabledir/uninstall" ]]; then
107 if [[ "$branch" == "1.8.0" ]]; then
108 uninstallexe="$executabledir/uninstall/uninstall.exe"
109 uninstallini="$executabledir/uninstall/uninstall.ini"
110 if [[ -n "$uninstallexe" && -e "$uninstallexe" ]]; then
111 if sed -i.bak 's/Run Mode=Normal/Run Mode=Silent/' $uninstallini;
112 then
113 # uninstall.exe will return non zero exit codes
114 # for no damn reason.
115 if $uninstallexe; then
116 true
120 elif [[ "$branch" == "1.8.1" || "$branch" == "1.9.0" || "$branch" == "1.9.1" ]]; then
121 uninstalloldexe="$executabledir/uninstall/uninst.exe"
122 uninstallnewexe="$executabledir/uninstall/helper.exe"
123 if [[ -n "$uninstallnewexe" && -e "$uninstallnewexe" ]]; then
124 $uninstallnewexe /S /D=`cygpath -a -w $executabledir | sed 's@\\\\@\\\\\\\\@g'`
125 elif [[ -n "$uninstalloldexe" && -e "$uninstalloldexe" ]]; then
126 $uninstalloldexe /S /D=`cygpath -a -w $executabledir | sed 's@\\\\@\\\\\\\\@g'`
127 else
128 uninstallexe="$executabledir/$product/uninstall/uninstaller.exe"
129 if [[ -n "$uninstallexe" && -e "$uninstallexe" ]]; then
130 $uninstallexe /S /D=`cygpath -a -w "$executabledir" | sed 's@\\\\@\\\\\\\\@g'`
133 else
134 error "Unknown branch $branch" $LINENO
136 # the NSIS uninstaller will copy itself, then fork to the new
137 # copy so that it can delete itself. This causes a race condition
138 # between the uninstaller deleting the files and the rm command below
139 # sleep for 10 seconds to give the uninstaller time to complete before
140 # the installation directory is removed.
141 sleep 10
146 # safely creates/deletes a directory. If we pass this,
147 # then we know it is safe to remove the directory.
149 $TEST_DIR/bin/create-directory.sh -d "$executablepath" -n
151 rm -fR "$executablepath"