2019-05-23 21:13:50 +02:00
|
|
|
#!/usr/bin/env bash
|
2015-05-31 21:09:48 +00:00
|
|
|
|
|
|
|
[ -z "$inc_misc" ] && . "$basedir/build/misc.sh"
|
|
|
|
|
2015-06-01 14:31:08 +00:00
|
|
|
if [ -z "$inc_arguments" ]; then
|
2015-06-01 13:15:58 +00:00
|
|
|
inc_arguments=true
|
2015-10-28 21:28:21 +00:00
|
|
|
basedir="$(realpath "${0%/*}/..")"
|
2015-05-31 21:09:48 +00:00
|
|
|
|
2015-06-01 13:15:58 +00:00
|
|
|
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"
|
|
|
|
;;
|
2015-06-04 17:21:37 +00:00
|
|
|
--stage|--stagedir)
|
|
|
|
[ "$#" -gt 0 ] && shift 1 && stagedir="$1"
|
|
|
|
;;
|
2015-06-01 13:15:58 +00:00
|
|
|
-d|--dest|--destination)
|
|
|
|
[ "$#" -gt 0 ] && shift 1 && target="$1"
|
|
|
|
;;
|
2019-05-28 13:05:11 +02:00
|
|
|
--build-env)
|
|
|
|
[ "$#" -gt 0 ] && shift 1 && build_env="$1"
|
|
|
|
;;
|
2015-06-01 13:15:58 +00:00
|
|
|
-h|--help)
|
|
|
|
command="help"
|
|
|
|
;;
|
|
|
|
build_into)
|
|
|
|
command="$1$command"
|
|
|
|
[ "$#" -gt 0 ] && shift 1 && target="$1"
|
|
|
|
;;
|
2017-08-18 18:55:38 +02:00
|
|
|
git_build_into)
|
|
|
|
command="$1$command"
|
|
|
|
[ "$#" -gt 0 ] && shift 1 && target="$1"
|
|
|
|
;;
|
2020-05-16 21:32:02 +02:00
|
|
|
build_run)
|
|
|
|
command="$1$command"
|
|
|
|
[ "$#" -gt 0 ] && shift 1 && target="$1"
|
|
|
|
;;
|
2015-06-01 13:15:58 +00:00
|
|
|
build_xmlstream)
|
|
|
|
command="$1$command"
|
|
|
|
[ "$#" -gt 0 ] && shift 1 && workfile="$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"
|
|
|
|
;;
|
|
|
|
*)
|
2015-07-28 17:20:54 +00:00
|
|
|
print_error "Unknown option: $1"
|
2015-06-01 13:15:58 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
[ "$#" -gt 0 ] && shift 1
|
|
|
|
done
|
|
|
|
|
|
|
|
tree="${tree:-$basedir}"
|
2015-10-28 21:28:21 +00:00
|
|
|
stagedir="${stagedir:-$target}"
|
2015-06-01 13:15:58 +00:00
|
|
|
readonly tree="${tree:+$(realpath "$tree")}"
|
2015-06-04 17:21:37 +00:00
|
|
|
readonly stagedir="${stagedir:+$(realpath "$stagedir")}"
|
2015-06-01 13:15:58 +00:00
|
|
|
readonly basedir="${basedir:+$(realpath "$basedir")}"
|
|
|
|
readonly domain="${domain:-www.fsfe.org}"
|
|
|
|
readonly command
|
2016-09-08 00:40:34 +00:00
|
|
|
if [ "$stagedir" != "$target" ] && printf %s "$target" |egrep -q '^.+@.+:(.+)?$'; then
|
|
|
|
readonly target
|
|
|
|
else
|
|
|
|
readonly target="${target:+$(realpath "$target")}"
|
|
|
|
fi
|
2015-06-01 13:15:58 +00:00
|
|
|
|
|
|
|
case "$command" in
|
|
|
|
build_into) [ -z "$target" ] && die "Missing destination directory" ;;
|
2017-08-18 18:55:38 +02:00
|
|
|
git_build_into) [ -z "$target" ] && die "Missing destination directory" ;;
|
2020-05-16 21:32:02 +02:00
|
|
|
build_run) [ -z "$target" ] && die "Missing destination directory" ;;
|
2015-06-01 13:15:58 +00:00
|
|
|
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" ;;
|
2020-04-24 08:52:01 +02:00
|
|
|
*help*) cat "$basedir/build/HELP"; exit 0 ;;
|
2015-06-01 13:15:58 +00:00
|
|
|
*) die "Urecognised command or no command given" ;;
|
|
|
|
esac
|
|
|
|
fi
|