[pacman-dev] [PATCH] Show used/freed space when syncing
Shows the "Total Used/Freed Size" after "Total Download Size" and "Total Installed Size" when syncing packages. It is the difference of installation size between packages to be updated and the installation size of the older version of these packages on disk. For exemple, if uploading to a new version of a package that has an installed size of 60 and the old version has an installed size of 50, this will show 10. Negative numbers represent space actually freed. Signed-off-by: Hugo Chargois <hugo.chargois@free.fr> --- src/pacman/util.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pacman/util.c b/src/pacman/util.c index 14a0f6c..3b4a695 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -44,6 +44,7 @@ #include "conf.h" #include "callback.h" +extern pmdb_t db_local; int trans_init(pmtransflag_t flags) { @@ -498,8 +499,8 @@ void display_targets(const alpm_list_t *pkgs, int install) { char *str; const alpm_list_t *i; - off_t isize = 0, dlsize = 0; - double mbisize = 0.0, mbdlsize = 0.0; + off_t isize = 0, dlsize = 0, localsize = 0; + double mbisize = 0.0, mbdlsize = 0.0, mdeltasize = 0.0; alpm_list_t *targets = NULL; if(!pkgs) { @@ -510,8 +511,14 @@ void display_targets(const alpm_list_t *pkgs, int install) for(i = pkgs; i; i = alpm_list_next(i)) { pmpkg_t *pkg = alpm_list_getdata(i); + char *name = alpm_pkg_get_name(pkg); + pmpkg_t *local_pkg = alpm_db_get_pkg(db_local, name); + dlsize += alpm_pkg_download_size(pkg); isize += alpm_pkg_get_isize(pkg); + if (local_pkg != NULL){ + localsize += alpm_pkg_get_isize(local_pkg); + } /* print the package size with the output if ShowSize option set */ if(config->showsize) { @@ -527,9 +534,10 @@ void display_targets(const alpm_list_t *pkgs, int install) targets = alpm_list_add(targets, str); } - /* Convert byte sizes to MB */ + /* Convert byte sizes to MB and calculate delta size*/ mbdlsize = dlsize / (1024.0 * 1024.0); mbisize = isize / (1024.0 * 1024.0); + mdeltasize = (isize - localsize) / (1024.0 * 1024.0); if(install) { asprintf(&str, _("Targets (%d):"), alpm_list_count(targets)); @@ -539,6 +547,7 @@ void display_targets(const alpm_list_t *pkgs, int install) printf(_("Total Download Size: %.2f MB\n"), mbdlsize); printf(_("Total Installed Size: %.2f MB\n"), mbisize); + printf(_("Total Size Used/Freed: % .2f MB\n"), mdeltasize); } else { asprintf(&str, _("Remove (%d):"), alpm_list_count(targets)); list_display(str, targets); -- 1.6.3.3
Shows the "Total Used/Freed Size" after "Total Download Size" and "Total Installed Size" when syncing packages. It is the difference of installation size between packages to be updated and the installation size of the older version of these packages on disk. For exemple, if uploading to a new version of a package that has an installed size of 60 and the old version has an installed size of 50, this will show 10. Negative numbers represent space actually freed.
Signed-off-by: Hugo Chargois <hugo.chargois@free.fr>
Just a side note: we have a FR for this: FS#12566, you may mention it in the commit message. "Total Size Used/Freed" is not very descriptive to me. However, I have no better proposal... Bye
Hi, I sent a new patch that mentions the ref of the FR. It also fixes some typos. As for the name of the field, well I don't know, I wrote "Total Used/Freed Size" because it resembles aptitude's "x MB will be used" or "x MB will be freed" that I am accustomed to. But there sure are other ways to phrase it. The FR says "Total Upgrade Size", that may be better. Best, Hugo. On Sun, Jan 10, 2010 at 12:34 PM, Nagy Gabor <ngaba@bibl.u-szeged.hu> wrote:
Shows the "Total Used/Freed Size" after "Total Download Size" and "Total Installed Size" when syncing packages. It is the difference of installation size between packages to be updated and the installation size of the older version of these packages on disk. For exemple, if uploading to a new version of a package that has an installed size of 60 and the old version has an installed size of 50, this will show 10. Negative numbers represent space actually freed.
Signed-off-by: Hugo Chargois <hugo.chargois@free.fr>
Just a side note: we have a FR for this: FS#12566, you may mention it in the commit message. "Total Size Used/Freed" is not very descriptive to me. However, I have no better proposal...
Bye
Hugo Chargois wrote:
Hi, I sent a new patch that mentions the ref of the FR. It also fixes some typos. As for the name of the field, well I don't know, I wrote "Total Used/Freed Size" because it resembles aptitude's "x MB will be used" or "x MB will be freed" that I am accustomed to. But there sure are other ways to phrase it. The FR says "Total Upgrade Size", that may be better.
Best, Hugo.
Please do not top post. I can not see a mention of the FR in the new patch you sent. Did you just resend the old one? But getting to more a basic level with this. What does this achieve? It is not an actual measure of additional space needed to update given it does not account for the downloaded file. So it can not be used to check if your system will run out of space on an upgrade. Allan
On Mon, Jan 11, 2010 at 2:02 AM, Allan McRae <allan@archlinux.org> wrote:
Please do not top post.
I can not see a mention of the FR in the new patch you sent. Did you just resend the old one?
But getting to more a basic level with this. What does this achieve? It is not an actual measure of additional space needed to update given it does not account for the downloaded file. So it can not be used to check if your system will run out of space on an upgrade.
Allan
Yeah, I can not see the new patch I sent, maybe I made a mistake. I'll resend it. The point is to show how much bigger the installed size of packages is getting. Not to show exactly what diskspace the entire transaction will take. Package cache can be cleaned, and if you don't have enough diskpace to store some packages for the time of their installation, you're doing it wrong and should buy a new hdd. (and well, now you could get this information by summing the download size and the used/freed space). I think it's good to know if packages are getting bloatier or slimmer. When I upload big packages and the installation size is 300 MB, I don't know if I will actually have 100 MB freed on my disk because the previous versions were 400, or if I will lose 100 because they were 200. If it's plus 100, well maybe I'd think of replacing some programs by lighter ones, if it's minus 100 well great (but maybe some functionalities were moved to a new package which I'd want to install?). Aptitude/apt-get shows that information in lieu of the "Total Installed Size", and I think that's much more sensible.
On Sun, Jan 10, 2010 at 8:44 PM, Hugo Chargois <hugo.chargois@free.fr> wrote:
On Mon, Jan 11, 2010 at 2:02 AM, Allan McRae <allan@archlinux.org> wrote:
Please do not top post.
I can not see a mention of the FR in the new patch you sent. Did you just resend the old one?
But getting to more a basic level with this. What does this achieve? It is not an actual measure of additional space needed to update given it does not account for the downloaded file. So it can not be used to check if your system will run out of space on an upgrade.
Of course this fact is available two lines above, so this is a bit of a straw man to use in this case.
Yeah, I can not see the new patch I sent, maybe I made a mistake. I'll resend it.
The point is to show how much bigger the installed size of packages is getting. Not to show exactly what diskspace the entire transaction will take. Package cache can be cleaned, and if you don't have enough diskpace to store some packages for the time of their installation, you're doing it wrong and should buy a new hdd. (and well, now you could get this information by summing the download size and the used/freed space). I think it's good to know if packages are getting bloatier or slimmer. When I upload big packages and the installation size is 300 MB, I don't know if I will actually have 100 MB freed on my disk because the previous versions were 400, or if I will lose 100 because they were 200. If it's plus 100, well maybe I'd think of replacing some programs by lighter ones, if it's minus 100 well great (but maybe some functionalities were moved to a new package which I'd want to install?). Aptitude/apt-get shows that information in lieu of the "Total Installed Size", and I think that's much more sensible.
The naming is not my favorite, but that may be a detail we can get around. Instead of "Total Size Used/Freed:", hmm. It is something more like "Total Installed Size Delta", but that sucks more than what you came up with. As a side note, "% .2f MB" will never work as a format- that is "%<space>.2f MB" and will not work as expected. I didn't check if that got fixed in a later patch, but just an FYI. Are there widespread objections to this patch? I like the idea, but I also worry we are getting quite cluttered here with junk that some people might care less about, and as Allan said, this isn't a very valid substitute for a disk space check. -Dan
On Wed, Jan 20, 2010 at 6:08 AM, Dan McGee <dpmcgee@gmail.com> wrote:
The naming is not my favorite, but that may be a detail we can get around. Instead of "Total Size Used/Freed:", hmm. It is something more like "Total Installed Size Delta", but that sucks more than what you came up with.
I like "Total Installed Size Delta". In fact it's what I called it in my head when I was thinking about it. I called the var that holds the value mbdeltasize, too. I finally came up with something different because first, that was too long to align with the preceding two "Total..." so it wouldn't look good, and I didn't want to touch these strings because it would have broken the translations. Secondly, I thought that maybe it was a bit non-user friendly because delta is a scientific denomination and probably not everyone is familiar with what it means. So I just used something that reminds what apt-get says because I'm familiar with it.
As a side note, "% .2f MB" will never work as a format- that is "%<space>.2f MB" and will not work as expected. I didn't check if that got fixed in a later patch, but just an FYI.
It works. <space> is a valid flag for printf formatting that means: put a space before a positive number (and of course a minus before a positive one). That way, the number is aligned with the ones from the two lines above, whether it's negative or positive, and the minus, if any, 'sticks out'.
Are there widespread objections to this patch? I like the idea, but I also worry we are getting quite cluttered here with junk that some people might care less about, and as Allan said, this isn't a very valid substitute for a disk space check.
To me, I think that this delta installed size is more important than the installed size. If I installed a package, it's that I deemed its size acceptable. I don't really care afterwards what size the update takes, I prefer knowing how it's growing. If I really want to know what size it is, I would query its info, and this has nothing to do with an update. So if had created pacman, I would probably showed delta installed size instead of installed size. But I totally understand that some people do care about the total installed size, and know it couldn't be changed anyway because people are now familiar with it. But I think it's a useful information and it well deserves an extra line. As for the disk space check, now you just have to sum the download size and the installed size delta and you have the total diskspace used. Without the delta, you have no way to know.
On Wed, Jan 20, 2010 at 10:03 AM, Hugo Chargois <hugo.chargois@free.fr> wrote:
On Wed, Jan 20, 2010 at 6:08 AM, Dan McGee <dpmcgee@gmail.com> wrote:
The naming is not my favorite, but that may be a detail we can get around. Instead of "Total Size Used/Freed:", hmm. It is something more like "Total Installed Size Delta", but that sucks more than what you came up with.
I like "Total Installed Size Delta". In fact it's what I called it in my head when I was thinking about it. I called the var that holds the value mbdeltasize, too. I finally came up with something different because first, that was too long to align with the preceding two "Total..." so it wouldn't look good, and I didn't want to touch these strings because it would have broken the translations. Secondly, I thought that maybe it was a bit non-user friendly because delta is a scientific denomination and probably not everyone is familiar with what it means. So I just used something that reminds what apt-get says because I'm familiar with it.
As a side note, "% .2f MB" will never work as a format- that is "%<space>.2f MB" and will not work as expected. I didn't check if that got fixed in a later patch, but just an FYI.
It works. <space> is a valid flag for printf formatting that means: put a space before a positive number (and of course a minus before a positive one). That way, the number is aligned with the ones from the two lines above, whether it's negative or positive, and the minus, if any, 'sticks out'.
Are there widespread objections to this patch? I like the idea, but I also worry we are getting quite cluttered here with junk that some people might care less about, and as Allan said, this isn't a very valid substitute for a disk space check.
To me, I think that this delta installed size is more important than the installed size. If I installed a package, it's that I deemed its size acceptable. I don't really care afterwards what size the update takes, I prefer knowing how it's growing. If I really want to know what size it is, I would query its info, and this has nothing to do with an update. So if had created pacman, I would probably showed delta installed size instead of installed size. But I totally understand that some people do care about the total installed size, and know it couldn't be changed anyway because people are now familiar with it. But I think it's a useful information and it well deserves an extra line.
As for the disk space check, now you just have to sum the download size and the installed size delta and you have the total diskspace used. Without the delta, you have no way to know.
I am on your side. I don't really care about installed size, I only look at the download one. And the delta size is probably more interesting than installed one. If people care about both, I am also fine with having the two. I don't care much either way.
On Wed, Jan 20, 2010 at 3:03 AM, Hugo Chargois <hugo.chargois@free.fr> wrote:
On Wed, Jan 20, 2010 at 6:08 AM, Dan McGee <dpmcgee@gmail.com> wrote:
As a side note, "% .2f MB" will never work as a format- that is "%<space>.2f MB" and will not work as expected. I didn't check if that got fixed in a later patch, but just an FYI.
It works. <space> is a valid flag for printf formatting that means: put a space before a positive number (and of course a minus before a positive one). That way, the number is aligned with the ones from the two lines above, whether it's negative or positive, and the minus, if any, 'sticks out'.
/me eats his words
Shows the "Total Used/Freed Size" after "Total Download Size" and "Total Installed Size" when syncing packages. It is the difference of installation size between packages to be updated and the installation size of the older version of these packages on disk. For exemple, if uploading to a new version of a package that has an installed size of 60 and the old version has an installed size of 50, this will show 10. Negative numbers represent space actually freed. Signed-off-by: Hugo Chargois <hugo.chargois@free.fr> --- src/pacman/util.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pacman/util.c b/src/pacman/util.c index 14a0f6c..e1e0064 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -44,6 +44,7 @@ #include "conf.h" #include "callback.h" +extern pmdb_t db_local; int trans_init(pmtransflag_t flags) { @@ -498,8 +499,8 @@ void display_targets(const alpm_list_t *pkgs, int install) { char *str; const alpm_list_t *i; - off_t isize = 0, dlsize = 0; - double mbisize = 0.0, mbdlsize = 0.0; + off_t isize = 0, dlsize = 0, localsize = 0; + double mbisize = 0.0, mbdlsize = 0.0, mbdeltasize = 0.0; alpm_list_t *targets = NULL; if(!pkgs) { @@ -510,8 +511,14 @@ void display_targets(const alpm_list_t *pkgs, int install) for(i = pkgs; i; i = alpm_list_next(i)) { pmpkg_t *pkg = alpm_list_getdata(i); + char *name = alpm_pkg_get_name(pkg); + pmpkg_t *local_pkg = alpm_db_get_pkg(db_local, name); + dlsize += alpm_pkg_download_size(pkg); isize += alpm_pkg_get_isize(pkg); + if(local_pkg != NULL){ + localsize += alpm_pkg_get_isize(local_pkg); + } /* print the package size with the output if ShowSize option set */ if(config->showsize) { @@ -527,9 +534,10 @@ void display_targets(const alpm_list_t *pkgs, int install) targets = alpm_list_add(targets, str); } - /* Convert byte sizes to MB */ + /* Convert byte sizes to MB and calculate delta size*/ mbdlsize = dlsize / (1024.0 * 1024.0); mbisize = isize / (1024.0 * 1024.0); + mbdeltasize = (isize - localsize) / (1024.0 * 1024.0); if(install) { asprintf(&str, _("Targets (%d):"), alpm_list_count(targets)); @@ -539,6 +547,7 @@ void display_targets(const alpm_list_t *pkgs, int install) printf(_("Total Download Size: %.2f MB\n"), mbdlsize); printf(_("Total Installed Size: %.2f MB\n"), mbisize); + printf(_("Total Size Used/Freed: % .2f MB\n"), mbdeltasize); } else { asprintf(&str, _("Remove (%d):"), alpm_list_count(targets)); list_display(str, targets); -- 1.6.3.3
participants (5)
-
Allan McRae
-
Dan McGee
-
Hugo Chargois
-
Nagy Gabor
-
Xavier Chantry