Re: List of packages upgraded last time `pkg upgrade` was executed

2021-01-27 Thread Mike Andrews via freebsd-ports

On Wed, 27 Jan 2021, Yasuhiro Kimura wrote:


From: Freddie Cash 
Subject: Re: List of packages upgraded last time `pkg upgrade` was executed
Date: Tue, 26 Jan 2021 17:26:29 -0800


/var/log/messages and I think /var/log/daemon include the output of the pkg
commands. If you have the log files backed up from the last time it was
run, you could grep for pkg in those.

No idea if this info is also stored in the sqlite databases pkg uses.


Thank you for reply. But my intention is to write shell script that
gets the list of upgraded packages and does something by using
it. Because of that the list need to be gotton without any user
interaction. So unfortunately your method is not applicable to my
case.


Try something like this as a starting point for a shell script:

sqlite3 /var/db/pkg/local.sqlite \
 "select datetime(time,'unixepoch'),origin,version from packages \
 where datetime(time,'unixepoch')>=date('now','-7 day') \
 order by time desc"
___
freebsd-ports@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"


Re: List of packages upgraded last time `pkg upgrade` was executed

2021-01-27 Thread Michael Gmelin



On Thu, 28 Jan 2021 03:23:57 +0900 (JST)
Yasuhiro Kimura  wrote:

