xbps-uhelper: use xbps_(un)register_pkg() again.
This commit is contained in:
parent
a7f3a56e19
commit
c0f81bd482
@ -112,8 +112,8 @@ main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
struct xbps_handle *xhp = NULL;
|
struct xbps_handle *xhp = NULL;
|
||||||
struct xferstat xfer;
|
struct xferstat xfer;
|
||||||
prop_dictionary_t dict;
|
prop_dictionary_t dict, pkgd;
|
||||||
const char *version, *rootdir = NULL, *confdir = NULL;
|
const char *pkgn, *version, *rootdir = NULL, *confdir = NULL;
|
||||||
char *pkgname, *pkgver, *in_chroot_env, *hash;
|
char *pkgname, *pkgver, *in_chroot_env, *hash;
|
||||||
bool debug = false, in_chroot = false;
|
bool debug = false, in_chroot = false;
|
||||||
int i, c, rv = 0;
|
int i, c, rv = 0;
|
||||||
@ -194,29 +194,37 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
prop_dictionary_set_cstring(dict, "pkgver", pkgver);
|
prop_dictionary_set_cstring(dict, "pkgver", pkgver);
|
||||||
prop_dictionary_set_bool(dict, "automatic-install", false);
|
prop_dictionary_set_bool(dict, "automatic-install", false);
|
||||||
free(pkgver);
|
|
||||||
|
|
||||||
(void)xbps_regpkgdb_update(xhp, false);
|
pkgd = xbps_regpkgdb_get_pkgd(argv[1], false);
|
||||||
|
if (pkgd != NULL) {
|
||||||
rv = xbps_set_pkg_state_installed(argv[1], argv[2], pkgver,
|
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||||
XBPS_PKG_STATE_INSTALLED);
|
"pkgname", &pkgn);
|
||||||
if (rv != 0)
|
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||||
goto out;
|
"version", &version);
|
||||||
|
prop_object_release(pkgd);
|
||||||
rv = xbps_register_pkg(dict);
|
fprintf(stderr, "%s%s=> ERROR: `%s-%s' is already "
|
||||||
if (rv != 0) {
|
"registered!%s\n", MSG_ERROR,
|
||||||
fprintf(stderr, "%s%s=> couldn't register %s-%s "
|
in_chroot ? "[chroot] " : "",
|
||||||
"(%s).%s\n", MSG_ERROR,
|
pkgn, version, MSG_RESET);
|
||||||
in_chroot ? "[chroot] " : "" , argv[1], argv[2],
|
|
||||||
strerror(rv), MSG_RESET);
|
|
||||||
} else {
|
} else {
|
||||||
if ((rv = xbps_regpkgdb_update(xhp, true)) != 0)
|
rv = xbps_set_pkg_state_installed(argv[1], argv[2],
|
||||||
exit(EXIT_FAILURE);
|
pkgver, XBPS_PKG_STATE_INSTALLED);
|
||||||
|
if (rv != 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
printf("%s%s=> %s-%s registered successfully.%s\n",
|
rv = xbps_register_pkg(dict, true);
|
||||||
MSG_NORMAL, in_chroot ? "[chroot] " : "",
|
if (rv != 0) {
|
||||||
argv[1], argv[2], MSG_RESET);
|
fprintf(stderr, "%s%s=> couldn't register %s-%s "
|
||||||
|
"(%s).%s\n", MSG_ERROR,
|
||||||
|
in_chroot ? "[chroot] " : "" , argv[1],
|
||||||
|
argv[2], strerror(rv), MSG_RESET);
|
||||||
|
} else {
|
||||||
|
printf("%s%s=> %s-%s registered successfully.%s\n",
|
||||||
|
MSG_NORMAL, in_chroot ? "[chroot] " : "",
|
||||||
|
argv[1], argv[2], MSG_RESET);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
free(pkgver);
|
||||||
prop_object_release(dict);
|
prop_object_release(dict);
|
||||||
|
|
||||||
} else if (strcasecmp(argv[0], "unregister") == 0) {
|
} else if (strcasecmp(argv[0], "unregister") == 0) {
|
||||||
@ -224,19 +232,15 @@ main(int argc, char **argv)
|
|||||||
if (argc != 3)
|
if (argc != 3)
|
||||||
usage(xhp);
|
usage(xhp);
|
||||||
|
|
||||||
if (!xbps_regpkgdb_remove_pkgd(argv[1])) {
|
rv = xbps_unregister_pkg(argv[1], argv[2], true);
|
||||||
if (errno == ENOENT)
|
if (rv == ENOENT) {
|
||||||
fprintf(stderr, "%s=> ERROR: %s not registered "
|
fprintf(stderr, "%s=> ERROR: %s not registered "
|
||||||
"in database.%s\n", MSG_WARN, argv[1], MSG_RESET);
|
"in database.%s\n", MSG_WARN, argv[1], MSG_RESET);
|
||||||
else
|
} else if (rv != 0 && rv != ENOENT) {
|
||||||
fprintf(stderr, "%s=> ERROR: couldn't unregister %s "
|
fprintf(stderr, "%s=> ERROR: couldn't unregister %s "
|
||||||
"from database (%s)%s\n", MSG_ERROR,
|
"from database (%s)%s\n", MSG_ERROR,
|
||||||
argv[1], strerror(errno), MSG_RESET);
|
argv[1], strerror(errno), MSG_RESET);
|
||||||
} else {
|
} else {
|
||||||
rv = xbps_regpkgdb_update(xhp, true);
|
|
||||||
if (rv != 0)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
printf("%s%s=> %s-%s unregistered successfully.%s\n",
|
printf("%s%s=> %s-%s unregistered successfully.%s\n",
|
||||||
MSG_NORMAL, in_chroot ? "[chroot] " : "", argv[1],
|
MSG_NORMAL, in_chroot ? "[chroot] " : "", argv[1],
|
||||||
argv[2], MSG_RESET);
|
argv[2], MSG_RESET);
|
||||||
|
Loading…
Reference in New Issue
Block a user