| 1 | #!/bin/bash |
|---|
| 2 | # vim: set sw=4 sts=4 et : |
|---|
| 3 | |
|---|
| 4 | # Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org> |
|---|
| 5 | # |
|---|
| 6 | # This file is part of the Paludis package manager. Paludis is free software; |
|---|
| 7 | # you can redistribute it and/or modify it under the terms of the GNU General |
|---|
| 8 | # Public License, version 2, as published by the Free Software Foundation. |
|---|
| 9 | # |
|---|
| 10 | # Paludis is distributed in the hope that it will be useful, but WITHOUT ANY |
|---|
| 11 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|---|
| 12 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|---|
| 13 | # details. |
|---|
| 14 | # |
|---|
| 15 | # You should have received a copy of the GNU General Public License along with |
|---|
| 16 | # this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
|---|
| 17 | # Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 18 | |
|---|
| 19 | export PATH="$(${PALUDIS_EBUILD_DIR}/utils/canonicalise ${PALUDIS_EBUILD_DIR}/utils/ ):${PATH}" |
|---|
| 20 | source ${PALUDIS_EBUILD_DIR}/echo_functions.bash |
|---|
| 21 | |
|---|
| 22 | if [[ -n "${PALUDIS_USE_SAFE_RESUME}" ]] ; then |
|---|
| 23 | |
|---|
| 24 | if [[ -f "${2}.-PARTIAL-" ]] ; then |
|---|
| 25 | if [[ $(getfsize "${2}".-PARTIAL- ) -ge 123456 ]] ; then |
|---|
| 26 | einfo_unhooked "Attempting resume using ${2}.-PARTIAL-" |
|---|
| 27 | else |
|---|
| 28 | einfo_unhooked "Not attempting resume using ${2}.-PARTIAL- (too small)" |
|---|
| 29 | echo rm -f "${2}".-PARTIAL- |
|---|
| 30 | rm -f "${2}".-PARTIAL- |
|---|
| 31 | fi |
|---|
| 32 | fi |
|---|
| 33 | |
|---|
| 34 | # Deltup fetch |
|---|
| 35 | if test -n ${DELTUP} |
|---|
| 36 | echo ${DELTUP} "${1}" "$2".-PARTIAL- 1>&2 |
|---|
| 37 | if ${DELTUP} "${1}" "$2".-PARTIAL- ; then |
|---|
| 38 | echo mv -f "${2}".-PARTIAL- "${2}" |
|---|
| 39 | mv -f "${2}".-PARTIAL- "${2}" |
|---|
| 40 | exit 0 |
|---|
| 41 | else |
|---|
| 42 | rm -f "${2}" |
|---|
| 43 | exit 1 |
|---|
| 44 | fi |
|---|
| 45 | # Normal fetch |
|---|
| 46 | else |
|---|
| 47 | echo ${WGET_WRAPPER} ${LOCAL_WGET:-wget} ${EXTRA_WGET} -T 30 -t 1 --continue -O "${2}".-PARTIAL- "${1}" 1>&2 |
|---|
| 48 | if ${WGET_WRAPPER} ${LOCAL_WGET:-wget} ${EXTRA_WGET} -T 30 -t 1 --continue -O "${2}".-PARTIAL- "${1}" ; then |
|---|
| 49 | echo mv -f "${2}".-PARTIAL- "${2}" |
|---|
| 50 | mv -f "${2}".-PARTIAL- "${2}" |
|---|
| 51 | exit 0 |
|---|
| 52 | else |
|---|
| 53 | rm -f "${2}" |
|---|
| 54 | exit 1 |
|---|
| 55 | fi |
|---|
| 56 | fi |
|---|
| 57 | |
|---|
| 58 | else |
|---|
| 59 | echo ${WGET_WRAPPER} ${LOCAL_WGET:-wget} ${EXTRA_WGET} -T 30 -t 1 -O "${2}" "${1}" 1>&2 |
|---|
| 60 | if ${WGET_WRAPPER} ${LOCAL_WGET:-wget} ${EXTRA_WGET} -T 30 -t 1 -O "${2}" "${1}" ; then |
|---|
| 61 | exit 0 |
|---|
| 62 | else |
|---|
| 63 | rm -f "${2}" |
|---|
| 64 | exit 1 |
|---|
| 65 | fi |
|---|
| 66 | |
|---|
| 67 | fi |
|---|
| 68 | |
|---|