summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2021-11-15 14:37:25 +0200
committerTimo Teräs <timo.teras@iki.fi>2021-12-14 20:58:36 +0200
commit89a4039285784550d9a4a15c1fdc1ac2b9d338f2 (patch)
tree417f3f8913b597ceed5d1c19e5eeb20666a18ded /src
parent74f67ab81c646b9c1fb1136776cf05a949de2526 (diff)
downloadapk-tools-89a4039285784550d9a4a15c1fdc1ac2b9d338f2.tar.gz
apk-tools-89a4039285784550d9a4a15c1fdc1ac2b9d338f2.tar.bz2
apk-tools-89a4039285784550d9a4a15c1fdc1ac2b9d338f2.tar.xz
apk-tools-89a4039285784550d9a4a15c1fdc1ac2b9d338f2.zip
commit: print download size of packages in interactive mode
ref #10788
Diffstat (limited to 'src')
-rw-r--r--src/commit.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/commit.c b/src/commit.c
index c01a39b..e9b6dbe 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -262,7 +262,7 @@ int apk_solver_commit_changeset(struct apk_database *db,
struct apk_change *change;
char buf[32];
const char *size_unit;
- off_t humanized, size_diff = 0;
+ off_t humanized, size_diff = 0, download_size = 0;
int r, errors = 0;
assert(world);
@@ -279,12 +279,15 @@ int apk_solver_commit_changeset(struct apk_database *db,
memset(&prog, 0, sizeof(prog));
foreach_array_item(change, changeset->changes) {
count_change(change, &prog.total);
- if (change->new_pkg)
+ if (change->new_pkg) {
size_diff += change->new_pkg->installed_size;
+ if (change->new_pkg != change->old_pkg &&
+ !(change->new_pkg->repos & db->local_repos))
+ download_size += change->new_pkg->size;
+ }
if (change->old_pkg)
size_diff -= change->old_pkg->installed_size;
}
- size_unit = apk_get_human_size(llabs(size_diff), &humanized);
if ((apk_verbosity > 1 || (apk_flags & APK_INTERACTIVE)) &&
!(apk_flags & APK_SIMULATE)) {
@@ -299,6 +302,12 @@ int apk_solver_commit_changeset(struct apk_database *db,
"The following packages will be upgraded");
r += dump_packages(changeset, cmp_reinstall,
"The following packages will be reinstalled");
+ if (download_size) {
+ size_unit = apk_get_human_size(download_size, &humanized);
+ printf("Need to download %lld %s of packages.\n",
+ (long long)humanized, size_unit);
+ }
+ size_unit = apk_get_human_size(llabs(size_diff), &humanized);
printf("After this operation, %lld %s of %s.\n",
(long long)humanized,
size_unit,