summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Kyrylych <roman@archlinux.org>2008-02-10 18:56:47 +0200
committerDan McGee <dan@archlinux.org>2008-03-10 18:45:58 -0500
commitf56f7ff39102dab754573b0bc40dbceb5a8ec301 (patch)
tree43aca0cead43ed2e72e0e1acdb8c1142ae17ebce
parent91b7f288fe65b96d4af64f6308b0e33b14ad85e0 (diff)
makepkg: Support for resuming source downloads
Download to *.part and remove the suffix if successful, thus md5sums will be checked only for complete files, and next time makepkg will resume downloading of partial file instead of complaining about invalid md5sums. Old DLAGENTS format is still supported. Late fix: Do not try to download %u first The output of grep was not suppressed, thus the output of get_downloadcmd was wrong because of extra line at the beginning that contained an unsubstituted (with %o and %u) entry from DLAGENTS. Signed-off-by: Roman Kyrylych <roman@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--doc/makepkg.conf.5.txt3
-rw-r--r--etc/makepkg.conf.in10
-rw-r--r--scripts/makepkg.sh.in21
3 files changed, 27 insertions, 7 deletions
diff --git a/doc/makepkg.conf.5.txt b/doc/makepkg.conf.5.txt
index f6e4b382..3f6d74c4 100644
--- a/doc/makepkg.conf.5.txt
+++ b/doc/makepkg.conf.5.txt
@@ -37,6 +37,9 @@ Options
well; the download URL is placed on the end of the command. This is more
flexible than the former `FTPAGENT` variable, as any protocol can have a
download agent. Several examples are provided in the default makepkg.conf.
+ All instances of `%u` will be replaced with the download URL. If present,
+ instances of `%o` will be replaced with the local filename, plus a ``.part''
+ extension, which allows to do file resumes properly.
**CARCH=**"carch"::
Specifies your computer architecture; possible values include such things
diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in
index 4da4a63d..a034b516 100644
--- a/etc/makepkg.conf.in
+++ b/etc/makepkg.conf.in
@@ -8,11 +8,11 @@
#
#-- The download utilities that makepkg should use to acquire sources
# Format: 'protocol::agent'
-DLAGENTS=('ftp::/usr/bin/wget -c --passive-ftp -t 3 --waitretry=3'
- 'http::/usr/bin/wget -c -t 3 --waitretry=3'
- 'https::/usr/bin/wget -c -t 3 --waitretry=3 --no-check-certificate'
- 'rsync::/usr/bin/rsync -z'
- 'scp::/usr/bin/scp -C')
+DLAGENTS=('ftp::/usr/bin/wget -c --passive-ftp -t 3 --waitretry=3 -O %o %u'
+ 'http::/usr/bin/wget -c -t 3 --waitretry=3 -O %o %u'
+ 'https::/usr/bin/wget -c -t 3 --waitretry=3 --no-check-certificate -O %o %u'
+ 'rsync::/usr/bin/rsync -z %u %o'
+ 'scp::/usr/bin/scp -C %u %o')
# Other common tools:
# /usr/bin/snarf
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 79c3fd17..f2f7109b 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -299,6 +299,20 @@ get_downloadclient() {
echo "$agent"
}
+get_downloadcmd() {
+ local dlagent=$1
+ local netfile=$2
+ local file=$3
+
+ if echo "$dlagent" | grep -q "%u" ; then
+ local dlcmd=$(echo "$dlagent" | sed "s|%o|$file.part|" | sed "s|%u|$netfile|")
+ else
+ local dlcmd="$dlagent $netfile"
+ fi
+
+ echo "$dlcmd"
+}
+
check_deps() {
[ $# -gt 0 ] || return
@@ -471,17 +485,20 @@ download_sources() {
fi
# find the client we should use for this URL
- local dlclient=$(get_downloadclient $netfile) || exit $?
+ local dlclient=$(get_downloadclient "$netfile") || exit $?
msg2 "$(gettext "Downloading %s...")" "$file"
# fix flyspray bug #3289
local ret=0
- $dlclient "$netfile" || ret=$?
+ $(get_downloadcmd "$dlclient" "$netfile" "$file") || ret=$?
if [ $ret -gt 0 ]; then
error "$(gettext "Failure while downloading %s")" "$file"
plain "$(gettext "Aborting...")"
exit 1
fi
+ if echo "$dlclient" | grep -q "%o" ; then
+ mv -f "$SRCDEST/$file.part" "$SRCDEST/$file"
+ fi
cp -s --remove-destination "$SRCDEST/$file" "$srcdir/"
done