Commit 983bed75 authored by Vitaly Lipatov's avatar Vitaly Lipatov

rpmgs: skip redownloading for tarballs already exists

parent 1d9b0f5a
...@@ -34,7 +34,7 @@ phelp() ...@@ -34,7 +34,7 @@ phelp()
echo echo
echog "Options:" echog "Options:"
echog " -a get all source (not only Source|Source0)" echog " -a get all source (not only Source|Source0)"
echog " -f force download (remove source file before download)" echog " -f force download and commit tarball(s) (remove source file before download)"
} }
while getopts :haf opt; do while getopts :haf opt; do
...@@ -60,6 +60,13 @@ repack_tarball() ...@@ -60,6 +60,13 @@ repack_tarball()
docmd erc -f repack "$1" "$2" docmd erc -f repack "$1" "$2"
} }
check_tarball()
{
[ -s "$1" ] || return
erc -q check "$1"
}
# Args: URL target_file
download_any_tarball() download_any_tarball()
{ {
local GETSOURCE="$1" local GETSOURCE="$1"
...@@ -68,7 +75,7 @@ download_any_tarball() ...@@ -68,7 +75,7 @@ download_any_tarball()
local BASESOURCE="$GETSOURCE" local BASESOURCE="$GETSOURCE"
local ORIGEXT=$(rhas "$BASESOURCE" "\." && echo "$BASESOURCE" | sed -e "s|.*\.||") local ORIGEXT=$(rhas "$BASESOURCE" "\." && echo "$BASESOURCE" | sed -e "s|.*\.||")
[ -n "$ORIGEXT" ] || fatal "Have no idea how to load files without extension" [ -n "$ORIGEXT" ] || fatal "Error with $GETSOURCE. Have no idea how to load files without extension"
# first try download with original extension (exclude for tar) # first try download with original extension (exclude for tar)
if [ "$ORIGEXT" != "tar" ] ; then if [ "$ORIGEXT" != "tar" ] ; then
...@@ -81,6 +88,7 @@ download_any_tarball() ...@@ -81,6 +88,7 @@ download_any_tarball()
# try download by exts list # try download by exts list
for ext in $FORMATS ; do for ext in $FORMATS ; do
[ -n "$FORCEDOWNLOAD" ] && docmd rm -f "$BASESOURCE.$ext" [ -n "$FORCEDOWNLOAD" ] && docmd rm -f "$BASESOURCE.$ext"
[ -z "$FORCEDOWNLOAD" ] && check_tarball "$TARGET" && { echo "$TARGET already exists, continue... " ; continue; }
download_url "$BASESOURCE.$ext" || continue download_url "$BASESOURCE.$ext" || continue
repack_tarball "$(basename "$BASESOURCE.$ext")" "$TARGET" || continue repack_tarball "$(basename "$BASESOURCE.$ext")" "$TARGET" || continue
return return
...@@ -342,10 +350,14 @@ do ...@@ -342,10 +350,14 @@ do
# TODO: rewrite code to use original file format and temp. download dir # TODO: rewrite code to use original file format and temp. download dir
elif [ -n "${GETSOURCEURL}" ] ; then elif [ -n "${GETSOURCEURL}" ] ; then
echog "Try to load ${GETSOURCEURL} for $spec" if [ -z "$FORCEDOWNLOAD" ] && check_tarball "$FTB" ; then
download_url "$GETSOURCEURL" || fatal "Can't download $GETSOURCEURL" echo "$FTB already exists, skipping... "
# FIXME: gear-update can use any tarball else
repack_tarball "$(basename "$GETSOURCEURL")" "$FTB" echog "Try to load ${GETSOURCEURL} for $spec"
download_url "$GETSOURCEURL" || fatal "Can't download $GETSOURCEURL"
# FIXME: gear-update can use any tarball
repack_tarball "$(basename "$GETSOURCEURL")" "$FTB"
fi
else else
if ! rhas "$GETSOURCE" "ps?://" ; then if ! rhas "$GETSOURCE" "ps?://" ; then
if [ "$SN" != "Source" ] && [ "$SN" != "Source0" ] ; then if [ "$SN" != "Source" ] && [ "$SN" != "Source0" ] ; then
......
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