pck-update, libspec, libapse: support for a special specfile macro to disable scraping from specified sources

E.g.: enter the macro below in the specfile to disable scrape sources with indexes 0,2 and 4:
This commit is contained in:
Silvan Calarco 2013-06-05 00:23:06 +02:00
parent 85d14ca35f
commit 8b06b41b20
3 changed files with 25 additions and 4 deletions

View File

@ -238,6 +238,7 @@ Copyright (C) 2008-2011 Silvan Calarco <silvan.calarco@mambasoft.it>""
-v, --pckurlverbatim "$"URL with no variable expansion""
-p, --proxy "$"Proxy""
-u, --proxy-user "$"Proxy user""
-o, --autoupdate-off "$"Indexes of apse sources to disable""
"$"Operation modes"":
-h, --help "$"Print this help, then exit""
@ -250,9 +251,9 @@ Copyright (C) 2008-2011 Silvan Calarco <silvan.calarco@mambasoft.it>""
}
local ARGS
ARGS=`LC_ALL=C getopt -o han:s:w:p:u: \
ARGS=`LC_ALL=C getopt -o han:s:w:p:u:o: \
--long help,allurl,pckname:,specname:,pckurl:,pckurlverbatim:,\
proxy:,proxy-user: \
proxy:,proxy-user:,autoupdate-off: \
-n "$FUNCNAME" -- "$@"`
[ $? = 0 ] || notify.error $"\
(bug)"" -- $FUNCNAME: "$"\`getopt' error"
@ -287,6 +288,10 @@ proxy:,proxy-user: \
proxy_user="$2"; shift
notify.debug "$FUNCNAME: proxy_user = \"***\""
;;
-o|--autoupdate-off)
autoupdate_off=($2); shift
notify.debug "$FUNCNAME: autoupdate_off = ($autoupdate_off)"
;;
-h|--help)
usage
${EXIT_FUNC:-"exit"}
@ -317,6 +322,10 @@ proxy:,proxy-user: \
local curr_curl_proxy_opts="\
${proxy:+ --proxy $proxy}${proxy_user:+ --proxy-user $proxy_user}"
for i in `seq 1 ${#autoupdate_off[*]}`; do
apse_enabled[${autoupdate_off[$i-1]}]="0"
done
# SOURCE0 url based search (only if 'pckurl' is a valid url)
if [ "${apse_enabled[0]}" = "0" ]; then
notify.debug "$FUNCNAME: skipping ${apse_site_name[0]}"

View File

@ -1253,12 +1253,20 @@ $FUNCNAME: SPEC_OBSOLETES = ( ${SPEC_OBSOLETES[*]} )"
fi
notify.debug "$FUNCNAME: $var = $SPEC_BUILDROOT"
;;
SPEC_AUTOUPDATE_OFF)
[ "$SPEC_AUTOUPDATE_OFF" ] && continue
SPEC_AUTOUPDATE_OFF=($(sed -n "\
/^### AUTOUPDATE-OFF:/{
s,### AUTOUPDATE-OFF:[ \t]*,,;{p}}" \
$specfile))
notify.debug "$FUNCNAME: $var = (${SPEC_AUTOUPDATE_OFF[*]})"
;;
*) notify.error $"(bug)"" -- $FUNCNAME: "$"bad arg \`$var'" ;;
esac
# note: some entries are not mandatory in a specfile
case "$var" in
"SPEC_SOURCE"|"SPEC_PATCH"|\
"SPEC_SOURCE"|"SPEC_PATCH"|"SPEC_AUTOUPDATE_OFF"| \
"SPEC_OBSOLETES"|"SPEC_BUILDARCH"|"SPEC_BUILDREQUIRES")
;;
*) if [[ "$var" = "SPEC_BUILDROOT" && \

View File

@ -1057,13 +1057,17 @@ check if a new version is available""${NORM}"
unset SPEC_SOURCE0_VERBATIM
specfile.getvars -s $SRPM_SPECFILE_WITH_PATH --verbatim SPEC_SOURCE0
unset SPEC_AUTOUPDATE_OFF
specfile.getvars -s $SRPM_SPECFILE_WITH_PATH SPEC_AUTOUPDATE_OFF
apse.scrapeversion \
--pckname "$SPEC_SOURCE0_PCKNAME" \
--pckurl "${SPEC_SOURCE[0]}" \
--pckurlverbatim "${SPEC_SOURCE0_VERBATIM}" \
--specname "$SPEC_NAME" \
${proxy:+ --proxy $proxy} \
${proxy_user:+ --proxy-user $proxy_user}
${proxy_user:+ --proxy-user $proxy_user} \
--autoupdate-off "${SPEC_AUTOUPDATE_OFF[*]}"
retval=$?