From 7350b61bb27b291e646d14e6524d485eceddd184 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sat, 8 May 2021 12:13:41 +0200 Subject: [PATCH] pck-update.in: don't replace build requirement block if it contains a conditional macro; basic support for rich deps --- plugins/pck-update.in | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/plugins/pck-update.in b/plugins/pck-update.in index db9d544..f69960e 100644 --- a/plugins/pck-update.in +++ b/plugins/pck-update.in @@ -2124,7 +2124,6 @@ ${proxy:+--proxy $proxy} ${proxy_user:+--proxy-user $proxy_user} \ $USER_RPMDEFINE_OPTS $rpmbuild_opts $rpm_root_opts \ $SRPM_SPECFILE_WITH_PATH 2>&1" || notify.error $"rpmbuild exited with error code":" \`$?'" - notify.debug "define_list_name = (${define_list_name[*]})" notify.debug "define_list_value = (${define_list_value[*]})" @@ -2299,6 +2298,9 @@ build the list of the build requirements""${NORM}" elif [ "${req:0:1}" = "/" ]; then # file requirement; ignore : + elif [ "${req:0:1}" = "(" ]; then + # rich requirement; add as it is + buildreq="$line" elif [ "${req:0:7}" = "rpmlib(" -o \ "${req:0:7}" = "config(" -o \ "${req:0:5}" = "rtld(" -o \ @@ -2315,7 +2317,7 @@ build the list of the build requirements""${NORM}" sed "s|\(.*\)-[^-]*-[^-]*|\1|") [ "$buildreq" ] && break done - [ "$buildreq" ] || echo "BuildRequires: $req" + [ "$buildreq" ] || buildreq="$req" elif [ "${req}" = "python(abi)" ]; then # FIXME: libpython-devel should be defined in autospec.conf # python requirement @@ -2402,25 +2404,29 @@ $(echo $solibpath | sed "s|-[0-9.]*\.so|.so|")" fi done ) | sort -u >> $frequires - [ "$replace_autobuildreq" = 1 ] && - notify.note " -${NOTE}"$"replacing the AUTOBUILDREQ block by:""${NORM}" - notify.note " ## AUTOBUILDREQ-BEGIN" cat $frequires - notify.note "## AUTOBUILDREQ-END -" + notify.note "## AUTOBUILDREQ-END" if [ "$replace_autobuildreq" = 1 ]; then - sed -i "/^## AUTOBUILDREQ/d" $frequires - sed -i -ne "/## AUTOBUILDREQ-BEGIN/{p;r $frequires" \ - -e ':a;n;/## AUTOBUILDREQ-END/{p;b};ba};p' \ - $SRPM_SPECFILE_WITH_PATH - notify.note " -${NOTE}"$"recreating the SRPM""${NORM}" - eval "\ + sed -n '/^## AUTOBUILDREQ-BEGIN/,/^## AUTOBUILDREQ-END/p' \ + $SRPM_SPECFILE_WITH_PATH | grep -q "%if" && skip_replace_autobuildreq=1 + + if [ "$skip_replace_autobuildreq" ]; then + notify.note "${NOTE}"$" +skipping replacing the AUTOBUILDREQ block because it contains a conditional macro""${NORM}" + else + notify.note "${NOTE}"$" +Replacing the AUTOBUILDREQ block and recreating the SRPM""${NORM}" + + sed -i "/^## AUTOBUILDREQ/d" $frequires + sed -i -ne "/## AUTOBUILDREQ-BEGIN/{p;r $frequires" \ + -e ':a;n;/## AUTOBUILDREQ-END/{p;b};ba};p' \ + $SRPM_SPECFILE_WITH_PATH + eval "\ rpmbuild -bs $USER_RPMDEFINE_OPTS $rpmbuild_opts \ $SRPM_SPECFILE_WITH_PATH 2>&1" + fi fi rm -f $frequires