#!/bin/bash

source /etc/init.d/functions.sh

# for has()/hasq() and others
source /usr/lib/portage/bin/isolated-functions.sh

inherit() {
	local e
	for e in "$@" ; do
		source ../${e}.eclass
	done
}

EXPORT_FUNCTIONS() {
	:
}

die() {
	return 1
}

# two scenarios, one that returns 0 and another that returns 1
built_with_use() {
	if [[ -n ${BUILT_WITH} ]]; then
		return 0
	else
		return 1
	fi
}

has_version() {
	if [[ -n ${HAS_VER} ]]; then
		return 0
	else
		return 1
	fi
}

# pulled from ebuild.sh, which is unsourceable
use() {
	useq ${1}
}

useq() {
	local u=$1
	local found=0

	# if we got something like '!flag', then invert the return value
	if [[ ${u:0:1} == "!" ]] ; then
		u=${u:1}
		found=1
	fi

	if hasq ${u} ${USE} ; then
		return ${found}
	else
		return $((!found))
	fi
}
