Hi all,
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.
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.
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.
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
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.