New configuration schemas changes, round 3.
struct xbps_handle::conffile has been renamed to confdir, and it now expects the path to a directory, where the configuration files are stored. Change xbps-bin(8) and xbps-repo(8) along with its manpages to mention that -C expects a directory.
This commit is contained in:
		@@ -37,25 +37,36 @@
 | 
			
		||||
 * @brief Initialization of virtual package settings.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define _VPKGDIR	XBPS_SYSCONF_PATH "/" XBPS_VIRTUALPKGD_PATH
 | 
			
		||||
 | 
			
		||||
void HIDDEN
 | 
			
		||||
xbps_init_virtual_pkgs(struct xbps_handle *xh)
 | 
			
		||||
{
 | 
			
		||||
	struct dirent *dp;
 | 
			
		||||
	DIR *dirp;
 | 
			
		||||
	prop_dictionary_t vpkgd;
 | 
			
		||||
	prop_string_t vpkgdir;
 | 
			
		||||
	char *vpkgfile;
 | 
			
		||||
 | 
			
		||||
	if (prop_object_type(xh->confdir) != PROP_TYPE_STRING) {
 | 
			
		||||
		vpkgdir = prop_string_create_cstring(XBPS_SYSCONF_PATH);
 | 
			
		||||
		prop_string_append_cstring(vpkgdir, "/");
 | 
			
		||||
		prop_string_append_cstring(vpkgdir, XBPS_VIRTUALPKGD_PATH);
 | 
			
		||||
	} else {
 | 
			
		||||
		vpkgdir = prop_string_copy(xh->confdir);
 | 
			
		||||
		prop_string_append_cstring(vpkgdir, "/");
 | 
			
		||||
		prop_string_append_cstring(vpkgdir, XBPS_VIRTUALPKGD_PATH);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * Internalize all plist files from _VPKGDIR and add them
 | 
			
		||||
	 * Internalize all plist files from vpkgdir and add them
 | 
			
		||||
	 * into xhp->virtualpkgs_array.
 | 
			
		||||
	 */
 | 
			
		||||
	dirp = opendir(_VPKGDIR);
 | 
			
		||||
	dirp = opendir(prop_string_cstring_nocopy(vpkgdir));
 | 
			
		||||
	if (dirp == NULL) {
 | 
			
		||||
		xbps_dbg_printf("%s: cannot access to %s for virtual "
 | 
			
		||||
		    "packages: %s\n", __func__, _VPKGDIR,
 | 
			
		||||
		    "packages: %s\n", __func__,
 | 
			
		||||
		    prop_string_cstring_nocopy(vpkgdir),
 | 
			
		||||
		    strerror(errno));
 | 
			
		||||
		prop_object_release(vpkgdir);
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	while ((dp = readdir(dirp)) != NULL) {
 | 
			
		||||
@@ -66,7 +77,8 @@ xbps_init_virtual_pkgs(struct xbps_handle *xh)
 | 
			
		||||
		if (strstr(dp->d_name, ".plist") == NULL)
 | 
			
		||||
			continue;
 | 
			
		||||
 | 
			
		||||
		vpkgfile = xbps_xasprintf("%s/%s", _VPKGDIR, dp->d_name);
 | 
			
		||||
		vpkgfile = xbps_xasprintf("%s/%s",
 | 
			
		||||
		    prop_string_cstring_nocopy(vpkgdir), dp->d_name);
 | 
			
		||||
		if (vpkgfile == NULL) {
 | 
			
		||||
			(void)closedir(dirp);
 | 
			
		||||
			xbps_dbg_printf("%s: failed to alloc mem for %s\n",
 | 
			
		||||
@@ -96,4 +108,5 @@ xbps_init_virtual_pkgs(struct xbps_handle *xh)
 | 
			
		||||
		    __func__, dp->d_name);
 | 
			
		||||
	}
 | 
			
		||||
	(void)closedir(dirp);
 | 
			
		||||
	prop_object_release(vpkgdir);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -49,6 +49,7 @@ int
 | 
			
		||||
xbps_init(struct xbps_handle *xh)
 | 
			
		||||
{
 | 
			
		||||
	prop_dictionary_t confd;
 | 
			
		||||
	prop_string_t conffile = NULL, repofile = NULL;
 | 
			
		||||
	const char *conf_rootdir = NULL, *conf_cachedir = NULL;
 | 
			
		||||
	uint16_t fetch_cache_conn = 0, fetch_cache_conn_host = 0;
 | 
			
		||||
	int rv;
 | 
			
		||||
@@ -58,18 +59,29 @@ xbps_init(struct xbps_handle *xh)
 | 
			
		||||
	xhp = xh;
 | 
			
		||||
	debug = xhp->debug;
 | 
			
		||||
 | 
			
		||||
	/* 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);
 | 
			
		||||
	/* If confdir not set, defaults to XBPS_SYSCONF_PATH */
 | 
			
		||||
	if (prop_object_type(xhp->confdir) != PROP_TYPE_STRING) {
 | 
			
		||||
		conffile = prop_string_create_cstring(_CONFFILE);
 | 
			
		||||
		repofile = prop_string_create_cstring(_REPOFILE);
 | 
			
		||||
	} else {
 | 
			
		||||
		conffile = prop_string_copy(xhp->confdir);
 | 
			
		||||
		prop_string_append_cstring(conffile, "/");
 | 
			
		||||
		prop_string_append_cstring(conffile, XBPS_CONF_PLIST);
 | 
			
		||||
 | 
			
		||||
		repofile = prop_string_copy(xhp->confdir);
 | 
			
		||||
		prop_string_append_cstring(repofile, "/");
 | 
			
		||||
		prop_string_append_cstring(repofile, XBPS_CONF_REPOS_PLIST);
 | 
			
		||||
	}
 | 
			
		||||
	/*
 | 
			
		||||
	 * Internalize the XBPS_CONF_REPOS_PLIST array.
 | 
			
		||||
	 */
 | 
			
		||||
	xhp->repos_array = prop_array_internalize_from_file(_REPOFILE);
 | 
			
		||||
	xhp->repos_array =
 | 
			
		||||
	    prop_array_internalize_from_file(prop_string_cstring_nocopy(repofile));
 | 
			
		||||
	/*
 | 
			
		||||
	 * Internalize the XBPS_CONF_PLIST dictionary.
 | 
			
		||||
	 */
 | 
			
		||||
	confd = prop_dictionary_internalize_from_file(
 | 
			
		||||
	    prop_string_cstring_nocopy(xhp->conffile));
 | 
			
		||||
	    prop_string_cstring_nocopy(conffile));
 | 
			
		||||
	if (confd == NULL) {
 | 
			
		||||
		if (errno != ENOENT) {
 | 
			
		||||
			xbps_dbg_printf("%s: cannot internalize conf "
 | 
			
		||||
@@ -140,11 +152,15 @@ xbps_init(struct xbps_handle *xh)
 | 
			
		||||
	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);
 | 
			
		||||
	    prop_string_cstring_nocopy(conffile));
 | 
			
		||||
	xbps_dbg_printf("repofile: %s\n",
 | 
			
		||||
	    prop_string_cstring_nocopy(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.
 | 
			
		||||
@@ -157,12 +173,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);
 | 
			
		||||
	if (prop_object_type(conffile) == PROP_TYPE_STRING)
 | 
			
		||||
		prop_object_release(conffile);
 | 
			
		||||
	if (prop_object_type(repofile) == PROP_TYPE_STRING)
 | 
			
		||||
		prop_object_release(repofile);
 | 
			
		||||
 | 
			
		||||
	/* Initialize virtual package settings */
 | 
			
		||||
	xbps_init_virtual_pkgs(xhp);
 | 
			
		||||
@@ -179,6 +195,8 @@ xbps_end(struct xbps_handle *xh)
 | 
			
		||||
 | 
			
		||||
	if (xh == NULL)
 | 
			
		||||
		return;
 | 
			
		||||
	if (prop_object_type(xh->confdir) == PROP_TYPE_STRING)
 | 
			
		||||
		prop_object_release(xh->confdir);
 | 
			
		||||
	if (prop_object_type(xh->rootdir) == PROP_TYPE_STRING)
 | 
			
		||||
		prop_object_release(xh->rootdir);
 | 
			
		||||
	if (prop_object_type(xh->cachedir) == PROP_TYPE_STRING)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user