Solved [SOLVED] Getting the port/package installation date

freethread

Well-Known Member

Reaction score: 32
Messages: 359

I'm trying to get the date when each port/pkg was istalled or upgraded. Actually I'm using the command

# pkg query '%t' <pkg-name>

or (in my case)

# pkg query '%t' `pkg info -q -O <port-name>`

where <port-name> is the common form used by portmaster and portupgrade 'category_name/port_name' (for example the package tmux correspond to port sysutils/tmux). As far as I know the date returned is not the first installation date as I guessed at first sight, it change when port is upgraded and this is what I'm looking for. Anyone know if what I said is right?
 

ljboiler

Well-Known Member

Reaction score: 100
Messages: 334

Re: Getting the port/package installation date

When you "upgrade", you are "installing" a new version of a port/pkg, and the timestamp will be updated.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 7,298
Messages: 29,745

Re: Getting the port/package installation date

freethread said:
I'm trying to get the date when each port/pkg was istalled or upgraded.
Slightly different approach but the installation also logs to /var/log/messages. Keeping track of that might be the only way to find out when a package was first installed.
 
OP
OP
freethread

freethread

Well-Known Member

Reaction score: 32
Messages: 359

Re: Getting the port/package installation date

ljboiler said:
When you "upgrade", you are "installing" a new version of a port/pkg, and the timestamp will be updated.
Thank you @ljboiler, that's also my thought.

SirDice said:
Slightly different approach but the installation also logs to /var/log/messages. Keeping track of that might be the only way to find out when a package was first installed.
Thank you @SirDice, I need this information in a C++ program, from my point of view I prefer to have that kind of information directly, I guess there are no system calls (APIs) or calls exposed by pkg component, if not I'm glad to know a more direct alternative. At the moment I run the commands, shown in the first post of this thread, with a system(3) or execve(2) or popen(3) call, don't know which one is the more direct to have the resulting output information.
 
Last edited by a moderator:

qrthur

New Member


Messages: 10

Re: Getting the port/package installation date

freethread said:
At the moment I run the commands, shown in the first post of this thread, with a system(3) or execve(2) or popen(3) call, don't know which one is the more direct to have the resulting output information.
If you need your C++ program to read the output of the command (so you can parse it) you must go with popen(3). Otherwise If you just want to print the output go with execve(2). I hardly use system(3) as it is more prone to command-line injection and it uses more resources (as far as I know).
 
OP
OP
freethread

freethread

Well-Known Member

Reaction score: 32
Messages: 359

Re: Getting the port/package installation date

qrthur said:
freethread said:
At the moment I run the commands, shown in the first post of this thread, with a system(3) or execve(2) or popen(3) call, don't know which one is the more direct to have the resulting output information.
If you need your C++ program to read the output of the command (so you can parse it) you must go with popen(3). Otherwise If you just want to print the output go with execve(2). I hardly use system(3) as it is more prone to command-line injection and it uses more resources (as far as I know).
Thank you @qrthur, that's right. I have a class that implements the process functionality only for Windows (using process API) and still not implemented for Unix (well, FreeBSD only). That class will surely use popen(3), but now I'm using system(3) redirecting output to a file, the program is still at an early stage and the priority is to porting TUI classes to use ncurses on FreeBSD, this is not a simple task, maintaining the same abstraction as in Windows, at least modifying a bit without reinventing it. However it's time to give priority to the process class. Thank you all for your answers, the new package system is powerful and surely it will improve functionality in the future.
 
Last edited by a moderator:
Top