Commit 91465846 authored by Natanael Copa's avatar Natanael Copa

support for resuming partial downloads. check md5 in separate step

parent ade4a54a
......@@ -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)
......
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