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

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

SETS="
	hppa11_openrc_23
	hppa11_systemd_23
	hppa20_openrc_23
	hppa20_systemd_23
	hppa11_openrc
	hppa20_openrc 
"

SET_hppa11_openrc_SPECS="hppa1.1/stage1-openrc.spec hppa1.1/stage3-openrc.spec"

SET_hppa20_openrc_SPECS="hppa2.0/stage1-openrc.spec hppa2.0/stage3-openrc.spec"

SET_hppa11_openrc_23_SPECS="hppa1.1/stage1-openrc-23.spec hppa1.1/stage3-openrc-23.spec"
SET_hppa11_openrc_23_OPTIONAL_SPECS="installcd-stage1.spec installcd-stage2-minimal.spec netboot-hppa32.spec"

SET_hppa11_systemd_23_SPECS="hppa1.1/stage1-systemd-23.spec hppa1.1/stage3-systemd-23.spec"

SET_hppa20_openrc_23_SPECS="hppa2.0/stage1-openrc-23.spec hppa2.0/stage3-openrc-23.spec"
SET_hppa20_openrc_23_OPTIONAL_SPECS="netboot-hppa64.spec"

SET_hppa20_systemd_23_SPECS="hppa2.0/stage1-systemd-23.spec hppa2.0/stage3-systemd-23.spec"


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

EMAIL_SUBJECT_PREPEND="[hppa-auto]"

TMP_PATH=/var/tmp/catalyst/tmp

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

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

	pushd "${BUILD_SRCDIR_BASE}/builds/default" >/dev/null
	case ${spec} in
	hppa1.1/stage3-openrc.spec)
		upsync_binpackages "${BUILD_SRCDIR_BASE}/packages/default/stage3-hppa1.1" hppa/17.0/hppa1.1
		;;
	hppa2.0/stage3-openrc.spec)
		upsync_binpackages "${BUILD_SRCDIR_BASE}/packages/default/stage3-hppa2.0" hppa/17.0/hppa2.0
		;;
	esac
	popd >/dev/null

	pushd "${BUILD_SRCDIR_BASE}/builds/23.0-default" >/dev/null
	case ${spec} in
	hppa1.1/stage3-openrc-23.spec)
		upload stage3-hppa1.1-openrc-${TIMESTAMP}.tar.xz*
		;;
	hppa1.1/stage3-systemd-23.spec)
		upload stage3-hppa1.1-systemd-${TIMESTAMP}.tar.xz*
		upsync_binpackages "${BUILD_SRCDIR_BASE}/packages/23.0-default/stage3-hppa1.1" hppa/23.0/hppa1.1
		;;
	hppa2.0/stage3-openrc-23.spec)
		upload stage3-hppa2.0-openrc-${TIMESTAMP}.tar.xz*
		;;
	hppa2.0/stage3-systemd-23.spec)
		upload stage3-hppa2.0-systemd-${TIMESTAMP}.tar.xz*
		upsync_binpackages "${BUILD_SRCDIR_BASE}/packages/23.0-default/stage3-hppa2.0" hppa/23.0/hppa2.0
		;;
	netboot-hppa32.spec)
		ls -l netboot-hppa1.1-${TIMESTAMP}/
		mv -v netboot-hppa1.1-${TIMESTAMP}/hppa32-hppa.lif netboot-hppa1.1-${TIMESTAMP}/netboot-hppa32-${TIMESTAMP}.lif
		upload netboot-hppa1.1-${TIMESTAMP}/netboot-hppa32-${TIMESTAMP}.lif
		;;
	netboot-hppa64.spec)
		ls -l netboot-hppa2.0-${TIMESTAMP}/
		mv -v netboot-hppa2.0-${TIMESTAMP}/hppa64-hppa.lif netboot-hppa2.0-${TIMESTAMP}/netboot-hppa64-${TIMESTAMP}.lif
		upload netboot-hppa2.0-${TIMESTAMP}/netboot-hppa64-${TIMESTAMP}.lif
		;;
	installcd-stage2-minimal.spec)
		upload install-hppa-minimal-*${TIMESTAMP}*.iso*
		;;
	esac
	popd >/dev/null
}
