summaryrefslogtreecommitdiff
path: root/src/state.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-04-15 17:01:46 +0300
committerTimo Teras <timo.teras@iki.fi>2009-04-15 17:01:46 +0300
commit371b68b8bffafc1887bce245eddf3326249840c0 (patch)
tree009b2ff2cf98aff71b637eebf1ec7ce542d4f39e /src/state.c
parent6f7719d3f481c8f1f71e3ed58bfa7a2f7bf00a69 (diff)
downloadapk-tools-371b68b8bffafc1887bce245eddf3326249840c0.tar.gz
apk-tools-371b68b8bffafc1887bce245eddf3326249840c0.tar.bz2
apk-tools-371b68b8bffafc1887bce245eddf3326249840c0.tar.xz
apk-tools-371b68b8bffafc1887bce245eddf3326249840c0.zip
state: print also the changeset affect on installed-size
Diffstat (limited to 'src/state.c')
-rw-r--r--src/state.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/state.c b/src/state.c
index 5125567..c1149ea 100644
--- a/src/state.c
+++ b/src/state.c
@@ -10,6 +10,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
#include <malloc.h>
@@ -637,6 +638,7 @@ int apk_state_commit(struct apk_state *state,
{
struct progress prog;
struct apk_change *change;
+ int size_diff = 0;
int r;
/* Count what needs to be done */
@@ -645,18 +647,27 @@ int apk_state_commit(struct apk_state *state,
if (change->newpkg == NULL)
apk_state_autoclean(state, change->oldpkg);
apk_count_change(change, &prog.total);
+ if (change->newpkg)
+ size_diff += change->newpkg->installed_size;
+ if (change->oldpkg)
+ size_diff -= change->oldpkg->installed_size;
}
+ size_diff /= 1024;
- if (apk_verbosity >= 1) {
+ if (apk_verbosity > 1) {
r = dump_packages(state, cmp_remove,
"The following packages will be REMOVED");
r += dump_packages(state, cmp_downgrade,
"The following packages will be DOWNGRADED");
- if (r || apk_verbosity >= 2) {
+ if (r || apk_verbosity > 2) {
dump_packages(state, cmp_new,
"The following NEW packages will be installed");
dump_packages(state, cmp_upgrade,
"The following packages will be upgraded");
+ fprintf(stderr, "%d kB of %s\n", abs(size_diff),
+ (size_diff < 0) ?
+ "disk space will be freed" :
+ "additional disk space will be used");
fprintf(stderr, "Do you want to continue [Y/n]? ");
fflush(stderr);
r = fgetc(stdin);