System updating - package size

Hi all, :wave:

Note: this is for Ubuntu-based systems, apt package management

I always want to know the download size of packages to be updated with the command
sudo apt-get update && sudo apt-get upgrade
in advance so that I can make in informed decision whether or not to apply the upgrade at the present time or whether to defer it. :blush:

I know I get the relevant information before saying “yes” to the upgrade and I can abort in time:

env LANG=en_GB:en sudo apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
 [...]
5 upgraded, 5 newly installed, 0 to remove and 3 not upgraded.
Need to get 122 MB of archives.
After this operation, 597 MB of additional disk space will be used.
Do you want to continue? [Y/n] n
Abort.

Yes, that´s a possibility.

But I was looking for a procedure without user interaction and my research led me to the command

sudo apt-get --print-uris upgrade

–print-uris
Instead of fetching the files to install their URIs are printed. Each URI will have the path, the destination file name, the size and the expected md5 hash. […]

(from man-pages)

So I tried it:

env LANG=en_GB:en sudo apt-get --print-uris upgrade

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
[...]
2 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
Need to get 7454 kB of archives.
After this operation, 395 kB of additional disk space will be used.
'https://ftp.uni-stuttgart.de/ubuntu/pool/main/l/linux/linux-libc-dev_5.15.0-79.86_amd64.deb' linux-libc-dev_5.15.0-79.86_amd64.deb 1337766 MD5Sum:1c14eb2fa52781627feafc2c68531dfb
'https://ftp.uni-stuttgart.de/ubuntu/pool/main/i/intel-microcode/intel-microcode_3.20230808.0ubuntu0.22.04.1_amd64.deb' intel-microcode_3.20230808.0ubuntu0.22.04.1_amd64.deb 6116510 MD5Sum:cc752a72ecf1c0da4cad7541b8b3416e

O.K. I got the result I needed with no user interaction at all. :smiley:
The package size is part of the output. It´s the third field of each line, just before “MD5Sum”.
Now I checked with bash´s calculator:

bc -l
bc 1.07.1
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
1337766+6116510
7454276
7454276/1000
7454.27600000000000000000
quit

Right. It matches perfectly. :+1:

Well, there´s not much to be gained by the command using the “–print-uris” option. It´s just meant to be a theoretical proof that apt adds up the values correctly in the background.

Plus: as you can see it says

Need to get 7454 kB of archives

well in advance. So there´s actually no need of doing the calculation oneself.

It would be great if such a solution was available when installing a new package so to get at least a rough estimate of how large the download
is going to be before triggering the installation (and thus the download itself).

Many greetings from Rosika :slightly_smiling_face:

P.S.:

There´s a discrepancy when looking at the amount of data to be downloaded if we look at the two varieties of upgrade commands:

  • sudo apt upgrade : 122 MB

  • sudo apt-get --print-uris upgrade : 7454 kB

I seems the second command takes into account the packages that will be kept back whereas the first one doesn´t:

env LANG=en_GB:en sudo apt-get --print-uris upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  gjs google-chrome-stable libgjs0g linux-generic linux-headers-generic
  linux-image-generic
The following packages will be upgraded:
  intel-microcode linux-libc-dev
2 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
Need to get 7454 kB of archives.
After this operation, 395 kB of additional disk space will be used.
2 Likes

So when we looked at download sizes for rolling versus fixed release distros, some time ago, at least the ones that used apt-get were an overestimate.

I might look at Void again. I dont have Solus any more.

1 Like

Hi Neville, :wave:

Thanks for your comment.

I think you can evaluate the situation much better than me. So you´re certainly right there.

The packages which are held back surely account for the phased update policy ubuntu has introduced.
So they will be installed in a future update procedure but are currently deferred.

At any rate: the command sudo apt-get --print-uris upgrade seems to be of more use to me with arriving at an informed decision when to do an update. :wink:

Thanks a lot and many greetings from Rosika :slightly_smiling_face:

1 Like

Hi Neville, :wave:

Seems I spoke too soon. :neutral_face:

Yesterday I updated my system. I took this opportunity to compare the two commands

sudo apt-get --print-uris upgrade and
sudo apt upgrade
in a real-life situation.

The results were different from what I expected them to be:

  • First I wanted to get some info about the expected download size:
sudo apt-get --print-uris upgrade

Paketlisten werden gelesen… Fertig
Abhängigkeitsbaum wird aufgebaut… Fertig
Statusinformationen werden eingelesen… Fertig
Paketaktualisierung (Upgrade) wird berechnet… Fertig
Die folgenden Pakete sind zurückgehalten worden:
  apt apt-transport-https apt-utils gjs google-chrome-stable libapt-pkg6.0 libgjs0g linux-generic linux-headers-generic linux-image-generic
