libapse.lib: support for user-agent in curl request

This commit is contained in:
Silvan Calarco 2024-04-15 12:17:36 +02:00
parent a12a4f740b
commit b391f4952c
3 changed files with 14 additions and 11 deletions

View File

@ -192,4 +192,3 @@ mostlyclean:
$(MAKE) clean -C po/$$loc || exit 1;\
done
@rm -f po/*.pot

View File

@ -7,10 +7,12 @@
curl_opts_netlink="--connect-timeout 15 --retry 3"
# (default: "-L --remote-name --fail --progress-bar $curl_opts_netlink")
curl_options="-R -L --remote-name --fail --progress-bar $curl_opts_netlink"
# Sintax for 'proxy': "proxyhost:port"
# Syntax for 'proxy': "proxyhost:port"
proxy=""
# Sintax for 'proxy_user': "user:password"
proxy_user=""
# curl user agent
curl_user_agent="autospec/@version@ (Linux; openmamba; reports@openmamba.org)"
# Commands to run when a rpm package must be automatically installed
# (NOTE: it could be necessary to manually configure sudo

View File

@ -1,7 +1,7 @@
#!/bin/bash
# libapse.lib -- Autospec Package Search Engine library
# Copyright (C) 2007,2012 Stefano Cotta Ramusino <stefano.cotta@openmamba.org>
# Copyright (C) 2008-2021 Silvan Calarco <silvan.calarco@mambasoft.it>
# Copyright (C) 2008-2024 Silvan Calarco <silvan.calarco@mambasoft.it>
[ "$libapse_is_loaded" = 1 ] || {
libapse_is_loaded=1
@ -321,6 +321,8 @@ proxy:,proxy-user:,autoupdate-off: \
local curr_curl_url pck_file new_version last_version
local curr_curl_proxy_opts="\
${proxy:+ --proxy $proxy}${proxy_user:+ --proxy-user $proxy_user}"
local curr_curl_user_agent_opts="\
${curl_user_agent:+ --user-agent \"$curl_user_agent\"}"
for i in `seq 1 ${#autoupdate_off[*]}`; do
apse_enabled[${autoupdate_off[$i-1]}]="0"
@ -343,9 +345,9 @@ ${proxy:+ --proxy $proxy}${proxy_user:+ --proxy-user $proxy_user}"
<${NOTE}$curr_curl_url${NORM}> (\`${NOTE}source0${NORM}')..."
notify.debug "\
running: curl \$curr_curl_proxy_opts -s -L \"$curr_curl_url\""
running: curl $curr_curl_proxy_opts $curr_curl_user_agent_opts -s -L \"$curr_curl_url\""
curl $curl_opts_netlink \
$curr_curl_proxy_opts -s -L "$curr_curl_url" \
$curr_curl_proxy_opts $curr_curl_user_agent_opts -s -L "$curr_curl_url" \
> $fcurlout
let "retval = $?"
@ -446,8 +448,8 @@ sort -t. -n -r -k1 -k2 -k3 -k4 -k5 -k6 -k7 -k8 -k9 -k10 ))
curr_curl_url="http://sourceforge.net/projects/$src_name/files/latest/download"
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" \
"running: curl $curr_curl_proxy_opts $curr_curl_user_agent_opts -s -L \"$curr_curl_url\""
curl $curr_curl_proxy_opts $curr_curl_user_agent_opts -I -A Linux -s -L "$curr_curl_url" \
> $fcurlout
let "retval = $?"
@ -503,15 +505,15 @@ $"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 \
running: curl $curr_curl_proxy_opts $curr_curl_user_agent_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 $curr_curl_user_agent_opts -s -L -d \
"${apse_put_fields[$i]}${search_name}" "$curr_curl_url" \
> $fcurlout
else
notify.debug "\
running: curl \$curr_curl_proxy_opts -s -L \"$curr_curl_url\""
curl $curr_curl_proxy_opts -s -L "$curr_curl_url" > $fcurlout
running: curl $curr_curl_proxy_opts $curr_curl_user_agent_opts -s -L \"$curr_curl_url\""
curl $curr_curl_proxy_opts $curr_curl_user_agent_opts -s -L "$curr_curl_url" > $fcurlout
fi
let "retval = $?"