#!/bin/bash [ "${FLOCKER}" != "$0" ] && exec env FLOCKER="$0" flock -en "$0" "$0" "$@" || : logdir="/var/log" sync_log="${logdir}/rsync.log" up_log="${logdir}/emerge-updates.log" GS_SYNC=true GS_RSYNC=false GS_EUPDATEDB=true GS_FETCH=false GS_UPWORLD=true GS_LAYMAN=true conf="/etc/gentoo-sync.conf" [[ -e ${conf} ]] && . "${conf}" export NOCOLOR=true ( date if ${GS_RSYNC} ; then # For slow systems, run rsync directly. for f in make.globals make.conf ; do for d in /etc /etc/portage /usr/share/portage/config ; do f="${d}/make.globals" [[ -e ${f} ]] && . ${f} && break done done > "${up_log}" : ${PORTAGE_RSYNC_OPTS:=-azO --delete --exclude=/distfiles --exclude=/local --exclude=/packages} : ${SYNC:=rsync://rsync.gentoo.org/gentoo-portage} : ${PORTDIR:=/usr/portage} exec rsync ${PORTAGE_RSYNC_OPTS} ${PORTAGE_RSYNC_EXTRA_OPTS} ${SYNC}/ ${PORTDIR}/ >& "${sync_log}" fi if ${GS_SYNC} ; then emerge --sync -q date ${GS_EUPDATEDB} && $(type -P eupdatedb) date ${GS_LAYMAN} && l=$(type -P layman) && ${l} -S -q date ${GS_FETCH} && emerge world -Duf #q -qr fi date ) >& ${sync_log} if ${GS_UPWORLD} ; then ( eval $(portageq envvar -v PORTDIR) cd "${PORTDIR}" bad_pkgs=() good_pkgs=() for p in `qlist -ICS` ; do if [[ -d ${p%:*} ]] ; then good_pkgs+=( ${p} ) else bad_pkgs+=( ${p} ) fi done if [[ ${#bad_pkgs[@]} -gt 0 ]] ; then echo 'These packages no longer exist:' printf '\t%s\n' "${bad_pkgs[@]}" echo fi echo 'emerge -u1 --keep-going $(awk '\''$2 ~ /\// {print $2}'\'' '${up_log}')' emerge ${good_pkgs[*]} -upq --cols ) >& ${up_log} fi