#!/bin/sh

rc=0

case "$PKG_BOOTSTRAP,$PKG_BASENAME" in
,*-x86-64*)
    case `uname -m` in
    i386)
	xsdt=`kenv hint.acpi.0.xsdt 2> /dev/null`
	if test -z ${xsdt}; then
	    echo "ERROR: this machine does not support a 64-bit operating system."
	    exit 1
	fi
	;;
    esac
    ;;
esac
case "$PKG_BOOTSTRAP$PKG_BUNDLE" in
""|junos*upgrade*|junos*install*)
    tdir=/tmp/t$$mp

    # we don't need anything here
    rm -rf $PKGDIR/upgrade $PKGDIR/+[A-Z]*

    if test -s $PKGDIR/pkgtools.tgz; then
	mkdir -p $tdir
	tar zxf $PKGDIR/pkgtools.tgz -C $tdir
	veriexec -onoext -C $tdir $tdir/pkg/manifest
	echo Checking PIC combinations
	# for testing
	# test ! -f /var/tmp/checkpic.fail || { echo FAILED; exit 1; }
	$tdir/bin/checkpic || { test -n "$PKG_FORCE" || rc=1; }
    fi
    ;;
esac
exit $rc
