--- emerge-webrsync.orig Thu Jul 22 03:03:41 2004 +++ emerge-webrsync.orig Thu Jul 22 04:05:17 2004 @@ -7,6 +7,7 @@ GENTOO_MIRRORS="$(/usr/lib/portage/bin/portageq gentoo_mirrors)" PORTDIR="$(/usr/lib/portage/bin/portageq portdir)" +USERLAND="$(/usr/lib/portage/bin/portageq envvar USERLAND)" syncpath="/var/tmp/emerge-webrsync" if [ ! -d $syncpath ] ; then @@ -18,10 +19,20 @@ found=0 attempts=0 download=1 +if which wget >/dev/null 2>&1 ; then + fetchcommand="wget" +else + fetchcommand="curl -O" +fi + if [ "$1" == "-v" ] ; then - wgetops= + opts= else - wgetops=-q + case $fetchcommand in + wget) opts=-q ;; + curl) opts=-s ;; + *) opts= ;; + esac fi if [ "$1" == "-n" ] ; then @@ -33,7 +44,8 @@ tar jxf $file rm -f $file # Make sure user and group file ownership is root - chown -R root:root portage + # Specify with numeric expression because of Mac OS X + chown -R 0:0 portage cd portage rsync -av --progress --stats --delete --delete-after \ --exclude='distfiles/*' --exclude='packages/*' . ${PORTDIR%%/} @@ -45,13 +57,21 @@ while (( $attempts < 40 )) ; do - day=`date -d "-$attempts day" +"%d"` - month=`date -d "-$attempts day" +"%m"` - year=`date -d "-$attempts day" +"%Y"` + if [ "$USERLAND" == "BSD" ] ; then + daysbefore=$(expr $(date +"%s") - 86400 \* $attempts) + + day=$(date -r $daysbefore +"%d") + month=$(date -r $daysbefore +"%m") + year=$(date -r $daysbefore +"%Y") + else + day=$(date -d "-$attempts day" +"%d") + month=$(date -d "-$attempts day" +"%m") + year=$(date -d "-$attempts day" +"%Y") + fi file="portage-${year}${month}${day}.tar.bz2" - if [ -f $file ] && [ $download == 0 ] ; then + if [ -f "$file" ] && [ "$download" == 0 ] ; then sync_local exit 0 fi @@ -60,7 +80,7 @@ url="${i}/snapshots/$file" rm -f $file - if (wget $wgetops $url) && [ -s $file ] ; then + if ($fetchcommand $opts $url) && [ -s $file ] ; then sync_local echo echo " *** Completed websync, please now perform a normal rsync if possible."