#!/bin/sh
#
# $Id$
#
# Copyright 2019-2020, Juniper Networks, Inc
# All Rights Reserved
#

VERIEXEC=/sbin/veriexec

if ! type is_verified > /dev/null 2>&1; then
    # we'll override this below if appropriate
    is_verified() { return 0; }

    if test -s $VERIEXEC; then
        if $VERIEXEC -i active > /dev/null 2>&1; then
            is_verified() { $VERIEXEC -x $1; }
        fi
    fi
fi

# avoid multiple inclusion and duplicate effort
_VDOT_SH=:

# in case we want to avoid repeats
dotted=
# try not to include things we cannot verify
vdot() {
    local f rc=0

    for f in "$@"
    do
        test -s $f || continue
        if is_verified $f 2> /dev/null; then
            dotted="$dotted $f"
            . $f
        else
            rc=80               # EAUTH
        fi
    done
    return $rc
}

vdot_once() {
    local f rc=0

    for f in "$@"
    do
        case " $dotted " in
        *" $f "*) continue;;
        esac
        vdot $f || rc=$?
    done
    return $rc
}

# for unverified things
dot() {
    local f

    for f in "$@"
    do
        if test -s $f; then
            dotted="$dotted $f"
            . $f
        fi
    done
}

dot_once() {
    local f

    for f in "$@"
    do
        case " $dotted " in
        *" $f "*) continue;;
        esac
        dot $f
    done
}

# unit test
case "/$0" in
*/vdot*) vdot "$@";;
esac
#!/bin/sh
#
# Copyright (c) 2019, Juniper Networks, Inc.
# All rights reserved.
#

# facilitate testing
PKGTOOLS=${PKGTOOLS:-/usr/libexec}
PKGSMNT=${PKGSMNT:-$PKGROOT/mnt}

vdot $PKGDIR/scripts/pkg_funcs.sh
get_features ${PKGSETS:-/packages/sets}/${PKGSET-active}/os-runtime
if test -z "$feature_xml_output_e"; then
    # os-runtime has xml-output without -E
    # we need to tweak the version of package we use
    make_symlink /packages/mnt/$PKG_BASENAME/usr/libexec/ui/packagexf /usr/libexec/ui/package
fi
