libapse: perform sourceforge search for any package and modify to use http://sourceforge.com/projects/project_name/files/latest to retrieve latest version number
This commit is contained in:
parent
aa237198c2
commit
37e4431bd3
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
# libapse.lib -- Autospec Package Search Engine library
|
||||
# Copyright (C) 2007 Stefano Cotta Ramusino <stefano.cotta@openmamba.org>
|
||||
# Copyright (C) 2008,2009,2010 Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
# Copyright (C) 2008-2011 Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
|
||||
[ -z "$BASH" ] || [ ${BASH_VERSION:0:1} -lt 2 ] &&
|
||||
echo $"this script requires bash version 2 or better" >&2 && exit 1
|
||||
@ -399,46 +399,34 @@ sort -t. -n -r -k1 -k2 -k3 -k4 -k5 -k6 -k7 -k8 -k9 -k10 ))
|
||||
|
||||
local prj_name
|
||||
|
||||
if [ "$(echo $pckurl | grep "sourceforge.net\|sf.net")" ]; then
|
||||
notify.note $"looking at"" <${NOTE}http://sourceforge.net${NORM}>..."
|
||||
notify.note $"looking at"" <${NOTE}http://sourceforge.net${NORM}>..."
|
||||
|
||||
prj_name=$(echo "$pckurl" | sed -n 's,.*/\(.*\)/.*,\1,p')
|
||||
[ "$prj_name" ] || notify.error $"\
|
||||
prj_name=$specname
|
||||
[ "$prj_name" ] || notify.error $"\
|
||||
(bug)"" -- $FUNCNAME: "$"assertion failed:"" \"\$prj_name\" != \"\""
|
||||
|
||||
curr_curl_url="http://sourceforge.net/projects/$prj_name"
|
||||
notify.debug "curl \$curr_curl_proxy_opts -s -L \"$curr_curl_url\""
|
||||
curl $curr_curl_proxy_opts -s -L "$curr_curl_url" > $fcurlout
|
||||
curr_curl_url="http://sourceforge.net/projects/$prj_name/files/latest"
|
||||
notify.debug "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
|
||||
0) ;;
|
||||
6) notify.warning $"couldn't resolve host" ;;
|
||||
7) notify.warning $"failed to connect to host" ;;
|
||||
*) notify.warning $"curl error (exit code: $retval)" ;;
|
||||
esac
|
||||
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
|
||||
|
||||
[ "$retval" = "0" ] &&
|
||||
if [ "$(sed -n "s,.*Invalid Project.*,error,pi" $fcurlout)" != \
|
||||
"error" ]; then
|
||||
[ "$src_name" ] || src_name="$specname"
|
||||
|
||||
pck_file=`grep -i -m1 "/download" $fcurlout | \
|
||||
[ "$retval" = "0" ] &&
|
||||
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,.*\"\([^\"]*\)\/download\".*,\1,pi"`
|
||||
notify.debug "pck_file = \"$pck_file\""
|
||||
[ "$src_name" ] && unset src_name
|
||||
|
||||
new_version=`echo $pck_file | sed -n "\
|
||||
/[0-9]/!q # return nothing if no number is found in the package name
|
||||
s,.*/,, # remove directory name, if any
|
||||
s/\.[^0-9].*// # remove trailing stuff (.tar.gz, ...)
|
||||
/-[0-9]*/{s/.*-\([0-9]*.*\)/\1/p;q} # <pck_name>-<pck_ver>
|
||||
/_[0-9]*/{s/.*_\([0-9]*.*\)/\1/p;q} # <pck_name>_<pck_ver>
|
||||
/[^-\.][0-9]\./{s/.*[^-\.]\([0-9]\..*\)/\1/p;q} # <pck_name><pck_ver>
|
||||
# <pck_name> (no version, but <pck_name> can end with numbers)
|
||||
/^[^0-9]*[0-9]*$/q"`
|
||||
fi
|
||||
sed -n "s,Location: \(.*\)/download,\1,pi"`
|
||||
notify.debug "pck_file = \"$pck_file\""
|
||||
[ "$src_name" ] && unset src_name
|
||||
new_version=`echo $pck_file | sed "s|.*/\([0-9.]*\)/.*|\1|"`
|
||||
fi
|
||||
|
||||
if [ "$new_version" ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user