Is there a way to log activities done by a rpm?

2019-06-04 18:49发布

问题:

I am trying to log the activities done by my rpm, but unable to find a way to do it. I am looking for some way to do it through the spec file itself. If there are 5 steps my rpm performs, I need a way to log these steps and their results to a log.

I found this after a brief google search - http://www.rpm.org/wiki/RpmLog . It seems like this work is still underway(?).

I was able to create a directory to save the logs following this, but how do I actually write something to a log file in this specially created directory? Some statements I should add to the spec file?

回答1:

I was able to log the activities of my rpm by a little extension to a link I had mentioned earlier - Create log file when installing rpm. After creating this file, I started echo-ing my log messages to the file I created in the spec file.

echo "this is a log message" >> $RPM_BUILD_ROOT/var/log/mylogfile.txt

So, wherever I wanted to note an important activity done by the rpm, I was adding such statements. I also observed that this file got removed when I uninstalled the rpm.



回答2:

rpm registers all installation information in a /var/lib/rpm database. One can query the database at any time, format to taste (including the http://www.rpm.org/wiki/RpmLog format) and save the output wherever you wish. Use --queryformat (examples in /usr/lib/rpm/rpmpopt*) and sort the installed/queried packages by install time first.



标签: rpm rpm-spec