libapse.lib: style fixes

Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>
This commit is contained in:
Davide Madrisan 2012-07-07 19:47:23 +02:00
parent 1504e58b3e
commit 037669307b
2 changed files with 114 additions and 84 deletions

View File

@ -49,6 +49,10 @@ Changes in version 1.12.3
Action 3: generate correct download URL getting new version from action 2
or from command line parameter.
+ update
* lib/libapse.lib, lib/libspec.lib - Davide Madrisan:
Style fixes.
-------------------------------------------------------------------------------
Changes in version 1.12.2

View File

@ -240,7 +240,8 @@ Copyright (C) 2008-2011 Silvan Calarco <silvan.calarco@mambasoft.it>""
local ARGS
ARGS=`LC_ALL=C getopt -o han:s:w:p:u: \
--long help,allurl,pckname:,specname:,pckurl:,pckurlverbatim:,proxy:,proxy-user: \
--long help,allurl,pckname:,specname:,pckurl:,pckurlverbatim:,\
proxy:,proxy-user: \
-n "$FUNCNAME" -- "$@"`
[ $? = 0 ] || notify.error $"\
(bug)"" -- $FUNCNAME: "$"\`getopt' error"
@ -306,64 +307,71 @@ Copyright (C) 2008-2011 Silvan Calarco <silvan.calarco@mambasoft.it>""
${proxy:+ --proxy $proxy}${proxy_user:+ --proxy-user $proxy_user}"
# SOURCE0 url based search (only if 'pckurl' is a valid url)
[ "${apse_enabled[0]}" = "0" ] && notify.debug "$FUNCNAME: skipping ${apse_site_name[0]}" || \
if [[ "$pckurl" =~ .*://.* ]]; then
local pckurldir="`dirname $pckurl`/"
notify.debug "$FUNCNAME: pckurldir = $pckurldir"
if [ "${apse_enabled[0]}" = "0" ]; then
notify.debug "$FUNCNAME: skipping ${apse_site_name[0]}"
else
if [[ "$pckurl" =~ .*://.* ]]; then
local pckurldir="`dirname $pckurl`/"
notify.debug "$FUNCNAME: pckurldir = $pckurldir"
local pcknameverbatim=`basename $pckurlverbatim`
notify.debug "$FUNCNAME: pcknameverbatim = $pcknameverbatim"
local pcknameverbatim=`basename $pckurlverbatim`
notify.debug "$FUNCNAME: pcknameverbatim = $pcknameverbatim"
curr_curl_url="$pckurldir"
curr_curl_url="$pckurldir"
notify.note $"looking at"" ${NOTE}(#0)${NORM} <${NOTE}$curr_curl_url${NORM}> (\`${NOTE}source0${NORM}')..."
notify.note $"looking at"" ${NOTE}(#0)${NORM} \
<${NOTE}$curr_curl_url${NORM}> (\`${NOTE}source0${NORM}')..."
notify.debug "running: curl \$curr_curl_proxy_opts -s -L \"$curr_curl_url\""
curl $curl_opts_netlink $curr_curl_proxy_opts -s -L "$curr_curl_url" > $fcurlout
let "retval = $?"
notify.debug "\
running: curl \$curr_curl_proxy_opts -s -L \"$curr_curl_url\""
curl $curl_opts_netlink \
$curr_curl_proxy_opts -s -L "$curr_curl_url" \
> $fcurlout
let "retval = $?"
case "$retval" in
0) ;;
6) notify.warning $"couldn't resolve host" ;;
7) notify.warning $"failed to connect to host" ;;
*) notify.warning $"curl error (exit code: $retval)" ;;
esac
case "$retval" in
0) ;;
6) notify.warning $"couldn't resolve host" ;;
7) notify.warning $"failed to connect to host" ;;
*) notify.warning $"curl error (exit code: $retval)" ;;
esac
local svar svalue spck candidate_version
# filter "?var:" expressions
spck=`echo $pcknameverbatim | sed "s,%{?[A-Za-z0-9_]*:.*\(%[A-Za-z0-9_]*\)},\1,"`
local svar svalue spck candidate_version
# filter "?var:" expressions
spck=`echo $pcknameverbatim | \
sed "s,%{?[A-Za-z0-9_]*:.*\(%[A-Za-z0-9_]*\)},\1,"`
while true; do
svar=`echo $spck | sed "\
s,.*%[{]*\([A-Za-z0-9_]*\)[}]*.*,\1,"`
[ "$svar" = "$spck" ] && break
if [ "$svar" = "version" ]; then
svalue="\\\([A-Za-z0-9._]*\\\)"
else
svalue=`rpmvars.solve "%$svar" "$spec_dir/$specname.spec"`
[ "$svalue" = "%$svar" ] && svalue=
fi
spck=`echo $spck | sed "\
s,%[{]*$svar[}]*,$svalue,"`
done
while true; do
svar=`echo $spck | sed "\
s,.*%[{]*\([A-Za-z0-9_]*\)[}]*.*,\1,"`
[ "$svar" = "$spck" ] && break
if [ "$svar" = "version" ]; then
svalue="\\\([A-Za-z0-9._]*\\\)"
else
svalue=`rpmvars.solve "%$svar" "$spec_dir/$specname.spec"`
[ "$svalue" = "%$svar" ] && svalue=
fi
spck=`echo $spck | sed "\
s,%[{]*$svar[}]*,$svalue,"`
done
# remove archiver extension from rexexp to match changes
local pcknameregexp=$(echo [^A-Za-z0-9._-]$spck | sed "\
s,\.gz$,\\\.,
s,\.tgz$,\\\.,
s,\.bz2$,\\\.,
s,\.lzma$,\\\.,
s,\.lz$,\\\.,
s,\.tbz2$,\\\.,")
# remove archiver extension from rexexp to match changes
local pcknameregexp=$(echo [^A-Za-z0-9._-]$spck | sed "\
s,\.gz$,\\\.,
s,\.tgz$,\\\.,
s,\.bz2$,\\\.,
s,\.lzma$,\\\.,
s,\.lz$,\\\.,
s,\.tbz2$,\\\.,")
local retval=$?
notify.debug "$FUNCNAME: pcknameregexp = $pcknameregexp"
local retval=$?
notify.debug "$FUNCNAME: pcknameregexp = $pcknameregexp"
if [ $retval -eq 0 ]; then
if [ "${pcknameregexp/(/}" = "${pcknameregexp}" ]; then
notify.warning "* "$"not parametric source0 name; cannot update"
else
candidate_versions=($(\
if [ $retval -eq 0 ]; then
if [ "${pcknameregexp/(/}" = "${pcknameregexp}" ]; then
notify.warning "* "$"not parametric source0 name; cannot update"
else
candidate_versions=($(\
grep -i "$pcknameregexp" $fcurlout | \
sed "\
s,.*$pcknameregexp.*,\1,g
@ -383,42 +391,46 @@ s,\.tbz2$,,
s,\.lz$,," |
sort -t. -n -r -k1 -k2 -k3 -k4 -k5 -k6 -k7 -k8 -k9 -k10 ))
local curr_version_dots new_version_dots candidate_version
curr_version_dots=`echo $SPEC_VERSION | tr -d [0-9][A-Z][a-z]_`
for candidate_version in ${candidate_versions[*]}; do
# skip version with no dots if current version has at least one
# (e.g. date release like 20000110)
new_version_dots=`echo $candidate_version | tr -d [0-9][A-Z][a-z]_`
[ "${#new_version_dots}" = 0 -a ${#curr_version_dots} -gt 0 ] &&
continue
new_version="$candidate_version"
break
done
local curr_version_dots new_version_dots candidate_version
curr_version_dots=`echo $SPEC_VERSION | tr -d [0-9][A-Z][a-z]_`
for candidate_version in ${candidate_versions[*]}; do
# skip version with no dots if current version has at least
# one (e.g. date release like 20000110)
new_version_dots=`echo $candidate_version | \
tr -d [0-9][A-Z][a-z]_`
[ "${#new_version_dots}" = 0 -a \
${#curr_version_dots} -gt 0 ] &&
continue
new_version="$candidate_version"
break
done
fi
fi
fi
if [ "$new_version" ]; then
notify.note "* "$"found version:"" \`${NOTE}$new_version${NORM}'"
last_version="$new_version"
else
notify.debug "$FUNCNAME: no new version found in current site"
if [ "$new_version" ]; then
notify.note "* "$"found version:"" \`${NOTE}$new_version${NORM}'"
last_version="$new_version"
else
notify.debug "$FUNCNAME: no new version found in current site"
fi
fi
fi
# sourceforge.net, sf.net
if [ "${apse_enabled[1]}" = "1" ]; then
notify.note $"looking at"" ${NOTE}(#1)${NORM} \
<${NOTE}${apse_site_name[1]}${NORM}>..."
local prj_name
notify.note $"looking at"" ${NOTE}(#1)${NORM} <${NOTE}${apse_site_name[1]}${NORM}>..."
prj_name=$specname
prj_name="$specname"
[ "$prj_name" ] || notify.error $"\
(bug)"" -- $FUNCNAME: "$"assertion failed:"" \"\$prj_name\" != \"\""
curr_curl_url="http://sourceforge.net/projects/$prj_name/files/latest"
notify.debug "running: curl \$curr_curl_proxy_opts -s -L \"$curr_curl_url\""
curl $curr_curl_proxy_opts -I -A Linux -s -L "$curr_curl_url" > $fcurlout
notify.debug \
"running: curl \$curr_curl_proxy_opts -s -L \"$curr_curl_url\""
curl $curr_curl_proxy_opts -I -A Linux -s -L "$curr_curl_url" \
> $fcurlout
let "retval = $?"
case "$retval" in
@ -432,12 +444,15 @@ sort -t. -n -r -k1 -k2 -k3 -k4 -k5 -k6 -k7 -k8 -k9 -k10 ))
if [ "$(sed -n "s,.*Invalid Project.*,error,pi" $fcurlout)" != \
"error" ]; then
[ "$src_name" ] || src_name="$specname"
pck_file=`grep -i -m1 "Location:" $fcurlout | \
grep -i "$src_name" | \
sed -n "s,Location: \(.*\)/download,\1,pi"`
notify.debug "$FUNCNAME: pck_file = \"$pck_file\""
[ "$src_name" ] && unset src_name
new_version=`echo $pck_file | sed "s|.*/\([0-9.]*\)/.*|\1|"`
[ "$new_version" ] || \
new_version=`echo $pck_file | sed -n "\
/[0-9]/!q # return nothing if no number is found in the package name
@ -463,11 +478,13 @@ s|.*/\([0-9.]*\)/.*|\1|
# look at the other supported web sites...
# skip perl packages to prevent name confusion; these are checked above via Source0
# skip perl packages to prevent name confusion;
# these are checked above via Source0
if [ ! "$(echo $pckurl | grep "cpan.org")" ]; then
for i in ${!apse_site_name[@]}; do
[ $i -le 1 ] && continue
[ "${apse_enabled[$i]}" = "0" ] && { notify.debug \
[ "${apse_enabled[$i]}" = "0" ] &&
{ notify.debug \
"$FUNCNAME: skipping ${apse_site_name[$i]}"; continue; }
notify.note \
$"looking at"" ${NOTE}(#$i)${NORM} <${NOTE}${apse_site_name[$i]}${NORM}>..."
@ -479,9 +496,11 @@ $"looking at"" ${NOTE}(#$i)${NORM} <${NOTE}${apse_site_name[$i]}${NORM}>..."
if [ "${apse_put_fields[$i]}" ]; then
notify.debug "\
running: curl \$curr_curl_proxy_opts -s -L -d \"${apse_put_fields[$i]}${search_name}\" \"$curr_curl_url\""
running: curl \$curr_curl_proxy_opts -s -L -d \
\"${apse_put_fields[$i]}${search_name}\" \"$curr_curl_url\""
curl $curr_curl_proxy_opts -s -L -d \
"${apse_put_fields[$i]}${search_name}" "$curr_curl_url" > $fcurlout
"${apse_put_fields[$i]}${search_name}" "$curr_curl_url" \
> $fcurlout
else
notify.debug "\
running: curl \$curr_curl_proxy_opts -s -L \"$curr_curl_url\""
@ -500,12 +519,15 @@ running: curl \$curr_curl_proxy_opts -s -L \"$curr_curl_url\""
if [ "$(cat $fcurlout | sed -n "\
s,.*${apse_error_msg[$i]}.*,error,pi")" != "error" ]; then
current_sed="$(echo "${apse_sed[$i]}" | sed -e "s,\${search_name},${search_name},g")"
if [ "${apse_grep[$i]}" ]; then
current_grep="$(echo "${apse_grep[$i]}" | sed -e "s,\${search_name},${search_name},g")"
current_sed="\
$(echo "${apse_sed[$i]}" | sed -e "s,\${search_name},${search_name},g")"
if [ "${apse_grep[$i]}" ]; then
current_grep="\
$(echo "${apse_grep[$i]}" | sed -e "s,\${search_name},${search_name},g")"
notify.debug "\
running: grep -i -m1 \"$current_grep\" \$fcurlout | sed -n \"$current_sed\""
new_version=$(grep -i -m1 "$current_grep" $fcurlout | sed -n "$current_sed")
new_version="$(\
grep -i -m1 "$current_grep" $fcurlout | sed -n "$current_sed")"
else
notify.debug "\
running: sed -n \"$current_sed\" \$fcurlout"
@ -515,14 +537,16 @@ running: sed -n \"$current_sed\" \$fcurlout"
notify.note "\
* "$"found version:"" \`${NOTE}$new_version${NORM}'"
if [ "$last_version" ]; then
notify.debug "apse.cmpversion \"$last_version\" \"$new_version\""
notify.debug "\
apse.cmpversion \"$last_version\" \"$new_version\""
apse.cmpversion "$last_version" "$new_version"
[ $? -eq 2 ] && last_version="$new_version"
else
last_version="$new_version"
fi
else
notify.debug "$FUNCNAME: no new version found in current site"
notify.debug \
"$FUNCNAME: no new version found in current site"
fi
else
notify.debug "$FUNCNAME: no new version found in current site"
@ -543,12 +567,14 @@ last version of \`${NOTE}$specname${NORM}' found:"" \
retval=$?
if [ $retval -eq 0 ]; then
notify.note $"package \`${NOTE}$specname${NORM}' is already the latest version"
notify.note \
$"package \`${NOTE}$specname${NORM}' is already the latest version"
elif [ $retval -eq 2 ]; then
notify.note $"\
a new version of \`${NOTE}$specname${NORM}' is available!"
else
notify.warning $"a newer version of \`${NOTE}$specname${NORM}' is already installed"
notify.warning $"\
a newer version of \`${NOTE}$specname${NORM}' is already installed"
fi
else
notify.warning $"cannot find a new version of \`$specname'"