Is there a way to log activities done by a rpm?
Solution 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.
Solution 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.
Related videos on Youtube
Ravindra Mijar
Updated on June 04, 2022Comments
-
Ravindra Mijar almost 2 years
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?
-
Ravindra Mijar over 9 yearsJeff, thanks for the answer. However, I had seen this link, and didn't find it useful. I wanted to have my own log statements for the steps taken during my rpm's installation / un-installation. Like you said, it will give information on which rpms got installed etc, right?
-
Jeff Johnson over 9 yearssee "rpm -qa --last" if you want package names by install time. otherwise yum logs actions, and much of the information in the rpm log format can only be supplied by yum: its simply isn't available nor stored by rpm itself.