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 Action 3: generate correct download URL getting new version from action 2
or from command line parameter. or from command line parameter.
+ update
* lib/libapse.lib, lib/libspec.lib - Davide Madrisan:
Style fixes.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Changes in version 1.12.2 Changes in version 1.12.2

View File

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