Ticket #68: dohttp.2

File dohttp.2, 2.3 KB (added by eternaleye@…, 3 years ago)

1st update: Can ANYONE tell me why the heck paludis keeps barfing line 46?!? kwrite's code folding likes it.

Line 
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
19export PATH="$(${PALUDIS_EBUILD_DIR}/utils/canonicalise ${PALUDIS_EBUILD_DIR}/utils/ ):${PATH}"
20source ${PALUDIS_EBUILD_DIR}/echo_functions.bash
21
22if [[ -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
33# Deltup fetch
34    elif [[ -n "$DELTUP" ]]
35        echo ${DELTUP} "${1}" "$2".-PARTIAL- 1>&2
36        if ${DELTUP} "${1}" "$2".-PARTIAL- ; then
37           echo mv -f "${2}".-PARTIAL- "${2}"
38           mv -f "${2}".-PARTIAL- "${2}"
39           exit 0
40        else
41           rm -f "${2}"
42           exit 1
43        fi
44
45# Normal wget 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
58else
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
67fi
68