From 08bfa59a98f4ee110b15d38ea133414fa6a37aad Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Tue, 25 Jun 2019 22:21:20 +0200 Subject: [PATCH] libspec.lib: use rpmspec -P instead of rpm -q --specedit ... if rpm 4 is detected --- conf/autospec.conf.in | 3 +++ lib/libspec.lib.in | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/conf/autospec.conf.in b/conf/autospec.conf.in index 8876875..36e5902 100644 --- a/conf/autospec.conf.in +++ b/conf/autospec.conf.in @@ -23,6 +23,9 @@ packager_fullname= packager_email= +## Detect rpm version +rpm_version="`rpm --version | sed 's|.* .* ||'`" + ## Mode to be used when creating and updating the specfiles ------------------- rpm_specfile_mode="644" diff --git a/lib/libspec.lib.in b/lib/libspec.lib.in index 5866c04..842ebb2 100644 --- a/lib/libspec.lib.in +++ b/lib/libspec.lib.in @@ -637,12 +637,21 @@ $FUNCNAME: specfile_preprocessed = \"$specfile_preprocessed\"" notify.error "$FUNCNAME: "$"can't create temporary files" notify.debug "$FUNCNAME: tmpspreprerr = \`${NOTE}$tmpspreprerr${NORM}'" - notify.debug "\ + if [ "${rpm_version:0:2}" == "5." ]; then + notify.debug "\ $FUNCNAME: running: rpm -q $rpm_options --specfile --specedit $specfile ..." - eval "\ + eval "\ rpm -q $rpm_options --specfile --specedit $specfile \ - > $specfile_preprocessed 2> $tmpspreprerr" + > $specfile_preprocessed 2> $tmpspreprerr" + else + notify.debug "\ +$FUNCNAME: running: rpmspec $rpm_options -P $specfile ..." + + eval "\ +rpmspec $rpm_options -P $specfile \ + > $specfile_preprocessed 2> $tmpspreprerr" + fi if [ -s "$tmpspreprerr" ]; then notify.warning $"\