Introduce xbps_regpkgdb_remove_pkgd, and use regpkgdb funcs to make xbps-uhelper work.
This commit is contained in:
parent
39d064aff8
commit
5a1ab26972
@ -114,7 +114,7 @@ main(int argc, char **argv)
|
||||
struct xferstat xfer;
|
||||
prop_dictionary_t dict;
|
||||
const char *version, *rootdir = NULL, *confdir = NULL;
|
||||
char *plist = NULL, *pkgname, *pkgver, *in_chroot_env, *hash;
|
||||
char *pkgname, *pkgver, *in_chroot_env, *hash;
|
||||
bool debug = false, in_chroot = false;
|
||||
int i, c, rv = 0;
|
||||
|
||||
@ -168,13 +168,6 @@ main(int argc, char **argv)
|
||||
"initialize libxbps: %s.\n", strerror(rv));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
plist = xbps_xasprintf("%s/%s/%s", rootdir,
|
||||
XBPS_META_PATH, XBPS_REGPKGDB);
|
||||
if (plist == NULL) {
|
||||
xbps_end(xhp);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
in_chroot_env = getenv("in_chroot");
|
||||
@ -229,7 +222,7 @@ main(int argc, char **argv)
|
||||
if (argc != 3)
|
||||
usage(xhp);
|
||||
|
||||
if (!xbps_remove_pkg_dict_from_plist_by_name(argv[1], plist)) {
|
||||
if (!xbps_regpkgdb_remove_pkgd(argv[1])) {
|
||||
if (errno == ENOENT)
|
||||
fprintf(stderr, "%s=> ERROR: %s not registered "
|
||||
"in database.%s\n", MSG_WARN, argv[1], MSG_RESET);
|
||||
@ -250,8 +243,7 @@ main(int argc, char **argv)
|
||||
if (argc != 2)
|
||||
usage(xhp);
|
||||
|
||||
dict = xbps_find_pkg_dict_from_plist_by_name(plist,
|
||||
"packages", argv[1]);
|
||||
dict = xbps_regpkgdb_get_pkgd(argv[1], false);
|
||||
if (dict == NULL)
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
|
@ -56,7 +56,7 @@
|
||||
*/
|
||||
#define XBPS_PKGINDEX_VERSION "1.3"
|
||||
|
||||
#define XBPS_API_VERSION "20111224"
|
||||
#define XBPS_API_VERSION "20111224-1"
|
||||
#define XBPS_VERSION "0.12"
|
||||
|
||||
/**
|
||||
@ -821,6 +821,16 @@ int xbps_regpkgdb_foreach_reverse_pkg_cb(
|
||||
*/
|
||||
prop_dictionary_t xbps_regpkgdb_get_pkgd(const char *pkg, bool bypattern);
|
||||
|
||||
/**
|
||||
* Removes a package dictionary from regpkgdb plist matching the key
|
||||
* \a pkgname.
|
||||
*
|
||||
* @param[in] pkgname Package name to match in a dictionary.
|
||||
*
|
||||
* @return true on success, false otherwise.
|
||||
*/
|
||||
bool xbps_regpkgdb_remove_pkgd(const char *pkgname);
|
||||
|
||||
/**
|
||||
* Updates the regpkgdb plist with new contents from disk to the cached copy
|
||||
* in memory.
|
||||
|
@ -201,3 +201,16 @@ xbps_regpkgdb_get_pkgd(const char *pkg, bool bypattern)
|
||||
|
||||
return prop_dictionary_copy(pkgd);
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_regpkgdb_remove_pkgd(const char *pkgname)
|
||||
{
|
||||
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
|
||||
if (xbps_regpkgdb_dictionary_init(xhp) != 0)
|
||||
return false;
|
||||
|
||||
return xbps_remove_pkg_from_dict_by_name(xhp->regpkgdb,
|
||||
"packages", pkgname);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user