#!/bin/bash # $Header: /var/cvsroot/gentoo-projects/portage-utils/qsync,v 1.8 2010/12/04 11:09:51 vapier Exp $ get_portage_var() { local var=$1 val [[ -n ${!var} ]] && return 0 val=$( ( source /etc/make.globals source /etc/make.conf source /etc/portage/make.conf echo ${!var} ) 2>/dev/null ) [[ -n ${val} ]] && export ${var}=${val} && return export ${var}=$(portageq envvar ${var}) [[ -z ${!var} ]] && export ${var}=$2 } get_portage_var PORTDIR /usr/portage get_portage_var RSYNC_TIMEOUT 300 get_portage_var RSYNC_EXCLUDEFROM get_portage_var SYNC [[ -z ${SYNC} ]] && echo could not get SYNC var && exit 1 add() { RSYNC_OPTS="${RSYNC_OPTS} $@" ; } RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=${RSYNC_TIMEOUT} --exclude=/distfiles --exclude=/local --exclude=/packages --progress" [[ -n ${RSYNC_EXCLUDEFROM} ]] && add --exclude-from="${RSYNC_EXCLUDEFROM}" METADATA_ONLY=0 while [[ -n $1 ]] ; do x=$1 shift case ${x} in -v|--verbose) add --verbose ;; -q|--quiet) add --quiet ;; --metadata) METADATA_ONLY=1 ;; --) break ;; *) echo unknown opt "${x}" ; exit 1 ;; esac done set -x if [[ ${METADATA_ONLY} -eq 1 ]] ; then #echo /usr/bin/rsync ${RSYNC_OPTS} "$@" ${SYNC}/profiles ${PORTDIR} /usr/bin/rsync ${RSYNC_OPTS} "$@" ${SYNC}/metadata/ ${PORTDIR}/metadata/ else /usr/bin/rsync ${RSYNC_OPTS} "$@" ${SYNC} ${PORTDIR} || exit 1 /usr/bin/rsync --progress -a ${PORTDIR}/metadata/cache/ /var/cache/edb/dep${PORTDIR}/ fi