[OT] how to see if an rpm file will modify config files upon update

Gianluca Cecchi gianluca.cecchi at gmail.com
Thu May 8 14:57:23 UTC 2014


Finally I found the culprit.. in other occasions I have searched for it but
I was not able to find.
Probably the correct google search combination today ;-)

http://www.redhat.com/archives/rpm-list/2003-October/msg00134.html

"
The bit that implements %config(noreplace) maps to (from lib/rpmlib.h):
rpmlib.h: RPMFILE_NOREPLACE = (1 << 4), /*!< from %%config(noreplace) */
"

One way to check against a file (eg httpd.conf):

QFILE=/etc/httpd/conf/httpd.conf
BITSET=$(rpm -q --qf '[%{filenames}: %{fileflags}\n]' -f $QFILE | grep
"^${QFILE}:" | cut -d ":" -f 2)
RESULT=$(echo $(($BITSET & 16)))
if [ $RESULT -eq 16 ]; then echo "NO replace"; else  echo "REPLACE"; fi

For example in RH EL 6.5 with httpd-2.2.22-25.ep6.el6.x86_64  that has in
its source rpm a line such as

%config %{_sysconfdir}/httpd/conf/httpd.conf

$ echo $QFILE
/etc/httpd/conf/httpd.conf

$ echo $BITSET
1

$ echo $RESULT
0

$ if [ $RESULT -eq 16 ]; then echo "NO replace"; else  echo "REPLACE"; fi
REPLACE

While in Fedora 20 with httpd-2.4.9-2.fc20.x86_64 that comes instead in
source rpm with:

%config(noreplace) %{_sysconfdir}/httpd/conf/httpd.conf

[g.cecchi at ope46 ~]$ QFILE=/etc/httpd/conf/httpd.conf
[g.cecchi at ope46 ~]$ BITSET=$(rpm -q --qf '[%{filenames}: %{fileflags}\n]'
-f $QFILE | grep "^${QFILE}:" | cut -d ":" -f 2)
[g.cecchi at ope46 ~]$ RESULT=$(echo $(($BITSET & 16)))

[g.cecchi at ope46 ~]$ if [ $RESULT -eq 16 ]; then echo "NO replace"; else
 echo "REPLACE"; fi
NO replace

[g.cecchi at ope46 ~]$ echo $QFILE
/etc/httpd/conf/httpd.conf
[g.cecchi at ope46 ~]$ echo $BITSET
17
[g.cecchi at ope46 ~]$ echo $RESULT
16

And the thing works querying both the package and the rpm file (eg using in
this last case
rpm -q --qf '[%{filenames}: %{fileflags}\n]' -p
httpd-2.2.22-25.ep6.el6.x86_64.rpm | grep "^${QFILE}:" | cut -d ":" -f 2
)

Thanks anyway,
Gianluca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.fedoraproject.org/pipermail/users/attachments/20140508/c3fa2fa3/attachment.html>


More information about the users mailing list