Artifact Content

Artifact f1d1c682804b6c71e7b0ba0d682228b21bd1fe4d:


#! /bin/bash

if [ ! -x "./platform" ]; then
	echo 'ERROR: Platform script not found: ./platform' >&2

	exit 1
fi

CLEANONLY=0
DISTCLEAN=0
if [ "$1" = "clean" ]; then
	CLEANONLY=1
fi
if [ "$1" = "distclean" ]; then
	CLEANONLY=1
	DISTCLEAN=1
fi
export CLEANONLY DISTCLEAN

# Build all appropriate directories
faileddirs=""
for dir in */; do
	export dir

	if [ ! -f "${dir}/build.sh" ]; then
		continue
	fi

	failed=0
	(
		cd "${dir}" || exit 1

		rm -f "build.log"
		rm -rf "build" "out"
		if [ "${DISTCLEAN}" = "1" ]; then
			rm -rf "src"
		fi
		if [ "${CLEANONLY}" = "1" ]; then
			exit 0
		fi

		./build.sh 2>&1 | tee "build.log" || exit 1
	) || failed=1

	if [ "${failed}" = "1" ]; then
		rm -rf "${dir}/out"
		faileddirs="${faileddirs} ${dir}"
	fi
done

# Let the user know what failed to build
if [ -n "${faileddirs}" ]; then
	echo "The following failed to build:${failddirs}"
fi

# Create tarfile of built packages
PLATFORM="$(./platform)"
DATECODE="$(date +%Y%m%d%H%M)"
OUTFILEBASE="tclpkgs-${PLATFORM}-${DATECODE}"
tar -cf - */out */build.log | bzip2 -9c > "${OUTFILEBASE}.tar.bz2"

exit 0