From 8b06b41b205c000282b88f4f9e1e8bcffbb7b01f Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Wed, 5 Jun 2013 00:23:06 +0200 Subject: [PATCH] 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: --- lib/libapse.lib.in | 13 +++++++++++-- lib/libspec.lib.in | 10 +++++++++- plugins/pck-update.in | 6 +++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/lib/libapse.lib.in b/lib/libapse.lib.in index 16bce9d..a1a96ce 100644 --- a/lib/libapse.lib.in +++ b/lib/libapse.lib.in @@ -238,6 +238,7 @@ Copyright (C) 2008-2011 Silvan Calarco "" -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 "" } 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]}" diff --git a/lib/libspec.lib.in b/lib/libspec.lib.in index 69de8e2..9769dfd 100644 --- a/lib/libspec.lib.in +++ b/lib/libspec.lib.in @@ -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" && \ diff --git a/plugins/pck-update.in b/plugins/pck-update.in index bb52f77..ff83fb0 100644 --- a/plugins/pck-update.in +++ b/plugins/pck-update.in @@ -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=$?