xbps-uhelper: fix the 'unregister' target, wasn't updated for 0.7.0 API changes.

This commit is contained in:
Juan RP 2010-12-16 00:25:53 +01:00
parent f9db3b1805
commit e6503b98cc
2 changed files with 19 additions and 15 deletions

5
NEWS
View File

@ -1,3 +1,8 @@
xbps-0.7.1 (?):
* Fixed the xbps-uhelper 'unregister' target that was using the old returned
type to check for errors.
xbps-0.7.0 (2010-12-15): xbps-0.7.0 (2010-12-15):
* xbps-repo(8): implemented the 'find-files' target to print which packages * xbps-repo(8): implemented the 'find-files' target to print which packages

View File

@ -104,7 +104,7 @@ main(int argc, char **argv)
{ {
prop_dictionary_t dict; prop_dictionary_t dict;
const char *version; const char *version;
char *plist, *pkgname, *pkgver, *in_chroot_env, *root = "", *hash; char *plist, *pkgname, *pkgver, *in_chroot_env, *hash;
bool in_chroot = false; bool in_chroot = false;
int i, c, rv = 0; int i, c, rv = 0;
@ -112,10 +112,7 @@ main(int argc, char **argv)
switch (c) { switch (c) {
case 'r': case 'r':
/* To specify the root directory */ /* To specify the root directory */
root = strdup(optarg); xbps_set_rootdir(optarg);
if (root == NULL)
exit(EXIT_FAILURE);
xbps_set_rootdir(root);
break; break;
case 'V': case 'V':
printf("%s\n", XBPS_RELVER); printf("%s\n", XBPS_RELVER);
@ -132,9 +129,10 @@ main(int argc, char **argv)
if (argc < 1) if (argc < 1)
usage(); usage();
xbps_init(false); xbps_init(true);
plist = xbps_xasprintf("%s/%s/%s", root, XBPS_META_PATH, XBPS_REGPKGDB); plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(),
XBPS_META_PATH, XBPS_REGPKGDB);
if (plist == NULL) { if (plist == NULL) {
fprintf(stderr, fprintf(stderr,
"%s=> ERROR: couldn't find regpkdb file (%s)%s\n", "%s=> ERROR: couldn't find regpkdb file (%s)%s\n",
@ -189,14 +187,15 @@ main(int argc, char **argv)
if (argc != 3) if (argc != 3)
usage(); usage();
rv = xbps_remove_pkg_dict_from_file(argv[1], plist); if (!xbps_remove_pkg_dict_from_file(argv[1], plist)) {
if (rv == ENOENT) { if (errno == 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 if (rv != 0) { else
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(rv), MSG_RESET); argv[1], strerror(errno), MSG_RESET);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }