Commit 91465846 authored by Natanael Copa's avatar Natanael Copa
Browse files

support for resuming partial downloads. check md5 in separate step

parent ade4a54a
...@@ -23,7 +23,7 @@ pkgrel=0 ...@@ -23,7 +23,7 @@ pkgrel=0
SRCDEST=${SRCDEST:-$startdir} SRCDEST=${SRCDEST:-$startdir}
PKGDEST=${PKGDEST:-$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" all_cmds="checksum fetch unpack rootpkg build package cleancache clean srcpkg"
# functions # functions
...@@ -56,20 +56,26 @@ checkdeps() { ...@@ -56,20 +56,26 @@ checkdeps() {
} }
checkmd5() { checkmd5() {
( cd "$SRCDEST" && echo "$md5sums" | awk '$2 == "'$1'" { print $0 } ' \ if [ -z "$md5sums" ]; then
| md5sum -c ) die "Use 'abuild checksum >>$APKBUILD' to generate a checksum"
fi
cd "$srcdir" && echo "$md5sums" | md5sum -c
} }
uri_fetch() { uri_fetch() {
local uri="$1" local uri="$1"
local d="${s##*/}" # $(basename $s) local d="${s##*/}" # $(basename $s)
local q local opts
[ -n "$quiet" ] && q="-q" [ -n "$quiet" ] && opts="-q"
[ -f "$SRCDEST/$d" ] && return 0
mkdir -p "$SRCDEST" mkdir -p "$SRCDEST"
if ! [ -f "$SRCDEST/$d" ] || ! checkmd5 "$d" 2>/dev/null; then if [ -f "$SRCDEST/$d.part" ]; then
rm -f "$SRCDEST/$d" msg "Partial download found. Trying to resume"
wget $q -c -P "$SRCDEST" "$uri" && checkmd5 "$d" opts="$opts -c"
fi fi
wget $opts -O "$SRCDEST/$d.part" "$uri" \
&& mv "$SRCDEST/$d.part" "$SRCDEST/$d"
} }
fetch() { fetch() {
...@@ -80,10 +86,6 @@ fetch() { ...@@ -80,10 +86,6 @@ fetch() {
http://*|ftp://*) http://*|ftp://*)
uri_fetch "$s" || return 1 uri_fetch "$s" || return 1
;; ;;
*)
[ -n "$genchecksum" ] && continue
checkmd5 "${s##*/}" || return 1
;;
esac esac
ln -sf "$SRCDEST/${s##*/}" "$srcdir"/ ln -sf "$SRCDEST/${s##*/}" "$srcdir"/
done done
...@@ -92,7 +94,6 @@ fetch() { ...@@ -92,7 +94,6 @@ fetch() {
# unpack the sources # unpack the sources
unpack() { unpack() {
local u local u
[ -z "$md5sums" ] && die "Use 'abuild checksum >>$APKBUILD' to generate a checksum"
mkdir -p "$srcdir" mkdir -p "$srcdir"
for u in $source; do for u in $source; do
local s="$SRCDEST/${u##*/}" # $(basename $s) local s="$SRCDEST/${u##*/}" # $(basename $s)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment