# This is the config file for the catalyst-auto script. It should be pretty
# self-explanatory.

UPLOAD_USER=sparc
UPLOAD_KEY=/root/.ssh/id_ed25519
SPECS_DIR=${REPO_DIR}/releases/specs/sparc

SETS="
	openrc_32_23
	systemd_32_23
	openrc_64_23
	systemd_64_23
	openrc_32
	openrc_64
"

SET_openrc_32_SPECS="sparc/stage1.spec sparc/stage3.spec"

SET_openrc_64_SPECS="sparc64/stage1.spec sparc64/stage3.spec"

SET_openrc_32_23_SPECS="sparc/stage1-openrc-23.spec sparc/stage3-openrc-23.spec"
SET_systemd_32_23_SPECS="sparc/stage1-systemd-23.spec sparc/stage3-systemd-23.spec"

SET_openrc_64_23_SPECS="sparc64/stage1-openrc-23.spec sparc64/stage3-openrc-23.spec"
SET_openrc_64_23_OPTIONAL_SPECS="sparc64/installcd-stage1.spec sparc64/installcd-stage2-minimal.spec"
SET_systemd_64_23_SPECS="sparc64/stage1-systemd-23.spec sparc64/stage3-systemd-23.spec"


KCONFIG_DIR=${REPO_DIR}/releases/kconfig/sparc

EMAIL_SUBJECT_PREPEND="[sparc-auto]"

update_symlinks() {
	# Symlink the latest stages3 to build from
	local d f
	for d in "${BUILD_SRCDIR_BASE}/builds"/* ; do
		mkdir -p "${d}"
		pushd "${d}" >/dev/null
		for f in $(ls stage3-sparc-*xz | grep -v latest | give_latest_from_dates) ; do
			local of=$(echo "${f}" | convert_filename)
			ln -sf "${f}" "${of}"
		done
		for f in $(ls stage3-sparc64-*xz | grep -v latest | give_latest_from_dates) ; do
			local of=$(echo "${f}" | convert_filename)
			ln -sf "${f}" "${of}"
		done
		popd >/dev/null
	done
}

post_build() {
	local set=$1 spec=$2

	pushd "${BUILD_SRCDIR_BASE}/builds/default" >/dev/null
	case ${spec} in
	sparc/stage3.spec)
		upsync_binpackages "${BUILD_SRCDIR_BASE}/packages/default/stage3-sparc" sparc/17.0/32
		;;
	sparc64/stage3.spec)
		upsync_binpackages "${BUILD_SRCDIR_BASE}/packages/default/stage3-sparc64" sparc/17.0/64
		;;
	esac
	popd >/dev/null

	pushd "${BUILD_SRCDIR_BASE}/builds/23.0-default" >/dev/null
	case ${spec} in
	sparc/stage3-openrc-23.spec)
		upload stage3-sparc-openrc-${TIMESTAMP}*.xz*
		;;
	sparc/stage3-systemd-23.spec)
		upload stage3-sparc-systemd-${TIMESTAMP}*.xz*
		upsync_binpackages "${BUILD_SRCDIR_BASE}/packages/23.0-default/stage3-sparc" sparc/23.0/32
		;;
	sparc64/stage3-openrc-23.spec)
		upload stage3-sparc64-openrc-${TIMESTAMP}*.xz*
		;;
	sparc64/stage3-systemd-23.spec)
		upload stage3-sparc64-systemd-${TIMESTAMP}*.xz*
		upsync_binpackages "${BUILD_SRCDIR_BASE}/packages/23.0-default/stage3-sparc64" sparc/23.0/64
		;;
	sparc64/installcd-stage2-minimal.spec)
		upload *${TIMESTAMP}*.iso*
		;;
	esac
	popd >/dev/null
}
