]> git.pld-linux.org Git - packages/poldek.git/blame - poldek-show_only_relative_used_space.patch
- rel .38; one more zlib fix
[packages/poldek.git] / poldek-show_only_relative_used_space.patch
CommitLineData
207c5e8d
BZ
1diff --git a/pkgfetch.c b/pkgfetch.c
2index 049eb0e..b2cffbd 100644
3--- a/pkgfetch.c
4+++ b/pkgfetch.c
5@@ -105,11 +105,6 @@ void packages_fetch_summary(struct pm_ctx *pmctx, const tn_array *pkgs,
6 msgn(1, _("_ (%s to download)."), buf);
7 }
8
9- if (bytesused) {
10- char buf[64];
11- snprintf_size(buf, sizeof(buf), bytesused, 1, 1);
12- msg(1, _("After unpacking %s will be used."), buf);
13- }
14 }
15
16 msg(1, "_\n");
17diff --git a/poldek_ts.c b/poldek_ts.c
249bab8b 18index a0dd436..a670379 100644
207c5e8d
BZ
19--- a/poldek_ts.c
20+++ b/poldek_ts.c
21@@ -834,9 +834,10 @@ void poldek__ts_update_summary(struct poldek_ts *ts,
22 void poldek__ts_display_summary(struct poldek_ts *ts)
23 {
24 int ninst = 0, ndep = 0, nrm = 0, npkgs = 0, parseable = 0;
375beaed 25+ long int sinsts = 0, sdeps = 0, srems = 0, sdiff = 0;
207c5e8d 26 tn_array *ipkgs, *idepkgs, *rmpkgs, *pkgs;
249bab8b 27 char ms[1024], *to, *prefix;
207c5e8d 28- int n;
207c5e8d
BZ
29+ int i, n;
30
31 ipkgs = n_hash_get(ts->ts_summary, "I");
32 idepkgs = n_hash_get(ts->ts_summary, "D");
249bab8b 33@@ -846,16 +847,34 @@ void poldek__ts_display_summary(struct poldek_ts *ts)
207c5e8d
BZ
34 ndep = idepkgs ? n_array_size(idepkgs) : 0;
35 nrm = rmpkgs ? n_array_size(rmpkgs) : 0;
36
37- to = _("to install");
38- prefix = "I";
39- pkgs = ipkgs;
40- npkgs = ninst + ndep;
41-
42- if (ts->type == POLDEK_TS_UNINSTALL) {
43+ if (ipkgs)
375beaed 44+ for (i=0; i < ninst; i++) {
207c5e8d
BZ
45+ struct pkg *pkg = n_array_nth(ipkgs, i);
46+ sinsts += pkg->size;
47+ }
48+ if (idepkgs)
375beaed 49+ for (i=0; i < ndep; i++) {
207c5e8d
BZ
50+ struct pkg *pkg = n_array_nth(idepkgs, i);
51+ sdeps += pkg->size;
52+ }
53+ if (rmpkgs)
375beaed 54+ for (i=0; i < nrm; i++) {
207c5e8d
BZ
55+ struct pkg *pkg = n_array_nth(rmpkgs, i);
56+ srems += pkg->size;
57+ }
58+
59+ if (ts->type != POLDEK_TS_UNINSTALL) {
60+ to = _("to install");
61+ prefix = "I";
62+ pkgs = ipkgs;
63+ npkgs = ninst + ndep;
207c5e8d
BZ
64+ sdiff = sinsts + sdeps - srems;
65+ } else {
66 to = _("to remove");
67 prefix = "R";
68 pkgs = rmpkgs;
69 npkgs = nrm + ndep;
375beaed 70+ sdiff = - srems - sdeps;
207c5e8d
BZ
71 nrm = 0;
72 }
73 n_assert(pkgs);
249bab8b 74@@ -896,6 +915,16 @@ void poldek__ts_display_summary(struct poldek_ts *ts)
207c5e8d
BZ
75 if (rmpkgs)
76 packages_display_summary(1, "R", rmpkgs, parseable);
77 }
78+
375beaed 79+ if (sdiff != 0) {
80+ char size[64];
81+ snprintf_size(size, sizeof(size), labs(sdiff), 1, 1);
249bab8b 82+
375beaed 83+ if (sdiff > 0)
3c19bf7f 84+ msgn(1, _("This operation will use %s of disk space."), size);
375beaed 85+ else
86+ msgn(1, _("This operation will free %s of disk space."), size);
207c5e8d
BZ
87+ }
88 }
89
90 tn_array *poldek_ts_get_summary(const struct poldek_ts *ts, const char *mark)
This page took 0.474502 seconds and 4 git commands to generate.