> From: Michael Gmelin 
> Subject: Re: List of packages upgraded last time `pkg upgrade` was
> executed Date: Wed, 27 Jan 2021 10:05:57 +0100
> 
> > This will give you a list of all packages that were
> > updated/installed last:
> > 
> >   pkg query -e %t=$(pkg query %t | sort -n | tail -n1) %n-%v  
> 
> I tried this but unfortunately it doesn't seem to work as is expected.
> 
> On the host I tried it, following packages are upgraded when I did
> `pkg upgrade` last time.
> 
> p5-URI-5.06
> p5-Module-CoreList-5.20210120
> rubygem-bundler-2.2.7_1,1
> sudo-1.9.5p2 1611721387
> 
> And I got following result.
> 
> yasu@eastasia[1213]% pkg query -e %t=$(pkg query %t | sort -n | tail
> -n1) %n-%v p5-Module-CoreList-5.20210120
> p5-URI-5.06
> yasu@eastasia[1213]%
> 
> So I checked timestamp of install packages.
> 
> yasu@eastasia[1216]% pkg query -a '%n-%v %t'  | sort -k 2 -n -r |
> head -10   ~ p5-URI-5.06
> 1611721389 p5-Module-CoreList-5.20210120 1611721389
> rubygem-bundler-2.2.7_1,1 1611721388
> sudo-1.9.5p2 1611721387
> p5-Config-General-2.63 1611685127
> libunwind-20201110 1611685127
> bind916-9.16.11 1611685127
> zstd-1.4.8 1611685126
> sqlite3-3.34.1,1 1611685126
> bind-tools-9.16.11 1611685125
> yasu@eastasia[1217]%
> 
> As you can see timestamps of rubygem-bundler-2.2.7_1,1 and
> sudo-1.9.5p2 are smaller than that of p5-URI-5.06 and
> p5-Module-CoreList-5.20210120. So they aren't included in the list.
> 
> > As far as I can tell, packages installed by the same pkg invocation
> > run share the same installation timestamp (I didn't check the pkg
> > sources, but that's what appears to be the case),  
> 
> According to the above result, it doesn't seem to be true. And I think
> it's quite possible. When packages are upgraded they are upgraded not
> in parallel but sequentially. So let me assume following situation.
> 
> * Pakcage A and B are to be upgraded.
> * A is upgraded first and B is next.
> * Both are quite large package.
> * Host is low-spec.
> 
> In this case upgrade of each package may take a few minutes. And it
> result in that there is difference of a few minites between the
> timestamps of them after upgrade.

I could reproduce your results easily by running `pkg install llvm10
rust gcc10`, so my bad, sorry.

I could have sworn that this behaved differently in the past though.

> 
> > If you use a script to do upgrades, you could store the timestamp as
> > part of that and do something like this:
> > 
> >   touch /tmp/lastupgrade
> >   pkg upgrade
> >   # then, later:
> >   pkg query -e "%t>=$(stat -f %m /tmp/lastupgrade)" %n-%v  
> 
> This didn't hit upon me and I think it's really excellent way to use
> file for timestamp. I'll use it in my shell script. Thank you for
> letting me know.

That's good to hear :)

Cheers,
Michael

> 
> ---
> Yasuhiro Kimura
> ___
> freebsd-ports@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-ports
> To unsubscribe, send any mail to
> "freebsd-ports-unsubscr...@freebsd.org"



-- 
Michael Gmelin
___
freebsd-ports@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"


Re: List of packages upgraded last time `pkg upgrade` was executed

2021-01-27 Thread Yasuhiro Kimura
From: Michael Gmelin 
Subject: Re: List of packages upgraded last time `pkg upgrade` was executed
Date: Wed, 27 Jan 2021 10:05:57 +0100

> This will give you a list of all packages that were updated/installed
> last:
> 
>   pkg query -e %t=$(pkg query %t | sort -n | tail -n1) %n-%v

I tried this but unfortunately it doesn't seem to work as is expected.

On the host I tried it, following packages are upgraded when I did
`pkg upgrade` last time.

p5-URI-5.06
p5-Module-CoreList-5.20210120
rubygem-bundler-2.2.7_1,1
sudo-1.9.5p2 1611721387

And I got following result.

yasu@eastasia[1213]% pkg query -e %t=$(pkg query %t | sort -n | tail -n1) %n-%v
p5-Module-CoreList-5.20210120
p5-URI-5.06
yasu@eastasia[1213]%

So I checked timestamp of install packages.

yasu@eastasia[1216]% pkg query -a '%n-%v %t'  | sort -k 2 -n -r | head -10  
 ~
p5-URI-5.06 1611721389
p5-Module-CoreList-5.20210120 1611721389
rubygem-bundler-2.2.7_1,1 1611721388
sudo-1.9.5p2 1611721387
p5-Config-General-2.63 1611685127
libunwind-20201110 1611685127
bind916-9.16.11 1611685127
zstd-1.4.8 1611685126
sqlite3-3.34.1,1 1611685126
bind-tools-9.16.11 1611685125
yasu@eastasia[1217]%

As you can see timestamps of rubygem-bundler-2.2.7_1,1 and sudo-1.9.5p2
are smaller than that of p5-URI-5.06 and p5-Module-CoreList-5.20210120.
So they aren't included in the list.

> As far as I can tell, packages installed by the same pkg invocation run
> share the same installation timestamp (I didn't check the pkg sources,
> but that's what appears to be the case),

According to the above result, it doesn't seem to be true. And I think
it's quite possible. When packages are upgraded they are upgraded not
in parallel but sequentially. So let me assume following situation.

* Pakcage A and B are to be upgraded.
* A is upgraded first and B is next.
* Both are quite large package.
* Host is low-spec.

In this case upgrade of each package may take a few minutes. And it
result in that there is difference of a few minites between the
timestamps of them after upgrade.

> If you use a script to do upgrades, you could store the timestamp as
> part of that and do something like this:
> 
>   touch /tmp/lastupgrade
>   pkg upgrade
>   # then, later:
>   pkg query -e "%t>=$(stat -f %m /tmp/lastupgrade)" %n-%v

This didn't hit upon me and I think it's really excellent way to use
file for timestamp. I'll use it in my shell script. Thank you for
letting me know.

---
Yasuhiro Kimura
___
freebsd-ports@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"


Re: List of packages upgraded last time `pkg upgrade` was executed

2021-01-27 Thread Michael Gmelin



On Wed, 27 Jan 2021 10:35:38 +0200
Peter Pentchev  wrote:

> On Wed, Jan 27, 2021 at 10:57:22AM +0900, Yasuhiro Kimura wrote:
> > From: Freddie Cash 
> > Subject: Re: List of packages upgraded last time `pkg upgrade` was
> > executed Date: Tue, 26 Jan 2021 17:26:29 -0800
> >   
> > > /var/log/messages and I think /var/log/daemon include the output
> > > of the pkg commands. If you have the log files backed up from the
> > > last time it was run, you could grep for pkg in those.
> > > 
> > > No idea if this info is also stored in the sqlite databases pkg
> > > uses.  
> > 
> > Thank you for reply. But my intention is to write shell script that
> > gets the list of upgraded packages and does something by using
> > it. Because of that the list need to be gotton without any user
> > interaction. So unfortunately your method is not applicable to my
> > case.  
> 
> Well, there is the option of running a pkg query before and after
> the upgrade and comparing the results... especially if you write it in
> a higher-level language than the shell, it Should Not Be Too Hard(tm)
> to figure out which packages have changed their version, what new
> ones have appeared, which ones have been removed...
> 
> But, yeah, it is certainly easy for me to suggest that somebody else
> write something "simple" :)
> 

This will give you a list of all packages that were updated/installed
last:

  pkg query -e %t=$(pkg query %t | sort -n | tail -n1) %n-%v

Explained:

$(pkg query %t | sort -n | tail -n1)
- Get timestamps of when packages were installed
- Sort numerically
- Take the last one (which is the latest)

Feed this into `pkg query %t=x %n-%v` which returns all packages
matching that latest timestamp (== when last set of packages were
installed) and outputs their name and version.

As far as I can tell, packages installed by the same pkg invocation run
share the same installation timestamp (I didn't check the pkg sources,
but that's what appears to be the case), that's why this works. This
resulting list won't include the pkg package itself in case it was
updated as part as the run. There might also be other multi-pass
scenarios of pkg I'm not aware of though.

In case you know when pkg upgrade was called last, you can simply feed
it the timestamp directly, like in:

  pkg query -e "%t>=1609545326" %n-%v

If you use a script to do upgrades, you could store the timestamp as
part of that and do something like this:

  touch /tmp/lastupgrade
  pkg upgrade
  # then, later:
  pkg query -e "%t>=$(stat -f %m /tmp/lastupgrade)" %n-%v
  

Cheers,
Michael

-- 
Michael Gmelin
___
freebsd-ports@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"


Re: List of packages upgraded last time `pkg upgrade` was executed

2021-01-27 Thread Peter Pentchev
On Wed, Jan 27, 2021 at 10:57:22AM +0900, Yasuhiro Kimura wrote:
> From: Freddie Cash 
> Subject: Re: List of packages upgraded last time `pkg upgrade` was executed
> Date: Tue, 26 Jan 2021 17:26:29 -0800
> 
> > /var/log/messages and I think /var/log/daemon include the output of the pkg
> > commands. If you have the log files backed up from the last time it was
> > run, you could grep for pkg in those.
> > 
> > No idea if this info is also stored in the sqlite databases pkg uses.
> 
> Thank you for reply. But my intention is to write shell script that
> gets the list of upgraded packages and does something by using
> it. Because of that the list need to be gotton without any user
> interaction. So unfortunately your method is not applicable to my
> case.

Well, there is the option of running a pkg query before and after
the upgrade and comparing the results... especially if you write it in
a higher-level language than the shell, it Should Not Be Too Hard(tm) to
figure out which packages have changed their version, what new ones have
appeared, which ones have been removed...

But, yeah, it is certainly easy for me to suggest that somebody else
write something "simple" :)

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.org p...@storpool.com
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


signature.asc
Description: PGP signature


Re: List of packages upgraded last time `pkg upgrade` was executed

2021-01-26 Thread Yasuhiro Kimura
From: Freddie Cash 
Subject: Re: List of packages upgraded last time `pkg upgrade` was executed
Date: Tue, 26 Jan 2021 17:26:29 -0800

> /var/log/messages and I think /var/log/daemon include the output of the pkg
> commands. If you have the log files backed up from the last time it was
> run, you could grep for pkg in those.
> 
> No idea if this info is also stored in the sqlite databases pkg uses.

Thank you for reply. But my intention is to write shell script that
gets the list of upgraded packages and does something by using
it. Because of that the list need to be gotton without any user
interaction. So unfortunately your method is not applicable to my
case.

---
Yasuhiro Kimura
___
freebsd-ports@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"


Re: List of packages upgraded last time `pkg upgrade` was executed

2021-01-26 Thread Freddie Cash
On Tue., Jan. 26, 2021, 5:18 p.m. Yasuhiro Kimura,  wrote:

> Hello,
>
> Is there any way to get the list of packages upgraded (and installed
> as new dependency if there are) last time `pkg upgrade` was executed?
>
> Best Regards.
>
> ---
> Yasuhiro Kimura
>

/var/log/messages and I think /var/log/daemon include the output of the pkg
commands. If you have the log files backed up from the last time it was
run, you could grep for pkg in those.

No idea if this info is also stored in the sqlite databases pkg uses.

Cheers,
Freddie

Typos due to smartphone keyboard.

>
___
freebsd-ports@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"


List of packages upgraded last time `pkg upgrade` was executed

2021-01-26 Thread Yasuhiro Kimura
Hello,

Is there any way to get the list of packages upgraded (and installed
as new dependency if there are) last time `pkg upgrade` was executed?

Best Regards.

---
Yasuhiro Kimura
___
freebsd-ports@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"