Commit e448ab19 authored by Vitaly Lipatov's avatar Vitaly Lipatov

rpmgs: use has_ext function

parent f737c3f2
...@@ -263,6 +263,11 @@ function get_source_url() ...@@ -263,6 +263,11 @@ function get_source_url()
GETSOURCEURL=$(source_ext "$1" url "$2") GETSOURCEURL=$(source_ext "$1" url "$2")
} }
has_ext()
{
! test -n "${1/*$2/}"
}
function print_error() function print_error()
{ {
echog "Can't find any spec file. It is possible you run this script not in git dir." echog "Can't find any spec file. It is possible you run this script not in git dir."
...@@ -293,6 +298,7 @@ gear_update_from_tarball() ...@@ -293,6 +298,7 @@ gear_update_from_tarball()
fatal "can't import tarball '$TARBALL'" fatal "can't import tarball '$TARBALL'"
} }
parse_cmd_pre_spec "$@" parse_cmd_pre_spec "$@"
mygetopts $LISTARGS mygetopts $LISTARGS
...@@ -359,7 +365,7 @@ do ...@@ -359,7 +365,7 @@ do
is_gear $SPECDIR || fatal "Source-svn works only with gear repo" is_gear $SPECDIR || fatal "Source-svn works only with gear repo"
elif is_gear $SPECDIR; then elif is_gear $SPECDIR; then
echog "Try to load ${GETSOURCEURL:-$GETSOURCE} for $spec" echog "Try to load ${GETSOURCEURL:-$GETSOURCE} for $spec"
if [ -n "${GETSOURCE/*.tar/}" ] ; then if ! has_ext "$GETSOURCE" .tar ; then
warning "It is recommended to use .tar tarballs for sources in gear" warning "It is recommended to use .tar tarballs for sources in gear"
fi fi
# TODO: rewrite code to use original file format and temp. download dir # TODO: rewrite code to use original file format and temp. download dir
...@@ -368,11 +374,11 @@ do ...@@ -368,11 +374,11 @@ do
download_url "$GETSOURCEURL" download_url "$GETSOURCEURL"
# FIXME: gear-update can use any tarball # FIXME: gear-update can use any tarball
erc conv $(basename "$GETSOURCEURL") $FTB erc conv $(basename "$GETSOURCEURL") $FTB
elif [ -z "${GETSOURCE/*.tar/}" ] ; then elif has_ext "$GETSOURCE" .tar ; then
# tar target: try to load and convert # tar target: try to load and convert
download_any_tarball download_any_tarball
test -f $WEXT.tar.bz2 && FTB=$WEXT.tar.bz2 test -s $WEXT.tar.bz2 && FTB=$WEXT.tar.bz2
elif [ -z "${GETSOURCE/*.tar.bz2/}" ] ; then elif has_ext "$GETSOURCE" .tar.bz2 ; then
# tar.bz2 target: for src.rpm policy compatibility # tar.bz2 target: for src.rpm policy compatibility
download_any_tarball download_any_tarball
test -f $WEXT.tar.bz2 || erc $WEXT.tar tar.bz2: || fatal "Cannot bzip $WEXT.tar" test -f $WEXT.tar.bz2 || erc $WEXT.tar tar.bz2: || fatal "Cannot bzip $WEXT.tar"
...@@ -382,22 +388,22 @@ do ...@@ -382,22 +388,22 @@ do
else else
[ -z "${GETSOURCEURL}" ] || fatal "Source git works only with gear repo" [ -z "${GETSOURCEURL}" ] || fatal "Source git works only with gear repo"
echog "Try to load ${GETSOURCEURL:-$GETSOURCE} for $spec" echog "Try to load ${GETSOURCEURL:-$GETSOURCE} for $spec"
if [ -n "${GETSOURCE/*.bz2/}" ] ; then if ! has_ext "$GETSOURCE" .bz2 ; then
warning "It is recommended to use .bz2 tarballs for sources in rpm" warning "It is recommended to use .bz2 tarballs for sources in rpm"
fi fi
if [ -n "${GETSOURCEURL}" ] ; then if [ -n "${GETSOURCEURL}" ] ; then
# UpUrl for rpm # UpUrl for rpm
download_url "$GETSOURCEURL" download_url "$GETSOURCEURL"
erc conv $(basename "$GETSOURCEURL") $FTB erc conv $(basename "$GETSOURCEURL") $FTB
elif [ -n "${GETSOURCE/*.tar.bz2/}" ] ; then elif ! has_ext "$GETSOURCE" .tar.bz2 ; then
# if not tar.bz2 target, direct download # if not tar.bz2 target, direct download
download_url "$GETSOURCE" download_url "$GETSOURCE"
elif [ -z "${GETSOURCE/*.tar.bz2/}" ] ; then elif has_ext "$GETSOURCE" .tar.bz2 ; then
# if tar.bz2 target # if tar.bz2 target
download_any_tarball download_any_tarball
#echog -n "Compressing to $WEXT.tar.bz2..." #echog -n "Compressing to $WEXT.tar.bz2..."
test -f $WEXT.tar.bz2 || erc $WEXT.tar tar.bz2: || fatal "Cannot bzip $WEXT.tar" test -f $WEXT.tar.bz2 || erc $WEXT.tar tar.bz2: || fatal "Cannot bzip $WEXT.tar"
elif [ -z "${GETSOURCE/*.bz2/}" ] ; then elif has_ext "$GETSOURCE" .bz2 ; then
warning "It is not tarball (possible single file)..." warning "It is not tarball (possible single file)..."
get_bz2 || get_gz || get_raw || fatal "Cannot retrieve $GETSOURCE" get_bz2 || get_gz || get_raw || fatal "Cannot retrieve $GETSOURCE"
else else
...@@ -430,6 +436,7 @@ do ...@@ -430,6 +436,7 @@ do
docmd git svn rebase docmd git svn rebase
elif is_gear ; then elif is_gear ; then
CURNAME=$BASENAME CURNAME=$BASENAME
echo $CURNAME
test -d "$CURNAME" || CURNAME=$(get_tarballname "$spec") test -d "$CURNAME" || CURNAME=$(get_tarballname "$spec")
gear_update_from_tarball "$RPMSOURCEDIR/$FTB" "$CURNAME" $FORCEDOWNLOAD gear_update_from_tarball "$RPMSOURCEDIR/$FTB" "$CURNAME" $FORCEDOWNLOAD
rm -f "$RPMSOURCEDIR/$FTB" rm -f "$RPMSOURCEDIR/$FTB"
......
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