2 # Copyright 1999-2013 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4 # Author: Brian Harring <ferringb@gentoo.org>, karltk@gentoo.org originally.
5 # Rewritten from the old, Perl-based emerge-webrsync script
10 # gpg --homedir /etc/portage/gnupg --keyserver subkeys.pgp.net --recv-keys $KEY_ID
11 # gpg --homedir /etc/portage/gnupg --edit-key $KEY_ID trust
16 # Only echo if not in verbose mode
17 nvecho() { [[ ${do_verbose} -eq 0 ]] && echo "$@" ; }
19 wecho() { echo "${argv0##*/}: warning: $*" 1>&2 ; }
21 eecho() { echo "${argv0##*/}: error: $*" 1>&2 ; }
28 # Use portageq from the same directory/prefix as the current script, so
29 # that we don't have to rely on PATH including the current EPREFIX.
30 scriptpath=${BASH_SOURCE[0]}
31 if [ -x "${scriptpath%/*}/portageq" ]; then
32 portageq=${scriptpath%/*}/portageq
33 elif type -P portageq > /dev/null ; then
36 eecho "could not find 'portageq'; aborting"
39 eval $("${portageq}" envvar -v DISTDIR EPREFIX FEATURES \
40 FETCHCOMMAND GENTOO_MIRRORS \
41 PORTAGE_BIN_PATH PORTAGE_CONFIGROOT PORTAGE_GPG_DIR \
42 PORTAGE_NICENESS PORTAGE_RSYNC_EXTRA_OPTS \
43 PORTAGE_RSYNC_OPTS PORTAGE_TMPDIR PORTDIR \
44 USERLAND http_proxy ftp_proxy)
45 export http_proxy ftp_proxy
47 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
49 if [ -z "$NICENESS_PULLED" ]; then
50 if [ -n "${PORTAGE_NICENESS}" ]; then
51 export NICENESS_PULLED=asdf
52 exec nice -n "${PORTAGE_NICENESS}" "$0" "$@"
53 echo "failed setting PORTAGE_NICENESS to '$PORTAGE_NICENESS', disabling"
57 STATE_DIR="${EPREFIX}/var/delta-webrsync/"
60 if [ "${FETCHCOMMAND/getdelta.sh}" != "${FETCHCOMMAND}" ]; then
62 eval "$(grep "^FETCHCOMMAND=" "${EPREFIX}/usr/share/portage/config/make.globals")"
78 if [[ $x == "-u" ]]; then
80 elif [[ $x == "-k" ]]; then
82 elif [[ $x == "-h" ]]; then
84 elif [[ $x == "-v" ]]; then
88 echo "$x isn't a valid arg. bailing."
90 if [[ -n $PUKE_HELP ]]; then
91 echo "-u for upgrade; sync only if new snapshots are found"
92 echo "-k for keep; keep old tree snapshots around"
97 if [[ ! -d $STATE_DIR ]]; then
98 echo "$STATE_DIR doesn't exist. don't have the ability to compensate for compressor differences without it!"
102 if has webrsync-gpg ${FEATURES} ; then
103 WEBSYNC_VERIFY_SIGNATURE=1
105 WEBSYNC_VERIFY_SIGNATURE=0
107 if [ ${WEBSYNC_VERIFY_SIGNATURE} != 0 -a -z "${PORTAGE_GPG_DIR}" ]; then
108 eecho "please set PORTAGE_GPG_DIR in make.conf"
112 [[ -d ${PORTDIR} ]] || mkdir -p "${PORTDIR}"
113 if [[ ! -w ${PORTDIR} ]] ; then
114 eecho "PORTDIR is not writable: ${PORTDIR}"
118 [[ -d ${DISTDIR} ]] || mkdir -p "${DISTDIR}"
119 if [[ ! -w ${DISTDIR} ]] ; then
120 eecho "DISTDIR is not writable: ${DISTDIR}"
124 [[ -d ${PORTAGE_TMPDIR}/portage ]] || mkdir -p "${PORTAGE_TMPDIR}/portage"
125 TMPDIR=$(mktemp -d "${PORTAGE_TMPDIR}/portage/delta-webrsync-XXXXXX")
126 if [[ ! -w ${TMPDIR} ]] ; then
127 eecho "TMPDIR is not writable: ${TMPDIR}"
135 if type -p md5sum > /dev/null; then
136 md5_com='md5sum -c "${MD5_LOC}" &> /dev/null'
137 elif type -p md5 > /dev/null; then
138 md5_com='[ "$(md5 -q ${FILE})" == "$(cut -d \ -f 1 ${MD5_LOC})" ]'
140 echo "warning, unable to do md5 verification of the snapshot!"
141 echo "no suitable md5/md5sum binary was found!"
149 cleanse_state_dir() {
150 [[ ${STATE_DIR:-/} != '/' ]] && rm -f "${STATE_DIR}"/* &> /dev/null
157 *.xz) decompressor="xzcat" ;;
158 *.bz2) decompressor="bzcat" ;;
159 *.gz) decompressor="zcat" ;;
160 *) decompressor="cat" ;;
162 ${decompressor} "${file}" | tar "$@"
163 _pipestatus=${PIPESTATUS[*]}
164 [[ ${_pipestatus// /} -eq 0 ]]
167 get_utc_date_in_seconds() {
172 local utc_time_in_secs="$1"
175 if [[ ${USERLAND} == BSD ]] ; then
176 date -r ${utc_time_in_secs} -u +"${part}"
178 date -d @${utc_time_in_secs} -u +"${part}"
182 get_utc_second_from_string() {
184 if [[ ${USERLAND} == BSD ]] ; then
185 # Specify zeros for the least significant digits, or else those
186 # digits are inherited from the current system clock time.
187 date -juf "%Y%m%d%H%M.%S" "${s}0000.00" +"%s"
189 date -d "${s:0:4}-${s:4:2}-${s:6:2}" -u +"%s"
193 get_portage_timestamp() {
194 local portage_current_timestamp=0
196 if [ -f "${PORTDIR}/metadata/timestamp.x" ]; then
197 portage_current_timestamp=$(cut -f 1 -d " " "${PORTDIR}/metadata/timestamp.x" )
200 echo "${portage_current_timestamp}"
204 local s="$1" inc="$2"
205 if [[ ${USERLAND} == BSD ]] ; then
206 # Specify zeros for the least significant digits, or else those
207 # digits are inherited from the current system clock time.
208 date -v${inc}d -juf "%Y%m%d%H%M.%S" "${s}0000.00" +"%Y%m%d"
210 date -d "${s:0:4}-${s:4:2}-${s:6:2} ${inc} day" -u +"%Y%m%d"
220 if [ "${FETCHCOMMAND/wget/}" != "${FETCHCOMMAND}" ]; then
221 opts="--continue $(nvecho -q)"
222 elif [ "${FETCHCOMMAND/curl/}" != "${FETCHCOMMAND}" ]; then
223 opts="--continue-at - $(nvecho -s -f)"
228 __vecho "Fetching file ${FILE} ..."
229 # already set DISTDIR=
230 eval "${FETCHCOMMAND} ${opts}"
231 [ -s "${DISTDIR}/${FILE}" ]
234 check_file_digest() {
239 __vecho "Checking digest ..."
241 if type -P md5sum > /dev/null; then
242 local md5sum_output=$(md5sum "${file}")
243 local digest_content=$(< "${digest}")
244 [ "${md5sum_output%%[[:space:]]*}" = "${digest_content%%[[:space:]]*}" ] && r=0
245 elif type -P md5 > /dev/null; then
246 [ "$(md5 -q "${file}")" == "$(cut -d ' ' -f 1 "${digest}")" ] && r=0
248 eecho "cannot check digest: no suitable md5/md5sum binaries found"
254 check_file_signature() {
259 if [[ ${WEBSYNC_VERIFY_SIGNATURE} != 0 ]] ; then
261 __vecho "Checking signature ..."
263 if type -P gpg > /dev/null; then
264 gpg --homedir "${PORTAGE_GPG_DIR}" --verify "$signature" "$file" && r=0
266 eecho "cannot check signature: gpg binary not found"
276 get_snapshot_timestamp() {
279 do_tar "${file}" --to-stdout -xf - portage/metadata/timestamp.x | cut -f 1 -d " "
285 __vecho "Syncing local tree ..."
287 local ownership="portage:portage"
288 if has usersync ${FEATURES} ; then
289 case "${USERLAND}" in
291 ownership=$(stat -f '%Su:%Sg' "${PORTDIR}")
294 ownership=$(stat -c '%U:%G' "${PORTDIR}")
299 if type -P tarsync > /dev/null ; then
300 local chown_opts="-o ${ownership%:*} -g ${ownership#*:}"
301 chown ${ownership} "${PORTDIR}" > /dev/null 2>&1 || chown_opts=""
302 if ! tarsync $(__vecho -v) -s 1 ${chown_opts} \
303 -e /distfiles -e /packages -e /local "${file}" "${PORTDIR}"; then
304 eecho "tarsync failed; tarball is corrupt? (${file})"
308 if ! do_tar "${file}" xf - -C "${TMPDIR}" ; then
309 eecho "tar failed to extract the image. tarball is corrupt? (${file})"
310 rm -fr "${TMPDIR}"/portage
314 local rsync_opts="${PORTAGE_RSYNC_OPTS} ${PORTAGE_RSYNC_EXTRA_OPTS}"
315 if chown ${ownership} "${TMPDIR}"/portage > /dev/null 2>&1; then
316 chown -R ${ownership} "${TMPDIR}"/portage
317 rsync_opts+=" --owner --group"
319 cd "${TMPDIR}"/portage
320 rsync ${rsync_opts} . "${PORTDIR%%/}"
323 __vecho "Cleaning up ..."
327 if has metadata-transfer ${FEATURES} ; then
328 __vecho "Updating cache ..."
329 "${PORTAGE_BIN_PATH}/emerge" --metadata
331 local post_sync=${PORTAGE_CONFIGROOT}etc/portage/bin/post_sync
332 [ -x "${post_sync}" ] && "${post_sync}"
333 # --quiet suppresses output if there are no relevant news items
334 has news ${FEATURES} && "${PORTAGE_BIN_PATH}/emerge" --check-news --quiet
339 local ignore_timestamp="$1"
344 local base_file="portage-${date}.tar"
349 local compressions=""
350 type -P bzcat > /dev/null && compressions="${compressions} bz2"
352 if [[ -z ${compressions} ]] ; then
353 eecho "unable to locate any decompressors (xzcat or bzcat or zcat)"
357 for mirror in ${GENTOO_MIRRORS} ; do
360 __vecho "Trying to retrieve ${date} snapshot from ${mirror} ..."
362 for compression in ${compressions} ; do
363 local file="portage-${date}.tar.${compression}"
364 local digest="${file}.md5sum"
365 local signature="${file}.gpgsig"
367 if [ -s "${DISTDIR}/${file}" -a -s "${DISTDIR}/${digest}" -a -s "${DISTDIR}/${signature}" ] ; then
368 check_file_digest "${DISTDIR}/${digest}" "${DISTDIR}/${file}" && \
369 check_file_signature "${DISTDIR}/${signature}" "${DISTDIR}/${file}" && \
373 if [ ${have_files} -eq 0 ] ; then
374 fetch_file "${mirror}/snapshots/${digest}" "${digest}" && \
375 fetch_file "${mirror}/snapshots/${signature}" "${signature}" && \
376 fetch_file "${mirror}/snapshots/${file}" "${file}" && \
377 check_file_digest "${DISTDIR}/${digest}" "${DISTDIR}/${file}" && \
378 check_file_signature "${DISTDIR}/${signature}" "${DISTDIR}/${file}" && \
383 # If timestamp is invalid
384 # we want to try and retrieve
385 # from a different mirror
387 if [ ${have_files} -eq 1 ]; then
389 __vecho "Getting snapshot timestamp ..."
390 local snapshot_timestamp=$(get_snapshot_timestamp "${DISTDIR}/${file}")
392 if [ ${ignore_timestamp} == 0 ]; then
393 if [ ${snapshot_timestamp} -lt $(get_portage_timestamp) ]; then
394 wecho "portage is newer than snapshot"
398 local utc_seconds=$(get_utc_second_from_string "${date}")
401 # Check that this snapshot
402 # is what it claims to be ...
404 if [ ${snapshot_timestamp} -lt ${utc_seconds} ] || \
405 [ ${snapshot_timestamp} -gt $((${utc_seconds}+ 2*86400)) ]; then
407 wecho "snapshot timestamp is not in acceptable period"
413 if [ ${have_files} -eq 1 ]; then
417 # Remove files and use a different mirror
419 rm -f "${DISTDIR}/${file}" "${DISTDIR}/${digest}" "${DISTDIR}/${signature}"
423 [ ${have_files} -eq 1 ] && break
426 if [ ${have_files} -eq 1 ]; then
427 sync_local "${DISTDIR}/${file}" && r=0
429 __vecho "${date} snapshot was not found"
435 do_latest_snapshot() {
439 __vecho "Fetching most recent snapshot ..."
441 # The snapshot for a given day is generated at 00:45 UTC on the following
442 # day, so the current day's snapshot (going by UTC time) hasn't been
443 # generated yet. Therefore, always start by looking for the previous day's
444 # snapshot (for attempts=1, subtract 1 day from the current UTC time).
446 # Timestamps that differ by less than 2 hours
447 # are considered to be approximately equal.
448 local min_time_diff=$(( 2 * 60 * 60 ))
450 local existing_timestamp=$(get_portage_timestamp)
451 local timestamp_difference
452 local timestamp_problem
453 local approx_snapshot_time
454 local start_time=$(get_utc_date_in_seconds)
455 local start_hour=$(get_date_part ${start_time} "%H")
457 # Daily snapshots are created at 00:45 and are not
458 # available until after 01:00. Don't waste time trying
459 # to fetch a snapshot before it's been created.
460 if [ ${start_hour} -lt 1 ] ; then
461 (( start_time -= 86400 ))
463 local snapshot_date=$(get_date_part ${start_time} "%Y%m%d")
464 local snapshot_date_seconds=$(get_utc_second_from_string ${snapshot_date})
466 while (( ${attempts} < 40 )) ; do
468 (( snapshot_date_seconds -= 86400 ))
469 # snapshots are created at 00:45
470 (( approx_snapshot_time = snapshot_date_seconds + 86400 + 2700 ))
471 (( timestamp_difference = existing_timestamp - approx_snapshot_time ))
472 [ ${timestamp_difference} -lt 0 ] && (( timestamp_difference = -1 * timestamp_difference ))
473 snapshot_date=$(get_date_part ${snapshot_date_seconds} "%Y%m%d")
476 if [ ${timestamp_difference} -eq 0 ]; then
477 timestamp_problem="is identical to"
478 elif [ ${timestamp_difference} -lt ${min_time_diff} ]; then
479 timestamp_problem="is possibly identical to"
480 elif [ ${approx_snapshot_time} -lt ${existing_timestamp} ] ; then
481 timestamp_problem="is newer than"
484 if [ -n "${timestamp_problem}" ]; then
485 ewarn "Latest snapshot date: ${snapshot_date}"
487 ewarn "Approximate snapshot timestamp: ${approx_snapshot_time}"
488 ewarn " Current local timestamp: ${existing_timestamp}"
490 echo -e "The current local timestamp" \
491 "${timestamp_problem} the" \
492 "timestamp of the latest" \
493 "snapshot. In order to force sync," \
494 "use the --revert option or remove" \
495 "the timestamp file located at" \
496 "'${PORTDIR}/metadata/timestamp.x'." | fmt -w 70 | \
497 while read -r line ; do
504 if do_snapshot 0 "${snapshot_date}"; then
513 fetch_from_mirrors() {
514 local i URI FILE MIRRORS
515 if [[ "$#" == 3 ]]; then
518 MIRRORS=$GENTOO_MIRRORS
521 for i in $MIRRORS ; do
523 fetch_file "${URI}" "${FILE}" && return 0
531 if [[ $# == 2 ]]; then
534 MD5_LOC="$(pwd)/$1.md5sum"
536 check_file_digest "${MD5_LOC}" "${FILE}"
539 #--------------------
540 #inline actual script
541 #--------------------
543 if ! type -p patcher &> /dev/null; then
545 echo "!!! cannot find patcher, did you emerge dev-util/diffball?"
546 echo "!!! lack of patcher == have to do full fetch"
549 if do_latest_snapshot; then
557 echo "Looking for available base versions for a delta"
559 #note we're already in distdir
562 # portage-snapshots in reverse order.
565 potentials="$(ls -1 portage-2[[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]].tar.bz2 ${STATE_DIR}/portage-2[[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]][[:digit:]].tar.bz2 2> /dev/null | sed -e 's:^.*/::' | sort -r)"
566 for basef in ${potentials}; do
569 if [ -e "${STATE_DIR}/${basef}.md5sum" ]; then
570 chksum="${STATE_DIR}/${basef}.md5sum"
571 elif [ -e "${basef}.md5sum" ]; then
572 chksum="${DISTDIR}/${basef}.md5sum"
574 echo "attempting to get md5sum for $basef"
575 if ! fetch_from_mirrors "/snapshots/${basef}.md5sum" "${basef}.md5sum"; then
576 echo "can't get md5 for ${basef}"
579 chksum="${basef}.md5sum"
581 if [ -e "${basef}" ]; then
582 dfile="${DISTDIR}/${basef}"
584 dfile="${STATE_DIR}/${basef}"
586 if ! verify_md5_file "${dfile}" "${chksum}"; then
587 echo "found a stale snapshot. cleansing"
588 rm -f "${dfile}" &> /dev/null
589 rm -f "${chksum}.md5sum" &> /dev/null
592 base_version="${basef}"
597 #by this point, we either have a base_version, or we don't.
598 if [[ -z ${base_version} ]]; then
599 echo "no base found. resorting to pulling a full version"
600 if do_latest_snapshot; then
608 #we have a md5 verified base. now we get the patch.
610 base_date="${base_version%.tar.bz2}"
611 base_date="${base_date#portage-}"
612 # we now have yyyymmdd
615 echo "fetching patches"
617 while [[ -n ${fetched} ]]; do
618 next_day=$(increment_date ${base_date} +1)
619 # if we can't get a *single* patch or md5, even one missing, do full.
620 p="snapshot-${base_date}-${next_day}.patch.bz2"
621 if [[ ! -e ${p}.md5sum ]] && ! fetch_from_mirrors "/snapshots/deltas/${p}.md5sum" "${p}.md5sum"; then
622 echo "failed fetching ${p}.md5sum"
627 if [[ -e ${p} ]]; then
628 if ! verify_md5_file "${p}"; then
629 rm -f "${p}" &> /dev/null
634 if [[ -n $fetch ]]; then
635 if ! fetch_from_mirrors "/snapshots/deltas/${p}" "${p}"; then
636 echo "failed fetching ${p}"
640 if [[ -z ${fetched} ]]; then
643 if ! verify_md5_file "${p}"; then
644 echo "md5 failed on ${p}"
648 patches="${patches} ${p}"
649 base_date="${next_day}"
651 final_date=${base_date}
653 if [[ -z $patches ]]; then
654 echo "no patches found? up to date?"
655 if [[ -n $MUST_SYNC ]]; then
656 echo "syncing with existing file"
657 if [[ ${WEBSYNC_VERIFY_SIGNATURE} == 1 &&
658 ! -e ${DISTDIR}/portage-${base_date}.tar.bz2.gpgsig ]] && \
659 ! fetch_from_mirrors "/snapshots/portage-${base_date}.tar.bz2.gpgsig" "portage-${base_date}.tar.bz2.gpgsig" ; then
660 eecho "Couldn't fetch portage-${base_date}.tar.bz2.gpgsig"
663 if [[ ${WEBSYNC_VERIFY_SIGNATURE} == 1 ]] ; then
664 check_file_signature "${DISTDIR}/portage-${base_date}.tar.bz2.gpgsig" "${dfile}" || exit 1
666 sync_local "${dfile}" && rm -fr "${TMPDIR}"
674 #grab the md5 for later usage.
675 if [[ ! -e portage-${final_date}.tar.bz2.md5sum ]] && ! fetch_from_mirrors "/snapshots/portage-${final_date}.tar.bz2.md5sum" "portage-${final_date}.tar.bz2.md5sum"; then
676 echo "warning... couldn't grab the md5sum for ${final_date}. which is odd"
677 echo "thus, bailing (sorry)"
680 if [[ ! -e portage-${final_date}.tar.bz2.umd5sum ]] && ! fetch_from_mirrors "/snapshots/portage-${final_date}.tar.bz2.umd5sum" "portage-${final_date}.tar.bz2.umd5sum"; then
681 if ! fetch_from_mirrors "/snapshots/portage-${final_date}.tar.bz2.umd5sum" "portage-${final_date}.tar.bz2.umd5sum"; then
682 echo "couldn't grab umd5sum (uncompressed md5sum) for ${final_date}."
683 echo "can't compensate for bzip2 version differences iow."
692 if [[ ${WEBSYNC_VERIFY_SIGNATURE} == 1 && ! -e portage-${final_date}.tar.bz2.gpgsig ]] && \
693 ! fetch_from_mirrors "/snapshots/portage-${final_date}.tar.bz2.gpgsig" "portage-${final_date}.tar.bz2.gpgsig" ; then
694 echo "warning... couldn't grab the gpgsig for ${final_date}. which is odd"
695 echo "thus, bailing (sorry)"
700 if ! patcher -v "${dfile}" ${patches} "${TMPDIR}/portage-${final_date}.tar"; then
701 echo "reconstruction failed (contact the author with the error from the reconstructor please)"
702 rm -f "${TMPDIR}/portage-${final_date}.tar"
703 if do_latest_snapshot; then
711 if [[ -n $got_umd5 ]]; then
712 echo "verifying uncompressed md5"
713 if ! verify_md5_file "${TMPDIR}/portage-${final_date}.tar" "${DISTDIR}/portage-${final_date}.tar.bz2.umd5sum"; then
714 echo "uncompressed verification failed. This means either you found a bug in diffball, or something odd is going on"
715 echo "with upstream patch generation"
716 echo "trying md5sum next, which probably will fail."
723 if [ "$verified" == "1" ]; then
725 if [[ ${WEBSYNC_VERIFY_SIGNATURE} == 1 ]] ; then
726 # BUG: Signature verification will fail if the local bzip2
727 # program does not produce output that is perfectly identical
728 # to the bzip2 program used to compress the signed tar file.
729 echo "recompressing ..."
730 bzip2 -vk9 "${TMPDIR}/portage-${final_date}.tar"
731 check_file_signature "${DISTDIR}/portage-${final_date}.tar.bz2.gpgsig" "${TMPDIR}/portage-${final_date}.tar.bz2" || exit 1
733 echo "recompressing. (backgrounding)"
734 bzip2 -vk9 "${TMPDIR}/portage-${final_date}.tar" &
737 echo "beginning update to the tree"
738 sync_local "${TMPDIR}/portage-${final_date}.tar"
739 echo "doing final md5 stuff"
741 # bzip2 is finished now.
742 rm -f "${TMPDIR}/portage-${final_date}.tar"
744 echo "recompressing."
745 bzip2 -v9 "${TMPDIR}/portage-${final_date}.tar.bz2"
748 echo "verifying generated tarball"
750 if ! verify_md5_file "${TMPDIR}/portage-${final_date}.tar.bz2" "${DISTDIR}/portage-${final_date}.tar.bz2.md5sum"; then
751 if [[ -z $verified ]]; then
752 echo "couldn't verify the generated tarball. bug, most likely."
755 # hokay. md5 doesn't agree with umd5. bzip2 issue in effect.
756 echo "compressed md5 differs, but uncompressed md5 says it right. bzip2 version incompatability in other words"
757 echo "saving the md5"
758 if type -p md5sum &> /dev/null; then
759 md5sum "${TMPDIR}/portage-${final_date}.tar.bz2" | sed -e "s:${TMPDIR}/\?::" > \
760 "${STATE_DIR}/portage-${final_date}.tar.bz2.md5sum"
761 elif type -p md5 &> /dev/null; then
762 echo "$(md5 -q "${TMPDIR}/portage-${final_date}.tar.bz2") portage-${final_date}.tar.bz2" > \
763 "${STATE_DIR}/portage-${final_date}.tar.bz2.md5sum"
765 echo "couldn't find either md5 or md5sum. something is screwed... (bailing, sorry)"
768 mv "${DISTDIR}/portage-${final_date}.tar.bz2.umd5sum" "${TMPDIR}/portage-${final_date}.tar.bz2" "${STATE_DIR}/"
769 dfile="${STATE_DIR}/portage-${final_date}.tar.bz2"
771 dfile="${DISTDIR}/portage-${final_date}.tar.bz2"
772 mv "${TMPDIR}/portage-${final_date}.tar.bz2" "${DISTDIR}/"
775 if [ -z "${need_last_sync}" ]; then
776 if [[ ${WEBSYNC_VERIFY_SIGNATURE} == 1 ]] ; then
777 check_file_signature "${DISTDIR}/portage-${final_date}.tar.bz2.gpgsig" "${dfile}" || exit 1
779 echo "beginning update to the tree"
780 sync_local "${dfile}"
783 if [[ -z $KEEP_OLDIES ]]; then
785 for x in $potentials; do
787 rm -f "${DISTDIR}/${x}"{,.md5sum,.umd5sum,.gpgsig} &> /dev/null
788 rm -f "${STATE_DIR}/${x}"{,.md5sum,.umd5sum} &> /dev/null