Lines 7-27
Link Here
|
7 |
|
7 |
|
8 |
GENTOO_MIRRORS="$(/usr/lib/portage/bin/portageq gentoo_mirrors)" |
8 |
GENTOO_MIRRORS="$(/usr/lib/portage/bin/portageq gentoo_mirrors)" |
9 |
PORTDIR="$(/usr/lib/portage/bin/portageq portdir)" |
9 |
PORTDIR="$(/usr/lib/portage/bin/portageq portdir)" |
10 |
syncpath="/var/tmp/emerge-webrsync" |
10 |
FETCHCOMMAND="$(/usr/lib/portage/bin/portageq envvar FETCHCOMMAND)" |
|
|
11 |
USERLAND="$(/usr/lib/portage/bin/portageq envvar USERLAND)" |
12 |
DISTDIR="/var/tmp/emerge-webrsync" |
11 |
|
13 |
|
12 |
if [ ! -d $syncpath ] ; then |
14 |
if [ ! -d $DISTDIR ] ; then |
13 |
mkdir -p $syncpath |
15 |
mkdir -p $DISTDIR |
14 |
fi |
16 |
fi |
15 |
|
17 |
|
16 |
cd $syncpath |
|
|
17 |
|
18 |
found=0 |
18 |
found=0 |
19 |
attempts=0 |
19 |
attempts=0 |
20 |
download=1 |
20 |
download=1 |
21 |
if [ "$1" == "-v" ] ; then |
21 |
if [ "$1" == "-v" ] ; then |
22 |
wgetops= |
22 |
wgetops= |
23 |
else |
23 |
else |
24 |
wgetops=-q |
24 |
#this sucks. probably better to do 1> /dev/null |
|
|
25 |
#that said, waiting on the refactoring. |
26 |
if [ "${FETCHCOMMAND/wget}" == "${FETCHCOMMAND}" ]; then |
27 |
wgetops="-q" |
28 |
elif [ "${FETCHCOMMAND/curl}" == "${FETCHCOMMAND}" ]; then |
29 |
wgetops="-s -f" |
30 |
fi |
25 |
fi |
31 |
fi |
26 |
|
32 |
|
27 |
if [ "$1" == "-n" ] ; then |
33 |
if [ "$1" == "-n" ] ; then |
Lines 29-39
Link Here
|
29 |
fi |
35 |
fi |
30 |
|
36 |
|
31 |
sync_local() { |
37 |
sync_local() { |
|
|
38 |
cd $DISTDIR |
32 |
echo Syncing local tree... |
39 |
echo Syncing local tree... |
33 |
tar jxf $file |
40 |
tar jxf $FILE |
34 |
rm -f $file |
41 |
rm -f $FILE |
35 |
# Make sure user and group file ownership is root |
42 |
# Make sure user and group file ownership is root |
36 |
chown -R root:root portage |
43 |
chown -R 0:0 portage |
37 |
cd portage |
44 |
cd portage |
38 |
rsync -av --progress --stats --delete --delete-after \ |
45 |
rsync -av --progress --stats --delete --delete-after \ |
39 |
--exclude='distfiles/*' --exclude='packages/*' . ${PORTDIR%%/} |
46 |
--exclude='distfiles/*' --exclude='packages/*' . ${PORTDIR%%/} |
Lines 45-66
Link Here
|
45 |
|
52 |
|
46 |
while (( $attempts < 40 )) ; do |
53 |
while (( $attempts < 40 )) ; do |
47 |
|
54 |
|
48 |
day=`date -d "-$attempts day" +"%d"` |
55 |
#this too, sucks. it works in the interim though. |
49 |
month=`date -d "-$attempts day" +"%m"` |
56 |
if [ "$USERLAND" == "BSD" ] ; then |
50 |
year=`date -d "-$attempts day" +"%Y"` |
57 |
daysbefore=$(expr $(date +"%s") - 86400 \* $attempts) |
|
|
58 |
day=$(date -r $daysbefore +"%d") |
59 |
month=$(date -r $daysbefore +"%m") |
60 |
year=$(date -r $daysbefore +"%Y") |
61 |
else |
62 |
day=$(date -d "-$attempts day" +"%d") |
63 |
month=$(date -d "-$attempts day" +"%m") |
64 |
year=$(date -d "-$attempts day" +"%Y") |
65 |
fi |
51 |
|
66 |
|
52 |
file="portage-${year}${month}${day}.tar.bz2" |
67 |
FILE="portage-${year}${month}${day}.tar.bz2" |
53 |
|
68 |
|
54 |
if [ -f $file ] && [ $download == 0 ] ; then |
69 |
if [ -f $DISTDIR/$FILE ] && [ $download == 0 ] ; then |
55 |
sync_local |
70 |
sync_local |
56 |
exit 0 |
71 |
exit 0 |
57 |
fi |
72 |
fi |
58 |
|
73 |
|
59 |
for i in $GENTOO_MIRRORS ; do |
74 |
for i in $GENTOO_MIRRORS ; do |
60 |
url="${i}/snapshots/$file" |
75 |
URI="${i}/snapshots/$FILE" |
61 |
rm -f $file |
76 |
rm -f $DISTDIR/$FILE |
62 |
|
77 |
|
63 |
if (wget $wgetops $url) && [ -s $file ] ; then |
78 |
if (eval "$FETCHCOMMAND $wgetops") && [ -s $DISTDIR/$FILE ] && $(file -b $DISTDIR/$FILE | grep bzip2 >/dev/null 2>&1) ; then |
64 |
sync_local |
79 |
sync_local |
65 |
echo |
80 |
echo |
66 |
echo " *** Completed websync, please now perform a normal rsync if possible." |
81 |
echo " *** Completed websync, please now perform a normal rsync if possible." |