xbps-install(8): added support to list pkgs that will be downloaded from remote repos.
This commit is contained in:
parent
207e95c029
commit
26fca48da2
3
NEWS
3
NEWS
@ -1,5 +1,8 @@
|
|||||||
xbps-0.38 (???):
|
xbps-0.38 (???):
|
||||||
|
|
||||||
|
* xbps-install(8): added support to list packages that will be downloaded, if those
|
||||||
|
were available in a remote repository and were not in the cache directory.
|
||||||
|
|
||||||
* Before accepting a transaction, xbps now checks if there's enough free space
|
* Before accepting a transaction, xbps now checks if there's enough free space
|
||||||
on the target rootdir (on disk) to proceed with the operation. In code terms,
|
on the target rootdir (on disk) to proceed with the operation. In code terms,
|
||||||
xbps_transaction_prepare() now returns ENOSPC if the size of the transaction
|
xbps_transaction_prepare() now returns ENOSPC if the size of the transaction
|
||||||
|
@ -43,6 +43,7 @@ struct transaction {
|
|||||||
uint32_t up_pkgcnt;
|
uint32_t up_pkgcnt;
|
||||||
uint32_t cf_pkgcnt;
|
uint32_t cf_pkgcnt;
|
||||||
uint32_t rm_pkgcnt;
|
uint32_t rm_pkgcnt;
|
||||||
|
uint32_t dl_pkgcnt;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -78,7 +79,7 @@ show_actions(xbps_object_iterator_t iter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_package_list(xbps_object_iterator_t iter, const char *match, int cols)
|
show_package_list(xbps_object_iterator_t iter, const char *match, int cols, bool dload)
|
||||||
{
|
{
|
||||||
xbps_object_t obj;
|
xbps_object_t obj;
|
||||||
const char *pkgver, *tract;
|
const char *pkgver, *tract;
|
||||||
@ -86,9 +87,11 @@ show_package_list(xbps_object_iterator_t iter, const char *match, int cols)
|
|||||||
while ((obj = xbps_object_iterator_next(iter)) != NULL) {
|
while ((obj = xbps_object_iterator_next(iter)) != NULL) {
|
||||||
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
||||||
xbps_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
|
xbps_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
|
||||||
if (strcmp(match, tract))
|
if (dload && xbps_dictionary_get(obj, "download")) {
|
||||||
continue;
|
|
||||||
print_package_line(pkgver, cols, false);
|
print_package_line(pkgver, cols, false);
|
||||||
|
} else if (strcmp(match, tract) == 0) {
|
||||||
|
print_package_line(pkgver, cols, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
xbps_object_iterator_reset(iter);
|
xbps_object_iterator_reset(iter);
|
||||||
print_package_line(NULL, cols, true);
|
print_package_line(NULL, cols, true);
|
||||||
@ -101,14 +104,23 @@ show_transaction_sizes(struct transaction *trans, int cols)
|
|||||||
char size[8];
|
char size[8];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show the list of packages that will be installed.
|
* Show the list of packages that will be downloaded, installed, updated,
|
||||||
|
* removed or configured.
|
||||||
*/
|
*/
|
||||||
|
xbps_dictionary_get_uint32(trans->d, "total-download-pkgs",
|
||||||
|
&trans->dl_pkgcnt);
|
||||||
|
if (trans->dl_pkgcnt) {
|
||||||
|
printf("%u package%s will be downloaded:\n",
|
||||||
|
trans->dl_pkgcnt, trans->dl_pkgcnt == 1 ? "" : "s");
|
||||||
|
show_package_list(trans->iter, "install", cols, true);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
xbps_dictionary_get_uint32(trans->d, "total-install-pkgs",
|
xbps_dictionary_get_uint32(trans->d, "total-install-pkgs",
|
||||||
&trans->inst_pkgcnt);
|
&trans->inst_pkgcnt);
|
||||||
if (trans->inst_pkgcnt) {
|
if (trans->inst_pkgcnt) {
|
||||||
printf("%u package%s will be installed:\n",
|
printf("%u package%s will be installed:\n",
|
||||||
trans->inst_pkgcnt, trans->inst_pkgcnt == 1 ? "" : "s");
|
trans->inst_pkgcnt, trans->inst_pkgcnt == 1 ? "" : "s");
|
||||||
show_package_list(trans->iter, "install", cols);
|
show_package_list(trans->iter, "install", cols, false);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
xbps_dictionary_get_uint32(trans->d, "total-update-pkgs",
|
xbps_dictionary_get_uint32(trans->d, "total-update-pkgs",
|
||||||
@ -116,7 +128,7 @@ show_transaction_sizes(struct transaction *trans, int cols)
|
|||||||
if (trans->up_pkgcnt) {
|
if (trans->up_pkgcnt) {
|
||||||
printf("%u package%s will be updated:\n",
|
printf("%u package%s will be updated:\n",
|
||||||
trans->up_pkgcnt, trans->up_pkgcnt == 1 ? "" : "s");
|
trans->up_pkgcnt, trans->up_pkgcnt == 1 ? "" : "s");
|
||||||
show_package_list(trans->iter, "update", cols);
|
show_package_list(trans->iter, "update", cols, false);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
xbps_dictionary_get_uint32(trans->d, "total-configure-pkgs",
|
xbps_dictionary_get_uint32(trans->d, "total-configure-pkgs",
|
||||||
@ -124,7 +136,7 @@ show_transaction_sizes(struct transaction *trans, int cols)
|
|||||||
if (trans->cf_pkgcnt) {
|
if (trans->cf_pkgcnt) {
|
||||||
printf("%u package%s will be configured:\n",
|
printf("%u package%s will be configured:\n",
|
||||||
trans->cf_pkgcnt, trans->cf_pkgcnt == 1 ? "" : "s");
|
trans->cf_pkgcnt, trans->cf_pkgcnt == 1 ? "" : "s");
|
||||||
show_package_list(trans->iter, "configure", cols);
|
show_package_list(trans->iter, "configure", cols, false);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
xbps_dictionary_get_uint32(trans->d, "total-remove-pkgs",
|
xbps_dictionary_get_uint32(trans->d, "total-remove-pkgs",
|
||||||
@ -132,7 +144,7 @@ show_transaction_sizes(struct transaction *trans, int cols)
|
|||||||
if (trans->rm_pkgcnt) {
|
if (trans->rm_pkgcnt) {
|
||||||
printf("%u package%s will be removed:\n",
|
printf("%u package%s will be removed:\n",
|
||||||
trans->rm_pkgcnt, trans->rm_pkgcnt == 1 ? "" : "s");
|
trans->rm_pkgcnt, trans->rm_pkgcnt == 1 ? "" : "s");
|
||||||
show_package_list(trans->iter, "remove", cols);
|
show_package_list(trans->iter, "remove", cols, false);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -314,8 +326,9 @@ exec_transaction(struct xbps_handle *xhp, int maxcols, bool yes, bool drun)
|
|||||||
* It's time to run the transaction!
|
* It's time to run the transaction!
|
||||||
*/
|
*/
|
||||||
if ((rv = xbps_transaction_commit(xhp)) == 0) {
|
if ((rv = xbps_transaction_commit(xhp)) == 0) {
|
||||||
printf("\n%u installed, %u updated, "
|
printf("\n%u downloaded, %u installed, %u updated, "
|
||||||
"%u configured, %u removed.\n", trans->inst_pkgcnt,
|
"%u configured, %u removed.\n",
|
||||||
|
trans->dl_pkgcnt, trans->inst_pkgcnt,
|
||||||
trans->up_pkgcnt, trans->cf_pkgcnt + trans->inst_pkgcnt,
|
trans->up_pkgcnt, trans->cf_pkgcnt + trans->inst_pkgcnt,
|
||||||
trans->rm_pkgcnt);
|
trans->rm_pkgcnt);
|
||||||
}
|
}
|
||||||
|
@ -62,10 +62,10 @@ compute_transaction_stats(struct xbps_handle *xhp)
|
|||||||
struct statvfs svfs;
|
struct statvfs svfs;
|
||||||
unsigned long rootdir_free_size;
|
unsigned long rootdir_free_size;
|
||||||
uint64_t tsize, dlsize, instsize, rmsize;
|
uint64_t tsize, dlsize, instsize, rmsize;
|
||||||
uint32_t inst_pkgcnt, up_pkgcnt, cf_pkgcnt, rm_pkgcnt;
|
uint32_t inst_pkgcnt, up_pkgcnt, cf_pkgcnt, rm_pkgcnt, dl_pkgcnt;
|
||||||
const char *tract, *pkgver, *repo;
|
const char *tract, *pkgver, *repo;
|
||||||
|
|
||||||
inst_pkgcnt = up_pkgcnt = cf_pkgcnt = rm_pkgcnt = 0;
|
inst_pkgcnt = up_pkgcnt = cf_pkgcnt = rm_pkgcnt = dl_pkgcnt = 0;
|
||||||
tsize = dlsize = instsize = rmsize = 0;
|
tsize = dlsize = instsize = rmsize = 0;
|
||||||
|
|
||||||
iter = xbps_array_iter_from_dict(xhp->transd, "packages");
|
iter = xbps_array_iter_from_dict(xhp->transd, "packages");
|
||||||
@ -108,6 +108,8 @@ compute_transaction_stats(struct xbps_handle *xhp)
|
|||||||
tsize += 512;
|
tsize += 512;
|
||||||
dlsize += tsize;
|
dlsize += tsize;
|
||||||
instsize += tsize;
|
instsize += tsize;
|
||||||
|
dl_pkgcnt++;
|
||||||
|
xbps_dictionary_set_bool(obj, "download", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -153,7 +155,9 @@ compute_transaction_stats(struct xbps_handle *xhp)
|
|||||||
if (!xbps_dictionary_set_uint32(xhp->transd,
|
if (!xbps_dictionary_set_uint32(xhp->transd,
|
||||||
"total-remove-pkgs", rm_pkgcnt))
|
"total-remove-pkgs", rm_pkgcnt))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
if (!xbps_dictionary_set_uint32(xhp->transd,
|
||||||
|
"total-download-pkgs", dl_pkgcnt))
|
||||||
|
return EINVAL;
|
||||||
if (!xbps_dictionary_set_uint64(xhp->transd,
|
if (!xbps_dictionary_set_uint64(xhp->transd,
|
||||||
"total-installed-size", instsize))
|
"total-installed-size", instsize))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user