xbps-bin: print current/total pkgs counter in 'check all' target.
This commit is contained in:
parent
5e0b06dc00
commit
b7961ae611
@ -35,6 +35,7 @@
|
|||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
|
||||||
struct checkpkg {
|
struct checkpkg {
|
||||||
|
size_t totalpkgs;
|
||||||
size_t npkgs;
|
size_t npkgs;
|
||||||
size_t nbrokenpkgs;
|
size_t nbrokenpkgs;
|
||||||
bool flush;
|
bool flush;
|
||||||
@ -51,12 +52,14 @@ cb_pkg_integrity(prop_object_t obj, void *arg, bool *done)
|
|||||||
|
|
||||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||||
prop_dictionary_get_cstring_nocopy(obj, "version", &version);
|
prop_dictionary_get_cstring_nocopy(obj, "version", &version);
|
||||||
printf("Checking %s-%s ...\n", pkgname, version);
|
printf("[%zu/%zu] checking %s-%s ...\n",
|
||||||
|
cpkg->npkgs, cpkg->totalpkgs, pkgname, version);
|
||||||
if (check_pkg_integrity(obj, pkgname, false, &flush) != 0)
|
if (check_pkg_integrity(obj, pkgname, false, &flush) != 0)
|
||||||
cpkg->nbrokenpkgs++;
|
cpkg->nbrokenpkgs++;
|
||||||
else
|
else
|
||||||
printf("\033[1A\033[K");
|
printf("\033[1A\033[K");
|
||||||
|
|
||||||
|
|
||||||
if (flush && !cpkg->flush)
|
if (flush && !cpkg->flush)
|
||||||
cpkg->flush = flush;
|
cpkg->flush = flush;
|
||||||
cpkg->npkgs++;
|
cpkg->npkgs++;
|
||||||
@ -66,10 +69,15 @@ cb_pkg_integrity(prop_object_t obj, void *arg, bool *done)
|
|||||||
int
|
int
|
||||||
check_pkg_integrity_all(void)
|
check_pkg_integrity_all(void)
|
||||||
{
|
{
|
||||||
|
struct xbps_handle *xhp = xbps_handle_get();
|
||||||
struct checkpkg cpkg;
|
struct checkpkg cpkg;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
memset(&cpkg, 0, sizeof(cpkg));
|
memset(&cpkg, 0, sizeof(cpkg));
|
||||||
|
/* force an update to get total pkg count */
|
||||||
|
(void)xbps_pkgdb_update(false);
|
||||||
|
cpkg.totalpkgs = prop_array_count(xhp->pkgdb);
|
||||||
|
|
||||||
(void)xbps_pkgdb_foreach_cb(cb_pkg_integrity, &cpkg);
|
(void)xbps_pkgdb_foreach_cb(cb_pkg_integrity, &cpkg);
|
||||||
if (cpkg.flush) {
|
if (cpkg.flush) {
|
||||||
if ((rv = xbps_pkgdb_update(true)) != 0) {
|
if ((rv = xbps_pkgdb_update(true)) != 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user