You are not logged in.

#1 2023-12-29 18:30:29

xerxes_
Member
Registered: 2018-04-29
Posts: 801

[SOLVED] How many packages were updated in the past at certain update?

How to count how many packages were updated in the past at certain update? I think the only way would be to count it from pacman.log fille from date on beginning of line, but this would be an approx number, but better this then nothing. But maybe you have better ideas? And some interesting scripts?

Last edited by xerxes_ (2023-12-30 14:12:38)

Offline

#2 2023-12-29 19:53:52

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: [SOLVED] How many packages were updated in the past at certain update?

What's wrong with checking the log?  Why do you say that would be an approximate number - all upgrades are logged.

awk '$1 ~ "2023-12-29" && $3 == "upgraded" { print $4; }' /var/log/pacman.log

If you really just want the count, you can either pass that to 'wc -l' or you can just sum it in awk:

awk '$1 ~ "2023-12-29" && $3 == "upgraded" { sum+=1; } END {print sum; }' /var/log/pacman.log

Last edited by Trilby (2023-12-29 19:55:04)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2023-12-29 20:05:16

xerxes_
Member
Registered: 2018-04-29
Posts: 801

Re: [SOLVED] How many packages were updated in the past at certain update?

Nice. It should be even accurate. Will use it, but I though about all updates to compare them and see which was the biggest. That would require using date as variable for all updates somehow...

Offline

#4 2023-12-29 20:20:11

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: [SOLVED] How many packages were updated in the past at certain update?

Well no, then you have a different task of extracting data for that analysis (which itself is just a "uniq -c | sort"):

sed -n '/ALPM] upgraded /{s/^.\([^T]*\).*/\1/p;}' /var/log/pacman.log  | uniq -c | sort -rn

Alternatively, the same extraction in awk:

awk -F'[[T ]' '$6 == "upgraded" { print $2; }' /var/log/pacman.log | uniq -c | sort -rn

Note that this will miss-count any updates that were in the process of running at midnight ... the single midnight update could be split into the two days.  This will also group any updates done on the same day.  If these are not acceptable, a smarter parsing / extraction would be needed.  I think there is a tool in pacman-contrib that does some data extraction from the pacman log. (edit: nope, nvm - but it could be a cool tool to parse a pacman log into a structured data format)

EDIT: for a transaction-aware count (which can separate multiple upgrades per day and group any that span midnight):

#!/bin/sh

sed -n '
	/transaction started/ {
		s/.\([^T]*\)T\([0-9:]*\).*/\1 \2/
		h
		:loop
		/transaction completed/ {
			b end
		}
		/ALPM] upgraded / {
			g
			p
		}
		n
		b loop
		:end
		n
	}
' /var/log/pacman.log | uniq -c | sort -rn

Last edited by Trilby (2023-12-29 20:40:22)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2023-12-30 14:11:21

xerxes_
Member
Registered: 2018-04-29
Posts: 801

Re: [SOLVED] How many packages were updated in the past at certain update?

Thanks. Your scripts solved my issue, I learned something and will use them.

Offline

#6 2024-02-13 00:40:13

mountaintrek
Member
Registered: 2024-02-01
Posts: 38

Re: [SOLVED] How many packages were updated in the past at certain update?

xerxes_ wrote:

How to count how many packages were updated in the past at certain update?...

This will not help with past installs, but perhaps in the future.

Use the verbose pacman.conf option VerbosePkgLists.

When you do an update at a tty use the command below. If you do the update in a terminal, you may need to widen the terminal.

stdbuf -eL -oL pacman -Syu |& tee upgrade-$(date '+%Y%m%d%H%M%S')

There is a lot of good information in that output, but you'll be interested in the section that begins with ":: Starting full system upgrade" and finishes with "Net Upgrade Size".  The "Package (nnn)" will tell you how many packages are going to be updated.

...
:: Starting full system upgrade...
...
Package (nnn)                            Old Version            New Version            Net Change
...
Total Download Size:    nnn.nn MiB
Total Installed Size:  nnnn.nn MiB
Net Upgrade Size:        nn.nn MiB
...

Offline

#7 2024-02-13 01:37:05

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: [SOLVED] How many packages were updated in the past at certain update?

Ah, mountaintrek, that's a pretty complex way to get a count of what would be updated.  If that's actually your question, it's far easier:

pacman -Syup | grep -c pkg.tar

Or ... just look at pacman's output on the screen.

Last edited by Trilby (2024-02-13 01:37:55)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#8 2024-02-13 07:28:46

bulletmark
Member
From: Brisbane, Australia
Registered: 2013-10-22
Posts: 675

Re: [SOLVED] How many packages were updated in the past at certain update?

@xerxes_ you may want to consider this. It groups the updates by time to guess each "set" of updates. I created it for Arch but also use it on Debian, Ubuntu, Fedora, etc.

Offline

#9 2024-02-13 21:47:35

mountaintrek
Member
Registered: 2024-02-01
Posts: 38

Re: [SOLVED] How many packages were updated in the past at certain update?

Trilby wrote:

Ah, mountaintrek, that's a pretty complex way to get a count of what would be updated. 
If that's actually your question, it's far easier:

pacman -Syup | grep -c pkg.tar

Or ... just look at pacman's output on the screen.

I got the impression that the OP was interested in historical data.

The stdbuf is used so stdout and stderr don't merge at the character level, but the line level. From an end user's perspective, what you might see, or rather not see, are parts of a Selection. You'll be asked to enter option 1 or 2, but you won't see the values.  I only recently added this. The "|& tee" lets me see all output on the terminal and log it. This is handy for a couple of reasons. Off the top of my head --- One, I have consistent, easily accessible documentation if there is an error; Two, I can review the output in more details and spot warnings, errors, new optional dependencies, etc; Three, I can review and parse the output as needed, to easily view which packages were installed, versions, download and install sizes. It isn't much data and has proven to be very helpful and informative smile This process is a moving target, but so far so good.

For current information I might use checkupdates. It doesn't update the running system's core database, but rather creates it in /tmp (Lots one can do with that with pacman --dbpath=/tmp/checkup-db-$UID/).   I'm not sure if checkupdates will show a user all updates though.  For example, there might be a new dependency that gets pulled in and I'm not sure if checkupdates includes those. In the pacman verbose output they'll appear in the report with a blank in the "old version" column.

checkupdates |& tee /dev/tty | wc -l

Last edited by mountaintrek (2024-02-13 21:48:35)

Offline

#10 2024-02-14 10:57:53

xerxes_
Member
Registered: 2018-04-29
Posts: 801

Re: [SOLVED] How many packages were updated in the past at certain update?

Does enabling option VerbosePkgLists in pacman.conf change output log format in /var/log/pacman.log ?

Offline

#11 2024-02-14 19:01:11

mountaintrek
Member
Registered: 2024-02-01
Posts: 38

Re: [SOLVED] How many packages were updated in the past at certain update?

xerxes_ wrote:

Does enabling option VerbosePkgLists in pacman.conf change output log format in /var/log/pacman.log ?

No.  It'll produce a nice table if the terminal is wide enough.

This is one of the reasons I capture the output.

From the pacman.conf man page

VerbosePkgLists
Displays name, version and size of target packages formatted as a table for upgrade, sync and remove operations.

I find images helpful, here's a before and after image: Lorenzo Bettini blog

Offline

Board footer

Powered by FluxBB