View transaction history with pkg?

I have recently been obligated to use CentOS for work, and while yum is terrible in most respects, I have become quite fond of the yum history feature. For those who are not familiar, yum will record each transaction executed, with the ability to view the elements of each transaction and even roll transactions back. Is there a similar feature for pkg, where I can step through the changes made to the system?
 
I was referring to RedHat/CentOS yum. I wasn't aware that it was in ports, though I don't see why I'd want to use it. pkg(8) is awesome, but I haven't seen a feature for it that can do transaction history. Is this a thing?
 
No, it doesn't have that feature. It doesn't even seem, as far as I can tell, to make entries in logfiles, as I found out the other day to my aggravation. (Hence my updating of this thread in the hope that someone can correct me.)

That is, if you install using ports, there will at least be an entry in /var/log/messages. (I'm not sure about removals.) However, if you install or remove by using pkg install whatever the only entry will be in /var/log/backups in a compressed pkg.sql.xz file. One can then decompress and either look at the raw sql or create a database and import the sql file into it.

As that seems such a drastic lack on a server O/S, I have a strong feeling I'm missing something.
 
That is, if you install using ports, there will at least be an entry in /var/log/messages. (I'm not sure about removals.)
They are.

Code:
root@armitage:~ # grep pkg /var/log/messages
Jun  5 11:27:38 armitage pkg: nmap-6.47 installed
root@armitage:~ #
root@armitage:~ # pkg delete nmap
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):

Installed packages to be REMOVED:
        nmap-6.47

The operation will free 18 MiB.

Proceed with deinstalling packages? [y/N]: y
[1/1] Deinstalling nmap-6.47...
[1/1] Deleting files for nmap-6.47: 100%
root@armitage:~ # tail -1 /var/log/messages
Jun 11 19:49:14 armitage pkg: nmap-6.47 deinstalled
root@armitage:~ #
 
Ok, so deletes should be shown then. Bah, I also realize that I'm dealing with an older server, 9.2 or 9.3 so what I say may no longer be relevant. I'm not going to say I'm an idiot, (my wife will be happy to say it for me), but I haven't checked if there's anything in messages when installing with pkg on 10.x
I will try that either later tonight or tomorrow and update.
 
And to update--yup, at least what happens in pkg is shown in /var/log/messages. In an older version (9.0? 9.2?) it wasn't. Thanks everyone.

There is nothing like yum history, which is too bad, but at least it's easy to see when something was installed.
 
They are.

Code:
root@armitage:~ # grep pkg /var/log/messages
Jun  5 11:27:38 armitage pkg: nmap-6.47 installed
root@armitage:~ #
root@armitage:~ # pkg delete nmap
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):

Installed packages to be REMOVED:
        nmap-6.47

The operation will free 18 MiB.

Proceed with deinstalling packages? [y/N]: y
[1/1] Deinstalling nmap-6.47...
[1/1] Deleting files for nmap-6.47: 100%
root@armitage:~ # tail -1 /var/log/messages
Jun 11 19:49:14 armitage pkg: nmap-6.47 deinstalled
root@armitage:~ #
8 1/2 years later - still great hint!
 
That just shows how great a FreeBSD resource these forums are!
Yeah, no kidding. I see some folks moving to discord and think to myself, what a shame, forums are flat out superior. But hey, what do I know, I’ve only been doing this Internet thing since 1991... and the forum since 2015... oh wait, why wonder? Just search and all of the posts I’ve made are there... in the forums. So sad that discord is less history friendly. Kinda like IRC with a bit of history (point forward) and tons of crap like Giga-Mega-Uber animated icons and ads thrown in :) I
 
This can be done as an external program that greps /var/log/message, removes duplicates and stores them in a nicer format in /var/log/pkg. Run it daily from cron.
 
discord is less history friendly
This is part of the general trend where more and more people are moving from "System 2" thinking to "System 1" thinking (See "Thinking, Fast and Slow" by Kahneman. Sys2 thinking is slow, deliberate and logical. Sys1 thinking is fast, instinctive and emotional). The trend is "books -> articles -> mailing lists -> forums -> instant messaging".
 
Code:
drop table if exists pkg_log;
drop trigger if exists pkg_add;
drop trigger if exists pkg_del;
CREATE TABLE pkg_log (log_id integer primary key, log_pkg_name varchar(64),log_pkg_id int,log_action char(20),
log_time datetime, log_pkg_version varchar(32));
CREATE TRIGGER pkg_add after insert on packages
for each row
begin
insert into pkg_log (log_pkg_id,log_pkg_name,log_pkg_version,log_action,log_time)
      values (NEW.id,NEW.name,NEW.version,"Add",datetime());
end;
CREATE TRIGGER pkg_del after delete on packages
for each row
begin
insert into pkg_log (log_pkg_id,log_pkg_name,log_pkg_version,log_action,log_time)
      values (OLD.id,OLD.name,OLD.version,"Delete",datetime());
end;
Code:
sqlite> select * from pkg_log;
1|mc|49|Delete|2024-01-30 06:39:53|4.8.30_1
2|glib|46|Delete|2024-01-30 06:40:12|2.78.3_1,2
3|libxml2|42|Delete|2024-01-30 06:40:12|2.11.6
4|libslang2|44|Delete|2024-01-30 06:40:12|2.3.3_2
5|diffutils|48|Delete|2024-01-30 06:40:12|3.8
6|png|40|Delete|2024-01-30 06:40:12|1.6.40
7|libsigsegv|41|Delete|2024-01-30 06:40:12|2.14
8|pcre|43|Delete|2024-01-30 06:40:12|8.45_3
9|zip|45|Delete|2024-01-30 06:40:12|3.0_2
10|perl5|47|Delete|2024-01-30 06:40:13|5.36.3_1
11|png|40|Add|2024-01-30 06:40:58|1.6.40
12|libsigsegv|41|Add|2024-01-30 06:40:58|2.14
13|libxml2|42|Add|2024-01-30 06:40:58|2.11.6
14|pcre|43|Add|2024-01-30 06:40:58|8.45_3
15|libslang2|44|Add|2024-01-30 06:40:58|2.3.3_2
16|zip|45|Add|2024-01-30 06:40:59|3.0_2
17|glib|46|Add|2024-01-30 06:40:59|2.78.3_1,2
18|perl5|47|Add|2024-01-30 06:40:59|5.36.3_1
19|diffutils|48|Add|2024-01-30 06:41:06|3.8
20|mc|49|Add|2024-01-30 06:41:07|4.8.30_1
this is sort of crude but it was hacked in 15 minutes
 
Back
Top