libapse.lib.in: support for repology.org: add replace for \${search_name} in apse_uri; add jq JSON parse support via apse_jq

03-apse.conf: add repology.org and treat as obsolete all other sources by disabling or commenting them
This commit is contained in:
Silvan Calarco 2021-03-27 13:23:09 +01:00
parent b182afc54c
commit 88490f3dfe
2 changed files with 75 additions and 62 deletions

View File

@ -3,69 +3,75 @@
apse_enabled[0]=1 apse_enabled[0]=1
apse_site_name[0]="source0" apse_site_name[0]="source0"
apse_enabled[1]=1 apse_enabled[1]=0
apse_site_name[1]="http://sourceforge.net" apse_site_name[1]="https://sourceforge.net"
apse_enabled[2]=1 apse_enabled[2]=1
apse_site_name[2]="http://fileforum.betanews.com" apse_site_name[2]="https://repology.org"
apse_uri[2]="http://fileforum.betanews.com/search?search_advanced=Search+Fileforum&os%5B%5D=12&alphabeta=R&title=" apse_uri[2]="https://repology.org/api/v1/projects/\${search_name}/"
apse_put_fields[2]="" apse_error_msg[2]="Not found"
apse_error_msg[2]="No releases " apse_jq[2]="try [.\"\${search_name}\"[] | select(.status | contains(\"newest\"))][0] |.version"
apse_grep[2]=""
apse_sed[2]="s,.*<p><a href=\"http://fileforum.betanews.com/detail/[^ ]*>\${search_name}[^<]*[ ]\([^ <]*\)</a></p>.*,\1,pi"
apse_enabled[3]=1 #apse_enabled[2]=0
apse_site_name[3]="http://linux.softpedia.com" #apse_site_name[2]="http://fileforum.betanews.com"
apse_uri[3]="http://linux.softpedia.com/progFinder" #apse_uri[2]="http://fileforum.betanews.com/search?search_advanced=Search+Fileforum&os%5B%5D=12&alphabeta=R&title="
apse_put_fields[3]="search_term=" #apse_put_fields[2]=""
apse_error_msg[3]="No results " #apse_error_msg[2]="No releases "
apse_grep[3]="<h2><a[^<]*\${search_name}[^a-zA-Z]" #apse_grep[2]=""
apse_sed[3]="s,.*<h2><a[^<]*\${search_name}[^<]*[ ]\([^ <]*\)</a>.*,\1,pi" #apse_sed[2]="s,.*<p><a href=\"http://fileforum.betanews.com/detail/[^ ]*>\${search_name}[^<]*[ ]\([^ <]*\)</a></p>.*,\1,pi"
apse_enabled[4]=1 #apse_enabled[3]=0
apse_site_name[4]="http://gnomefiles.org" #apse_site_name[3]="http://linux.softpedia.com"
apse_uri[4]="http://gnomefiles.org/content/search.php" #apse_uri[3]="http://linux.softpedia.com/progFinder"
apse_put_fields[4]="search=Search&text=" #apse_put_fields[3]="search_term="
apse_error_msg[4]="No entries\. " #apse_error_msg[3]="No results "
apse_grep[4]="" #apse_grep[3]="<h2><a[^<]*\${search_name}[^a-zA-Z]"
apse_sed[4]="s,.*\${search_name}</span></a></h1>&nbsp;\([^&]*\)&nbsp;<.*,\1,pi" #apse_sed[3]="s,.*<h2><a[^<]*\${search_name}[^<]*[ ]\([^ <]*\)</a>.*,\1,pi"
apse_enabled[5]=1 #apse_enabled[4]=0
apse_site_name[5]="http://freecode.com" #apse_site_name[4]="http://gnomefiles.org"
apse_uri[5]="http://freecode.com/projects/" #apse_uri[4]="http://gnomefiles.org/content/search.php"
apse_put_fields[5]="" #apse_put_fields[4]="search=Search&text="
apse_error_msg[5]="404 Not Found" #apse_error_msg[4]="No entries\. "
apse_grep[5]="/releases/" #apse_grep[4]=""
apse_sed[5]="s,.*<a href=\"/projects/\${search_name}/releases/[0-9]*\">\([^ <]*\)</a>.*,\1,pi" #apse_sed[4]="s,.*\${search_name}</span></a></h1>&nbsp;\([^&]*\)&nbsp;<.*,\1,pi"
apse_enabled[6]=1 #apse_enabled[5]=0
apse_site_name[6]="http://sourcewell.berlios.de" #apse_site_name[5]="http://freecode.com"
apse_uri[6]="http://sourcewell.berlios.de/appsearch.php?by=Importance&search=" #apse_uri[5]="http://freecode.com/projects/"
apse_put_fields[6]="" #apse_put_fields[5]=""
apse_error_msg[6]="No Application found" #apse_error_msg[5]="404 Not Found"
apse_grep[6]="appbyid.*\${search_name}[^a-zA-Z].*Stable" #apse_grep[5]="/releases/"
apse_sed[6]="s,.*<a href=\"appbyid.*\">\${search_name} \([^ <]*\)</a>.*,\1,pi" #apse_sed[5]="s,.*<a href=\"/projects/\${search_name}/releases/[0-9]*\">\([^ <]*\)</a>.*,\1,pi"
apse_enabled[7]=1 #apse_enabled[6]=0
apse_site_name[7]="http://distrowatch.gds.tuwien.ac.at" #apse_site_name[6]="http://sourcewell.berlios.de"
apse_uri[7]="http://distrowatch.gds.tuwien.ac.at/packages.php?" #apse_uri[6]="http://sourcewell.berlios.de/appsearch.php?by=Importance&search="
apse_put_fields[7]="" #apse_put_fields[6]=""
apse_error_msg[7]="is currently being redesigned" #apse_error_msg[6]="No Application found"
apse_grep[7]="td.*/\${search_name}[-_][0-9]" #apse_grep[6]="appbyid.*\${search_name}[^a-zA-Z].*Stable"
apse_sed[7]="s,.*td><[^>]*>\([^ <]*\)<.*,\1,pi" #apse_sed[6]="s,.*<a href=\"appbyid.*\">\${search_name} \([^ <]*\)</a>.*,\1,pi"
apse_enabled[8]=1 #apse_enabled[7]=0
apse_site_name[8]="http://directory.fsf.org" #apse_site_name[7]="http://distrowatch.gds.tuwien.ac.at"
apse_uri[8]="http://directory.fsf.org/wiki/" #apse_uri[7]="http://distrowatch.gds.tuwien.ac.at/packages.php?"
apse_put_fields[8]="" #apse_put_fields[7]=""
apse_error_msg[8]="is currently no text" #apse_error_msg[7]="is currently being redesigned"
apse_grep[8]="" #apse_grep[7]="td.*/\${search_name}[-_][0-9]"
apse_sed[8]="s,^version \([^ ]*\).*,\1,pi" #apse_sed[7]="s,.*td><[^>]*>\([^ <]*\)<.*,\1,pi"
apse_enabled[9]=1 #apse_enabled[8]=0
apse_site_name[9]="http://launchpad.net" #apse_site_name[8]="http://directory.fsf.org"
apse_uri[9]="http://launchpad.net/" #apse_uri[8]="http://directory.fsf.org/wiki/"
apse_put_fields[9]="" #apse_put_fields[8]=""
apse_error_msg[9]="page does not exist" #apse_error_msg[8]="is currently no text"
apse_grep[9]="" #apse_grep[8]=""
apse_sed[9]="s,.*Latest version is \([^ ]*\).*,\1,pi" #apse_sed[8]="s,^version \([^ ]*\).*,\1,pi"
#apse_enabled[9]=0
#apse_site_name[9]="http://launchpad.net"
#apse_uri[9]="http://launchpad.net/"
#apse_put_fields[9]=""
#apse_error_msg[9]="page does not exist"
#apse_grep[9]=""
#apse_sed[9]="s,.*Latest version is \([^ ]*\).*,\1,pi"

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# libapse.lib -- Autospec Package Search Engine library # libapse.lib -- Autospec Package Search Engine library
# Copyright (C) 2007,2012 Stefano Cotta Ramusino <stefano.cotta@openmamba.org> # Copyright (C) 2007,2012 Stefano Cotta Ramusino <stefano.cotta@openmamba.org>
# Copyright (C) 2008-2011 Silvan Calarco <silvan.calarco@mambasoft.it> # Copyright (C) 2008-2021 Silvan Calarco <silvan.calarco@mambasoft.it>
[ "$libapse_is_loaded" = 1 ] || { [ "$libapse_is_loaded" = 1 ] || {
libapse_is_loaded=1 libapse_is_loaded=1
@ -497,10 +497,10 @@ sed -n "s,Location: \(.*\)?.*,\1,pi"`
$"looking at"" ${NOTE}(#$i)${NORM} <${NOTE}${apse_site_name[$i]}${NORM}>..." $"looking at"" ${NOTE}(#$i)${NORM} <${NOTE}${apse_site_name[$i]}${NORM}>..."
for search_name in $src_name $specname; do for search_name in $src_name $specname; do
[ "${apse_put_fields[$i]}" ] && [ "${apse_put_fields[$i]}" ] && curr_curl_url="${apse_uri[$i]}" || {
curr_curl_url="${apse_uri[$i]}" || curr_curl_url="$(echo "${apse_uri[$i]}" | sed -e "s,\${search_name},\L${search_name},g")"
curr_curl_url="${apse_uri[$i]}${search_name}" [ "${curr_curl_url}" = "${apse_uri[$i]}" ] && curr_curl_url="${apse_uri[$i]}${search_name}"
}
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 \ running: curl \$curr_curl_proxy_opts -s -L -d \
@ -535,6 +535,13 @@ $(echo "${apse_grep[$i]}" | sed -e "s,\${search_name},${search_name},g")"
running: grep -i -m1 \"$current_grep\" \$fcurlout | sed -n \"$current_sed\"" running: grep -i -m1 \"$current_grep\" \$fcurlout | sed -n \"$current_sed\""
new_version="$(\ new_version="$(\
grep -i -m1 "$current_grep" $fcurlout | sed -n "$current_sed")" grep -i -m1 "$current_grep" $fcurlout | sed -n "$current_sed")"
elif [ "${apse_jq[$i]}" ]; then
current_jq="\
$(echo "${apse_jq[$i]}" | sed -e "s,\${search_name},\L${search_name},g")"
notify.debug "\
running: jq \"$current_jq\" \$fcurlout"
new_version="$(\
jq -r "$current_jq" $fcurlout)"
else else
notify.debug "\ notify.debug "\
running: sed -n \"$current_sed\" \$fcurlout" running: sed -n \"$current_sed\" \$fcurlout"