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

不羁岁月 提交于 2019-12-23 02:31:31

问题


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.



来源:https://stackoverflow.com/questions/27703398/is-there-a-way-to-log-activities-done-by-a-rpm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!