mirror of
https://github.com/void-linux/void-packages.git
synced 2025-07-29 08:52:56 +02:00
xbps-bin: show which pkgs are updated and installed before proceeding.
--HG-- extra : convert_revision : 2c2fcd7f3c5909d14d1519ffc7e8ac0cad124b34
This commit is contained in:
parent
b8c4131798
commit
45a58485eb
2 changed files with 57 additions and 26 deletions
|
@ -50,10 +50,11 @@ struct transaction {
|
||||||
bool update;
|
bool update;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void cleanup(int);
|
||||||
|
static int exec_transaction(struct transaction *);
|
||||||
static void show_missing_deps(prop_dictionary_t, const char *);
|
static void show_missing_deps(prop_dictionary_t, const char *);
|
||||||
static int show_missing_dep_cb(prop_object_t, void *, bool *);
|
static int show_missing_dep_cb(prop_object_t, void *, bool *);
|
||||||
static int exec_transaction(struct transaction *);
|
static void show_package_list(prop_object_iterator_t, const char *);
|
||||||
static void cleanup(int);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_missing_deps(prop_dictionary_t d, const char *pkgname)
|
show_missing_deps(prop_dictionary_t d, const char *pkgname)
|
||||||
|
@ -119,15 +120,44 @@ check_pkg_hashes(prop_object_iterator_t iter)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
show_package_list(prop_object_iterator_t iter, const char *match)
|
||||||
|
{
|
||||||
|
prop_object_t obj;
|
||||||
|
size_t cols = 0;
|
||||||
|
const char *pkgname, *version, *tract;
|
||||||
|
bool first = false;
|
||||||
|
|
||||||
|
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
||||||
|
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||||
|
prop_dictionary_get_cstring_nocopy(obj, "version", &version);
|
||||||
|
prop_dictionary_get_cstring_nocopy(obj, "trans-action", &tract);
|
||||||
|
if (strcmp(match, tract))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
cols += strlen(pkgname) + strlen(version) + 4;
|
||||||
|
if (cols <= 80) {
|
||||||
|
if (first == false) {
|
||||||
|
printf(" ");
|
||||||
|
first = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printf("\n ");
|
||||||
|
cols = strlen(pkgname) + strlen(version) + 4;
|
||||||
|
}
|
||||||
|
printf("%s-%s ", pkgname, version);
|
||||||
|
}
|
||||||
|
prop_object_iterator_reset(iter);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
show_transaction_sizes(prop_object_iterator_t iter, const char *descr)
|
show_transaction_sizes(prop_object_iterator_t iter)
|
||||||
{
|
{
|
||||||
prop_object_t obj;
|
prop_object_t obj;
|
||||||
uint64_t tsize = 0, dlsize = 0, instsize = 0;
|
uint64_t tsize = 0, dlsize = 0, instsize = 0;
|
||||||
size_t cols = 0;
|
const char *tract;
|
||||||
const char *pkgname, *version;
|
|
||||||
char size[64];
|
char size[64];
|
||||||
bool first = false;
|
bool trans_inst = false, trans_up = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Iterate over the list of packages that are going to be
|
* Iterate over the list of packages that are going to be
|
||||||
|
@ -143,28 +173,28 @@ show_transaction_sizes(prop_object_iterator_t iter, const char *descr)
|
||||||
}
|
}
|
||||||
prop_object_iterator_reset(iter);
|
prop_object_iterator_reset(iter);
|
||||||
|
|
||||||
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
|
prop_dictionary_get_cstring_nocopy(obj, "trans-action", &tract);
|
||||||
|
if (strcmp(tract, "install") == 0)
|
||||||
|
trans_inst = true;
|
||||||
|
else if (strcmp(tract, "update") == 0)
|
||||||
|
trans_up = true;
|
||||||
|
}
|
||||||
|
prop_object_iterator_reset(iter);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show the list of packages that will be installed.
|
* Show the list of packages that will be installed.
|
||||||
*/
|
*/
|
||||||
printf("\nThe following new packages will be %s:\n\n", descr);
|
if (trans_inst) {
|
||||||
|
printf("The following packages will be installed:\n\n");
|
||||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
show_package_list(iter, "install");
|
||||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
|
||||||
prop_dictionary_get_cstring_nocopy(obj, "version", &version);
|
|
||||||
cols += strlen(pkgname) + strlen(version) + 4;
|
|
||||||
if (cols <= 80) {
|
|
||||||
if (first == false) {
|
|
||||||
printf(" ");
|
|
||||||
first = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
printf("\n ");
|
|
||||||
cols = strlen(pkgname) + strlen(version) + 4;
|
|
||||||
}
|
|
||||||
printf("%s-%s ", pkgname, version);
|
|
||||||
}
|
|
||||||
prop_object_iterator_reset(iter);
|
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
|
}
|
||||||
|
if (trans_up) {
|
||||||
|
printf("The following packages will be updated:\n\n");
|
||||||
|
show_package_list(iter, "update");
|
||||||
|
printf("\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show total download/installed size for all required packages.
|
* Show total download/installed size for all required packages.
|
||||||
|
@ -291,8 +321,7 @@ exec_transaction(struct transaction *trans)
|
||||||
/*
|
/*
|
||||||
* Show download/installed size for the transaction.
|
* Show download/installed size for the transaction.
|
||||||
*/
|
*/
|
||||||
rv = show_transaction_sizes(trans->iter,
|
rv = show_transaction_sizes(trans->iter);
|
||||||
trans->type == TRANS_ALL ? "updated" : "installed");
|
|
||||||
if (rv != 0)
|
if (rv != 0)
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
|
|
|
@ -285,6 +285,8 @@ xbps_find_new_pkg(const char *pkgname, prop_dictionary_t instpkg)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prop_dictionary_set_cstring_nocopy(pkgrd, "trans-action", "update");
|
||||||
|
|
||||||
if (!prop_array_add(unsorted, pkgrd))
|
if (!prop_array_add(unsorted, pkgrd))
|
||||||
rv = errno;
|
rv = errno;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue