gecko-dev/tools/tinderbox/tinderbox
2004-04-25 21:07:34 +00:00

140 lines
4.2 KiB
Bash
Executable File

#!/bin/sh
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (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.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla Communicator.
#
# The Initial Developer of the Original Code is
# Chris McAfee. Portions created by Chris McAfee are Copyright (C) The Mozilla Organization. All Rights Reserved.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Chris McAfee <mcafee@netscape.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
#
# Tinderbox control script.
#
# Assumes that at most two tinderboxes are running
# simultaneously, depend and clobber.
#
# Assumes that if mozconfig exists, use it. Format:
# mk_add_options MOZ_MAKE_FLAGS=j8
# ac_add_options --disable-debug
# ac_add_options --enable-optimize
#
tinderbox_usage() {
echo "Usage: tinderbox [depend|clobber|multi] {start|stop|status|restart}"
exit 1
}
run_in_bg() {
nohup /bin/sh -c "exec $* > /dev/null 2>&1" &
}
if [ $# != 2 ]; then
echo "Wrong number of arguments."
tinderbox_usage
fi
build_type="$1"
build_action="$2"
# Depend or clobber build?
if [ "$build_type" != "depend" -a \
"$build_type" != "clobber" -a \
"$build_type" != "multi" ]; then
echo "Unknown option: $1"
tinderbox_usage
fi
# See how we were called.
case "$build_action" in
start)
if test -f $build_type.pid; then
echo "$build_type build already running with PID "`cat $build_type.pid`
else
echo "Starting $build_type tinderbox..."
# Say if we found post-mozilla.pl
if test -f post-mozilla.pl; then
echo "Found post-mozilla.pl"
fi
# Grab and use mozconfig if it exists.
if test "$build_type" = "multi"; then
run_in_bg ./multi-tinderbox.pl
elif test -f mozconfig; then
echo "Found mozconfig..."
run_in_bg ./build-seamonkey.pl --$build_type --mozconfig mozconfig
elif test -f .mozconfig; then
echo "Found .mozconfig..."
run_in_bg ./build-seamonkey.pl --$build_type --mozconfig .mozconfig
else
run_in_bg ./build-seamonkey.pl --$build_type
fi
# Write out PID so we can shut things down later.
# This needs to be right after the ./build-seamonkey.pl call to
# get the right PID.
echo "PID $!"
echo $! > $build_type.pid
/bin/sh -c "sleep 5; \rm -f nohup.out" &
fi
;;
stop)
if test -f $build_type.pid; then
pid=`cat $build_type.pid`
echo "Shutting down $build_type tinderbox, PID = $pid"
kill $pid
\rm $build_type.pid
else
echo "$build_type is not running."
fi
echo
;;
status)
if test -f $build_type.pid; then
echo "$build_type build is running with PID of "`cat $build_type.pid`
else
echo "$build_type build is not running."
fi
;;
restart)
echo "Restarting $build_type tinderbox:"
$0 $build_type stop
$0 $build_type start
;;
*)
tinderbox_usage
exit 1
esac
exit 0