summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2008-10-25 09:33:55 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2008-10-25 09:33:55 +0000
commit91465846cc7763a7832205f6ade440e3c4ed1ead (patch)
tree286b17ced31102f26d6f8ea16c0425e6024cf88b
parentade4a54a1601f3465fcbf4ab269a572fe76b1775 (diff)
downloadabuild-91465846cc7763a7832205f6ade440e3c4ed1ead.tar.gz
abuild-91465846cc7763a7832205f6ade440e3c4ed1ead.tar.bz2
abuild-91465846cc7763a7832205f6ade440e3c4ed1ead.tar.xz
abuild-91465846cc7763a7832205f6ade440e3c4ed1ead.zip
support for resuming partial downloads. check md5 in separate step
-rwxr-xr-xabuild27
1 files changed, 14 insertions, 13 deletions
diff --git a/abuild b/abuild
index ea687fe..4a17b73 100755
--- a/abuild
+++ b/abuild
@@ -23,7 +23,7 @@ pkgrel=0
SRCDEST=${SRCDEST:-$startdir}
PKGDEST=${PKGDEST:-$startdir}
-default_cmds="checkdeps clean fetch unpack rootpkg"
+default_cmds="checkdeps clean fetch checkmd5 unpack rootpkg"
all_cmds="checksum fetch unpack rootpkg build package cleancache clean srcpkg"
# functions
@@ -56,20 +56,26 @@ checkdeps() {
}
checkmd5() {
- ( cd "$SRCDEST" && echo "$md5sums" | awk '$2 == "'$1'" { print $0 } ' \
- | md5sum -c )
+ if [ -z "$md5sums" ]; then
+ die "Use 'abuild checksum >>$APKBUILD' to generate a checksum"
+ fi
+ cd "$srcdir" && echo "$md5sums" | md5sum -c
}
uri_fetch() {
local uri="$1"
local d="${s##*/}" # $(basename $s)
- local q
- [ -n "$quiet" ] && q="-q"
+ local opts
+ [ -n "$quiet" ] && opts="-q"
+ [ -f "$SRCDEST/$d" ] && return 0
+
mkdir -p "$SRCDEST"
- if ! [ -f "$SRCDEST/$d" ] || ! checkmd5 "$d" 2>/dev/null; then
- rm -f "$SRCDEST/$d"
- wget $q -c -P "$SRCDEST" "$uri" && checkmd5 "$d"
+ if [ -f "$SRCDEST/$d.part" ]; then
+ msg "Partial download found. Trying to resume"
+ opts="$opts -c"
fi
+ wget $opts -O "$SRCDEST/$d.part" "$uri" \
+ && mv "$SRCDEST/$d.part" "$SRCDEST/$d"
}
fetch() {
@@ -80,10 +86,6 @@ fetch() {
http://*|ftp://*)
uri_fetch "$s" || return 1
;;
- *)
- [ -n "$genchecksum" ] && continue
- checkmd5 "${s##*/}" || return 1
- ;;
esac
ln -sf "$SRCDEST/${s##*/}" "$srcdir"/
done
@@ -92,7 +94,6 @@ fetch() {
# unpack the sources
unpack() {
local u
- [ -z "$md5sums" ] && die "Use 'abuild checksum >>$APKBUILD' to generate a checksum"
mkdir -p "$srcdir"
for u in $source; do
local s="$SRCDEST/${u##*/}" # $(basename $s)