From 3a6d40b9a09f052abd3dabc3fd2c32bf92d3c953 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 16 Oct 2016 17:59:07 +0200 Subject: [PATCH] Add distfile cleanup hook --- hooks/ebuild_postinst_post/clean_pbin.bash | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 hooks/ebuild_postinst_post/clean_pbin.bash diff --git a/hooks/ebuild_postinst_post/clean_pbin.bash b/hooks/ebuild_postinst_post/clean_pbin.bash new file mode 100644 index 0000000..5ea7ec9 --- /dev/null +++ b/hooks/ebuild_postinst_post/clean_pbin.bash @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# set this only +reponame="hasufell-binhost" + + +if [[ ${CAVE_PERFORM_CMDLINE_destination} == ${reponame} ]] ; then + shopt -s nullglob + + repo="$(${CAVE} print-repository-metadata --format '%v' --raw-name location ${reponame})" + bins="$(${CAVE} print-repository-metadata --format '%v' --raw-name distdir ${reponame})" + + good_files=( + $(for pkg in "${repo}/packages/${CATEGORY}/${PN}/"*".pbin-1+exheres-0" ; do . "${pkg}" ; basename "${BINARY_URI}" ; done) + ) + + for file in "${bins}"/${reponame}--${CATEGORY}--${PN}-*.tar.bz2 ; do + file=${file##*/} + if ! echo "${good_files[@]}" | grep -q "${file}" ; then + rm -vf "${bins}/${file}" + fi + done +fi +