gentoo-server-config/hooks/sync_post/01-sync_gentoo_cache.bash

33 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2015-10-12 23:20:04 +00:00
#!/bin/bash
source "${PALUDIS_EBUILD_DIR}/echo_functions.bash"
source "/etc/paludis/hooks/set_portdir.bash"
if [[ ${TARGET} == gentoo ]] ; then
2016-01-18 12:31:35 +00:00
# Number of jobs for egencache, default is number of processors.
2015-10-12 23:20:04 +00:00
egencache_jobnum="$(nproc)"
2016-01-18 12:31:43 +00:00
if [[ -f ${PORTDIR}/metadata/timestamp.x ]]; then
portage_current_timestamp=$(cut -f 1 -d " " "${PORTDIR}/metadata/timestamp.x" )
else
portage_current_timestamp=0
fi
ebegin "Fetching metadata timestamp for ${TARGET}"
rsync -aq rsync://rsync.gentoo.org/gentoo-portage/metadata/timestamp.x "${PORTDIR}"/metadata/timestamp.x
eend $?
portage_new_timestamp=$(cut -f 1 -d " " "${PORTDIR}/metadata/timestamp.x" )
if [[ ${portage_current_timestamp} -lt ${portage_new_timestamp} ]]; then
ebegin "Fetching pre-generated metadata cache for ${TARGET}"
rsync -aq rsync://rsync.gentoo.org/gentoo-portage/metadata/md5-cache/ "${PORTDIR}"/metadata/md5-cache/
eend $?
else
einfo "Metadata cache for ${TARGET} already recent, no need to fetch it :-)"
fi
2015-10-12 23:20:04 +00:00
ebegin "Updating metadata cache for repository ${TARGET}"
egencache --jobs=${egencache_jobnum} --repo=${TARGET} --update --update-use-local-desc
eend $?
fi