From 2c5d930d0bdcd54467dedbea400ec087c49bbabb Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Thu, 6 Apr 2017 10:08:58 -0500 Subject: [PATCH] sync-portage: Added script to sync Portage squashfs images --- sync-portage.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 sync-portage.sh diff --git a/sync-portage.sh b/sync-portage.sh new file mode 100755 index 0000000..8fd34d4 --- /dev/null +++ b/sync-portage.sh @@ -0,0 +1,55 @@ +#!/bin/sh + +REMOTE=${SYNC_REMOTE:-caithe.pyrocufflink.jazz::portage-squashfs/gentoo.sqxz} +NO_EMAINT_SYNC=0 +NO_LAYMAN_SYNC=0 +NO_EIX=0 + +while [ $# -gt 0 ]; do +case "$1" in +--no-eix) + NO_EIX=1 + shift + ;; +--quiet|-q) + QUIET=1 + shift + ;; +*) + if [ -z "${REMOTE}" ]; then + REMOTE="${arg}" + elif [ -z "${LOCAL}" ]; then + LOCAL="${arg}" + fi + shift + ;; +esac +done + +: ${PORTDIR:=$(portageq get_repo_path ${ROOT:-/} ${REPO_NAME:-gentoo})} + +[ x${QUIET} = x ] && RSYNC_ARGS=-v +rsync -a ${RSYNC_ARGS} "${REMOTE}" "${LOCAL:-${PORTDIR%/*}}" || exit $? + +if ! umount "${PORTDIR}"; then + printf 'Failed to unmount %s\n' "${PORTDIR}" + exit 1 +fi +if ! mount "${PORTDIR}"; then + printf 'Failed to mount %s\n' "${PORTDIR}" + exit 1 +fi + +if [ ${NO_EMAINT_SYNC} -ne 1 ]; then + if portageq repos_config / | grep -q sync-uri; then + PORTAGE_QUIET=${QUIET:+0} emaint sync --auto + fi +fi + +if [ ${NO_LAYMAN_SYNC} -ne 1 ] && [ -x "$(command -v layman)" ]; then + layman --sync-all ${QUIET:+--quiet} +fi + +if [ ${NO_EIX} -ne 1 ] && [ -x "$(command -v eix)" ]; then + eix-update ${QUIET:+--quiet} +fi