From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 1D2FC1381F4 for ; Wed, 15 Aug 2012 01:04:03 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2FCBE21C010; Wed, 15 Aug 2012 01:03:53 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id E6C2521C010 for ; Wed, 15 Aug 2012 01:03:52 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D34AF1B4063 for ; Wed, 15 Aug 2012 01:03:51 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id B25E4E543A for ; Wed, 15 Aug 2012 01:03:49 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1344992602.644c0dd5daad47b6392d99c706afaea56e17ee31.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/emerge-webrsync X-VCS-Directories: bin/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 644c0dd5daad47b6392d99c706afaea56e17ee31 X-VCS-Branch: master Date: Wed, 15 Aug 2012 01:03:49 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 173142e2-ca0d-47ef-b8c7-74de62d9a566 X-Archives-Hash: 581e8a9075c3cee31c63b088994b8376 commit: 644c0dd5daad47b6392d99c706afaea56e17ee31 Author: Zac Medico gentoo org> AuthorDate: Wed Aug 15 01:03:22 2012 +0000 Commit: Zac Medico gentoo org> CommitDate: Wed Aug 15 01:03:22 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=644c0dd5 emerge-webrsync: add -k/--keep option --- bin/emerge-webrsync | 39 ++++++++++++++++++++++++--------------- 1 files changed, 24 insertions(+), 15 deletions(-) diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync index 47d4519..57e3052 100755 --- a/bin/emerge-webrsync +++ b/bin/emerge-webrsync @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # Author: Karl Trygve Kalleberg # Rewritten from the old, Perl-based emerge-webrsync script @@ -39,11 +39,10 @@ else eecho "could not find 'portageq'; aborting" exit 1 fi -eval $("${portageq}" envvar -v FEATURES FETCHCOMMAND GENTOO_MIRRORS \ +eval $("${portageq}" envvar -v DISTDIR FEATURES FETCHCOMMAND GENTOO_MIRRORS \ PORTAGE_BIN_PATH PORTAGE_GPG_DIR \ PORTAGE_NICENESS PORTAGE_RSYNC_EXTRA_OPTS PORTAGE_TMPDIR PORTDIR \ SYNC http_proxy ftp_proxy) -DISTDIR="${PORTAGE_TMPDIR}/emerge-webrsync" export http_proxy ftp_proxy # If PORTAGE_NICENESS is overriden via the env then it will @@ -56,6 +55,7 @@ source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1 do_verbose=0 do_debug=0 +keep=false if has webrsync-gpg ${FEATURES} ; then WEBSYNC_VERIFY_SIGNATURE=1 @@ -131,7 +131,7 @@ fetch_file() { vecho "Fetching file ${FILE} ..." # already set DISTDIR= eval "${FETCHCOMMAND}" ${opts} - [ -s "${FILE}" ] + [ -s "${DISTDIR}/${FILE}" ] } check_file_digest() { @@ -142,7 +142,9 @@ check_file_digest() { vecho "Checking digest ..." if type -P md5sum > /dev/null; then - md5sum -c $digest && r=0 + local md5sum_output=$(md5sum "${file}") + local digest_content=$(< "${digest}") + [ "${md5sum_output%%[[:space:]]*}" = "${digest_content%%[[:space:]]*}" ] && r=0 elif type -P md5 > /dev/null; then [ "$(md5 -q "${file}")" == "$(cut -d ' ' -f 1 "${digest}")" ] && r=0 else @@ -201,7 +203,7 @@ sync_local() { fi # Free disk space - rm -f "${file}" + ${keep} || rm -f "${file}" chown portage:portage portage > /dev/null 2>&1 && \ chown -R portage:portage portage @@ -251,6 +253,7 @@ do_snapshot() { for mirror in ${GENTOO_MIRRORS} ; do + mirror=${mirror%/} vecho "Trying to retrieve ${date} snapshot from ${mirror} ..." for compression in ${compressions} ; do @@ -258,7 +261,7 @@ do_snapshot() { local digest="${file}.md5sum" local signature="${file}.gpgsig" - if [ -s "${file}" -a -s "${digest}" -a -s "${signature}" ] ; then + if [ -s "${DISTDIR}/${file}" -a -s "${DISTDIR}/${digest}" -a -s "${DISTDIR}/${signature}" ] ; then check_file_digest "${DISTDIR}/${digest}" "${DISTDIR}/${file}" && \ check_file_signature "${DISTDIR}/${signature}" "${DISTDIR}/${file}" && \ have_files=1 @@ -281,7 +284,7 @@ do_snapshot() { if [ ${have_files} -eq 1 ]; then vecho "Getting snapshot timestamp ..." - local snapshot_timestamp=$(get_snapshot_timestamp "${file}") + local snapshot_timestamp=$(get_snapshot_timestamp "${DISTDIR}/${file}") if [ ${ignore_timestamp} == 0 ]; then if [ ${snapshot_timestamp} -lt $(get_portage_timestamp) ]; then @@ -310,7 +313,7 @@ do_snapshot() { # # Remove files and use a different mirror # - rm -f "${file}" "${digest}" "${signature}" + rm -f "${DISTDIR}/${file}" "${DISTDIR}/${digest}" "${DISTDIR}/${signature}" fi done @@ -318,12 +321,12 @@ do_snapshot() { done if [ ${have_files} -eq 1 ]; then - sync_local "${file}" && r=0 + sync_local "${DISTDIR}/${file}" && r=0 else vecho "${date} snapshot was not found" fi - - rm -f "${file}" "${digest}" "${signature}" + + ${keep} || rm -f "${DISTDIR}/${file}" "${DISTDIR}/${digest}" "${DISTDIR}/${signature}" return "${r}" } @@ -411,6 +414,7 @@ usage() { Options: --revert=yyyymmdd Revert to snapshot + -k, --keep Keep snapshots in DISTDIR (don't delete) -q, --quiet Only output errors -v, --verbose Enable verbose output -x, --debug Enable debug output @@ -427,14 +431,12 @@ usage() { main() { local arg local revert_date - - [ ! -d "${DISTDIR}" ] && mkdir -p "${DISTDIR}" - cd "${DISTDIR}" for arg in "$@" ; do local v=${arg#*=} case ${arg} in -h|--help) usage ;; + -k|--keep) keep=true ;; -q|--quiet) PORTAGE_QUIET=1 ;; -v|--verbose) do_verbose=1 ;; -x|--debug) do_debug=1 ;; @@ -443,6 +445,13 @@ main() { esac done + TMPDIR=${PORTAGE_TMPDIR}/emerge-webrsync + ${keep} || DISTDIR=${TMPDIR} + + [ ! -d "${TMPDIR}" ] && mkdir -p "${TMPDIR}" + [ ! -d "${DISTDIR}" ] && mkdir -p "${DISTDIR}" + cd "${TMPDIR}" || exit 1 + # This is a sanity check to help prevent people like funtoo users # from accidentally wiping out their git tree. if [[ -n $SYNC && ${SYNC#rsync:} = $SYNC ]] ; then