make-kit-remote at [ffc6b46c9f]

File build/make-kit-remote artifact e83aa4603b part of check-in ffc6b46c9f


#! /bin/bash

TARGET="$1"
shift

buildid="$(( hostname; id -u; pwd ) | openssl sha1 | sed 's@^.*= *@@')"
workdir="/tmp/work-kitcreator-${buildid}"

rsync -aq --delete -e ssh . "${TARGET}:${workdir}/" || exit 1

(
	newArgv=("$@"); declare -p newArgv
	declare -p workdir
	export
	cat << \_EOF_
cd "${workdir}" || exit 1
export PATH="${PATH}:/usr/local/bin:/usr/bin"
./kitcreator "${newArgv[@]}"
exit "$?"
_EOF_
) | ssh "${TARGET}" bash -s
retval="$?"

rm -f */build.log
ssh "${TARGET}" "workdir='${workdir}'; "'cd "${workdir}" && tar -cf - tclkit-* libtclkit* */build.log 2>/dev/null' | tar -xf -

# Clean-up if appropriate
case "$(pwd)" in
	/home/rkeene/*)
		;;
	*)
		ssh "${TARGET}" "workdir='${workdir}'; "'rm -rf "${workdir}"'
		;;
esac

exit "${retval}"