From 2dedf3a1852e9eb902cb715221c52f536056fe09 Mon Sep 17 00:00:00 2001 From: hasufell Date: Fri, 14 Aug 2015 21:35:32 +0200 Subject: [PATCH] saving uncommitted changes in /etc prior to emerge run --- paludis/hooks/set_portdir.bash | 12 ++++++++++++ paludis/hooks/sync_all_post/sync_cache.bash | 5 +---- paludis/hooks/sync_all_post/sync_dtd.bash | 5 +---- paludis/hooks/sync_all_post/sync_glsa.bash | 5 +---- paludis/hooks/sync_all_post/sync_herds_xml.bash | 5 +---- paludis/hooks/sync_all_post/sync_news.bash | 12 +++++++----- 6 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 paludis/hooks/set_portdir.bash diff --git a/paludis/hooks/set_portdir.bash b/paludis/hooks/set_portdir.bash new file mode 100644 index 0000000..a87e2ab --- /dev/null +++ b/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/paludis/hooks/sync_all_post/sync_cache.bash b/paludis/hooks/sync_all_post/sync_cache.bash index 6cc1655..9f2fc35 100644 --- a/paludis/hooks/sync_all_post/sync_cache.bash +++ b/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/paludis/hooks/sync_all_post/sync_dtd.bash b/paludis/hooks/sync_all_post/sync_dtd.bash index 55b0867..8167604 100644 --- a/paludis/hooks/sync_all_post/sync_dtd.bash +++ b/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/paludis/hooks/sync_all_post/sync_glsa.bash b/paludis/hooks/sync_all_post/sync_glsa.bash index 49b4961..7035d74 100644 --- a/paludis/hooks/sync_all_post/sync_glsa.bash +++ b/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/paludis/hooks/sync_all_post/sync_herds_xml.bash b/paludis/hooks/sync_all_post/sync_herds_xml.bash index f6b5492..d89fef8 100644 --- a/paludis/hooks/sync_all_post/sync_herds_xml.bash +++ b/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/paludis/hooks/sync_all_post/sync_news.bash b/paludis/hooks/sync_all_post/sync_news.bash index f46f8c0..9afa371 100644 --- a/paludis/hooks/sync_all_post/sync_news.bash +++ b/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'!" @@ -20,4 +17,9 @@ fi cd "${PORTDIR}"/metadata/news || die "failed to cd into ${PORTDIR}/metadata/news" git clean -fdxq || die "failed to clean git repo!" -cp -a */* . || die "could not copy news dirs to base news dir!" + +if [[ -n "$(find . -mindepth 1 -maxdepth 1 -type d -name "*-*-*")" ]] ; then + die "it seems the repository format of proj/gentoo-news has changed! Update your script!" +else + cp -a */* . || die "could not copy news dirs to base news dir!" +fi