Ticket #68: dohttp.6

File dohttp.6, 2.7 KB (added by meka, 3 years ago)

-z $PN checking moved to dohttp. All you have to do is set USE_GETDELTA in /etc/paludis/bashrc

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
22# If this is tarball sync, we don't need getdelta (at the moment)
23if [[ -z "${PN}" ]]; then
24    unset USE_GETDELTA
25fi
26
27if [[ -n "${PALUDIS_USE_SAFE_RESUME}" ]] ; then
28    if [[ -f "${2}.-PARTIAL-" ]] ; then
29        if [[ $(getfsize "${2}".-PARTIAL- ) -ge 123456 ]] ; then
30            einfo_unhooked "Attempting resume using ${2}.-PARTIAL-"
31        else
32            einfo_unhooked "Not attempting resume using ${2}.-PARTIAL- (too small)"
33            echo rm -f "${2}".-PARTIAL-
34            rm -f "${2}".-PARTIAL-
35        fi
36    fi
37
38    if [ "$USE_GETDELTA" == "yes" ]; then
39        echo /usr/bin/getdelta-paludis.sh "${1}" 1>&2
40        if /usr/bin/getdelta-paludis.sh "${1}" ; then
41            echo mv -f "${2}".-PARTIAL- "${2}"
42            mv -f "${2}".-PARTIAL- "${2}" >&/dev/null
43            exit 0
44        else
45            rm -f "${2}"
46            exit 1
47        fi
48    else
49        echo ${WGET_WRAPPER} ${LOCAL_WGET:-wget} ${EXTRA_WGET} -T 30 -t 1 --continue -O "${2}".-PARTIAL- "${1}" 1>&2
50        if ${WGET_WRAPPER} ${LOCAL_WGET:-wget} ${EXTRA_WGET} -T 30 -t 1 --continue -O "${2}".-PARTIAL- "${1}" ; then
51            echo mv -f "${2}".-PARTIAL- "${2}"
52            mv -f "${2}".-PARTIAL- "${2}"
53            exit 0
54        else
55            rm -f "${2}"
56            exit 1
57        fi
58    fi
59else
60    if [ "$USE_GETDELTA" == "yes" ]; then
61        echo /usr/bin/getdelta.sh "${1}" 1>&2
62        if /usr/bin/getdelta.sh "${1}" ; then
63            exit 0
64        else
65            rm -f "${2}"
66            exit 1
67        fi
68    else
69        echo ${WGET_WRAPPER} ${LOCAL_WGET:-wget} ${EXTRA_WGET} -T 30 -t 1 -O "${2}" "${1}" 1>&2
70        if ${WGET_WRAPPER} ${LOCAL_WGET:-wget} ${EXTRA_WGET} -T 30 -t 1 -O "${2}" "${1}" ; then
71            exit 0
72        else
73            rm -f "${2}"
74            exit 1
75        fi
76    fi
77fi
78