XBPS major changes in June 2011.
- A configuration file "xbps-conf.plist" replaces the (un)register target in xbps-repo(8) and (un)set-prop in xbps-bin(8). For now, you can set the repositories and prefered virtual packages. - New package pattern matching code from NetBSD. Supports more ways of matching patterns in packages. - Multiple bugs fixed in virtual packages related matching code. --HG-- rename : LICENSE => COPYING
This commit is contained in:
@@ -28,9 +28,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <xbps_api.h>
|
||||
#include "xbps_api_impl.h"
|
||||
|
||||
/**
|
||||
@@ -58,63 +56,47 @@
|
||||
* dictionary.
|
||||
*/
|
||||
|
||||
static prop_dictionary_t regpkgdb_dict;
|
||||
static size_t regpkgdb_refcnt;
|
||||
static bool regpkgdb_initialized;
|
||||
static pthread_mutex_t refcnt_mtx = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_regpkgdb_dictionary_get(void)
|
||||
int HIDDEN
|
||||
xbps_regpkgdb_dictionary_init(struct xbps_handle *xhp)
|
||||
{
|
||||
const struct xbps_handle *xhp;
|
||||
char *plist;
|
||||
|
||||
if (regpkgdb_initialized) {
|
||||
pthread_mutex_lock(&refcnt_mtx);
|
||||
regpkgdb_refcnt++;
|
||||
pthread_mutex_unlock(&refcnt_mtx);
|
||||
return regpkgdb_dict;
|
||||
}
|
||||
if (regpkgdb_initialized)
|
||||
return 0;
|
||||
|
||||
xhp = xbps_handle_get();
|
||||
plist = xbps_xasprintf("%s/%s/%s", xhp->rootdir,
|
||||
XBPS_META_PATH, XBPS_REGPKGDB);
|
||||
if (plist == NULL)
|
||||
return NULL;
|
||||
return ENOMEM;
|
||||
|
||||
regpkgdb_dict = prop_dictionary_internalize_from_zfile(plist);
|
||||
if (regpkgdb_dict == NULL) {
|
||||
xhp->regpkgdb_dictionary =
|
||||
prop_dictionary_internalize_from_zfile(plist);
|
||||
if (xhp->regpkgdb_dictionary == NULL) {
|
||||
free(plist);
|
||||
if (errno != ENOENT)
|
||||
xbps_dbg_printf("[regpkgdb] cannot internalize "
|
||||
"regpkgdb_dict %s\n", strerror(errno));
|
||||
return NULL;
|
||||
"regpkgdb dictionary: %s\n", strerror(errno));
|
||||
return errno;
|
||||
}
|
||||
free(plist);
|
||||
regpkgdb_initialized = true;
|
||||
xbps_dbg_printf("%s: initialized ok.\n", __func__);
|
||||
|
||||
pthread_mutex_lock(&refcnt_mtx);
|
||||
regpkgdb_refcnt = 1;
|
||||
pthread_mutex_unlock(&refcnt_mtx);
|
||||
|
||||
return regpkgdb_dict;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
void HIDDEN
|
||||
xbps_regpkgdb_dictionary_release(void)
|
||||
{
|
||||
size_t cnt;
|
||||
const struct xbps_handle *xhp;
|
||||
|
||||
pthread_mutex_lock(&refcnt_mtx);
|
||||
cnt = regpkgdb_refcnt--;
|
||||
pthread_mutex_unlock(&refcnt_mtx);
|
||||
|
||||
if (cnt != 1)
|
||||
if (!regpkgdb_initialized)
|
||||
return;
|
||||
|
||||
prop_object_release(regpkgdb_dict);
|
||||
regpkgdb_dict = NULL;
|
||||
xhp = xbps_handle_get();
|
||||
prop_object_release(xhp->regpkgdb_dictionary);
|
||||
regpkgdb_initialized = false;
|
||||
xbps_dbg_printf("%s: released ok.\n", __func__);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user