New configuration scheme changes, round 1.

- Configuration file 'xbps-conf.plist' has been splitted off into
  two files: conf.plist and repositories.plist. By default they
  are stored in etc/xbps.
- Changed some members in xbps_handle struct, mostly to make it easy
  to change its value in {cache,root}dir and conffile.
- Made xbps_init() release proplib objects as soon as we don't need
  them, that way it uses 35% less of memory or in some cases even more.

There will be another commit that will implement to read new virtualpkg
settings by the user, as specified in:

	http://code.google.com/p/xbps/issues/detail?id=12
This commit is contained in:
Juan RP 2011-10-17 12:37:15 +02:00
parent b6da7393c1
commit 5642ffa86e
27 changed files with 236 additions and 207 deletions

View File

@ -155,7 +155,8 @@ check_pkg_integrity(const char *pkgname)
"empty target object!\n", pkgname, file);
continue;
}
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
path = xbps_xasprintf("%s/%s",
prop_string_cstring_nocopy(xhp->rootdir), file);
if (path == NULL)
abort();
@ -168,8 +169,9 @@ check_pkg_integrity(const char *pkgname)
}
free(path);
if (strcmp(xhp->rootdir, "/") && strstr(buf, xhp->rootdir))
path = buf + strlen(xhp->rootdir);
if (!prop_string_equals_cstring(xhp->rootdir, "/") &&
strstr(buf, prop_string_cstring_nocopy(xhp->rootdir)))
path = buf + prop_string_size(xhp->rootdir);
else
path = buf;
@ -201,7 +203,8 @@ check_pkg_integrity(const char *pkgname)
while ((obj = prop_object_iterator_next(iter))) {
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
path = xbps_xasprintf("%s/%s",
prop_string_cstring_nocopy(xhp->rootdir), file);
if (path == NULL) {
prop_object_iterator_release(iter);
abort();
@ -250,7 +253,8 @@ check_pkg_integrity(const char *pkgname)
while ((obj = prop_object_iterator_next(iter))) {
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
path = xbps_xasprintf("%s/%s",
prop_string_cstring_nocopy(xhp->rootdir), file);
if (path == NULL) {
prop_object_iterator_release(iter);
abort();

View File

@ -81,8 +81,8 @@ find_files_in_packages(const char *pattern)
unsigned int i, count;
xhp = xbps_handle_get();
path = xbps_xasprintf("%s/%s/metadata", xhp->rootdir,
XBPS_META_PATH);
path = xbps_xasprintf("%s/%s/metadata",
prop_string_cstring_nocopy(xhp->rootdir), XBPS_META_PATH);
if (path == NULL)
return -1;

View File

@ -285,10 +285,15 @@ main(int argc, char **argv)
xhp->xbps_unpack_cb = unpack_progress_cb_verbose;
else
xhp->xbps_unpack_cb = unpack_progress_cb;
xhp->rootdir = rootdir;
xhp->cachedir = cachedir;
if (rootdir)
xhp->rootdir = prop_string_create_cstring(rootdir);
if (cachedir)
xhp->cachedir = prop_string_create_cstring(cachedir);
if (conffile)
xhp->conffile = prop_string_create_cstring(conffile);
xhp->flags = flags;
xhp->conffile = conffile;
xhp->install_reason_manual = install_manual;
xhp->install_reason_auto = install_auto;

View File

@ -442,7 +442,7 @@ int
main(int argc, char **argv)
{
prop_dictionary_t plistd, confd = NULL;
struct xbps_handle xh;
struct xbps_handle *xhp;
FILE *f = NULL;
char *outfile = NULL;
const char *conf_file = NULL, *rootdir = NULL;
@ -484,9 +484,13 @@ main(int argc, char **argv)
usage();
/* Initialize libxbps */
memset(&xh, 0, sizeof(xh));
xh.rootdir = rootdir;
xbps_init(&xh);
xhp = xbps_handle_alloc();
if (xhp == NULL)
die("failed to allocate resources");
if (rootdir)
xhp->rootdir = prop_string_create_cstring(rootdir);
if (xbps_init(xhp))
die("failed to initialize libxbps");
/*
* Output file will be <pkgname>.dot if not specified.

View File

@ -139,9 +139,12 @@ main(int argc, char **argv)
xhp->xbps_transaction_err_cb = transaction_err_cb;
xhp->xbps_fetch_cb = fetch_file_progress_cb;
xhp->xfcd->cookie = &xfer;
xhp->rootdir = rootdir;
xhp->cachedir = cachedir;
xhp->conffile = conffile;
if (rootdir)
xhp->rootdir = prop_string_create_cstring(rootdir);
if (cachedir)
xhp->cachedir = prop_string_create_cstring(cachedir);
if (conffile)
xhp->conffile = prop_string_create_cstring(conffile);
if ((rv = xbps_init(xhp)) != 0) {
xbps_error_printf("xbps-repo: couldn't initialize library: %s\n",

View File

@ -156,8 +156,10 @@ main(int argc, char **argv)
xhp->debug = debug;
xhp->xbps_fetch_cb = fetch_file_progress_cb;
xhp->xfcd->cookie = &xfer;
xhp->rootdir = rootdir;
xhp->conffile = conffile;
if (rootdir)
xhp->rootdir = prop_string_create_cstring(rootdir);
if (conffile)
xhp->conffile = prop_string_create_cstring(conffile);
if ((rv = xbps_init(xhp)) != 0) {
xbps_error_printf("xbps-uhelper: failed to "

4
configure vendored
View File

@ -136,6 +136,8 @@ echo "INCLUDEDIR ?= $INCLUDEDIR" >>$CONFIG_MK
echo "LIBDIR ?= $LIBDIR" >>$CONFIG_MK
echo "MANDIR ?= $MANDIR" >>$CONFIG_MK
echo "SHAREDIR ?= $SHAREDIR" >>$CONFIG_MK
ETCDIR="${ETCDIR}/xbps"
echo "ETCDIR ?= $ETCDIR" >>$CONFIG_MK
[ -z "$DEBUG" ] && DEBUG=no
@ -172,7 +174,7 @@ if [ -n "$LDFLAGS" ]; then
fi
echo "CPPFLAGS = -I. -I\$(TOPDIR) -I\$(TOPDIR)/include" >>$CONFIG_MK
echo "CPPFLAGS += -DHAVE_CONFIG_H" >>$CONFIG_MK
echo "CPPFLAGS += -DXBPS_CONF_PATH=\\\"${ETCDIR}\\\"" >>$CONFIG_MK
echo "CPPFLAGS += -DXBPS_SYSCONF_PATH=\\\"${ETCDIR}\\\"" >>$CONFIG_MK
if [ -n "$DEBUG" -a "$DEBUG" != no -a "$DEBUG" != false ]; then
echo "Building with debugging symbols."

View File

@ -1,6 +1,6 @@
-include ../config.mk
CONF_FILE = xbps-conf.plist
CONF_FILE = conf.plist repositories.plist
.PHONY: all
all:

27
etc/conf.plist Normal file
View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- Default root directory, defaults to / -->
<key>root-directory</key>
<string>/</string>
<!-- Default cache directory to store downloaded binary packages.
If string begins with '/' it will be treated as full path,
otherwise it will be treated as relative to the root-directory. -->
<key>cache-directory</key>
<string>var/cache/xbps</string>
<!-- Default global limit of cached connections when fetching -->
<key>fetch-cache-connections</key>
<integer>10</integer>
<!-- Default per-host limit of cached connections when fetching -->
<key>fetch-cache-connections-per-host</key>
<integer>6</integer>
<!-- Default timeout limit for connections, in seconds. -->
<key>fetch-timeout-connection</key>
<integer>30</integer>
</dict>
</plist>

25
etc/repositories.plist Normal file
View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<!-- You can specify here your list of repositories,
the first repository that contains a package will
be used for most targets in xbps-bin(8) and
xbps-repo(8), with the exception for updating
on which all repositories will be looked at and
the newest version will be choosen.
Optionally a non default HTTP port can also be
specified like that:
http://foo.local:8080/xbps-repo
The order matters, and the top-most matching a package
pattern or name will be used.
By default we use the official "public" repositories.
you can add your own local repositories by specifying
the path to the directory. -->
<string>http://xbps.nopcode.org/repos/current</string>
</array>
</plist>

View File

@ -1,83 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- Default root directory, defaults to / -->
<key>root-directory</key>
<string>/</string>
<!-- Default cache directory to store downloaded binary packages.
If string begins with '/' it will be treated as full path,
otherwise it will be treated as relative to the root-directory. -->
<key>cache-directory</key>
<string>var/cache/xbps</string>
<!-- Default global limit of cached connections when fetching -->
<key>fetch-cache-connections</key>
<integer>10</integer>
<!-- Default per-host limit of cached connections when fetching -->
<key>fetch-cache-connections-per-host</key>
<integer>6</integer>
<!-- Default timeout limit for connections, in seconds. -->
<key>fetch-timeout-connection</key>
<integer>30</integer>
<!-- Repository list -->
<key>repositories</key>
<array>
<!-- You can specify here your list of repositories,
the first repository that contains a package will
be used for most targets in xbps-bin(8) and
xbps-repo(8), with the exception for updating
on which all repositories will be looked at and
the newest version will be choosen.
Optionally a non default HTTP port can also be
specified like that:
http://foo.local:8080/xbps-repo
The order matters, and the top-most matching a package
pattern or name will be used.
By default we use the official "public" repositories.
you can add your own local repositories by specifying
the path to the directory. -->
<string>http://xbps.nopcode.org/repos/current</string>
</array>
<!-- Virtual packages -->
<key>virtual-packages</key>
<array>
<!-- This dictionary sets that we _always_ want
the "dcron" package to be the default cron-daemon
package, over other alternatives.
Another option might be to change it to the
"cronie" package, or any package that "provides"
"cron-daemon-0". -->
<dict>
<key>virtual-pkgver</key>
<string>cron-daemon-0</string>
<key>target-pkgpattern</key>
<string>dcron>=0</string>
</dict>
<!-- Uncomment this dictionary to prefer the "xbps-devel"
package (snapshot from mercurial repository) rather
than the official stable version (don't do this if
you are not a developer :-) -->
<!-- #### REMOVE THIS LINE TO ENABLE ####
<dict>
<key>virtual-pkgver</key>
<string>xbps-9999</string>
<key>target-pkgpattern</key>
<string>xbps-devel>=0</string>
</dict>
#### REMOVE THIS LINE TO ENABLE #### -->
</array>
</dict>
</plist>

View File

@ -55,7 +55,7 @@
*/
#define XBPS_PKGINDEX_VERSION "1.2"
#define XBPS_API_VERSION "20111016-1"
#define XBPS_API_VERSION "20111017"
#define XBPS_VERSION "0.10.0"
/**
@ -103,18 +103,32 @@
#define XBPS_PKGINDEX "pkg-index.plist"
/**
* @def XBPS_CONF_PATH
* @def XBPS_SYSCONF_PATH
* Default configuration PATH to find XBPS_CONF_PLIST.
*/
#ifndef XBPS_CONF_PATH
#define XBPS_CONF_PATH "/etc"
#define XBPS_SYSDIR "/xbps"
#ifndef XBPS_SYSCONF_PATH
#define XBPS_SYSCONF_PATH "/etc" XBPS_SYSDIR
#endif
/**
* @def XBPS_CONF_PLIST
* Filename for the XBPS plist configuration file.
*/
#define XBPS_CONF_PLIST "xbps-conf.plist"
#define XBPS_CONF_PLIST "conf.plist"
/**
* @def XBPS_CONF_REPOS_PLIST
* Filename for the XBPS repositories plist configuration file.
*/
#define XBPS_CONF_REPOS_PLIST "repositories.plist"
/**
* @def XBPS_VIRTUALPKGD_PATH
* Default directory to load virtualpkg plist files, by default set
* to XBPS_SYSCONF_PATH + "/" + XBPS_VIRTUALPKGD_PATH.
*/
#define XBPS_VIRTUALPKGD_PATH "virtualpkg.d.wants"
/**
* @def XBPS_FLAG_VERBOSE
@ -372,12 +386,16 @@ struct xbps_unpack_cb_data {
*/
struct xbps_handle {
/**
* @private conf_dictionary
*
* Internalized proplib dictionary from conffile member.
* Used internally by xbps_init().
* @private
*/
prop_dictionary_t conf_dictionary;
prop_dictionary_t virtualpkg_dictionary;
/**
* @private repos_array
*
* Internalized proplib array from XBPS_CONF_REPOS_PLIST file.
* Used internally by xbps_init(), do not use it.
*/
prop_array_t repos_array;
/**
* @var regpkgdb_dictionary.
*
@ -435,6 +453,26 @@ struct xbps_handle {
* as argument to the \a xbps_fetch_cb function callback.
*/
struct xbps_fetch_cb_data *xfcd;
/**
* @var rootdir
*
* Root directory for all operations in XBPS. If NULL,
* by default it's set to /.
*/
prop_string_t rootdir;
/**
* @var cachedir
*
* Cache directory to store downloaded binary packages.
* If NULL default value in \a XBPS_CACHE_PATH is used.
*/
prop_string_t cachedir;
/**
* @var conffile
*
* Full path to the XBPS_CONF_PLIST configuration file.
*/
prop_string_t conffile;
/**
* @private fetch_timeout
*
@ -453,32 +491,6 @@ struct xbps_handle {
* - XBPS_FLAG_FORCE
*/
int flags;
/**
* @var rootdir
*
* Root directory for all operations in XBPS. If NULL,
* by default it's set to /.
*/
const char *rootdir;
/**
* @var cachedir
*
* Cache directory to store downloaded binary packages.
* If NULL default value in \a XBPS_CACHE_PATH is used.
*/
const char *cachedir;
/**
* @private pstring_cachedir
*
* Used internally by xbps_init(), do not use it.
*/
prop_string_t pstring_cachedir;
/**
* @var conffile
*
* Full path to the XBPS_CONF_PLIST configuration file.
*/
const char *conffile;
/**
* @var debug
*

View File

@ -42,9 +42,13 @@
static bool debug;
static struct xbps_handle *xhp;
#define _CONFFILE XBPS_SYSCONF_PATH "/" XBPS_CONF_PLIST
#define _REPOFILE XBPS_SYSCONF_PATH "/" XBPS_CONF_REPOS_PLIST
int
xbps_init(struct xbps_handle *xh)
{
prop_dictionary_t confd;
const char *conf_rootdir = NULL, *conf_cachedir = NULL;
uint16_t fetch_cache_conn = 0, fetch_cache_conn_host = 0;
int rv;
@ -54,16 +58,19 @@ xbps_init(struct xbps_handle *xh)
xhp = xh;
debug = xhp->debug;
/* If conffile not set, defaults to XBPS_CONF_PATH */
if (xhp->conffile == NULL)
xhp->conffile = XBPS_CONF_PATH "/" XBPS_CONF_PLIST;
/* If conffile not set, defaults to XBPS_SYSCONF_PATH */
if (prop_object_type(xhp->conffile) != PROP_TYPE_STRING)
xhp->conffile = prop_string_create_cstring(_CONFFILE);
/*
* Internalize the XBPS_CONF_REPOS_PLIST array.
*/
xhp->repos_array = prop_array_internalize_from_file(_REPOFILE);
/*
* Internalize the XBPS_CONF_PLIST dictionary.
*/
xhp->conf_dictionary =
prop_dictionary_internalize_from_file(xhp->conffile);
if (xhp->conf_dictionary == NULL) {
confd = prop_dictionary_internalize_from_file(
prop_string_cstring_nocopy(xhp->conffile));
if (confd == NULL) {
if (errno != ENOENT) {
xbps_dbg_printf("%s: cannot internalize conf "
"dictionary: %s\n", strerror(errno));
@ -76,15 +83,15 @@ xbps_init(struct xbps_handle *xh)
/*
* Get defaults from configuration file.
*/
prop_dictionary_get_cstring_nocopy(xhp->conf_dictionary,
prop_dictionary_get_cstring_nocopy(confd,
"root-directory", &conf_rootdir);
prop_dictionary_get_cstring_nocopy(xhp->conf_dictionary,
prop_dictionary_get_cstring_nocopy(confd,
"cache-directory", &conf_cachedir);
prop_dictionary_get_uint16(xhp->conf_dictionary,
prop_dictionary_get_uint16(confd,
"fetch-cache-connections", &fetch_cache_conn);
prop_dictionary_get_uint16(xhp->conf_dictionary,
prop_dictionary_get_uint16(confd,
"fetch-cache-connections-per-host", &fetch_cache_conn_host);
prop_dictionary_get_uint16(xhp->conf_dictionary,
prop_dictionary_get_uint16(confd,
"fetch-timeout-connection", &xhp->fetch_timeout);
}
@ -92,33 +99,32 @@ xbps_init(struct xbps_handle *xh)
* Client supplied values in xbps_handle will be choosen over the
* same values in configuration file. If not specified, use defaults.
*/
if (xhp->rootdir == NULL) {
if (prop_object_type(xhp->rootdir) != PROP_TYPE_STRING) {
if (conf_rootdir != NULL)
xhp->rootdir = conf_rootdir;
xhp->rootdir = prop_string_create_cstring(conf_rootdir);
else {
/* If rootdir not set, defaults to '/' */
xhp->rootdir = "/";
xhp->rootdir = prop_string_create_cstring("/");
}
}
if (xhp->cachedir == NULL) {
if (prop_object_type(xhp->cachedir) != PROP_TYPE_STRING) {
if (conf_cachedir != NULL) {
if (conf_cachedir[0] == '/') {
/* full path */
xhp->cachedir = conf_cachedir;
xhp->cachedir =
prop_string_create_cstring(conf_cachedir);
} else {
/* relative to rootdir */
xhp->pstring_cachedir =
prop_string_create_cstring(xhp->rootdir);
xhp->cachedir = prop_string_copy(xhp->rootdir);
prop_string_append_cstring(
xhp->pstring_cachedir, "/");
xhp->cachedir, "/");
prop_string_append_cstring(
xhp->pstring_cachedir, conf_cachedir);
xhp->cachedir = prop_string_cstring_nocopy(
xhp->pstring_cachedir);
xhp->cachedir, conf_cachedir);
}
} else {
/* If cachedir not set, defaults to XBPS_CACHE_PATH */
xhp->cachedir = XBPS_CACHE_PATH;
xhp->cachedir =
prop_string_create_cstring(XBPS_CACHE_PATH);
}
}
if (fetch_cache_conn == 0)
@ -129,12 +135,16 @@ xbps_init(struct xbps_handle *xh)
xbps_fetch_set_cache_connection(fetch_cache_conn,
fetch_cache_conn_host);
xbps_dbg_printf("%s: rootdir: `%s' cachedir: `%s' conf: `%s'\n",
__func__, xhp->rootdir, xhp->cachedir, xhp->conffile);
xbps_dbg_printf("%s: fetch_cache_conn: %zu fetch_cache_host: %zu\n",
__func__, fetch_cache_conn, fetch_cache_conn_host);
xbps_dbg_printf("%s: fetch_timeout: %zu\n", __func__,
xhp->fetch_timeout);
xbps_dbg_printf("rootdir: %s\n",
prop_string_cstring_nocopy(xhp->rootdir));
xbps_dbg_printf("cachedir: %s\n",
prop_string_cstring_nocopy(xhp->cachedir));
xbps_dbg_printf("conffile: %s\n",
prop_string_cstring_nocopy(xhp->conffile));
xbps_dbg_printf("repofile: %s\n", _REPOFILE);
xbps_dbg_printf("fetch_cache_conn: %zu\n", fetch_cache_conn);
xbps_dbg_printf("fetch_cacche_conn_host: %zu\n", fetch_cache_conn_host);
xbps_dbg_printf("fetch_timeout: %zu\n", xhp->fetch_timeout);
/*
* Initialize regpkgdb dictionary.
@ -147,6 +157,12 @@ xbps_init(struct xbps_handle *xh)
return rv;
}
}
/* We don't need the confd dictionary internalized anymore */
if (prop_object_type(confd) == PROP_TYPE_DICTIONARY)
prop_object_release(confd);
/* We don't need the conffile string anymore */
if (prop_object_type(xh->conffile) == PROP_TYPE_STRING)
prop_object_release(xh->conffile);
return 0;
}
@ -157,14 +173,13 @@ xbps_end(struct xbps_handle *xh)
xbps_regpkgdb_dictionary_release();
xbps_repository_pool_release();
xbps_fetch_unset_cache_connection();
if (xh == NULL)
return;
if (prop_object_type(xh->conf_dictionary) == PROP_TYPE_DICTIONARY)
prop_object_release(xh->conf_dictionary);
if (prop_object_type(xh->pstring_cachedir) == PROP_TYPE_STRING)
prop_object_release(xh->pstring_cachedir);
if (prop_object_type(xh->rootdir) == PROP_TYPE_STRING)
prop_object_release(xh->rootdir);
if (prop_object_type(xh->cachedir) == PROP_TYPE_STRING)
prop_object_release(xh->cachedir);
if (xh->xfcd != NULL)
free(xh->xfcd);
if (xh->xucd != NULL)

View File

@ -127,9 +127,10 @@ xbps_configure_pkg(const char *pkgname,
return ENOMEM;
}
if (chdir(xhp->rootdir) == -1) {
if (chdir(prop_string_cstring_nocopy(xhp->rootdir)) == -1) {
xbps_dbg_printf("%s: [configure] chdir to '%s' returned %s\n",
pkgname, xhp->rootdir, strerror(errno));
pkgname, prop_string_cstring_nocopy(xhp->rootdir),
strerror(errno));
free(buf);
free(pkgver);
return EINVAL;

View File

@ -160,7 +160,7 @@ xbps_purge_pkg(const char *pkgname, bool check_state)
/*
* Execute the purge action in REMOVE script (if found).
*/
if (chdir(xhp->rootdir) == -1) {
if (chdir(prop_string_cstring_nocopy(xhp->rootdir)) == -1) {
rv = errno;
prop_object_release(dict);
xbps_error_printf("[purge] %s: cannot change to rootdir: %s.\n",
@ -194,7 +194,8 @@ xbps_purge_pkg(const char *pkgname, bool check_state)
/*
* Remove metadata dir and unregister package.
*/
if ((rv = remove_pkg_metadata(pkgname, xhp->rootdir)) != 0) {
if ((rv = remove_pkg_metadata(pkgname,
prop_string_cstring_nocopy(xhp->rootdir))) != 0) {
xbps_error_printf("%s: couldn't remove metadata files: %s\n",
pkgname, strerror(rv));
return rv;

View File

@ -51,7 +51,8 @@ xbps_register_pkg(prop_dictionary_t pkgrd)
bool autoinst = false;
xhp = xbps_handle_get();
plist = xbps_xasprintf("%s/%s/%s", xhp->rootdir,
plist = xbps_xasprintf("%s/%s/%s",
prop_string_cstring_nocopy(xhp->rootdir),
XBPS_META_PATH, XBPS_REGPKGDB);
if (plist == NULL)
return ENOMEM;
@ -162,7 +163,8 @@ xbps_unregister_pkg(const char *pkgname)
assert(pkgname != NULL);
xhp = xbps_handle_get();
plist = xbps_xasprintf("%s/%s/%s", xhp->rootdir,
plist = xbps_xasprintf("%s/%s/%s",
prop_string_cstring_nocopy(xhp->rootdir),
XBPS_META_PATH, XBPS_REGPKGDB);
if (plist == NULL)
return ENOMEM;

View File

@ -106,7 +106,8 @@ xbps_remove_pkg_files(prop_dictionary_t dict, const char *key)
while ((obj = prop_object_iterator_next(iter))) {
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
path = xbps_xasprintf("%s/%s",
prop_string_cstring_nocopy(xhp->rootdir), file);
if (path == NULL) {
rv = ENOMEM;
break;
@ -194,7 +195,7 @@ xbps_remove_pkg(const char *pkgname, const char *version, bool update)
if (buf == NULL)
return ENOMEM;
if (chdir(xhp->rootdir) == -1) {
if (chdir(prop_string_cstring_nocopy(xhp->rootdir)) == -1) {
free(buf);
return EINVAL;
}

View File

@ -110,7 +110,8 @@ xbps_requiredby_pkg_remove(const char *pkgname)
assert(pkgname != NULL);
xhp = xbps_handle_get();
plist = xbps_xasprintf("%s/%s/%s", xhp->rootdir,
plist = xbps_xasprintf("%s/%s/%s",
prop_string_cstring_nocopy(xhp->rootdir),
XBPS_META_PATH, XBPS_REGPKGDB);
if (plist == NULL)
return ENOMEM;

View File

@ -175,7 +175,8 @@ xbps_set_pkg_state_installed(const char *pkgname,
assert(pkgname != NULL);
xhp = xbps_handle_get();
metadir = xbps_xasprintf("%s/%s", xhp->rootdir, XBPS_META_PATH);
metadir = xbps_xasprintf("%s/%s",
prop_string_cstring_nocopy(xhp->rootdir), XBPS_META_PATH);
if (metadir == NULL)
return ENOMEM;
plist = xbps_xasprintf("%s/%s", metadir, XBPS_REGPKGDB);

View File

@ -172,7 +172,7 @@ unpack_archive(prop_dictionary_t pkg_repod,
preserve = update = false;
if (chdir(xhp->rootdir) == -1) {
if (chdir(prop_string_cstring_nocopy(xhp->rootdir)) == -1) {
xbps_error_printf("cannot chdir to rootdir for "
"`%s-%s': %s\n", pkgname, version, strerror(errno));
return errno;

View File

@ -196,7 +196,8 @@ xbps_dictionary_from_metadata_plist(const char *pkgname,
xhp = xbps_handle_get();
plistf = xbps_xasprintf("%s/%s/metadata/%s/%s",
xhp->rootdir, XBPS_META_PATH, pkgname, plist);
prop_string_cstring_nocopy(xhp->rootdir),
XBPS_META_PATH, pkgname, plist);
if (plistf == NULL)
return NULL;
@ -209,7 +210,8 @@ xbps_dictionary_from_metadata_plist(const char *pkgname,
}
free(plistf);
plistf = xbps_xasprintf("%s/%s/metadata/%s/%s",
xhp->rootdir, XBPS_META_PATH, pkgname, plist);
prop_string_cstring_nocopy(xhp->rootdir),
XBPS_META_PATH, pkgname, plist);
if (plistf == NULL)
return NULL;
}

View File

@ -127,10 +127,10 @@ find_virtualpkg_user_in_conf(const char *vpkg, bool bypattern)
char *vpkgname = NULL;
xhp = xbps_handle_get();
if (xhp->conf_dictionary == NULL)
if (xhp->virtualpkg_dictionary == NULL)
return NULL;
if ((iter = xbps_array_iter_from_dict(xhp->conf_dictionary,
if ((iter = xbps_array_iter_from_dict(xhp->virtualpkg_dictionary,
"virtual-packages")) == NULL)
return NULL;

View File

@ -66,7 +66,8 @@ xbps_regpkgdb_dictionary_init(struct xbps_handle *xhp)
if (regpkgdb_initialized)
return 0;
plist = xbps_xasprintf("%s/%s/%s", xhp->rootdir,
plist = xbps_xasprintf("%s/%s/%s",
prop_string_cstring_nocopy(xhp->rootdir),
XBPS_META_PATH, XBPS_REGPKGDB);
if (plist == NULL)
return ENOMEM;

View File

@ -73,7 +73,6 @@ int HIDDEN
xbps_repository_pool_init(void)
{
struct xbps_handle *xhp;
prop_array_t array;
prop_object_t obj;
prop_object_iterator_t iter = NULL;
struct repository_pool *rpool;
@ -84,20 +83,16 @@ xbps_repository_pool_init(void)
bool duprepo;
xhp = xbps_handle_get();
if (xhp->conf_dictionary == NULL)
if (xhp->repos_array == NULL)
return ENOTSUP;
if (repolist_initialized)
return 0;
array = prop_dictionary_get(xhp->conf_dictionary, "repositories");
if (array == NULL)
return errno;
if (prop_array_count(array) == 0)
if (prop_array_count(xhp->repos_array) == 0)
return ENOTSUP;
iter = prop_array_iterator(array);
iter = prop_array_iterator(xhp->repos_array);
if (iter == NULL) {
rv = errno;
goto out;
@ -189,6 +184,7 @@ xbps_repository_pool_init(void)
}
repolist_initialized = true;
prop_object_release(xhp->repos_array);
xbps_dbg_printf("[rpool] initialized ok.\n");
out:
if (iter)

View File

@ -122,7 +122,8 @@ xbps_repository_sync_pkg_index(const char *uri)
/*
* Create metadir if necessary.
*/
metadir = xbps_xasprintf("%s/%s", xhp->rootdir, XBPS_META_PATH);
metadir = xbps_xasprintf("%s/%s",
prop_string_cstring_nocopy(xhp->rootdir), XBPS_META_PATH);
if (metadir == NULL) {
rv = -1;
goto out;
@ -154,7 +155,7 @@ xbps_repository_sync_pkg_index(const char *uri)
* file.
*/
lrepodir = xbps_xasprintf("%s/%s/%s",
xhp->rootdir, XBPS_META_PATH, uri_fixedp);
prop_string_cstring_nocopy(xhp->rootdir), XBPS_META_PATH, uri_fixedp);
if (lrepodir == NULL) {
rv = -1;
goto out;

View File

@ -137,9 +137,12 @@ download_binpkgs(struct xbps_handle *xhp, prop_object_iterator_t iter)
/*
* Create cachedir.
*/
if (xbps_mkpath(xhp->cachedir, 0755) == -1) {
if (xbps_mkpath(prop_string_cstring_nocopy(xhp->cachedir),
0755) == -1) {
xbps_error_printf("xbps-bin: cannot mkdir cachedir "
"`%s': %s.\n", xhp->cachedir, strerror(errno));
"`%s': %s.\n",
prop_string_cstring_nocopy(xhp->cachedir),
strerror(errno));
free(binfile);
rv = errno;
break;
@ -149,7 +152,8 @@ download_binpkgs(struct xbps_handle *xhp, prop_object_iterator_t iter)
/*
* Fetch binary package.
*/
rv = xbps_fetch_file(binfile, xhp->cachedir, false, NULL);
rv = xbps_fetch_file(binfile,
prop_string_cstring_nocopy(xhp->cachedir), false, NULL);
if (rv == -1) {
RUN_TRANS_ERR_CB(XBPS_TRANS_STATE_DOWNLOAD, pkgver, errno);
free(binfile);

View File

@ -214,7 +214,8 @@ get_pkg_index_remote_plist(const char *uri)
return NULL;
repodir = xbps_xasprintf("%s/%s/%s/%s",
xhp->rootdir, XBPS_META_PATH, uri_fixed, XBPS_PKGINDEX);
prop_string_cstring_nocopy(xhp->rootdir),
XBPS_META_PATH, uri_fixed, XBPS_PKGINDEX);
if (repodir == NULL) {
free(uri_fixed);
return NULL;
@ -261,7 +262,8 @@ xbps_path_from_repository_uri(prop_dictionary_t pkg_repod, const char *repoloc)
/*
* First check if binpkg is available in cachedir.
*/
lbinpkg = xbps_xasprintf("%s/%s", xhp->cachedir, filen);
lbinpkg = xbps_xasprintf("%s/%s",
prop_string_cstring_nocopy(xhp->cachedir), filen);
if (lbinpkg == NULL)
return NULL;