Die folgenden Pakete werden aktualisiert (Upgrade):
  firefox gir1.2-javascriptcoregtk-4.0 gir1.2-webkit2-4.0 intel-microcode libjavascriptcoregtk-4.0-18 libmysqlclient21 libsmbclient libtiff5 libtiff5:i386 libwbclient0
  libwebkit2gtk-4.0-37 linux-libc-dev python3-samba samba samba-common samba-common-bin samba-dsdb-modules samba-libs samba-vfs-modules smbclient
20 aktualisiert, 0 neu installiert, 0 zu entfernen und 10 nicht aktualisiert.
Es müssen 117 MB an Archiven heruntergeladen werden.
Nach dieser Operation werden 400 kB Plattenplatz zusätzlich benutzt.
[...]

So basically 117 MB of data would be downloaded as those packages should be held back:

apt apt-transport-https apt-utils gjs google-chrome-stable libapt-pkg6.0 libgjs0g linux-generic linux-headers-generic linux-image-generic

  • Immediately after getting that information I initiated the download. I didn´t issue another sudo apt update so that both commands were sure to work with the same set of available packages.
sudo apt upgrade

Paketlisten werden gelesen… Fertig
Abhängigkeitsbaum wird aufgebaut… Fertig
Statusinformationen werden eingelesen… Fertig
Paketaktualisierung (Upgrade) wird berechnet… Fertig
Die folgenden NEUEN Pakete werden installiert:
  linux-headers-5.15.0-79 linux-headers-5.15.0-79-generic
  linux-image-5.15.0-79-generic linux-modules-5.15.0-79-generic
  linux-modules-extra-5.15.0-79-generic
Die folgenden Pakete sind zurückgehalten worden:
  apt apt-transport-https apt-utils gjs google-chrome-stable libapt-pkg6.0
  libgjs0g
Die folgenden Pakete werden aktualisiert (Upgrade):
  firefox gir1.2-javascriptcoregtk-4.0 gir1.2-webkit2-4.0 intel-microcode
  libjavascriptcoregtk-4.0-18 libmysqlclient21 libsmbclient libtiff5
  libtiff5:i386 libwbclient0 libwebkit2gtk-4.0-37 linux-generic
  linux-headers-generic linux-image-generic linux-libc-dev python3-samba samba
  samba-common samba-common-bin samba-dsdb-modules samba-libs
  samba-vfs-modules smbclient
23 aktualisiert, 5 neu installiert, 0 zu entfernen und 7 nicht aktualisiert.
Es müssen 231 MB an Archiven heruntergeladen werden.
Nach dieser Operation werden 597 MB Plattenplatz zusätzlich benutzt.
Möchten Sie fortfahren? [J/n] J

Well, this looked different now:

231 MB of data will be downoaded due to the fact the packages held back were different, too:

apt apt-transport-https apt-utils gjs google-chrome-stable libapt-pkg6.0
libgjs0g

This time the command sudo apt upgrade is the one to go for as it represents the real values with respect of amount of data to be downloaded and the packages that are kept back.

So I guess I have to rectify my assumption:
It seems the best way to get a good estimate of how much data will be downloaded is to apply the command

sudo apt upgrade and to abort upgrade with “n” if asked

Möchten Sie fortfahren? [J/n] # do you want to continue

in case you just want to get the estimate.

Many greetings from Rosika :slightly_smiling_face:

So it would seem what I did some time ago was OK,
Thanks

1 Like

Hi Neville, :wave:

I guess by that you mean you also aborted the update procedure in case you just wanted to get the estimate?

Yes and no.
Some of that data I collected was real upgrades.

Hmm, sorry Neville. I don´t seem to be able to follow.
I´m not quite sure about the situation: It seems you aborted the updates :question:

But in what context?

Sorry Rosika,
I collected most of that data while I was doing routine upgrades on my system… so in most cases I answered Yes.
That would not affect the figure I obtained for download size… it is the same whether you go ahead and download it or not.

Cheers Neville

2 Likes

Ah, I see. Thanks for the clarification.

I agree. The figure of the download size should be the same in either case.

For me it´s interesting to know the size beforehand as my decision whether or not to go ahead with the update often depends on it.

So as I´m offered to say “Yes” or “No” to it, I guess opting for “No” shouldn´t get my system in any kind of trouble, right :question:

Cheers from Rosika :slightly_smiling_face:

Right. I do that quite often. It does nothing.

1 Like

Great. Thanks for confirming it, Neville. :heart:

Nothing like being sure :wink: .

Many greetings from Rosika :slightly_smiling_face: