#!/bin/sh -efu

# This should check that the build result is consistent on its own (sam
# po sebe).  This is NOT the right place to check if the build result is
# consistent with respect to a repo.

. gb-sh-functions

fail_if_task_abort_requested

rc=0
fail()
{
	stamp_echo >&2 "build check FAILED for $*"
	rc=1
}

# check each built package separately
for i in $(src_nums) $(copy_nums); do
	$0-i "$i" || fail "#$i"
done

# check all $arch packages in whole
for arch in $GB_ARCH; do
	$0-arch "$arch" || fail "$arch"
done

[ "$rc" = 0 ] && text=OK || text=FAILED
stamp_echo >&2 "build check $text"
exit $rc
