solver: report number of (mega)bytes used
parent
83b098d357
commit
34756e6b87
|
@ -153,6 +153,7 @@ struct apk_database {
|
|||
unsigned files;
|
||||
unsigned dirs;
|
||||
unsigned packages;
|
||||
size_t bytes;
|
||||
} stats;
|
||||
} installed;
|
||||
};
|
||||
|
|
|
@ -592,8 +592,12 @@ int apk_db_index_read(struct apk_database *db, struct apk_bstream *bs, int repo)
|
|||
if (pkg == NULL)
|
||||
continue;
|
||||
|
||||
if (repo >= 0)
|
||||
if (repo >= 0) {
|
||||
pkg->repos |= BIT(repo);
|
||||
} else if (repo == -1 && ipkg == NULL) {
|
||||
/* Installed package without files */
|
||||
ipkg = apk_pkg_install(db, pkg);
|
||||
}
|
||||
|
||||
if (apk_db_pkg_add(db, pkg) == NULL) {
|
||||
apk_error("Installed database load failed");
|
||||
|
@ -620,15 +624,15 @@ int apk_db_index_read(struct apk_database *db, struct apk_bstream *bs, int repo)
|
|||
/* Standard index line? */
|
||||
r = apk_pkg_add_info(db, pkg, field, l);
|
||||
if (r == 0) {
|
||||
if (repo == -1 && field == 'S') {
|
||||
continue;
|
||||
}
|
||||
if (r == 1 && repo == -1) {
|
||||
/* Instert to installed database; this needs to
|
||||
* happen after package name has been read, but
|
||||
* before first FDB entry. */
|
||||
ipkg = apk_pkg_install(db, pkg);
|
||||
diri_node = hlist_tail_ptr(&ipkg->owned_dirs);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (repo != -1 || ipkg == NULL)
|
||||
continue;
|
||||
|
||||
|
@ -668,11 +672,9 @@ int apk_db_index_read(struct apk_database *db, struct apk_bstream *bs, int repo)
|
|||
apk_blob_pull_csum(&l, &file->csum);
|
||||
break;
|
||||
case 'r':
|
||||
if (ipkg != NULL)
|
||||
apk_blob_pull_deps(&l, db, &ipkg->replaces);
|
||||
break;
|
||||
case 'q':
|
||||
if (ipkg != NULL)
|
||||
ipkg->replaces_priority = apk_blob_pull_uint(&l, 10);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -82,6 +82,7 @@ struct apk_installed_package *apk_pkg_install(struct apk_database *db,
|
|||
/* Overlay override information resides in a nameless package */
|
||||
if (pkg->name != NULL) {
|
||||
db->installed.stats.packages++;
|
||||
db->installed.stats.bytes += pkg->installed_size;
|
||||
list_add_tail(&ipkg->installed_pkgs_list,
|
||||
&db->installed.packages);
|
||||
}
|
||||
|
@ -97,8 +98,10 @@ void apk_pkg_uninstall(struct apk_database *db, struct apk_package *pkg)
|
|||
if (ipkg == NULL)
|
||||
return;
|
||||
|
||||
if (db != NULL)
|
||||
if (db != NULL) {
|
||||
db->installed.stats.packages--;
|
||||
db->installed.stats.bytes -= pkg->installed_size;
|
||||
}
|
||||
|
||||
list_del(&ipkg->installed_pkgs_list);
|
||||
|
||||
|
@ -729,7 +732,7 @@ int apk_pkg_add_info(struct apk_database *db, struct apk_package *pkg,
|
|||
db->compat_notinstallable = 1;
|
||||
}
|
||||
db->compat_newfeatures = 1;
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
if (APK_BLOB_IS_NULL(value))
|
||||
return -1;
|
||||
|
|
11
src/solver.c
11
src/solver.c
|
@ -1331,10 +1331,17 @@ all_done:
|
|||
apk_db_write_config(db);
|
||||
|
||||
if (r == 0 && !db->performing_self_update) {
|
||||
apk_message("OK: %d packages, %d dirs, %d files",
|
||||
if (apk_verbosity > 1) {
|
||||
apk_message("OK: %d packages, %d dirs, %d files, %zu MiB",
|
||||
db->installed.stats.packages,
|
||||
db->installed.stats.dirs,
|
||||
db->installed.stats.files);
|
||||
db->installed.stats.files,
|
||||
db->installed.stats.bytes / (1024 * 1024));
|
||||
} else {
|
||||
apk_message("OK: %zu MiB in %d packages",
|
||||
db->installed.stats.bytes / (1024 * 1024),
|
||||
db->installed.stats.packages);
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
|
|
Loading…
Reference in New Issue