From owner-freebsd-ports-bugs@FreeBSD.ORG Sat Feb 9 13:50:02 2008 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CB1E316A41B for ; Sat, 9 Feb 2008 13:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id ABB5E13C45B for ; Sat, 9 Feb 2008 13:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m19Do2Jf099102 for ; Sat, 9 Feb 2008 13:50:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m19Do2WL099101; Sat, 9 Feb 2008 13:50:02 GMT (envelope-from gnats) Resent-Date: Sat, 9 Feb 2008 13:50:02 GMT Resent-Message-Id: <200802091350.m19Do2WL099101@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Anton Statutov Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 813B716A496 for ; Sat, 9 Feb 2008 13:46:06 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 7127B13C442 for ; Sat, 9 Feb 2008 13:46:06 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m19DhvG4000781 for ; Sat, 9 Feb 2008 13:43:57 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.2/8.14.1/Submit) id m19Dhv25000780; Sat, 9 Feb 2008 13:43:57 GMT (envelope-from nobody) Message-Id: <200802091343.m19Dhv25000780@www.freebsd.org> Date: Sat, 9 Feb 2008 13:43:57 GMT From: Anton Statutov To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/120463: new port X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Feb 2008 13:50:02 -0000 >Number: 120463 >Category: ports >Synopsis: new port >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Feb 09 13:50:02 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Anton Statutov >Release: 6.2 >Organization: BeStyle Ltd >Environment: FreeBSD stant.bs 6.2-RELEASE-p7 FreeBSD 6.2-RELEASE-p7 #0: Sun Nov 18 04:51:07 MSK 2007 stant@stant.bs:/usr/obj/usr/src/sys/WORKSTATION i386 >Description: This is port of Gentoo getdelta.sh. Getdelta uses Deltup to reduce bandwidth load while upgrading ports distfiles. >How-To-Repeat: >Fix: Patch attached with submission follows: # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # /usr/ports/sysutils/getdelta # /usr/ports/sysutils/getdelta/files # /usr/ports/sysutils/getdelta/files/patch-getdelta.sh # /usr/ports/sysutils/getdelta/Makefile # /usr/ports/sysutils/getdelta/pkg-descr # /usr/ports/sysutils/getdelta/pkg-message # /usr/ports/sysutils/getdelta/pkg-plist # /usr/ports/sysutils/getdelta/distinfo # echo c - /usr/ports/sysutils/getdelta mkdir -p /usr/ports/sysutils/getdelta > /dev/null 2>&1 echo c - /usr/ports/sysutils/getdelta/files mkdir -p /usr/ports/sysutils/getdelta/files > /dev/null 2>&1 echo x - /usr/ports/sysutils/getdelta/files/patch-getdelta.sh sed 's/^X//' >/usr/ports/sysutils/getdelta/files/patch-getdelta.sh << 'END-of-/usr/ports/sysutils/getdelta/files/patch-getdelta.sh' X--- getdelta.sh.orig Fri Jul 13 20:30:26 2007 X+++ getdelta.sh Sat Feb 9 14:02:17 2008 X@@ -1,7 +1,7 @@ X-#!/bin/sh X-# getdelta.sh X-# A download-wrapper script for gentoo that tries to get dtu files X-# created by deltup instead of downloading complete source-files X+#!/usr/local/bin/bash X+# getdelta.sh X+# A download-wrapper script for gentoo that tries to get dtu files X+# created by deltup instead of downloading complete source-files X # to save bandwidth. X # X # (C) 2004-2007 Nicolai Lissner X@@ -25,12 +25,17 @@ X VERSION="0.7" X X # Changelog X+# version 0.7.8-freebsd 2009/02/09 by Anton Statutov stant@bestyle.ru X+# - replaced "stat -c %s" to "stat -f "%z" X+# - replaced "/etc/deltup" to "/usr/local/etc/deltup" X+# - replaced $1 to $2 because $1 is the size of file on freebsd X+# - some minor changes X # version 0.7.8 2007/07/13 X # - added option -O to call of emerge when finding mirrors X # - replaced some calls of coreutils with bash-internals X # - removed some unnecessary code X # version 0.7.7 2007/01/30 X-# - added support for more than one local mirror in getdelta.rc X+# - added support for more than one local mirror in getdelta.rc X # thanks to Alexander Polozov, who sent me the patch for this X # version 0.7.6 2006/10/08 X # - fixed a typo - thanks to Andrey, who reported this problem in gentoo bug #150426 X@@ -39,7 +44,7 @@ X # if configured it will reduce the waiting timeout to the expected download-time (based on size of old version) X # version 0.7.4 2006/09/06 X # - do not remove log file but reset only to make this work with FEATURE userfetch X-# version 0.7.3 X+# version 0.7.3 X # 2006/09/01 X # - fixed a bug in detection of original url (sometimes no url was found) X # version 0.7.2 X@@ -48,25 +53,25 @@ X # version 0.7.1 X # 2006/08/08 X # - fixed a problem in counting differences in filenames (aka bug #105011) X-# - X+# - X # version 0.7 X # 2005/05/09 X # - servers create dtu files based on bdelta instead of xdelta X # this happens for two reasons: smaller dtu-files and amd64-compatibilty X # (yes, it's true - welcome to all new amd64 users of the servers) X-# this is the reason for major update - and update forcing - you really X+# this is the reason for major update - and update forcing - you really X # NEED bdelta now to use the servers, while you do *not* need xdelta anymore :) X # - integrity change of old candidate is optional now and *disabled* by default X # if you want this time consuming "safe way" re-enable it via the config-file X-# - added some files to DO_NOT_REMOVE file X+# - added some files to DO_NOT_REMOVE file X # - added "&time=" to prevent ANY proxy from returning results from cache X # instead of asking the server - the server does not use this parameter - it just X # exists to create unique request-URLS (as proposed by bodo "bothie" thiesen) X # version 0.6.9 2005/03/11 X-# ­ exit with exitcode of wget to signal to portage if X+# � exit with exitcode of wget to signal to portage if X # download was successful X # - handle metadata.dtd as exception (repoman uses FETCHCOMMAND) X-# - you can disable fetching of dtu-files now by setting X+# - you can disable fetching of dtu-files now by setting X # the environment variable GETDELTA=0 X # version 0.6.8 2005/01/09 X # - init frontmatch and backmatch with 0 (thanks, Torsten Veller) X@@ -85,7 +90,7 @@ X # - inserted "break" to the TSTAMP>=QTMOUNT condition, too X # (reported by Torsten Veller) X # version 0.6.3 2004/11/08 X-# - added "^bash" and "^gtk-engines" to the default X+# - added "^bash" and "^gtk-engines" to the default X # do_not_remove file X # - inserted a "break" to prevent infinite looping X # when the server returns a queueposition higher than X@@ -96,16 +101,16 @@ X # version 0.6.1 2004/10/18 X # - give better original URL to the server X # - enhanced detection of former version (thanks to Jimmy Wennlund) X-# - the COLOR variable didn't work since 0.5.3, because X+# - the COLOR variable didn't work since 0.5.3, because X # the config file was not read before evaluating the variable X # - check, if the user have set RESUMECOMMAND to getdelta.sh X # and if so complain about this X # X # version 0.6 2004/10/12 X # - dropped the client-side mirror-detection X-# - Jimmy Wennlund sent me patch to X-# make getdelta.sh work in an own tempdir and to X-# remove any temporary files even when user pressed X+# - Jimmy Wennlund sent me patch to X+# make getdelta.sh work in an own tempdir and to X+# remove any temporary files even when user pressed X # ctrl-c -- I really like that. Thanks, Jimmy. X # version 0.5.4 2004/10/11 X # - fixed a security leak (possible symlink attack) X@@ -118,14 +123,14 @@ X # - fixed wrong path-detection with thirdpartymirrors X # version 0.5.3.3 2004/09/12 X # - changed the way the script finds the mirror-group to use X-# - setting GENTOO_MIRRORS="" is *not* necessary anymore X+# - setting GENTOO_MIRRORS="" is *not* necessary anymore X # removed check and warning about that X # version 0.5.3.2 2004/09/12 X # - fixed a bug in the ouput of remove() (thx to wiebel) X # version 0.5.3.1 2004/09/12 X-# - fixed a typo (FILESDIR) X+# - fixed a typo (FILESDIR) X # - fixed a missing "]" X-# version 0.5.3 2004/09/12 X+# version 0.5.3 2004/09/12 X # - some code cleanups X # - use a separated config file now X # - old file in DISTDIR is tested on corruption before trying to download a dtu X@@ -137,7 +142,7 @@ X # - added MAXIMUM_ACCEPTABLE_QUEUEPOS X # version 0.5.2.3 2004/09/06 X # - new variable QUERY_RETRY X-# - dont remove file added X+# - dont remove file added X # version 0.5.2.2 2004/08/30 X # - fixed a typo X # version 0.5.2.1 2004/08/29 X@@ -147,14 +152,14 @@ X # - server sends a queued-message including queue-position now X # show this. X # version 0.5.1 2003/08/24 X-# - for some reason a "broken pipe" message appears when X-# this script is called by portage/python, caused by X+# - for some reason a "broken pipe" message appears when X+# this script is called by portage/python, caused by X # "ls -c|head -n1" - Ok, that *IS* a broken pipe, "head" X # would not read anything more than 1 line, but I do not X # really understand, why it does not happen when the script X # is called manually -- ANY use of "head" in a pipe-construction X-# would result in a "broken-pipe", but bash itself never X-# complains about that. a cosmetic change to make the X+# would result in a "broken-pipe", but bash itself never X+# complains about that. a cosmetic change to make the X # output clean and the script-code ugly :-/ X # version 0.5.0 2003/08/21 X # - the exception handling for kde changed to the server X@@ -165,7 +170,7 @@ X # the deltup-server queues requests now X # and sends back a document "deltup-queued" X # the client then waits 10 seconds and tries X-# again until it either gets the dtu or a file X+# again until it either gets the dtu or a file X # named *.failed X # version 0.3.3 2003/05/06 X # transmit version to server X@@ -208,7 +213,9 @@ X # This file: # X #################################################### X X-GETDELTA_CONFIGFILE=/etc/deltup/getdelta.rc X+PREFIX=/usr/local X+DISTDIR=/usr/ports/distfiles X+GETDELTA_CONFIGFILE="${PREFIX}/etc/deltup/getdelta.rc" X # X X splitversion(){ X@@ -251,14 +258,14 @@ X ;; X [[:alpha:]]) X calced=0 X- if [ "${x[$i]:0:3}" = "pre" ] X+ if [ "${x[$i]:0:3}" = "pre" ] X then X vs=${x[$i]:3} X let vser=0x${vser}00-40+${vs:-0} X vser=$(printf "%02x" $vser) X calced=1 X fi X- if [ "${x[$i]:0:2}" = "rc" ] X+ if [ "${x[$i]:0:2}" = "rc" ] X then X vs=${x[$i]:2} X let vser=0x${vser}00-40+${vs:-0} X@@ -271,7 +278,7 @@ X let vser=0x${vser}00-80+${vs:-0} X vser=$(printf "%02x" $vser) X calced=1 X- fi X+ fi X if [ "${x[$i]:0:4}" = "beta" ] X then X vs=${x[$i]:4} X@@ -279,7 +286,7 @@ X vser=$(printf "%02x" $vser) X calced=1 X fi X- if [ "$calced" = "0" ] X+ if [ "$calced" = "0" ] X then X vs=$(echo -n ${x[$i]} | od -t x1 | head -n1| cut -d" " -f2-| tr -d " ") X vser="${vser}${vs}" X@@ -308,21 +315,21 @@ X then X echo -e "\n# ${3}\n${1}=\"${2}\"" >>$GETDELTA_CONFIGFILE X output "${CYAN}Added new variable ${YELLOW}$1${CYAN} to config file ${GETDELTA_CONFIGFILE}\n" X- output "please check if it fits your needs\n" X+ output "please check if it fits your needs\n" X fi X } X X # this checks for an entry in our do_not_remove-file and adds it if does not exist X # $1 is the name (as grep regexp) of the file not to be removed X add_to_donotremove() { X- X+ X if ! grep -q "^${1}" $DO_NOT_REMOVE X then X echo "${1}" >>$DO_NOT_REMOVE X output "${CYAN}Added new grep-regex \"${1}\" to config file ${DO_NOT_REMOVE}\n" X fi X } X- X+ X X remove() { X output "${GREEN}You have chosen to remove ${CYAN}$1\n" X@@ -351,20 +358,20 @@ X -e "s/src6/srcFFF/g" \ X -e "s/src7/srcGGG/g" <<< $MASK_FILENAME) X fi X- X+ X # ignore PR for src-files of firefox X if [ "${MASK_FILENAME:0:7}" = "firefox" ] X then X MASK_FILENAME="${MASK_FILENAME//PR}" X fi X- X+ X # ignore "try" with new mplayer X if [ "${MASK_FILENAME:0:7}" = "MPlayer" ] X then X MASK_FILENAME="${MASK_FILENAME//try}" X fi X- X- X+ X+ X # ignore some strings in any filename X echo $(sed -e "s/\.bz2$//g" \ X -e "s/\.gz$//g" \ X@@ -383,13 +390,13 @@ X add_to_configfile KDE_MIRROR "ftp://ftp.kde.org/pub/kde/stable" "we de not get kde-deltas from a delta-up-server, since kde provides own xdelta-files" X add_to_configfile LOCAL_MIRROR "" "set this to one or more (space separated) URI ending with '/' if you want to check one or more local mirror(s) first\n# most people just leave it empty." X add_to_configfile DELTUP_SERVER "http://linux01.gwdg.de/~nlissne/deltup.php" "deltup-server to use" X-add_to_configfile FETCH "/usr/bin/wget -t 1 --passive-ftp" "command to use for downloading" X+add_to_configfile FETCH "${PREFIX}/bin/wget -t 1 --passive-ftp" "command to use for downloading" X add_to_configfile QUEUERETRY 15 "number of seconds to wait before a queued request is retried" X add_to_configfile MAXIMUM_ACCEPTABLE_QUEUEPOS "15" "the maximum queuepos you would accept (if higher download full archive instead)" X add_to_configfile QUEUETIMEOUT 900 "when a dtu-request is queued - how long should we wait max. before downloading the original archive instead (in seconds)" X add_to_configfile CHECK_OLD_FILE "false" "set to \"true\", if you want getdelta.sh to use Pkunk's integrity check for the old file before downloading dtu-files" X add_to_configfile REMOVE_OLD "false" "set to \"true\", if you want getdelta.sh to delete the old file, if patch was succesful" X-add_to_configfile DO_NOT_REMOVE "/etc/deltup/do_not_remove" "a list of files not to be removed by REMOVE_OLD feature" X+add_to_configfile DO_NOT_REMOVE "${PREFIX}/etc/deltup/do_not_remove" "a list of files not to be removed by REMOVE_OLD feature" X add_to_configfile REMOVE_INCOMPLETE_OLD_FILES "false" "set this to \"true\" if you want getdelta.sh to delete old versions that seems to be corrupt,\n# or to \"false\" if you want to delete them manually\n# note: getdelta.sh will not use these files anyway" X add_to_configfile VERBOSITY true "set to \"true\", if you want verbose outputs (later to be set to a level [0-3])" X add_to_configfile COLOR true "set to \"true\", if you want colorful messages, \"false\" if not." X@@ -402,12 +409,12 @@ X source $GETDELTA_CONFIGFILE X X # create or update DO_NOT_REMOVE file X-# these files have "old" versions that are needed to build the new versions X+# these files have "old" versions that are needed to build the new versions X # so they should never removed by the REMOVE_OLD feature X DO_NOT_REMOVE_DIR=$(dirname $DO_NOT_REMOVE) X-if [ ! -e $DO_NOT_REMOVE ] X-then X- mkdir -p $DO_NOT_REMOVE_DIR X+if [ ! -e $DO_NOT_REMOVE ] X+then X+ mkdir -p $DO_NOT_REMOVE_DIR X echo "# This file contains regexp in 'grep-style' for files that should not be removed" >$DO_NOT_REMOVE X echo "# if REMOVE_OLD is set to 'true'" >>$DO_NOT_REMOVE X echo "# Some examples (actually these files are known to result" >>$DO_NOT_REMOVE X@@ -424,7 +431,7 @@ X add_to_donotremove "^rp-pppoe" X X X-if [ -z $1 ] X+if [ -z "$1" ] X then X COLOR=true X echo -e "${YELLOW}getdelta.sh version ${VERSION}" X@@ -435,13 +442,13 @@ X echo -e "\n${YELLOW}There is a config-file ${CYAN}${GETDELTA_CONFIGFILE}${YELLOW} with some variables to control the behaviour of this script." X echo -e "Edit it to your needs.${NORMAL}" X exit 1 X-fi X-# include variables from gentoo make.globals and make.conf X-source /etc/make.globals X+fi X+# include variables from freebsd make.globals and make.conf X+#source /etc/make.globals X source /etc/make.conf X X X-if ${COLOR} X+if ${COLOR} X then X RED="\033[01;31m" X GREEN="\033[01;32m" X@@ -459,14 +466,15 @@ X CYAN="" X NORMAL="" X fi X-grep -q "getdelta.sh" <<< "${RESUMECOMMAND}" && X- output "${RED}do NOT set RESUMECOMMAND to use getdelta.sh" && X+grep -q "getdelta.sh" <<< "${RESUMECOMMAND}" && X+ output "${RED}do NOT set RESUMECOMMAND to use getdelta.sh" && X output "use getdelta.sh for your FETCHCOMMAND, only." && X sleep 5 && exit 1 X X pushd $DISTDIR >/dev/null 2>/dev/null X-ORIG_URI=$1 X-NEW_FILE=$(basename $ORIG_URI) X+ORIG_URI=$2 X+output "${GREEN} Original URI: ${YELLOW}${ORIG_URI}" X+NEW_FILE=$(basename "$ORIG_URI") X X # repoman downloads metadata.dtd with FETCHCOMMAND X # this should not be done with getdelta - so just fetch the file and exit X@@ -495,8 +503,8 @@ X for localn in $LOCAL_MIRROR X do X output "${YELLOW}Trying to get ${CYAN}${NEW_FILE}${YELLOW} from local mirror ${CYAN}${localn}\n" X- if $FETCH "${localn}${NEW_FILE}" X- then X+ if $FETCH "${localn}${NEW_FILE}" X+ then X output "${GREEN}success.\n" X exit 0 X else X@@ -508,11 +516,11 @@ X # find an old file in $DISTDIR that matches the new one. This is tricky, X # and probably it will fail sometimes. X # X-# we just ignore any occurence of X+# we just ignore any occurence of X # "pre","rc","[0-9]","_","-","." in the filenames and test X # if they are the same (or VERY similar (differ only in 1 char)). X-# to reduce the files to check, we only check files X-# with the same beginning X+# to reduce the files to check, we only check files X+# with the same beginning X # X output "${GREEN}Searching for a previously downloaded file in ${YELLOW}${DISTDIR}\n" X X@@ -522,7 +530,7 @@ X X # if filename is lib* use first 4 letters to increase performance X [ "${NEW_FILE:0:3}" = "lib" ] && [ $length_first_chars -lt 5 ] && first_chars="${NEW_FILE:0:4}" X- X+ X mask=$(mask_name "${NEW_FILE}") X let len1=${#mask} X filelist="" X@@ -532,7 +540,7 @@ X mask2=$(mask_name "${name}") X # add any file, that results in the same mask or differ not more than two letters X let len2=${#mask2} X- if [ $len1 -gt $len2 ] X+ if [ $len1 -gt $len2 ] X then X max=${len1} X let min=${len2} X@@ -540,10 +548,10 @@ X let min=${len1} X max=${len2} X fi X- let df=${max}-${min} X- X+ let df=${max}-${min} X+ X # if masks differ in length more than 1 they cannot match X- if [ $df -le 1 ] X+ if [ $df -le 1 ] X then X let frontmatch=0 X let backmatch=0 X@@ -554,7 +562,7 @@ X else break X fi X done X- X+ X # now backwards X mask=$(rev <<< ${mask}) X mask2=$(rev <<< ${mask2}) X@@ -565,18 +573,18 @@ X else break X fi X done X- X+ X # forwards for mask again (need this for the next run of the loop) X mask=$(rev <<< ${mask}) X- X+ X let matchall=${frontmatch}+${backmatch} X let minmatch=${min}-1 X [ ${matchall} -ge ${minmatch} ] && filelist="${filelist} $name" X fi X done X X-if ! [ -z "$filelist" ] X-then X+if ! [ -z "$filelist" ] X+then X # we have got a list of candidates in $filelist now. find the best match . X output "${GREEN}We have the following candidates to choose from \n${YELLOW}`sed -e \"s/\ /\\n/g\" <<< $filelist` \n" X X@@ -607,7 +615,7 @@ X done X ((match--)) X backmatch=${a[0]:${#a[0]}-${match}} X- X+ X # isolate version from filename (foobar-1.2.3.tar.gz -> 1.2.3) X new_version=${NEW_FILE#${frontmatch}} X new_version=${new_version%${backmatch}} X@@ -642,7 +650,7 @@ X else X let serial_diff=0x${old_serial}-0x${new_serial} X fi X- if [ $serial_diff -le ${minimal_diff:-${serial_diff}} ] X+ if [ $serial_diff -le ${minimal_diff:-${serial_diff}} ] X then X best_candidate="$name" X minimal_diff=${serial_diff} X@@ -651,18 +659,18 @@ X X output "${GREEN}The best of all is ... ${CYAN}${best_candidate}\n" X output "${YELLOW}Checking if this file is OK.\n" X- X+ X # this part is based on Pkunk's code posted on http://bugs.gentoo.org/show_bug.cgi?id=63525 X # but with some changes X FILE_IS_CORRUPT=false X- if $CHECK_OLD_FILE X+ if $CHECK_OLD_FILE X then X file_digest=$(grep -h ${best_candidate} ${FILESDIR}/digest-* | sed -n 1p) X if [ "$file_digest" ] X then X- file_md5=$(cut -d ' ' -f2 <<< "$file_digest") X+ file_md5=$(cut -d ' ' -f2 <<< "$file_digest") X file_origsize=$(cut -d ' ' -f4 <<< "$file_digest") X- file_currentsize=$(stat -c %s ${best_candidate}) X+ file_currentsize=$(stat -f "%z" ${best_candidate}) X if [ $file_currentsize -ne $file_origsize ] X then X output "${RED}Found ${best_candidate}, but filesize ${CYAN}${file_currentsize} ${RED} does not match ${CYAN}${file_origsize} (found in digest-file)\n" X@@ -677,7 +685,7 @@ X output "${RED}reported an error while testing ${CYAN}${best_candidate}${RED} - so this file is unusable.\n" X FILE_IS_CORRUPT=true X fi X- X+ X if $FILE_IS_CORRUPT && $REMOVE_INCOMPLETE_OLD_FILES X then X output "${YELLOW}You have chosen to automatically delete such broken files from your distfiles-directory, so here we go...\n" X@@ -689,9 +697,9 @@ X # end of file-corruption check for $best_candidate found in distfiles X if ! $FILE_IS_CORRUPT X then X- X- QUERY_URL=$(GENTOO_MIRRORS="" emerge -fOp =${CATEGORY}/${PF} 2>&1 | X- sed -e "s/ /\\n/g" | egrep "(http|ftp)://" | X+ X+ QUERY_URL=$(GENTOO_MIRRORS="" emerge -fOp =${CATEGORY}/${PF} 2>&1 | X+ sed -e "s/ /\\n/g" | egrep "(http|ftp)://" | X grep "${NEW_FILE}" | tail -n 1) X query="?have=${best_candidate}&want=${NEW_FILE}&url=${QUERY_URL}&version=${VERSION}&time=$(date +%s)" X output "${GREEN}Trying to download ${YELLOW}${best_candidate}-${NEW_FILE}.dtu\n" X@@ -704,22 +712,22 @@ X pushd ${tmp_dwn_dest} >/dev/null 2>&1 X X # thanks to MATSUI Fe2+ Tetsushi for idea and patch X- FILESIZE=$(stat -c %s "${DISTDIR}/${best_candidate}") X+ FILESIZE=$(stat -f "%z" "${DISTDIR}/${best_candidate}") X let TIMELIMIT=${FILESIZE}/${BANDWIDTH} X [[ $TIMELIMIT -lt $QUEUETIMEOUT ]] && QUEUETIMEOUT=$TIMELIMIT X- X+ X if $FETCH "${DELTUP_SERVER}${query}" X then X # thanks to deelkar for this much more elegant solution to the "broken pipe" problem with "head -n1" X- GOTFILE=$(ls -c | sed -n 1p) X+ GOTFILE=$(ls -c | sed -n 1p) X output "${YELLOW}GOT ${CYAN}${GOTFILE}\n" X- X+ X # There are some possibilities what the deltup-server X # may have sento to us. X- X+ X # first: the request have been queued X if [ "${GOTFILE}" = "deltup-queued" ] X- then X+ then X let QTMOUT=$(date +%s)+QUEUETIMEOUT X while [ -f deltup-queued ] X do X@@ -732,11 +740,11 @@ X then X for ((sec=QUEUERETRY;sec>0;sec--)) X do X- if ((sec>1)) X+ if ((sec>1)) X then X- ${VERBOSITY} && echo -n -e "${YELLOW} I will try again in ${sec} seconds. \r" X+ ${VERBOSITY} && echo -n -e "${YELLOW} I will try again in ${sec} seconds. \r" X else X- ${VERBOSITY} && echo -n -e "${YELLOW} I will try again in ${sec} second. \r" X+ ${VERBOSITY} && echo -n -e "${YELLOW} I will try again in ${sec} second. \r" X fi X sleep 1 X done X@@ -745,7 +753,7 @@ X GOTFILE=$(ls -c | sed -n 1p) X else X if ((TSTAMP>=QTMOUT)) X- then X+ then X GOTFILE="timeout" X output "\n${RED}TIMEOUT exceeded.\n" X break X@@ -756,31 +764,31 @@ X output "\n${RED}You have configured getdelta.sh not to accept this queue-position.\n" X output "${YELLOW}We are going to download the ${RED}full archive${YELLOW} instead.\n" X break X- fi X+ fi X fi X done X fi X- X+ X if [ -f ${best_candidate}-${NEW_FILE}.failed ] X then X- output "\n${RED}The server could not build the dtu-file for ${NEW_FILE}\n" X- output "${YELLOW}reason:\n${RED}$(cat ${best_candidate}-${NEW_FILE}.failed)\n" X+ output "\n${RED}The server could not build the dtu-file for ${NEW_FILE}\n" X+ output "${YELLOW}reason:\n${RED}$(cat ${best_candidate}-${NEW_FILE}.failed)\n" X rm -rf ${best_candidate}-${NEW_FILE}.failed X fi X X if [ -f ${best_candidate}-${NEW_FILE}.dtu ] X then X- output "${GREEN}Successfully fetched the dtu-file - let's build ${NEW_FILE}...\n" X- downloadsize=$(stat -c %s ${best_candidate}-${NEW_FILE}.dtu) X- if deltup -p -v -D ${DISTDIR} ${best_candidate}-${NEW_FILE}.dtu X- then X- newsize=$(stat -c %s ${NEW_FILE}) X+ output "${GREEN}Successfully fetched the dtu-file - let's build ${NEW_FILE}...\n" X+ downloadsize=$(stat -f "%z" ${best_candidate}-${NEW_FILE}.dtu) X+ if deltup -p -v -D ${DISTDIR} ${best_candidate}-${NEW_FILE}.dtu X+ then X+ newsize=$(stat -f "%z" ${NEW_FILE}) X let savedsize=${newsize}-${downloadsize} X let percent=${savedsize}*100/${newsize} X unit="bytes" X [ $savedsize -gt 1024 ] && let savedsize=$savedsize/1024 && unit="kB" X [ $savedsize -gt 1024 ] && let savedsize=$savedsize/1024 && unit="MB" X- X+ X case $unit in X bytes) UCOLOR=${RED} X ;; X@@ -796,13 +804,13 @@ X fi X X fi # if $FETCH "${DELTUP_SERVER}${query}" X- X+ X # Clean up. X # We might got an important message X if [ -f ${tmp_dwn_dest}/deltup-server.msg ] X then X- echo -e "${RED}IMPORTANT MESSAGE FROM DELTUP-SERVER${YELLOW}$(cat ${tmp_dwn_dest}/deltup-server.msg)\n" X- for ((i=1;i<=5;i++)) X+ echo -e "${RED}IMPORTANT MESSAGE FROM DELTUP-SERVER${YELLOW}$(cat ${tmp_dwn_dest}/deltup-server.msg)\n" X+ for ((i=1;i<=5;i++)) X do X echo -n -e "\a" X sleep 1 X@@ -816,15 +824,15 @@ X #stop respond to trap2 X trap 2 X fi # if ! FILE_IS_CORRUPT X-else # if ! [ -z "$filelist" ] X+else # if ! [ -z "$filelist" ] X # No filelist - probably we do not have an old version of the file X- output "${RED}No old version of the requested file found.\n" X+ output "${RED}No old version of the requested file found.\n" X fi X X- X+ X # Ok, once we are here, we should have got the delta (and used it) X # or we still have to download the full file X-if ! [ -f ${DISTDIR}/${NEW_FILE} ] X+if ! [ -f ${DISTDIR}/${NEW_FILE} ] X then X output "${RED}The dtu could not be fetched,${YELLOW} downloading full file from original URL\n" X $FETCH $ORIG_URI X@@ -833,7 +841,7 @@ X fi X X X-if $SEPARATED_WINDOW X+if $SEPARATED_WINDOW X then X sleep 3 X kill $termpid END-of-/usr/ports/sysutils/getdelta/files/patch-getdelta.sh echo x - /usr/ports/sysutils/getdelta/Makefile sed 's/^X//' >/usr/ports/sysutils/getdelta/Makefile << 'END-of-/usr/ports/sysutils/getdelta/Makefile' X# Ports collection makefile for: stardict3 X# Date created: 15 December 2007 X# Whom: Anton Statutov X# X# $FreeBSD$ X# X XPORTNAME= getdelta XPORTVERSION= 0.7.8 X#PORTREVISION= 0 XCATEGORIES= sysutils XMASTER_SITES= http://132.207.4.160/distfiles/ X XMAINTAINER= astatutov@gmail.com XCOMMENT= Script for reducing bandwidth load while upgrading ports disfiles X XUSE_BZIP2= yes XNO_WRKSUBDIR= yes XNO_BUILD= yes X X.include X Xdo-install: X ${INSTALL} ${WRKSRC}/getdelta.sh ${PREFIX}/bin/getdelta.sh X Xpost-install: X @${CAT} ${PKGMESSAGE} X X.include END-of-/usr/ports/sysutils/getdelta/Makefile echo x - /usr/ports/sysutils/getdelta/pkg-descr sed 's/^X//' >/usr/ports/sysutils/getdelta/pkg-descr << 'END-of-/usr/ports/sysutils/getdelta/pkg-descr' XThis is port of Gentoo getdelta.sh. XGetdelta uses Deltup to reduce bandwidth load while upgrading ports distfiles. X XWWW: http://www.deltup.org/ X X- Anton Statutov Xastatutov@gmail.com END-of-/usr/ports/sysutils/getdelta/pkg-descr echo x - /usr/ports/sysutils/getdelta/pkg-message sed 's/^X//' >/usr/ports/sysutils/getdelta/pkg-message << 'END-of-/usr/ports/sysutils/getdelta/pkg-message' X========================================================================================= XATTENTION! XTo use Getdelta for upgrading ports you need to add following string into /etc/make.conf: XFETCH_CMD=/usr/local/bin/getdelta.sh X XTo do this you can simple run following command: Xecho "FETCH_CMD=/usr/local/bin/getdelta.sh" >> /etc/make.conf X========================================================================================= END-of-/usr/ports/sysutils/getdelta/pkg-message echo x - /usr/ports/sysutils/getdelta/pkg-plist sed 's/^X//' >/usr/ports/sysutils/getdelta/pkg-plist << 'END-of-/usr/ports/sysutils/getdelta/pkg-plist' Xbin/getdelta.sh X END-of-/usr/ports/sysutils/getdelta/pkg-plist echo x - /usr/ports/sysutils/getdelta/distinfo sed 's/^X//' >/usr/ports/sysutils/getdelta/distinfo << 'END-of-/usr/ports/sysutils/getdelta/distinfo' XMD5 (getdelta-0.7.8.tar.bz2) = e6feab0fe6a71f63e5a693c67ef7fd1e XSHA256 (getdelta-0.7.8.tar.bz2) = 72bd5dac59e86a5c78217a15e3198df513152dc784a8685b1a8c2c5efdb34217 XSIZE (getdelta-0.7.8.tar.bz2) = 10335 END-of-/usr/ports/sysutils/getdelta/distinfo exit >Release-Note: >Audit-Trail: >Unformatted: