# vim: ft=zsh noet
if [[ $1 == info ]]; then
	fsb_infer_gentoo_settings
	FSB_INFO_DEPEND=gentoo_system
	FSB_INFO_BASE=%s
	FSB_INFO_BASE+=-pkg$STAGE_OVERLAY_REVNO[ccx-packages]

	[[ $parameters[STAGE_GENTOO_OVERLAYS] == 'array' ]] || \
		die "The array STAGE_GENTOO_OVERLAYS needs to be defined in the config"
	local -A overlay_petnames
	overlay_petnames=(
		ccx-pypi pypi
		vserver-overlay vs
	)

	local ovr
	for ovr in $STAGE_GENTOO_OVERLAYS; do
		if (($+overlay_petnames[$ovr])); then
			FSB_INFO_BASE+=-$overlay_petnames[$ovr]$STAGE_OVERLAY_REVNO[$ovr]
		else
			FSB_INFO_BASE+=-$ovr-r$STAGE_OVERLAY_REVNO[$ovr]
		fi
	done

	# (( $+STAGE_GENTOO_OVERLAYS[ccx-pypi] )) && \
	# 	FSB_INFO_BASE+=-pypi$STAGE_OVERLAY_REVNO[ccx-pypi]

	# (( $+STAGE_GENTOO_OVERLAYS[vserver-overlay] )) && \
	# 	FSB_INFO_BASE+=-vs$STAGE_OVERLAY_REVNO[vserver-overlay]

	FSB_INFO_DIR=%s
	return
elif [[ $1 != build ]]; then
	die "unimplemented action: $*"
fi

fsb_gentoo_overlay_add ccx-packages
local ovr
for ovr in $STAGE_GENTOO_OVERLAYS; do
	fsb_gentoo_overlay_add $ovr
done
# (( $+STAGE_GENTOO_OVERLAYS[ccx-pypi] )) && \
# 	fsb_gentoo_overlay_add ccx-pypi
# (( $+STAGE_GENTOO_OVERLAYS[vserver-overlay] )) && \
# 	fsb_gentoo_overlay_add vserver-overlay
return 0