xbps-bin: move remove code into transaction.c::remove_pkg().
This commit is contained in:
parent
6229e06a67
commit
3ffb44f6fe
@ -62,14 +62,11 @@ cleanup(int signum)
|
|||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
prop_dictionary_t pkgd;
|
|
||||||
prop_array_t reqby;
|
|
||||||
struct xbps_handle *xhp;
|
struct xbps_handle *xhp;
|
||||||
struct xferstat xfer;
|
struct xferstat xfer;
|
||||||
struct list_pkgver_cb lpc;
|
struct list_pkgver_cb lpc;
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
const char *rootdir, *cachedir, *confdir, *option, *pkgver;
|
const char *rootdir, *cachedir, *confdir, *option;
|
||||||
size_t x;
|
|
||||||
int i, c, flags, rv;
|
int i, c, flags, rv;
|
||||||
bool yes, purge, debug, reqby_force, force_rm_with_deps, recursive_rm;
|
bool yes, purge, debug, reqby_force, force_rm_with_deps, recursive_rm;
|
||||||
bool install_auto, install_manual, show_download_pkglist_url;
|
bool install_auto, install_manual, show_download_pkglist_url;
|
||||||
@ -261,23 +258,8 @@ main(int argc, char **argv)
|
|||||||
continue;
|
continue;
|
||||||
else if (rv != EEXIST)
|
else if (rv != EEXIST)
|
||||||
goto out;
|
goto out;
|
||||||
|
else
|
||||||
/* pkg has revdeps */
|
reqby_force = true;
|
||||||
pkgd = xbps_find_pkg_dict_installed(argv[i], false);
|
|
||||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
|
||||||
"pkgver", &pkgver);
|
|
||||||
reqby = prop_dictionary_get(pkgd, "requiredby");
|
|
||||||
prop_object_release(pkgd);
|
|
||||||
printf("WARNING: %s IS REQUIRED BY %u PACKAGE%s:\n\n",
|
|
||||||
pkgver, prop_array_count(reqby),
|
|
||||||
prop_array_count(reqby) > 1 ? "S" : "");
|
|
||||||
for (x = 0; x < prop_array_count(reqby); x++) {
|
|
||||||
prop_array_get_cstring_nocopy(reqby, x, &pkgver);
|
|
||||||
print_package_line(pkgver, false);
|
|
||||||
}
|
|
||||||
printf("\n\n");
|
|
||||||
print_package_line(NULL, true);
|
|
||||||
reqby_force = true;
|
|
||||||
}
|
}
|
||||||
if (reqby_force && !force_rm_with_deps) {
|
if (reqby_force && !force_rm_with_deps) {
|
||||||
rv = EINVAL;
|
rv = EINVAL;
|
||||||
|
@ -324,12 +324,30 @@ update_pkg(const char *pkgname)
|
|||||||
int
|
int
|
||||||
remove_pkg(const char *pkgname, bool purge, bool recursive)
|
remove_pkg(const char *pkgname, bool purge, bool recursive)
|
||||||
{
|
{
|
||||||
|
prop_dictionary_t pkgd;
|
||||||
|
prop_array_t reqby;
|
||||||
|
const char *pkgver;
|
||||||
|
size_t x;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
rv = xbps_transaction_remove_pkg(pkgname, purge, recursive);
|
rv = xbps_transaction_remove_pkg(pkgname, purge, recursive);
|
||||||
if (rv == EEXIST)
|
if (rv == EEXIST) {
|
||||||
|
/* pkg has revdeps */
|
||||||
|
pkgd = xbps_find_pkg_dict_installed(pkgname, false);
|
||||||
|
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
|
||||||
|
reqby = prop_dictionary_get(pkgd, "requiredby");
|
||||||
|
prop_object_release(pkgd);
|
||||||
|
printf("WARNING: %s IS REQUIRED BY %u PACKAGE%s:\n\n",
|
||||||
|
pkgver, prop_array_count(reqby),
|
||||||
|
prop_array_count(reqby) > 1 ? "S" : "");
|
||||||
|
for (x = 0; x < prop_array_count(reqby); x++) {
|
||||||
|
prop_array_get_cstring_nocopy(reqby, x, &pkgver);
|
||||||
|
print_package_line(pkgver, false);
|
||||||
|
}
|
||||||
|
printf("\n\n");
|
||||||
|
print_package_line(NULL, true);
|
||||||
return rv;
|
return rv;
|
||||||
else if (rv == ENOENT) {
|
} else if (rv == ENOENT) {
|
||||||
printf("Package `%s' is not currently installed.\n", pkgname);
|
printf("Package `%s' is not currently installed.\n", pkgname);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (rv != 0) {
|
} else if (rv != 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user