# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DESCRIPTION="Setup the Lomiri build environment."
HOMEPAGE="https://github.com/renegart/gentoo-lomiri"
SRC_URI=""

LICENSE="GPL-2+"
SLOT="0"
KEYWORDS="amd64"

# 'dev' enables building with debug symbols and install sourrces for debugging
IUSE="dev"
RESTRICT="binchecks strip test"

DEPEND="
	dev? ( dev-util/debugedit sys-devel/dwz )
"

RDEPEND="${DEPEND}"

S="${WORKDIR}"

src_install() {
	n="gentoo-lomiri"

	for x in {accept_keywords,env,mask,unmask,use}; do
		dodir "/etc/portage/package.${x}"
		dosym -r "${REPO_ROOT}/profiles/${n}.${x}" \
			"/etc/portage/package.${x}/0000_${n}.${x}" || die
	done

	if use dev; then
		dosym -r "${REPO_ROOT}/profiles/${n}-dev.conf.env" \
				 "/etc/portage/env/0001_${n}-dev.conf"
		dosym -r "${REPO_ROOT}/profiles/${n}-dev.env" \
				 "/etc/portage/package.env/0001_${n}-dev.env"
	fi

	dodir "/etc/portage/env"
	dosym -r "${REPO_ROOT}/profiles/${n}.conf.env" \
		"/etc/portage/env/${n}.conf" || die

	# enable liblightdm-qt5
	dodir "/etc/portage/env/x11-misc"
	dosym "${REPO_ROOT}/profiles/lightdm.env" "/etc/portage/env/x11-misc/lightdm"
}