diff --git a/etc/paludis/hooks/set_portdir.bash b/etc/paludis/hooks/set_portdir.bash new file mode 100644 index 0000000..9ee3b08 --- /dev/null +++ b/etc/paludis/hooks/set_portdir.bash @@ -0,0 +1,12 @@ +#!/bin/bash + +# set PORTDIR + +PORTDIR="$(cave print-repository-metadata --raw-name location gentoo)" +PORTDIR="${PORTDIR#location=}" + +if [[ -z ${PORTDIR} || "$(dirname ${PORTDIR})" == "/" ]] ; then + die "PORTDIR empty or pointing to root!" +elif [[ ! -e ${PORTDIR} ]] ; then + die "PORTDIR does not exist!" +fi diff --git a/etc/paludis/hooks/sync_all_post/sync_cache.bash b/etc/paludis/hooks/sync_all_post/sync_cache.bash index f8b4acc..0ef6025 100644 --- a/etc/paludis/hooks/sync_all_post/sync_cache.bash +++ b/etc/paludis/hooks/sync_all_post/sync_cache.bash @@ -2,10 +2,7 @@ source "${PALUDIS_EBUILD_DIR}/echo_functions.bash" source "${PALUDIS_EBUILD_DIR}/die_functions.bash" - -PORTDIR="/usr/portage" - -[[ -z ${PORTDIR} || "$(dirname ${PORTDIR})" == "/" ]] && die "PORTDIR empty or pointing to root!" +source "/etc/paludis/hooks/set_portdir.bash" einfo "syncing metadata cache" diff --git a/etc/paludis/hooks/sync_all_post/sync_dtd.bash b/etc/paludis/hooks/sync_all_post/sync_dtd.bash index 55b0867..8167604 100644 --- a/etc/paludis/hooks/sync_all_post/sync_dtd.bash +++ b/etc/paludis/hooks/sync_all_post/sync_dtd.bash @@ -2,10 +2,7 @@ source "${PALUDIS_EBUILD_DIR}/echo_functions.bash" source "${PALUDIS_EBUILD_DIR}/die_functions.bash" - -PORTDIR="/usr/portage" - -[[ -z ${PORTDIR} || "$(dirname ${PORTDIR})" == "/" ]] && die "PORTDIR empty or pointing to root!" +source "/etc/paludis/hooks/set_portdir.bash" cd "${PORTDIR}"/metadata || die "could not cd into '${PORTDIR}/metadata'!" diff --git a/etc/paludis/hooks/sync_all_post/sync_glsa.bash b/etc/paludis/hooks/sync_all_post/sync_glsa.bash index 49b4961..7035d74 100644 --- a/etc/paludis/hooks/sync_all_post/sync_glsa.bash +++ b/etc/paludis/hooks/sync_all_post/sync_glsa.bash @@ -2,10 +2,7 @@ source "${PALUDIS_EBUILD_DIR}/echo_functions.bash" source "${PALUDIS_EBUILD_DIR}/die_functions.bash" - -PORTDIR="/usr/portage" - -[[ -z ${PORTDIR} || "$(dirname ${PORTDIR})" == "/" ]] && die "PORTDIR empty or pointing to root!" +source "/etc/paludis/hooks/set_portdir.bash" cd "${PORTDIR}"/metadata || die "could not cd into '${PORTDIR}/metadata'!" diff --git a/etc/paludis/hooks/sync_all_post/sync_herds_xml.bash b/etc/paludis/hooks/sync_all_post/sync_herds_xml.bash index f6b5492..d89fef8 100644 --- a/etc/paludis/hooks/sync_all_post/sync_herds_xml.bash +++ b/etc/paludis/hooks/sync_all_post/sync_herds_xml.bash @@ -2,10 +2,7 @@ source "${PALUDIS_EBUILD_DIR}/echo_functions.bash" source "${PALUDIS_EBUILD_DIR}/die_functions.bash" - -PORTDIR="/usr/portage" - -[[ -z ${PORTDIR} || "$(dirname ${PORTDIR})" == "/" ]] && die "PORTDIR empty or pointing to root!" +source "/etc/paludis/hooks/set_portdir.bash" cd "${PORTDIR}"/metadata || die "could not cd into '${PORTDIR}/metadata'!" diff --git a/etc/paludis/hooks/sync_all_post/sync_news.bash b/etc/paludis/hooks/sync_all_post/sync_news.bash index f46f8c0..36f0338 100644 --- a/etc/paludis/hooks/sync_all_post/sync_news.bash +++ b/etc/paludis/hooks/sync_all_post/sync_news.bash @@ -2,10 +2,7 @@ source "${PALUDIS_EBUILD_DIR}/echo_functions.bash" source "${PALUDIS_EBUILD_DIR}/die_functions.bash" - -PORTDIR="/usr/portage" - -[[ -z ${PORTDIR} || "$(dirname ${PORTDIR})" == "/" ]] && die "PORTDIR empty or pointing to root!" +source "/etc/paludis/hooks/set_portdir.bash" cd "${PORTDIR}"/metadata || die "could not cd into '${PORTDIR}/metadata'!"