Hello, sorry if this question is more for rpm devs... I know that in a spec file the definition
%confg ......./file_name1 will cause update of an edited file_name1, saving the on disk one into .rpmsave before overwriting
while %confg(noreplace) ......./file_name2 will retain the edited file_name2 on disk and save the provided new config file into .rpmnew
The question is: can I see if a config file was defined in its spec with or without (noreplace) if I have not the spec file and the .src.rpm file, but I have only the final binary rpm?
I made some tests but I didn't find any difference Tried queries with "-c" option, with "-V" option and with "--dump" option. Both either with "-f package.rpm" and directly against rpm db but no information extracted. But I think this information should be in any way in the rpm itself...
Thanks in advance
Gianluca
On Thu, May 8, 2014 at 6:43 AM, Gianluca Cecchi gianluca.cecchi@gmail.comwrote:
Hello, sorry if this question is more for rpm devs... I know that in a spec file the definition
%confg ......./file_name1 will cause update of an edited file_name1, saving the on disk one into .rpmsave before overwriting
while %confg(noreplace) ......./file_name2 will retain the edited file_name2 on disk and save the provided new config file into .rpmnew
The question is: can I see if a config file was defined in its spec with or without (noreplace) if I have not the spec file and the .src.rpm file, but I have only the final binary rpm?
I think this is what you're looking for:
$ rpm -q --scripts httpd preinstall scriptlet (using /bin/sh): # Add the "apache" user /usr/sbin/useradd -c "Apache" -u 48 \ -s /sbin/nologin -r -d /usr/share/httpd apache 2> /dev/null || : postinstall scriptlet (using /bin/sh):
if [ $1 -eq 1 ] ; then # Initial installation /usr/bin/systemctl preset httpd.service htcacheclean.service
/dev/null 2>&1 || :
fi preuninstall scriptlet (using /bin/sh):
if [ $1 -eq 0 ] ; then # Package removal, not upgrade /usr/bin/systemctl --no-reload disable httpd.service htcacheclean.service > /dev/null 2>&1 || : /usr/bin/systemctl stop httpd.service htcacheclean.service > /dev/null 2>&1 || : fi postuninstall scriptlet (using /bin/sh):
/usr/bin/systemctl daemon-reload >/dev/null 2>&1 || :
# Trigger for conversion from SysV, per guidelines at: # https://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Systemd posttrans scriptlet (using /bin/sh): test -f /etc/sysconfig/httpd-disable-posttrans || \ /bin/systemctl try-restart httpd.service htcacheclean.service >/dev/null 2>&1 || : ---end---
Add a pipe to grep for config and you should get what you need.
Richard
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@ope46 ~]$ QFILE=/etc/httpd/conf/httpd.conf [g.cecchi@ope46 ~]$ BITSET=$(rpm -q --qf '[%{filenames}: %{fileflags}\n]' -f $QFILE | grep "^${QFILE}:" | cut -d ":" -f 2) [g.cecchi@ope46 ~]$ RESULT=$(echo $(($BITSET & 16)))
[g.cecchi@ope46 ~]$ if [ $RESULT -eq 16 ]; then echo "NO replace"; else echo "REPLACE"; fi NO replace
[g.cecchi@ope46 ~]$ echo $QFILE /etc/httpd/conf/httpd.conf [g.cecchi@ope46 ~]$ echo $BITSET 17 [g.cecchi@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