xbps-uhelper: really fix this time after regpkgdb rototill.
This commit is contained in:
parent
b64fb39701
commit
9fa2804763
@ -180,29 +180,31 @@ main(int argc, char **argv)
|
|||||||
usage(xhp);
|
usage(xhp);
|
||||||
|
|
||||||
dict = prop_dictionary_create();
|
dict = prop_dictionary_create();
|
||||||
if (dict == NULL)
|
if (dict == NULL) {
|
||||||
exit(EXIT_FAILURE);
|
rv = -1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
prop_dictionary_set_cstring_nocopy(dict, "pkgname", argv[1]);
|
prop_dictionary_set_cstring_nocopy(dict, "pkgname", argv[1]);
|
||||||
prop_dictionary_set_cstring_nocopy(dict, "version", argv[2]);
|
prop_dictionary_set_cstring_nocopy(dict, "version", argv[2]);
|
||||||
prop_dictionary_set_cstring_nocopy(dict, "short_desc", argv[3]);
|
prop_dictionary_set_cstring_nocopy(dict, "short_desc", argv[3]);
|
||||||
pkgver = xbps_xasprintf("%s-%s", argv[1], argv[2]);
|
pkgver = xbps_xasprintf("%s-%s", argv[1], argv[2]);
|
||||||
if (pkgver == NULL)
|
if (pkgver == NULL) {
|
||||||
exit(EXIT_FAILURE);
|
rv = -1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
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);
|
free(pkgver);
|
||||||
|
|
||||||
|
(void)xbps_regpkgdb_update(xhp, false);
|
||||||
|
|
||||||
rv = xbps_set_pkg_state_installed(argv[1], argv[2], pkgver,
|
rv = xbps_set_pkg_state_installed(argv[1], argv[2], pkgver,
|
||||||
XBPS_PKG_STATE_INSTALLED);
|
XBPS_PKG_STATE_INSTALLED);
|
||||||
if (rv != 0)
|
if (rv != 0)
|
||||||
exit(EXIT_FAILURE);
|
goto out;
|
||||||
|
|
||||||
rv = xbps_register_pkg(dict);
|
rv = xbps_register_pkg(dict);
|
||||||
if (rv == EEXIST) {
|
if (rv != 0) {
|
||||||
printf("%s%s=> %s-%s already registered.%s\n", MSG_WARN,
|
|
||||||
in_chroot ? "[chroot] " : "", argv[1], argv[2],
|
|
||||||
MSG_RESET);
|
|
||||||
} else if (rv != 0) {
|
|
||||||
fprintf(stderr, "%s%s=> couldn't register %s-%s "
|
fprintf(stderr, "%s%s=> couldn't register %s-%s "
|
||||||
"(%s).%s\n", MSG_ERROR,
|
"(%s).%s\n", MSG_ERROR,
|
||||||
in_chroot ? "[chroot] " : "" , argv[1], argv[2],
|
in_chroot ? "[chroot] " : "" , argv[1], argv[2],
|
||||||
@ -230,23 +232,26 @@ main(int argc, char **argv)
|
|||||||
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 {
|
||||||
|
rv = xbps_regpkgdb_update(xhp, true);
|
||||||
|
if (rv != 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
exit(EXIT_FAILURE);
|
printf("%s%s=> %s-%s unregistered successfully.%s\n",
|
||||||
|
MSG_NORMAL, in_chroot ? "[chroot] " : "", argv[1],
|
||||||
|
argv[2], MSG_RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%s%s=> %s-%s unregistered successfully.%s\n",
|
|
||||||
MSG_NORMAL, in_chroot ? "[chroot] " : "", argv[1],
|
|
||||||
argv[2], MSG_RESET);
|
|
||||||
|
|
||||||
} else if (strcasecmp(argv[0], "version") == 0) {
|
} else if (strcasecmp(argv[0], "version") == 0) {
|
||||||
/* Prints version of an installed package */
|
/* Prints version of an installed package */
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
usage(xhp);
|
usage(xhp);
|
||||||
|
|
||||||
dict = xbps_regpkgdb_get_pkgd(argv[1], false);
|
dict = xbps_regpkgdb_get_pkgd(argv[1], false);
|
||||||
if (dict == NULL)
|
if (dict == NULL) {
|
||||||
exit(EXIT_FAILURE);
|
rv = errno;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
prop_dictionary_get_cstring_nocopy(dict, "version", &version);
|
prop_dictionary_get_cstring_nocopy(dict, "version", &version);
|
||||||
printf("%s\n", version);
|
printf("%s\n", version);
|
||||||
prop_object_release(dict);
|
prop_object_release(dict);
|
||||||
@ -366,7 +371,7 @@ main(int argc, char **argv)
|
|||||||
if (rv == -1) {
|
if (rv == -1) {
|
||||||
printf("%s: %s\n", argv[1],
|
printf("%s: %s\n", argv[1],
|
||||||
xbps_fetch_error_string());
|
xbps_fetch_error_string());
|
||||||
exit(EXIT_FAILURE);
|
goto out;
|
||||||
} else if (rv == 0) {
|
} else if (rv == 0) {
|
||||||
printf("%s: file is identical than remote.\n",
|
printf("%s: file is identical than remote.\n",
|
||||||
argv[1]);
|
argv[1]);
|
||||||
@ -377,7 +382,7 @@ main(int argc, char **argv)
|
|||||||
usage(xhp);
|
usage(xhp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
xbps_end(xhp);
|
xbps_end(xhp);
|
||||||
|
exit(rv ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user