From b8646c27e5be86c3e5e68bf08acefb39e90f7f95 Mon Sep 17 00:00:00 2001 From: hasufell Date: Mon, 17 Aug 2015 18:08:31 +0200 Subject: [PATCH] Sync with portage-gentoo-git-config repo --- etc/paludis/hooks/set_portdir.bash | 2 +- .../hooks/sync_all_post/sync_cache.bash | 19 ++++++++++-- etc/paludis/hooks/sync_all_post/sync_dtd.bash | 16 ++++------ .../hooks/sync_all_post/sync_glsa.bash | 16 ++++------ .../hooks/sync_all_post/sync_herds_xml.bash | 8 ++--- .../hooks/sync_all_post/sync_news.bash | 29 +++++++++---------- etc/paludis/hooks/util_functions.bash | 8 +++++ 7 files changed, 54 insertions(+), 44 deletions(-) create mode 100644 etc/paludis/hooks/util_functions.bash diff --git a/etc/paludis/hooks/set_portdir.bash b/etc/paludis/hooks/set_portdir.bash index a87e2ab..d9f7868 100644 --- a/etc/paludis/hooks/set_portdir.bash +++ b/etc/paludis/hooks/set_portdir.bash @@ -3,7 +3,7 @@ # set PORTDIR PORTDIR="$(cave print-repository-metadata --raw-name location gentoo)" -PORTDIR="${PORTDIR#location=}" +PORTDIR=${PORTDIR#location=} if [[ -z ${PORTDIR} || "$(dirname ${PORTDIR})" == "/" ]] ; then die "PORTDIR empty or pointing to root!" diff --git a/etc/paludis/hooks/sync_all_post/sync_cache.bash b/etc/paludis/hooks/sync_all_post/sync_cache.bash index 0ef6025..afbcc97 100644 --- a/etc/paludis/hooks/sync_all_post/sync_cache.bash +++ b/etc/paludis/hooks/sync_all_post/sync_cache.bash @@ -1,9 +1,22 @@ #!/bin/bash source "${PALUDIS_EBUILD_DIR}/echo_functions.bash" -source "${PALUDIS_EBUILD_DIR}/die_functions.bash" source "/etc/paludis/hooks/set_portdir.bash" +# add your overlays here (name of the overlay!) +overlay_list=( +) -einfo "syncing metadata cache" -egencache --jobs=8 --repo=gentoo --update --update-use-local-desc || die "egencache failed!" +ebegin "Syncing metadata cache for gentoo repository" +rsync -avPq rsync://rsync.gentoo.org/gentoo-portage/metadata/md5-cache/ "${PORTDIR}"/metadata/md5-cache/ +egencache --jobs=$(nproc) --repo=gentoo --update --update-use-local-desc +eend $? + +if [[ ${#overlay_list[@]} -gt 0 ]] ; then + ebegin "Syncing metadata cache for overlays" + for _overlay in ${overlay_list[@]} ; do + einfo " ${_overlay}" + egencache --jobs=$(nproc) --repo=${_overlay} --update --update-use-local-desc + done + eend $? +fi diff --git a/etc/paludis/hooks/sync_all_post/sync_dtd.bash b/etc/paludis/hooks/sync_all_post/sync_dtd.bash index 2e76cb5..60f38b4 100644 --- a/etc/paludis/hooks/sync_all_post/sync_dtd.bash +++ b/etc/paludis/hooks/sync_all_post/sync_dtd.bash @@ -1,17 +1,13 @@ #!/bin/bash source "${PALUDIS_EBUILD_DIR}/echo_functions.bash" -source "${PALUDIS_EBUILD_DIR}/die_functions.bash" source "/etc/paludis/hooks/set_portdir.bash" - -cd "${PORTDIR}"/metadata || die "could not cd into '${PORTDIR}/metadata'!" -if [[ -e dtd ]] ; then - einfo "dtd dir already exists, updating..." - cd dtd || die "could not cd into 'dtd'!" - git pull --ff || die "could not pull updates!" +DTDDIR=${PORTDIR}/metadata/dtd +ebegin "Updating DTDs" +if [[ -e ${DTDDIR} ]]; then + git -C "${DTDDIR}" pull --ff else - einfo "dtd directory does not exist, cloning..." - git clone https://anongit.gentoo.org/git/data/dtd.git || die "could not clone repository!" + git clone https://anongit.gentoo.org/git/data/dtd.git "${DTDDIR}" fi - +eend "$?" diff --git a/etc/paludis/hooks/sync_all_post/sync_glsa.bash b/etc/paludis/hooks/sync_all_post/sync_glsa.bash index 7035d74..47cff61 100644 --- a/etc/paludis/hooks/sync_all_post/sync_glsa.bash +++ b/etc/paludis/hooks/sync_all_post/sync_glsa.bash @@ -1,17 +1,13 @@ #!/bin/bash source "${PALUDIS_EBUILD_DIR}/echo_functions.bash" -source "${PALUDIS_EBUILD_DIR}/die_functions.bash" source "/etc/paludis/hooks/set_portdir.bash" - -cd "${PORTDIR}"/metadata || die "could not cd into '${PORTDIR}/metadata'!" -if [[ -e glsa ]] ; then - einfo "glsa dir already exists, updating..." - cd glsa || die "could not cd into 'glsa'!" - git pull --ff || die "could not pull updates!" +GLSADIR=${PORTDIR}/metadata/glsa +ebegin "Updating GLSAs" +if [[ -e ${GLSADIR} ]]; then + git -C "${GLSADIR}" pull --ff else - einfo "glsa directory does not exist, cloning..." - git clone https://anongit.gentoo.org/git/data/glsa.git || die "could not clone repository!" + git clone https://anongit.gentoo.org/git/data/glsa.git "${GLSADIR}" fi - +eend "$?" 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 fe50a82..7afb050 100644 --- a/etc/paludis/hooks/sync_all_post/sync_herds_xml.bash +++ b/etc/paludis/hooks/sync_all_post/sync_herds_xml.bash @@ -1,10 +1,8 @@ #!/bin/bash source "${PALUDIS_EBUILD_DIR}/echo_functions.bash" -source "${PALUDIS_EBUILD_DIR}/die_functions.bash" source "/etc/paludis/hooks/set_portdir.bash" - -cd "${PORTDIR}"/metadata || die "could not cd into '${PORTDIR}/metadata'!" -[[ -e "${PORTDIR}"/metadata/herds.xml ]] && { rm "${PORTDIR}"/metadata/herds.xml || die "failed to rm herds.xml!" ;} -wget https://gitweb.gentoo.org/data/api.git/plain/files/packages/herds.xml || die "failed to wget herds.xml" +ebegin "Updating herds.xml" +wget -O "${PORTDIR}"/metadata/herds.xml https://api.gentoo.org/packages/herds.xml +eend $? diff --git a/etc/paludis/hooks/sync_all_post/sync_news.bash b/etc/paludis/hooks/sync_all_post/sync_news.bash index 9afa371..3cb53c0 100644 --- a/etc/paludis/hooks/sync_all_post/sync_news.bash +++ b/etc/paludis/hooks/sync_all_post/sync_news.bash @@ -3,23 +3,22 @@ source "${PALUDIS_EBUILD_DIR}/echo_functions.bash" source "${PALUDIS_EBUILD_DIR}/die_functions.bash" source "/etc/paludis/hooks/set_portdir.bash" +source "/etc/paludis/hooks/util_functions.bash" - -cd "${PORTDIR}"/metadata || die "could not cd into '${PORTDIR}/metadata'!" -if [[ -e news ]] ; then - einfo "news dir already exists, updating..." - cd news || die "could not cd into 'news'!" - git pull --ff || die "could not pull updates!" +NEWSDIR="${PORTDIR}"/metadata/news +ebegin "Updating news items" +if [[ -e ${NEWSDIR} ]]; then + git -C "${NEWSDIR}" pull --ff else - einfo "glsa directory does not exist, cloning..." - git clone https://anongit.gentoo.org/git/proj/gentoo-news.git news || die "could not clone repository!" + git clone https://anongit.gentoo.org/git/proj/gentoo-news.git "${NEWSDIR}" fi +eend_die $? -cd "${PORTDIR}"/metadata/news || die "failed to cd into ${PORTDIR}/metadata/news" -git clean -fdxq || die "failed to clean git repo!" +ebegin "Cleaning news git repo" +git -C "${NEWSDIR}" clean -fdxq +eend_die $? + +ebegin "Copying news to base directory" +cp -a "${NEWSDIR}"/*/* "${NEWSDIR}" +eend $? -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 diff --git a/etc/paludis/hooks/util_functions.bash b/etc/paludis/hooks/util_functions.bash new file mode 100644 index 0000000..6a430a9 --- /dev/null +++ b/etc/paludis/hooks/util_functions.bash @@ -0,0 +1,8 @@ +#!/bin/bash + +source "${PALUDIS_EBUILD_DIR}/echo_functions.bash" + +eend_die() { + eend "$@" + [[ $1 -ne 0 ]] && exit $1 +}