refine detection of running instances, set up status directory before first potential error output
svn path=/trunk/; revision=31295
This commit is contained in:
parent
5194bfc354
commit
b6bb1f9bc4
@ -1,84 +1,87 @@
|
||||
#!/bin/sh
|
||||
|
||||
basedir="$(realpath "$(dirname "$0")/..")"
|
||||
[ -z "$inc_misc" ] && . "$basedir/build/misc.sh"
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
-s|--statusdir|--status-dir)
|
||||
[ "$#" -gt 0 ] && shift 1 && statusdir="$1"
|
||||
;;
|
||||
--domain)
|
||||
[ "$#" -gt 0 ] && shift 1 && domain="$1"
|
||||
;;
|
||||
--source)
|
||||
[ "$#" -gt 0 ] && shift 1 && basedir="$1"
|
||||
;;
|
||||
-d|--dest|--destination)
|
||||
[ "$#" -gt 0 ] && shift 1 && target="$1"
|
||||
;;
|
||||
-h|--help)
|
||||
command="help"
|
||||
;;
|
||||
build_into)
|
||||
command="$1$command"
|
||||
[ "$#" -gt 0 ] && shift 1 && target="$1"
|
||||
;;
|
||||
svn_build_into)
|
||||
command="$1$command"
|
||||
[ "$#" -gt 0 ] && shift 1 && target="$1"
|
||||
;;
|
||||
build_xmlstream)
|
||||
command="$1$command"
|
||||
[ "$#" -gt 0 ] && shift 1 && workfile="$1"
|
||||
[ "$#" -gt 0 ] && shift 1 && olang="$1"
|
||||
;;
|
||||
tree_maker)
|
||||
command="$1$command"
|
||||
[ -n "$target" -o -n "$3" ] && shift 1 && tree="$1"
|
||||
shift 1; [ -n "$1" ] && target="$1"
|
||||
;;
|
||||
process_file)
|
||||
command="$1$command"
|
||||
[ "$#" -gt 0 ] && shift 1 && workfile="$1"
|
||||
[ "$#" -gt 0 ] && shift 1 && processor="$1"
|
||||
[ "$#" -gt 0 ] && shift 1 && olang="$1"
|
||||
;;
|
||||
sourceglobs)
|
||||
command="$1$command"
|
||||
[ "$#" -gt 0 ] && shift 1 && sourcesfile="$1"
|
||||
;;
|
||||
cast_globfile)
|
||||
command="$1$command"
|
||||
[ "$#" -gt 0 ] && shift 1 && sourceglobfile="$1"
|
||||
[ "$#" -gt 0 ] && shift 1 && lang="$1"
|
||||
[ "$#" -gt 0 ] && shift 1 && globfile="$1"
|
||||
;;
|
||||
*)
|
||||
print_error "Unknown option $1"
|
||||
exit 1
|
||||
;;
|
||||
if [ -z "$inc_arguments" ]
|
||||
inc_arguments=true
|
||||
basedir="$(realpath "$(dirname "$0")/..")"
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
-s|--statusdir|--status-dir)
|
||||
[ "$#" -gt 0 ] && shift 1 && statusdir="$1"
|
||||
;;
|
||||
--domain)
|
||||
[ "$#" -gt 0 ] && shift 1 && domain="$1"
|
||||
;;
|
||||
--source)
|
||||
[ "$#" -gt 0 ] && shift 1 && basedir="$1"
|
||||
;;
|
||||
-d|--dest|--destination)
|
||||
[ "$#" -gt 0 ] && shift 1 && target="$1"
|
||||
;;
|
||||
-h|--help)
|
||||
command="help"
|
||||
;;
|
||||
build_into)
|
||||
command="$1$command"
|
||||
[ "$#" -gt 0 ] && shift 1 && target="$1"
|
||||
;;
|
||||
svn_build_into)
|
||||
command="$1$command"
|
||||
[ "$#" -gt 0 ] && shift 1 && target="$1"
|
||||
;;
|
||||
build_xmlstream)
|
||||
command="$1$command"
|
||||
[ "$#" -gt 0 ] && shift 1 && workfile="$1"
|
||||
[ "$#" -gt 0 ] && shift 1 && olang="$1"
|
||||
;;
|
||||
tree_maker)
|
||||
command="$1$command"
|
||||
[ -n "$target" -o -n "$3" ] && shift 1 && tree="$1"
|
||||
shift 1; [ -n "$1" ] && target="$1"
|
||||
;;
|
||||
process_file)
|
||||
command="$1$command"
|
||||
[ "$#" -gt 0 ] && shift 1 && workfile="$1"
|
||||
[ "$#" -gt 0 ] && shift 1 && processor="$1"
|
||||
[ "$#" -gt 0 ] && shift 1 && olang="$1"
|
||||
;;
|
||||
sourceglobs)
|
||||
command="$1$command"
|
||||
[ "$#" -gt 0 ] && shift 1 && sourcesfile="$1"
|
||||
;;
|
||||
cast_globfile)
|
||||
command="$1$command"
|
||||
[ "$#" -gt 0 ] && shift 1 && sourceglobfile="$1"
|
||||
[ "$#" -gt 0 ] && shift 1 && lang="$1"
|
||||
[ "$#" -gt 0 ] && shift 1 && globfile="$1"
|
||||
;;
|
||||
*)
|
||||
print_error "Unknown option $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
[ "$#" -gt 0 ] && shift 1
|
||||
done
|
||||
|
||||
olang="${olang:-en}"
|
||||
tree="${tree:-$basedir}"
|
||||
readonly tree="${tree:+$(realpath "$tree")}"
|
||||
readonly basedir="${basedir:+$(realpath "$basedir")}"
|
||||
readonly target="${target:+$(realpath "$target")}"
|
||||
readonly domain="${domain:-www.fsfe.org}"
|
||||
readonly command
|
||||
|
||||
case "$command" in
|
||||
build_into) [ -z "$target" ] && die "Missing destination directory" ;;
|
||||
svn_build_into) [ -z "$target" ] && die "Missing destination directory" ;;
|
||||
process_file) [ -z "$workfile" ] && die "Need at least input file" ;;
|
||||
build_xmlstream) [ -z "$workfile" ] && die "Missing xhtml file name" ;;
|
||||
tree_maker) [ -z "$target" ] && die "Missing target location" ;;
|
||||
sourceglobs) [ -z "$sourcesfile" ] && die "Missing .sources file" ;;
|
||||
cast_globfile) [ -z "$sourceglobfile" -o -z "$lang" -o -z "$globfile" ] && die "Need source globfile language and globfile" ;;
|
||||
*help*) print_help; exit 0 ;;
|
||||
*) die "Urecognised command or no command given" ;;
|
||||
esac
|
||||
[ "$#" -gt 0 ] && shift 1
|
||||
done
|
||||
|
||||
olang="${olang:-en}"
|
||||
tree="${tree:-$basedir}"
|
||||
readonly tree="${tree:+$(realpath "$tree")}"
|
||||
readonly basedir="${basedir:+$(realpath "$basedir")}"
|
||||
readonly target="${target:+$(realpath "$target")}"
|
||||
readonly domain="${domain:-www.fsfe.org}"
|
||||
readonly command
|
||||
|
||||
case "$command" in
|
||||
build_into) [ -z "$target" ] && die "Missing destination directory" ;;
|
||||
svn_build_into) [ -z "$target" ] && die "Missing destination directory" ;;
|
||||
process_file) [ -z "$workfile" ] && die "Need at least input file" ;;
|
||||
build_xmlstream) [ -z "$workfile" ] && die "Missing xhtml file name" ;;
|
||||
tree_maker) [ -z "$target" ] && die "Missing target location" ;;
|
||||
sourceglobs) [ -z "$sourcesfile" ] && die "Missing .sources file" ;;
|
||||
cast_globfile) [ -z "$sourceglobfile" -o -z "$lang" -o -z "$globfile" ] && die "Need source globfile language and globfile" ;;
|
||||
*help*) print_help; exit 0 ;;
|
||||
*) die "Urecognised command or no command given" ;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
@ -5,9 +5,18 @@ basedir="$(dirname "$0")/.."
|
||||
|
||||
. "$basedir/build/arguments.sh"
|
||||
|
||||
if [ -n "$statusdir" ]; then
|
||||
mkdir -p "$statusdir"
|
||||
[ ! -w "$statusdir" -o ! -d "$statusdir" ] && \
|
||||
die "Unable to set up status directory in \"$statusdir\",\n" \
|
||||
"either select a status directory that exists and is writable,\n" \
|
||||
"or run the build script without output to a status directory"
|
||||
fi
|
||||
readonly statusdir="${statusdir:+$(realpath "$statusdir")}"
|
||||
|
||||
buildpids=$(
|
||||
ps -eo pid,command \
|
||||
| egrep 'sh .*[b]uild_main.sh .*' \
|
||||
ps -eo command \
|
||||
| egrep "[s]h .*${0} .*" \
|
||||
| wc -l
|
||||
)
|
||||
if [ $command = "build_into" -o $command = "svn_build_into" ] && [ "$buildpids" -gt 2 ]; then
|
||||
@ -23,14 +32,7 @@ fi
|
||||
[ -z "$inc_scaffold" ] && . "$basedir/build/scaffold.sh"
|
||||
[ -z "$inc_sources" ] && . "$basedir/build/sources.sh"
|
||||
|
||||
if [ -n "$statusdir" ]; then
|
||||
mkdir -p "$statusdir"
|
||||
[ ! -w "$statusdir" -o ! -d "$statusdir" ] && \
|
||||
die "Unable to set up status directory in \"$statusdir\",\n" \
|
||||
"either select a status directory that exists and is writable,\n" \
|
||||
"or run the build script without output to a status directory"
|
||||
fi
|
||||
readonly statusdir="${statusdir:+$(realpath "$statusdir")}"
|
||||
[ -s "$(logname debug)" ] && truncate -s 0 "$(logname debug)"
|
||||
|
||||
case "$command" in
|
||||
build_into) build_into ;;
|
||||
|
@ -20,7 +20,6 @@ debug(){
|
||||
tee -a "$dbg_file"
|
||||
fi
|
||||
}
|
||||
[ -s "$(logname debug)" ] && truncate -s 0 "$(logname debug)"
|
||||
|
||||
print_error(){
|
||||
echo "Error: $@" |logstatus lasterror >&2
|
||||
|
Loading…
x
Reference in New Issue
Block a user