]> git.pld-linux.org Git - packages/poldek.git/blob - poldek-show_only_relative_used_space.patch
7fa96439e230275631e492bd1ce3fd3b9c2758bc
[packages/poldek.git] / poldek-show_only_relative_used_space.patch
1 diff --git a/pkgfetch.c b/pkgfetch.c
2 index 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");
17 diff --git a/poldek_ts.c b/poldek_ts.c
18 index a0dd436..a670379 100644
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;
25 +    long int sinsts = 0, sdeps = 0, srems = 0, sdiff = 0;
26      tn_array *ipkgs, *idepkgs, *rmpkgs, *pkgs;
27      char ms[1024], *to, *prefix;
28 -    int n;
29 +    int i, n;
30      
31      ipkgs = n_hash_get(ts->ts_summary, "I");
32      idepkgs = n_hash_get(ts->ts_summary, "D");
33 @@ -846,16 +847,34 @@ void poldek__ts_display_summary(struct poldek_ts *ts)
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)
44 +       for (i=0; i < ninst; i++) {
45 +           struct pkg *pkg = n_array_nth(ipkgs, i);
46 +           sinsts += pkg->size;
47 +       }
48 +    if (idepkgs)
49 +       for (i=0; i < ndep; i++) {
50 +           struct pkg *pkg = n_array_nth(idepkgs, i);
51 +           sdeps += pkg->size;
52 +       }
53 +    if (rmpkgs)
54 +       for (i=0; i < nrm; i++) {
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;
64 +        sdiff = sinsts + sdeps - srems;
65 +    } else {
66          to = _("to remove");
67          prefix = "R";
68          pkgs = rmpkgs;
69          npkgs = nrm + ndep;
70 +        sdiff = - srems - sdeps;
71          nrm = 0;
72      }
73      n_assert(pkgs);
74 @@ -896,6 +915,16 @@ void poldek__ts_display_summary(struct poldek_ts *ts)
75          if (rmpkgs)
76              packages_display_summary(1, "R", rmpkgs, parseable);
77      }
78 +
79 +    if (sdiff != 0) {
80 +        char size[64];
81 +        snprintf_size(size, sizeof(size), labs(sdiff), 1, 1);
82 +
83 +        if (sdiff > 0)
84 +           msgn(1, _("This operation will use %s of disk space."), size);
85 +        else
86 +           msgn(1, _("This operation will free %s of disk space."), size);
87 +    }
88  }
89  
90  tn_array *poldek_ts_get_summary(const struct poldek_ts *ts, const char *mark)
This page took 0.049887 seconds and 2 git commands to generate.