New configuration file via confuse: xbps.conf.
This commit is contained in:
		
							
								
								
									
										8
									
								
								NEWS
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								NEWS
									
									
									
									
									
								
							| @@ -1,9 +1,13 @@ | ||||
| xbps-0.11.0 (???): | ||||
|  | ||||
|  * New shared configuration file via libconfuse that replaces the | ||||
|    plist configuration files: xbps.conf. That means that libxbps | ||||
|    now requires confuse >= 2.7 available at | ||||
|    http://www.nongnu.org/confuse/. | ||||
|  | ||||
|  * Support for syslog logging common operations, such as install, update, | ||||
|    remove and purge via LOG_NOTICE, and errors with LOG_ERR. | ||||
|    By default we enable this in configuration file `conf.plist', set the | ||||
|    boolean `syslog-enabled' key to false to disable. | ||||
|    By default it's always enabled, can be disabled thru the conf file. | ||||
|  | ||||
|  * xbps-repo(8): new target: pkg-list [index]. This target will list all | ||||
|    packages from repository with index [index]. If optional argument | ||||
|   | ||||
							
								
								
									
										1
									
								
								README
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								README
									
									
									
									
									
								
							| @@ -6,6 +6,7 @@ To build this you'll need: | ||||
|   - zlib (development package with static libs) | ||||
|   - openssl (development package with static libs) | ||||
|   - libarchive >= 2.8.0 (development package with static libs) | ||||
|   - confuse >= 2.7 (development package with static libs) | ||||
|  | ||||
| Optionally to build the API documentation: | ||||
|  | ||||
|   | ||||
| @@ -73,8 +73,7 @@ check_pkg_autoinstall(prop_dictionary_t pkgd_regpkgdb, | ||||
| 		reqby = prop_dictionary_get(pkgd_regpkgdb, "requiredby"); | ||||
| 		if (((prop_object_type(reqby) == PROP_TYPE_ARRAY)) && | ||||
| 		    ((prop_array_count(reqby) > 0) && !autoinst)) { | ||||
| 		        path = xbps_xasprintf("%s/%s/%s", | ||||
| 			    prop_string_cstring_nocopy(xhp->rootdir), | ||||
| 		        path = xbps_xasprintf("%s/%s/%s", xhp->rootdir, | ||||
| 			    XBPS_META_PATH, XBPS_REGPKGDB); | ||||
| 			assert(path != NULL); | ||||
|  | ||||
|   | ||||
| @@ -72,8 +72,7 @@ check_pkg_files(prop_dictionary_t pkgd_regpkgdb, | ||||
|  | ||||
| 		while ((obj = prop_object_iterator_next(iter))) { | ||||
| 			prop_dictionary_get_cstring_nocopy(obj, "file", &file); | ||||
| 			path = xbps_xasprintf("%s/%s", | ||||
| 			    prop_string_cstring_nocopy(xhp->rootdir), file); | ||||
| 			path = xbps_xasprintf("%s/%s", xhp->rootdir, file); | ||||
| 			if (path == NULL) { | ||||
| 				prop_object_iterator_release(iter); | ||||
| 				return -1; | ||||
| @@ -122,8 +121,7 @@ check_pkg_files(prop_dictionary_t pkgd_regpkgdb, | ||||
|  | ||||
| 		while ((obj = prop_object_iterator_next(iter))) { | ||||
| 			prop_dictionary_get_cstring_nocopy(obj, "file", &file); | ||||
| 			path = xbps_xasprintf("%s/%s", | ||||
| 			    prop_string_cstring_nocopy(xhp->rootdir), file); | ||||
| 			path = xbps_xasprintf("%s/%s", xhp->rootdir, file); | ||||
| 			if (path == NULL) { | ||||
| 				prop_object_iterator_release(iter); | ||||
| 				return -1; | ||||
|   | ||||
| @@ -56,8 +56,7 @@ write_pkgd_to_regpkgdb(prop_dictionary_t pkgd, | ||||
| 		    "packages array: %s", pkgn, strerror(errno)); | ||||
| 		return -1; | ||||
| 	} | ||||
| 	path = xbps_xasprintf("%s/%s/%s", | ||||
| 	    prop_string_cstring_nocopy(xhp->rootdir), | ||||
| 	path = xbps_xasprintf("%s/%s/%s", xhp->rootdir, | ||||
| 	    XBPS_META_PATH, XBPS_REGPKGDB); | ||||
| 	if (path == NULL) | ||||
| 		return -1; | ||||
|   | ||||
| @@ -76,8 +76,7 @@ check_pkg_symlinks(prop_dictionary_t pkgd_regpkgdb, | ||||
| 				    "empty target object!\n", pkgname, file); | ||||
| 				continue; | ||||
| 			} | ||||
| 			path = xbps_xasprintf("%s/%s", | ||||
| 			    prop_string_cstring_nocopy(xhp->rootdir), file); | ||||
| 			path = xbps_xasprintf("%s/%s", xhp->rootdir, file); | ||||
| 			if (path == NULL) | ||||
| 				return -1; | ||||
|  | ||||
| @@ -90,9 +89,9 @@ check_pkg_symlinks(prop_dictionary_t pkgd_regpkgdb, | ||||
| 			} | ||||
|  | ||||
| 			free(path); | ||||
| 			if (!prop_string_equals_cstring(xhp->rootdir, "/") && | ||||
| 			    strstr(buf, prop_string_cstring_nocopy(xhp->rootdir))) | ||||
| 				path = buf + prop_string_size(xhp->rootdir); | ||||
| 			if (strcmp(xhp->rootdir, "/") && | ||||
| 			    strstr(buf, xhp->rootdir)) | ||||
| 				path = buf + strlen(xhp->rootdir); | ||||
| 			else | ||||
| 				path = buf; | ||||
|  | ||||
|   | ||||
| @@ -81,8 +81,7 @@ find_files_in_packages(const char *pattern) | ||||
| 	unsigned int i, count; | ||||
|  | ||||
| 	xhp = xbps_handle_get(); | ||||
| 	path = xbps_xasprintf("%s/%s/metadata", | ||||
| 	    prop_string_cstring_nocopy(xhp->rootdir), XBPS_META_PATH); | ||||
| 	path = xbps_xasprintf("%s/%s/metadata", xhp->rootdir, XBPS_META_PATH); | ||||
| 	if (path == NULL) | ||||
| 		return -1; | ||||
|  | ||||
|   | ||||
| @@ -66,12 +66,12 @@ main(int argc, char **argv) | ||||
| 	struct xferstat xfer; | ||||
| 	struct list_pkgver_cb lpc; | ||||
| 	struct sigaction sa; | ||||
| 	const char *rootdir, *cachedir, *confdir, *option; | ||||
| 	const char *rootdir, *cachedir, *conffile, *option; | ||||
| 	int i, c, flags, rv; | ||||
| 	bool yes, purge, debug, reqby_force, force_rm_with_deps, recursive_rm; | ||||
| 	bool install_auto, install_manual, show_download_pkglist_url; | ||||
|  | ||||
| 	rootdir = cachedir = confdir = option = NULL; | ||||
| 	rootdir = cachedir = conffile = option = NULL; | ||||
| 	flags = rv = 0; | ||||
| 	reqby_force = yes = purge = force_rm_with_deps = false; | ||||
| 	recursive_rm = debug = false; | ||||
| @@ -83,7 +83,7 @@ main(int argc, char **argv) | ||||
| 			install_auto = true; | ||||
| 			break; | ||||
| 		case 'C': | ||||
| 			confdir = optarg; | ||||
| 			conffile = optarg; | ||||
| 			break; | ||||
| 		case 'c': | ||||
| 			cachedir = optarg; | ||||
| @@ -155,7 +155,7 @@ main(int argc, char **argv) | ||||
| 	sigaction(SIGQUIT, &sa, NULL); | ||||
|  | ||||
| 	/* | ||||
| 	 * Initialize stuff for libxbps. | ||||
| 	 * Initialize libxbps. | ||||
| 	 */ | ||||
| 	xhp = xbps_handle_alloc(); | ||||
| 	if (xhp == NULL) { | ||||
| @@ -166,25 +166,20 @@ main(int argc, char **argv) | ||||
| 	xhp->state_cb = state_cb; | ||||
| 	xhp->fetch_cb = fetch_file_progress_cb; | ||||
| 	xhp->fetch_cb_data = &xfer; | ||||
| 	xhp->rootdir = rootdir; | ||||
| 	xhp->cachedir = cachedir; | ||||
| 	xhp->conffile = conffile; | ||||
| 	xhp->flags = flags; | ||||
| 	xhp->install_reason_manual = install_manual; | ||||
| 	xhp->install_reason_auto = install_auto; | ||||
| 	if (flags & XBPS_FLAG_VERBOSE) | ||||
| 		xhp->unpack_cb = unpack_progress_cb_verbose; | ||||
| 	else | ||||
| 		xhp->unpack_cb = unpack_progress_cb; | ||||
|  | ||||
| 	if (rootdir) | ||||
| 		xhp->rootdir = prop_string_create_cstring(rootdir); | ||||
| 	if (cachedir) | ||||
| 		xhp->cachedir = prop_string_create_cstring(cachedir); | ||||
| 	if (confdir) | ||||
| 		xhp->confdir = prop_string_create_cstring(confdir); | ||||
|  | ||||
| 	xhp->flags = flags; | ||||
| 	xhp->install_reason_manual = install_manual; | ||||
| 	xhp->install_reason_auto = install_auto; | ||||
|  | ||||
| 	if ((rv = xbps_init(xhp)) != 0) { | ||||
| 		xbps_error_printf("xbps-bin: couldn't initialize library: %s\n", | ||||
| 		    strerror(errno)); | ||||
| 		    strerror(rv)); | ||||
| 		exit(EXIT_FAILURE); | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -107,7 +107,7 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbdata) | ||||
| 		if (xhp->syslog_enabled) | ||||
| 			syslog(LOG_NOTICE, "Installed `%s-%s' successfully " | ||||
| 			    "(rootdir: %s).", xscd->pkgname, xscd->version, | ||||
| 			    prop_string_cstring_nocopy(xhp->rootdir)); | ||||
| 			    xhp->rootdir); | ||||
| 		break; | ||||
| 	case XBPS_STATE_UPDATE_DONE: | ||||
| 		printf("Updated `%s' to `%s' successfully.\n", | ||||
| @@ -115,7 +115,7 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbdata) | ||||
| 		if (xhp->syslog_enabled) | ||||
| 			syslog(LOG_NOTICE, "Updated `%s' to `%s' successfully " | ||||
| 			    "(rootdir: %s).", xscd->pkgname, xscd->version, | ||||
| 			    prop_string_cstring_nocopy(xhp->rootdir)); | ||||
| 			    xhp->rootdir); | ||||
| 		break; | ||||
| 	case XBPS_STATE_REMOVE_DONE: | ||||
| 		printf("Removed `%s-%s' successfully.\n", | ||||
| @@ -123,7 +123,7 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbdata) | ||||
| 		if (xhp->syslog_enabled) | ||||
| 			syslog(LOG_NOTICE, "Removed `%s-%s' successfully " | ||||
| 			    "(rootdir: %s).", xscd->pkgname, xscd->version, | ||||
| 			    prop_string_cstring_nocopy(xhp->rootdir)); | ||||
| 			    xhp->rootdir); | ||||
| 		break; | ||||
| 	case XBPS_STATE_PURGE_DONE: | ||||
| 		printf("Purged `%s-%s' successfully.\n", | ||||
| @@ -131,7 +131,7 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbdata) | ||||
| 		if (xhp->syslog_enabled) | ||||
| 			syslog(LOG_NOTICE, "Purged `%s-%s' successfully " | ||||
| 			    "(rootdir: %s).", xscd->pkgname, xscd->version, | ||||
| 			    prop_string_cstring_nocopy(xhp->rootdir)); | ||||
| 			    xhp->rootdir); | ||||
| 		break; | ||||
| 	/* errors */ | ||||
| 	case XBPS_STATE_UNPACK_FAIL: | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| .TH "XBPS\-BIN" "8" "03/12/2011" "\ \&" "\ \&" | ||||
| .TH "XBPS\-BIN" "8" "15/12/2011" "\ \&" "\ \&" | ||||
| .\" ----------------------------------------------------------------- | ||||
| .\" * set default formatting | ||||
| .\" ----------------------------------------------------------------- | ||||
| @@ -28,10 +28,10 @@ Use of this option takes effect in the \fIautoupdate\fR, \fIinstall\fR and | ||||
| matched. | ||||
| .RE | ||||
| .PP | ||||
| \fB\-C\fR \fIconfdir\fR | ||||
| \fB\-C\fR \fIconffile\fR | ||||
| .RS 4 | ||||
| Full path to the XBPS configuration directory where the configuration files are available\&. | ||||
| By default it\(cqs set to \fIETCDIR/xbps\fR\&. | ||||
| Full path to the XBPS configuration file\&. | ||||
| By default it\(cqs set to \fIETCDIR/xbps/xbps.conf\fR\&. | ||||
| .RE | ||||
| .PP | ||||
| \fB\-c\fR \fIcachedir\fR | ||||
|   | ||||
| @@ -446,7 +446,7 @@ main(int argc, char **argv) | ||||
| 	FILE *f = NULL; | ||||
| 	char *outfile = NULL; | ||||
| 	const char *conf_file = NULL, *rootdir = NULL; | ||||
| 	int c; | ||||
| 	int c, rv; | ||||
| 	bool revdeps = false; | ||||
|  | ||||
| 	while ((c = getopt(argc, argv, "c:gRr:o:")) != -1) { | ||||
| @@ -487,10 +487,9 @@ main(int argc, char **argv) | ||||
| 	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"); | ||||
| 	xhp->rootdir = rootdir; | ||||
| 	if ((rv = xbps_init(xhp)) != 0) | ||||
| 		die("failed to initialize libxbps: %s", strerror(rv)); | ||||
|  | ||||
| 	/* | ||||
| 	 * Output file will be <pkgname>.dot if not specified. | ||||
|   | ||||
| @@ -56,16 +56,16 @@ main(int argc, char **argv) | ||||
| 	struct xbps_handle *xhp; | ||||
| 	struct xferstat xfer; | ||||
| 	prop_dictionary_t pkgd; | ||||
| 	const char *rootdir, *cachedir, *confdir, *option; | ||||
| 	const char *rootdir, *cachedir, *conffile, *option; | ||||
| 	int c, rv = 0; | ||||
| 	bool debug = false; | ||||
|  | ||||
| 	rootdir = cachedir = confdir = option = NULL; | ||||
| 	rootdir = cachedir = conffile = option = NULL; | ||||
|  | ||||
| 	while ((c = getopt(argc, argv, "C:c:do:r:V")) != -1) { | ||||
| 		switch (c) { | ||||
| 		case 'C': | ||||
| 			confdir = optarg; | ||||
| 			conffile = optarg; | ||||
| 			break; | ||||
| 		case 'c': | ||||
| 			cachedir = optarg; | ||||
| @@ -107,16 +107,13 @@ main(int argc, char **argv) | ||||
| 	xhp->state_cb = state_cb; | ||||
| 	xhp->fetch_cb = fetch_file_progress_cb; | ||||
| 	xhp->fetch_cb_data = &xfer; | ||||
| 	if (rootdir) | ||||
| 		xhp->rootdir = prop_string_create_cstring(rootdir); | ||||
| 	if (cachedir) | ||||
| 		xhp->cachedir = prop_string_create_cstring(cachedir); | ||||
| 	if (confdir) | ||||
| 		xhp->confdir = prop_string_create_cstring(confdir); | ||||
| 	xhp->rootdir = rootdir; | ||||
| 	xhp->cachedir = cachedir; | ||||
| 	xhp->conffile = conffile; | ||||
|  | ||||
| 	if ((rv = xbps_init(xhp)) != 0) { | ||||
| 		xbps_error_printf("xbps-repo: couldn't initialize library: %s\n", | ||||
| 		    strerror(errno)); | ||||
| 		    strerror(rv)); | ||||
| 		exit(EXIT_FAILURE); | ||||
| 	} | ||||
|  | ||||
| @@ -238,7 +235,7 @@ main(int argc, char **argv) | ||||
| 		if (argc != 1) | ||||
| 			usage(xhp); | ||||
|  | ||||
| 		rv = xbps_repository_pool_sync(); | ||||
| 		rv = xbps_repository_pool_sync(xhp); | ||||
| 		if (rv == ENOTSUP) { | ||||
| 			xbps_error_printf("xbps-repo: no repositories " | ||||
| 			    "currently registered!\n"); | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| .TH "XBPS\-REPO" "8" "03/12/2011" "\ \&" "\ \&" | ||||
| .TH "XBPS\-REPO" "8" "15/12/2011" "\ \&" "\ \&" | ||||
| .\" ----------------------------------------------------------------- | ||||
| .\" * set default formatting | ||||
| .\" ----------------------------------------------------------------- | ||||
| @@ -19,10 +19,10 @@ xbps-repo \- XBPS command for binary package repositories | ||||
| The xbps\-repo(8) command is used to handle local or remote binary package repositories in the \fBXBPS binary package system\fR\&. You can use it to create a package index for a local repository, list repositories, search for packages and show information about a binary package in repository pool\&. | ||||
| .SH "OPTIONS" | ||||
| .PP | ||||
| \fB\-C\fR \fIconfdir\fR | ||||
| \fB\-C\fR \fIconffile\fR | ||||
| .RS 4 | ||||
| Full path to the XBPS configuration directory where the configuration files are available\&.  | ||||
| By default it\(cqs set to \fIETCDIR/xbps\fR\&. | ||||
| Full path to the XBPS configuration file\&. | ||||
| By default it\(cqs set to \fIETCDIR/xbps/xbps.conf\fR\&. | ||||
| .RE | ||||
| .PP | ||||
| \fB\-c\fR \fIcachedir\fR | ||||
|   | ||||
| @@ -150,7 +150,7 @@ main(int argc, char **argv) | ||||
| 	    (strcasecmp(argv[0], "version") == 0) || | ||||
| 	    (strcasecmp(argv[0], "fetch") == 0)) { | ||||
| 		/* | ||||
| 		* Initialize the callbacks and debug in libxbps. | ||||
| 		* Initialize libxbps. | ||||
| 		*/ | ||||
| 		xhp = xbps_handle_alloc(); | ||||
| 		if (xhp == NULL) { | ||||
| @@ -160,14 +160,12 @@ main(int argc, char **argv) | ||||
| 		xhp->debug = debug; | ||||
| 		xhp->fetch_cb = fetch_file_progress_cb; | ||||
| 		xhp->fetch_cb_data = &xfer; | ||||
| 		if (rootdir) | ||||
| 			xhp->rootdir = prop_string_create_cstring(rootdir); | ||||
| 		if (confdir) | ||||
| 			xhp->confdir = prop_string_create_cstring(confdir); | ||||
| 		xhp->rootdir = rootdir; | ||||
| 		xhp->conffile = confdir; | ||||
|  | ||||
| 		if ((rv = xbps_init(xhp)) != 0) { | ||||
| 			xbps_error_printf("xbps-uhelper: failed to " | ||||
| 			    "initialize libxbps.\n"); | ||||
| 			    "initialize libxbps: %s.\n", strerror(rv)); | ||||
| 			exit(EXIT_FAILURE); | ||||
| 		} | ||||
|  | ||||
|   | ||||
							
								
								
									
										15
									
								
								configure
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								configure
									
									
									
									
										vendored
									
									
								
							| @@ -530,6 +530,21 @@ else | ||||
| 		>>$CONFIG_MK | ||||
| fi | ||||
|  | ||||
| # | ||||
| # confuse >= 2.7 with pkg-config support is required. | ||||
| # | ||||
| printf "Checking for confuse via pkg-config ..." | ||||
| if ! $PKGCONFIG_BIN --exists libconfuse; then | ||||
| 	echo "libconfuse.pc not found, exiting." | ||||
| 	exit 1 | ||||
| else | ||||
| 	echo "found version $($PKGCONFIG_BIN --modversion libconfuse)." | ||||
| 	echo "CFLAGS += $($PKGCONFIG_BIN --cflags libconfuse)" >>$CONFIG_MK | ||||
| 	echo "LDFLAGS += $($PKGCONFIG_BIN --libs libconfuse)" >>$CONFIG_MK | ||||
| 	echo "STATIC_LIBS += $($PKGCONFIG_BIN --libs --static libconfuse)" \ | ||||
| 		>>$CONFIG_MK | ||||
| fi | ||||
|  | ||||
| # | ||||
| # OpenSSL libssl with pkg-config support is required. | ||||
| # | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| -include ../config.mk | ||||
|  | ||||
| CONF_FILES =	conf.plist repositories.plist | ||||
| CONF_FILES =	xbps.conf | ||||
|  | ||||
| .PHONY: all | ||||
| all: | ||||
|   | ||||
| @@ -1,31 +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> | ||||
|  | ||||
| 	<!-- Enable syslog messages, set the value to false to disable. --> | ||||
| 	<key>syslog-enabled</key> | ||||
| 	<true/> | ||||
| </dict> | ||||
| </plist> | ||||
| @@ -1,25 +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"> | ||||
| <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 such as: | ||||
| 		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 repositories by specifying the path (without the trailing | ||||
| 	'/' character) to the directory where the index.plist file is stored. | ||||
| 	--> | ||||
| 	<string>http://xbps.nopcode.org/repos/current/x86_64</string> | ||||
| 	<string>http://xbps.nopcode.org/repos/current/noarch</string> | ||||
| </array> | ||||
| </plist> | ||||
							
								
								
									
										62
									
								
								etc/xbps.conf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								etc/xbps.conf
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,62 @@ | ||||
| # Configuration file for XBPS. | ||||
| # ============================ | ||||
| # | ||||
| # Root directory. | ||||
| #rootdir = / | ||||
| # | ||||
| # 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. | ||||
| #cachedir = var/cache/xbps | ||||
| # | ||||
| # Default global limit of cached connections when fetching files. | ||||
| #fetch-cache-connections = 10 | ||||
| # | ||||
| # Default per-host limit of cached connections when fetching files. | ||||
| #fetch-cache-connections-per-host = 3 | ||||
| # | ||||
| # Default timeout limit for connections, in seconds. | ||||
| #fetch-timeout-connection = 30 | ||||
| # | ||||
| # Enable syslog messages, set the value to false or 0 to disable. | ||||
| #syslog = true | ||||
|  | ||||
| # Repositories. | ||||
| # | ||||
| # 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 such as: | ||||
| # 	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 repositories by specifying the path (without the trailing | ||||
| # '/' character) to the directory where the index.plist file is stored. | ||||
| # | ||||
| # Repositories not matching the host architecture are simply ignored. | ||||
| # | ||||
| repositories = { | ||||
| 	http://xbps.goodluckwith.us/binpkgs/i686, | ||||
| 	http://xbps.goodluckwith.us/binpkgs/noarch, | ||||
| 	http://xbps.goodluckwith.us/binpkgs/nonfree/i686, | ||||
| 	/mnt/xbps_builder/host/binpkgs/x86_64, | ||||
| 	/mnt/xbps_builder/host/binpkgs/noarch, | ||||
| 	/mnt/xbps_builder/host/binpkgs/nonfree/x86_64 | ||||
| } | ||||
|  | ||||
| # Virtual packages. | ||||
| # | ||||
| # The following syntax is used: | ||||
| # 	virtual-package <realpkgname> { targets = <virtualpkgname-version> } | ||||
| # | ||||
| # If a package supports multiple virtual packages these can be | ||||
| # specified in the 'targets' option such as: | ||||
| # | ||||
| # 	virtual-package foo { targets = blah-0, baz-1, ... } | ||||
| # | ||||
| @@ -33,6 +33,7 @@ | ||||
| #include <archive.h> | ||||
| #include <archive_entry.h> | ||||
| #include <prop/proplib.h> | ||||
| #include <confuse.h> | ||||
|  | ||||
| #ifdef  __cplusplus | ||||
| # define __BEGIN_DECLS  extern "C" { | ||||
| @@ -55,7 +56,7 @@ | ||||
|  */ | ||||
| #define XBPS_PKGINDEX_VERSION	"1.3" | ||||
|  | ||||
| #define XBPS_API_VERSION	"20111206" | ||||
| #define XBPS_API_VERSION	"20111215" | ||||
| #define XBPS_VERSION		"0.11.0" | ||||
|  | ||||
| /** | ||||
| @@ -70,13 +71,13 @@ | ||||
|  * @def XBPS_META_PATH | ||||
|  * Default root PATH to store metadata info. | ||||
|  */ | ||||
| #define XBPS_META_PATH		"/var/db/xbps" | ||||
| #define XBPS_META_PATH		"var/db/xbps" | ||||
|  | ||||
| /**  | ||||
|  * @def XBPS_CACHE_PATH | ||||
|  * Default cache PATH to store downloaded binpkgs. | ||||
|  */ | ||||
| #define XBPS_CACHE_PATH		"/var/cache/xbps" | ||||
| #define XBPS_CACHE_PATH		"var/cache/xbps" | ||||
|  | ||||
| /**  | ||||
|  * @def XBPS_REGPKGDB | ||||
| @@ -106,29 +107,16 @@ | ||||
|  * @def XBPS_SYSCONF_PATH | ||||
|  * Default configuration PATH to find XBPS_CONF_PLIST. | ||||
|  */ | ||||
| #define XBPS_SYSDIR		"/xbps" | ||||
| #define XBPS_SYSDIR            "/xbps" | ||||
| #ifndef XBPS_SYSCONF_PATH | ||||
| #define XBPS_SYSCONF_PATH	"/etc" XBPS_SYSDIR | ||||
| #define XBPS_SYSCONF_PATH      "/etc" XBPS_SYSDIR | ||||
| #endif | ||||
|  | ||||
| /** | ||||
|  * @def XBPS_CONF_PLIST | ||||
|  * Filename for the XBPS plist configuration file. | ||||
|  */ | ||||
| #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" | ||||
| #define XBPS_CONF_DEF		XBPS_SYSCONF_PATH "/xbps.conf" | ||||
|  | ||||
| /** | ||||
|  * @def XBPS_FLAG_VERBOSE | ||||
| @@ -153,6 +141,24 @@ | ||||
|  */ | ||||
| #define XBPS_FLAG_FORCE_REMOVE_FILES	0x00000004 | ||||
|  | ||||
| /** | ||||
|  * @def XBPS_FETCH_CACHECONN | ||||
|  * Default (global) limit of cached connections used in libfetch. | ||||
|  */ | ||||
| #define XBPS_FETCH_CACHECONN            6 | ||||
|  | ||||
| /** | ||||
|  * @def XBPS_FETCH_CACHECONN_HOST | ||||
|  * Default (per host) limit of cached connections used in libfetch. | ||||
|  */ | ||||
| #define XBPS_FETCH_CACHECONN_HOST       2 | ||||
|  | ||||
| /** | ||||
|  * @def XBPS_FETCH_TIMEOUT | ||||
|  * Default timeout limit (in seconds) to wait for stalled connections. | ||||
|  */ | ||||
| #define XBPS_FETCH_TIMEOUT		30 | ||||
|  | ||||
| __BEGIN_DECLS | ||||
|  | ||||
| void		xbps_dbg_printf(const char *, ...); | ||||
| @@ -411,14 +417,7 @@ struct xbps_handle { | ||||
| 	/** | ||||
| 	 * @private | ||||
| 	 */ | ||||
| 	prop_array_t virtualpkgs_array; | ||||
| 	/** | ||||
| 	 * @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; | ||||
| 	cfg_t *cfg; | ||||
| 	/** | ||||
| 	 * @var regpkgdb_dictionary. | ||||
| 	 * | ||||
| @@ -474,20 +473,20 @@ struct xbps_handle { | ||||
| 	 * Root directory for all operations in XBPS. If NULL, | ||||
| 	 * by default it's set to /. | ||||
| 	 */ | ||||
| 	prop_string_t rootdir; | ||||
| 	const char *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; | ||||
| 	const char *cachedir; | ||||
| 	/** | ||||
| 	 * @var confdir | ||||
| 	 * | ||||
| 	 * Full path to the XBPS_SYSCONF_PATH directory. | ||||
| 	 */ | ||||
| 	prop_string_t confdir; | ||||
| 	const char *conffile; | ||||
| 	/** | ||||
| 	 * @private fetch_timeout | ||||
| 	 * | ||||
| @@ -1292,7 +1291,7 @@ struct repository_pool_index { | ||||
| 	 *  | ||||
| 	 * URI string associated with repository. | ||||
| 	 */ | ||||
| 	char *rpi_uri; | ||||
| 	const char *rpi_uri; | ||||
| 	/** | ||||
| 	 * @var rpi_index | ||||
| 	 * | ||||
| @@ -1308,7 +1307,7 @@ struct repository_pool_index { | ||||
|  * @return 0 on success, ENOTSUP if no repositories were found in | ||||
|  * the configuration file. | ||||
|  */ | ||||
| int xbps_repository_pool_sync(void); | ||||
| int xbps_repository_pool_sync(const struct xbps_handle *xhp); | ||||
|  | ||||
| /** | ||||
|  * Iterates over the repository pool and executes the \a fn function | ||||
|   | ||||
| @@ -59,20 +59,6 @@ | ||||
| #define HIDDEN | ||||
| #endif | ||||
|  | ||||
| /** | ||||
|  * @def XBPS_FETCH_CACHECONN | ||||
|  * | ||||
|  * Default (global) limit of cached connections used in libfetch. | ||||
|  */ | ||||
| #define XBPS_FETCH_CACHECONN            6 | ||||
|  | ||||
| /** | ||||
|  * @def XBPS_FETCH_CACHECONN_HOST | ||||
|  * | ||||
|  * Default (per host) limit of cached connections used in libfetch. | ||||
|  */ | ||||
| #define XBPS_FETCH_CACHECONN_HOST       2 | ||||
|  | ||||
| __BEGIN_DECLS | ||||
|  | ||||
| /** | ||||
| @@ -92,7 +78,7 @@ void HIDDEN xbps_regpkgdb_dictionary_release(void); | ||||
|  * @private | ||||
|  * From lib/repository_pool.c | ||||
|  */ | ||||
| int HIDDEN xbps_repository_pool_init(void); | ||||
| int HIDDEN xbps_repository_pool_init(const struct xbps_handle *); | ||||
| void HIDDEN xbps_repository_pool_release(void); | ||||
|  | ||||
| /** | ||||
|   | ||||
| @@ -46,10 +46,10 @@ OBJS += package_remove.o package_remove_obsoletes.o package_state.o | ||||
| OBJS += package_unpack.o package_requiredby.o package_register.o | ||||
| OBJS += package_purge.o transaction_commit.o transaction_package_replace.o | ||||
| OBJS += transaction_dictionary.o transaction_sortdeps.o transaction_ops.o | ||||
| OBJS += download.o | ||||
| OBJS += download.o initend.o | ||||
| OBJS += plist.o plist_archive_entry.o plist_find.o plist_match.o | ||||
| OBJS += plist_remove.o plist_fetch.o util.o util_hash.o | ||||
| OBJS += initend.o regpkgdb_dictionary.o init_virtualpkgs.o | ||||
| OBJS += regpkgdb_dictionary.o | ||||
| OBJS += repository_finddeps.o cb_util.o | ||||
| OBJS += repository_pool.o repository_pool_find.o repository_sync_index.o | ||||
| OBJS += $(EXTOBJS) $(COMPAT_SRCS) | ||||
|   | ||||
| @@ -111,12 +111,7 @@ xbps_fetch_file(const char *uri, | ||||
| 	fetchLastErrCode = 0; | ||||
|  | ||||
| 	xhp = xbps_handle_get(); | ||||
|  | ||||
| 	if (xhp->fetch_timeout != 0) | ||||
| 		fetchTimeout = xhp->fetch_timeout; | ||||
| 	else | ||||
| 		fetchTimeout = 30; /* 30s if not set in configuration file. */ | ||||
|  | ||||
| 	fetchTimeout = xhp->fetch_timeout; | ||||
| 	/* | ||||
| 	 * Get the filename specified in URI argument. | ||||
| 	 */ | ||||
|   | ||||
| @@ -1,111 +0,0 @@ | ||||
| /*- | ||||
|  * Copyright (c) 2011 Juan Romero Pardines. | ||||
|  * All rights reserved. | ||||
|  * | ||||
|  * Redistribution and use in source and binary forms, with or without | ||||
|  * modification, are permitted provided that the following conditions | ||||
|  * are met: | ||||
|  * 1. Redistributions of source code must retain the above copyright | ||||
|  *    notice, this list of conditions and the following disclaimer. | ||||
|  * 2. Redistributions in binary form must reproduce the above copyright | ||||
|  *    notice, this list of conditions and the following disclaimer in the | ||||
|  *    documentation and/or other materials provided with the distribution. | ||||
|  * | ||||
|  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||||
|  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||||
|  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||||
|  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||||
|  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||||
|  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
|  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
|  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
|  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||||
|  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
|  */ | ||||
|  | ||||
| #include <stdio.h> | ||||
| #include <stdlib.h> | ||||
| #include <string.h> | ||||
| #include <errno.h> | ||||
| #include <stdarg.h> | ||||
| #include <dirent.h> | ||||
|  | ||||
| #include "xbps_api_impl.h" | ||||
|  | ||||
| /** | ||||
|  * @file lib/init_virtualpkg.c | ||||
|  * @brief Initialization of virtual package settings. | ||||
|  */ | ||||
| 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; | ||||
|  | ||||
| 	assert(xh != NULL); | ||||
|  | ||||
| 	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 | ||||
| 	 * into xhp->virtualpkgs_array. | ||||
| 	 */ | ||||
| 	dirp = opendir(prop_string_cstring_nocopy(vpkgdir)); | ||||
| 	if (dirp == NULL) { | ||||
| 		xbps_dbg_printf("[init_virtualpkgs] cannot access " | ||||
| 		    "to %s for virtual packages: %s\n", | ||||
| 		    prop_string_cstring_nocopy(vpkgdir), | ||||
| 		    strerror(errno)); | ||||
| 		prop_object_release(vpkgdir); | ||||
| 		return; | ||||
| 	} | ||||
| 	while ((dp = readdir(dirp)) != NULL) { | ||||
| 		if ((strcmp(dp->d_name, ".") == 0) || | ||||
| 		    (strcmp(dp->d_name, "..") == 0)) | ||||
| 			continue; | ||||
|  | ||||
| 		if (strstr(dp->d_name, ".plist") == NULL) | ||||
| 			continue; | ||||
|  | ||||
| 		vpkgfile = xbps_xasprintf("%s/%s", | ||||
| 		    prop_string_cstring_nocopy(vpkgdir), dp->d_name); | ||||
| 		if (vpkgfile == NULL) { | ||||
| 			xbps_dbg_printf("[init_virtualpkgs] failed to " | ||||
| 			    "alloc mem for %s\n", dp->d_name); | ||||
| 			continue; | ||||
| 		} | ||||
| 		vpkgd = prop_dictionary_internalize_from_file(vpkgfile); | ||||
| 		free(vpkgfile); | ||||
|  | ||||
| 		if (vpkgd == NULL) { | ||||
| 			xbps_dbg_printf("[init_virtualpkgs] failed to " | ||||
| 			    "internalize %s: %s\n", | ||||
| 			    dp->d_name, strerror(errno)); | ||||
| 			continue; | ||||
| 		} | ||||
| 		if (prop_object_type(xh->virtualpkgs_array) == PROP_TYPE_UNKNOWN) | ||||
| 			xh->virtualpkgs_array = prop_array_create(); | ||||
|  | ||||
| 		if (!xbps_add_obj_to_array(xh->virtualpkgs_array, vpkgd)) { | ||||
| 			xbps_dbg_printf("[init_virtualpkgs] failed to add %s " | ||||
| 			    "virtuapkg dictionary!\n", dp->d_name); | ||||
| 			prop_object_release(vpkgd); | ||||
| 			continue; | ||||
| 		} | ||||
| 		xbps_dbg_printf("[init_virtualpkgs] registered virtualpkg " | ||||
| 		    "'%s'\n", dp->d_name); | ||||
| 	} | ||||
| 	(void)closedir(dirp); | ||||
| 	prop_object_release(vpkgdir); | ||||
| } | ||||
							
								
								
									
										221
									
								
								lib/initend.c
									
									
									
									
									
								
							
							
						
						
									
										221
									
								
								lib/initend.c
									
									
									
									
									
								
							| @@ -42,129 +42,115 @@ | ||||
| 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 | ||||
| static int | ||||
| cb_validate_virtual(cfg_t *cfg, cfg_opt_t *opt) | ||||
| { | ||||
| 	unsigned int i; | ||||
|  | ||||
| 	for (i = 0; i < cfg_size(cfg, "virtual-package"); i++) { | ||||
| 		cfg_t *sec = cfg_opt_getnsec(opt, i); | ||||
| 		if (cfg_getstr(sec, "targets") == 0) { | ||||
| 			cfg_error(cfg, "targets must be set for " | ||||
| 			     "virtual-package %s", cfg_title(sec)); | ||||
| 			return -1; | ||||
| 		} | ||||
| 	} | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| 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; | ||||
| 	cfg_opt_t vpkg_opts[] = { | ||||
| 		CFG_STR_LIST((char *)"targets", NULL, CFGF_NONE), | ||||
| 		CFG_END() | ||||
| 	}; | ||||
| 	cfg_opt_t opts[] = { | ||||
| 		/* Defaults if not set in configuration file */ | ||||
| 		CFG_STR((char *)"rootdir", (char *)"/", CFGF_NONE), | ||||
| 		CFG_STR((char *)"cachedir", (char *)XBPS_CACHE_PATH, CFGF_NONE), | ||||
| 		CFG_INT((char *)"fetch-cache-connections", | ||||
| 		    XBPS_FETCH_CACHECONN, CFGF_NONE), | ||||
| 		CFG_INT((char *)"fetch-cache-connections-per-host", | ||||
| 		    XBPS_FETCH_CACHECONN_HOST, CFGF_NONE), | ||||
| 		CFG_INT((char *)"fetch-timeout-connection", | ||||
| 		    XBPS_FETCH_TIMEOUT, CFGF_NONE), | ||||
| 		CFG_BOOL((char *)"syslog", true, CFGF_NONE), | ||||
| 		CFG_STR_LIST((char *)"repositories", NULL, CFGF_MULTI), | ||||
| 		CFG_SEC((char *)"virtual-package", | ||||
| 		    vpkg_opts, CFGF_MULTI|CFGF_TITLE), | ||||
| 		CFG_FUNC((char *)"include", &cfg_include), | ||||
| 		CFG_END() | ||||
| 	}; | ||||
| 	int rv, cc, cch; | ||||
|  | ||||
| 	assert(xh != NULL); | ||||
|  | ||||
| 	xhp = xh; | ||||
| 	debug = xhp->debug; | ||||
|  | ||||
| 	/* 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); | ||||
| 	if (xhp->conffile == NULL) | ||||
| 		xhp->conffile = XBPS_CONF_DEF; | ||||
|  | ||||
| 		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(prop_string_cstring_nocopy(repofile)); | ||||
| 	/* | ||||
| 	 * Internalize the XBPS_CONF_PLIST dictionary. | ||||
| 	 */ | ||||
| 	confd = prop_dictionary_internalize_from_file( | ||||
| 	    prop_string_cstring_nocopy(conffile)); | ||||
| 	if (confd == NULL) { | ||||
| 		if (errno != ENOENT) { | ||||
| 			xbps_dbg_printf("%s: cannot internalize conf " | ||||
| 			    "dictionary: %s\n", strerror(errno)); | ||||
| 			xbps_end(xh); | ||||
| 			return errno; | ||||
| 		} | ||||
| 		xbps_dbg_printf("%s: conf_dictionary not internalized.\n", | ||||
| 		    __func__); | ||||
| 	} else { | ||||
| 		/* | ||||
| 		 * Get defaults from configuration file. | ||||
| 		 */ | ||||
| 		prop_dictionary_get_cstring_nocopy(confd, | ||||
| 		    "root-directory", &conf_rootdir); | ||||
| 		prop_dictionary_get_cstring_nocopy(confd, | ||||
| 		    "cache-directory", &conf_cachedir); | ||||
| 		prop_dictionary_get_uint16(confd, | ||||
| 		    "fetch-cache-connections", &fetch_cache_conn); | ||||
| 		prop_dictionary_get_uint16(confd, | ||||
| 		    "fetch-cache-connections-per-host", &fetch_cache_conn_host); | ||||
| 		prop_dictionary_get_uint16(confd, | ||||
| 		    "fetch-timeout-connection", &xhp->fetch_timeout); | ||||
| 	} | ||||
| 	/* parse configuration file */ | ||||
| 	xhp->cfg = cfg_init(opts, CFGF_NOCASE); | ||||
| 	cfg_set_validate_func(xhp->cfg, "virtual-package", &cb_validate_virtual); | ||||
|  | ||||
| 	/* | ||||
| 	 * Client supplied values in xbps_handle will be choosen over the | ||||
| 	 * same values in configuration file. If not specified, use defaults. | ||||
| 	 */ | ||||
| 	if (prop_object_type(xhp->rootdir) != PROP_TYPE_STRING) { | ||||
| 		if (conf_rootdir != NULL) | ||||
| 			xhp->rootdir = prop_string_create_cstring(conf_rootdir); | ||||
| 		else { | ||||
| 			/* If rootdir not set, defaults to '/' */ | ||||
| 			xhp->rootdir = prop_string_create_cstring("/"); | ||||
| 		} | ||||
| 	} | ||||
| 	if (prop_object_type(xhp->cachedir) != PROP_TYPE_STRING) { | ||||
| 		if (conf_cachedir != NULL) { | ||||
| 			if (conf_cachedir[0] == '/') { | ||||
| 				/* full path */ | ||||
| 				xhp->cachedir = | ||||
| 				    prop_string_create_cstring(conf_cachedir); | ||||
| 			} else { | ||||
| 				/* relative to rootdir */ | ||||
| 				xhp->cachedir = prop_string_copy(xhp->rootdir); | ||||
| 				prop_string_append_cstring( | ||||
| 				    xhp->cachedir, "/"); | ||||
| 				prop_string_append_cstring( | ||||
| 				    xhp->cachedir, conf_cachedir); | ||||
| 	if ((rv = cfg_parse(xhp->cfg, xhp->conffile)) != CFG_SUCCESS) { | ||||
| 		if (rv == CFG_PARSE_ERROR) { | ||||
| 			if (errno != ENOENT) { | ||||
| 				/* | ||||
| 				 * Don't error out if config file not found. | ||||
| 				 * We'll use defaults without any repo or | ||||
| 				 * virtual packages. | ||||
| 				 */ | ||||
| 				xbps_end(xh); | ||||
| 				return rv; | ||||
| 			} | ||||
| 		} else { | ||||
| 			/* If cachedir not set, defaults to XBPS_CACHE_PATH */ | ||||
| 			xhp->cachedir = | ||||
| 			    prop_string_create_cstring(XBPS_CACHE_PATH); | ||||
| 			errno = 0; | ||||
| 		} else if (rv == CFG_PARSE_ERROR) { | ||||
| 			/* | ||||
| 			 * Parser error from configuration file. | ||||
| 			 */ | ||||
| 			xbps_end(xh); | ||||
| 			return ENOTSUP; | ||||
| 		} | ||||
| 	} | ||||
| 	if (fetch_cache_conn == 0) | ||||
| 		fetch_cache_conn = XBPS_FETCH_CACHECONN; | ||||
| 	if (fetch_cache_conn_host == 0) | ||||
| 		fetch_cache_conn_host = XBPS_FETCH_CACHECONN_HOST; | ||||
|  | ||||
| 	xbps_fetch_set_cache_connection(fetch_cache_conn, | ||||
| 	    fetch_cache_conn_host); | ||||
|  | ||||
| 	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(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_cache_conn_host: %zu\n", | ||||
| 	    fetch_cache_conn_host); | ||||
| 	xbps_dbg_printf("fetch_timeout: %zu\n", | ||||
| 	    xhp->fetch_timeout); | ||||
|  | ||||
| 	prop_dictionary_get_bool(confd, "syslog-enabled", &xhp->syslog_enabled); | ||||
| 	xbps_dbg_printf("syslog logging: %d\n", xhp->syslog_enabled); | ||||
| 	/* | ||||
| 	 * Respect client setting in struct xbps_handle for {root,cache}dir; | ||||
| 	 * otherwise use values from configuration file or defaults if unset. | ||||
| 	 */ | ||||
| 	if (xhp->rootdir == NULL) { | ||||
| 		if (xhp->cfg == NULL) | ||||
| 			xhp->rootdir = "/"; | ||||
| 		else | ||||
| 			xhp->rootdir = cfg_getstr(xhp->cfg, "rootdir"); | ||||
| 	} | ||||
| 	if (xhp->cachedir == NULL) { | ||||
| 		if (xhp->cfg == NULL) | ||||
| 			xhp->cachedir = XBPS_CACHE_PATH; | ||||
| 		else | ||||
| 			xhp->cachedir = cfg_getstr(xhp->cfg, "cachedir"); | ||||
| 	} | ||||
| 	if (xhp->cfg == NULL) { | ||||
| 		xhp->syslog_enabled = true; | ||||
| 		xhp->fetch_timeout = XBPS_FETCH_TIMEOUT; | ||||
| 		cc = XBPS_FETCH_CACHECONN; | ||||
| 		cch = XBPS_FETCH_CACHECONN_HOST; | ||||
| 	} else { | ||||
| 		xhp->syslog_enabled = cfg_getbool(xhp->cfg, "syslog"); | ||||
| 		xhp->fetch_timeout = cfg_getint(xhp->cfg, "fetch-timeout-connection"); | ||||
| 		cc = cfg_getint(xhp->cfg, "fetch-cache-connections"); | ||||
| 		cch = cfg_getint(xhp->cfg, "fetch-cache-connections-per-host"); | ||||
| 	} | ||||
| 	xbps_fetch_set_cache_connection(cc, cch); | ||||
|  | ||||
| 	xbps_dbg_printf("rootdir=%s\n", xhp->rootdir); | ||||
| 	xbps_dbg_printf("cachedir=%s\n", xhp->cachedir); | ||||
| 	xbps_dbg_printf("fetch-timeout=%u\n", xhp->fetch_timeout); | ||||
| 	xbps_dbg_printf("fetch-cacheconn=%u\n", cc); | ||||
| 	xbps_dbg_printf("fetch-cacheconn-host=%u\n", cch); | ||||
| 	xbps_dbg_printf("syslog=%u\n", xhp->syslog_enabled); | ||||
| 	/* | ||||
| 	 * Initialize regpkgdb dictionary. | ||||
| 	 */ | ||||
| @@ -173,18 +159,9 @@ xbps_init(struct xbps_handle *xh) | ||||
| 		       xbps_dbg_printf("%s: couldn't initialize " | ||||
| 			    "regpkgdb: %s\n", strerror(rv)); | ||||
| 		       xbps_end(xh); | ||||
| 		       return rv; | ||||
| 		       return EINVAL; | ||||
| 	       } | ||||
| 	} | ||||
| 	if (prop_object_type(confd) == PROP_TYPE_DICTIONARY) | ||||
| 		prop_object_release(confd); | ||||
| 	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); | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
| @@ -198,14 +175,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) | ||||
| 		prop_object_release(xh->cachedir); | ||||
| 	if (prop_object_type(xh->virtualpkgs_array) == PROP_TYPE_ARRAY) | ||||
| 		prop_object_release(xh->virtualpkgs_array); | ||||
| 	if (xh->cfg != NULL) | ||||
| 		cfg_free(xh->cfg); | ||||
|  | ||||
| 	free(xh); | ||||
| 	xh = NULL; | ||||
|   | ||||
| @@ -128,12 +128,11 @@ xbps_configure_pkg(const char *pkgname, | ||||
| 		return ENOMEM; | ||||
| 	} | ||||
|  | ||||
| 	if (chdir(prop_string_cstring_nocopy(xhp->rootdir)) == -1) { | ||||
| 	if (chdir(xhp->rootdir) == -1) { | ||||
| 		xbps_set_cb_state(XBPS_STATE_CONFIGURE_FAIL, errno, | ||||
| 		    pkgname, lver, | ||||
| 		    "%s: [configure] failed to chdir to rootdir `%s': %s", | ||||
| 		    pkgver, prop_string_cstring_nocopy(xhp->rootdir), | ||||
| 		    strerror(errno)); | ||||
| 		    pkgver, xhp->rootdir, strerror(errno)); | ||||
| 		free(buf); | ||||
| 		free(pkgver); | ||||
| 		return EINVAL; | ||||
|   | ||||
| @@ -188,16 +188,15 @@ xbps_purge_pkg(const char *pkgname, bool check_state) | ||||
| 	/* | ||||
| 	 * Execute the purge action in REMOVE script (if found). | ||||
| 	 */ | ||||
| 	if (chdir(prop_string_cstring_nocopy(xhp->rootdir)) == -1) { | ||||
| 	if (chdir(xhp->rootdir) == -1) { | ||||
| 		rv = errno; | ||||
| 		xbps_set_cb_state(XBPS_STATE_PURGE_FAIL, | ||||
| 		    rv, pkgname, version, | ||||
| 		    "%s: [purge] failed to chdir to rootdir `%s': %s", | ||||
| 		    pkgver, prop_string_cstring_nocopy(xhp->rootdir), | ||||
| 		    strerror(rv)); | ||||
| 		    pkgver, xhp->rootdir, strerror(rv)); | ||||
| 		return rv; | ||||
| 	} | ||||
| 	buf = xbps_xasprintf(".%s/metadata/%s/REMOVE", XBPS_META_PATH, pkgname); | ||||
| 	buf = xbps_xasprintf("%s/metadata/%s/REMOVE", XBPS_META_PATH, pkgname); | ||||
| 	if (buf == NULL) { | ||||
| 		rv = ENOMEM; | ||||
| 		return rv; | ||||
| @@ -221,7 +220,7 @@ xbps_purge_pkg(const char *pkgname, bool check_state) | ||||
| 	 * Remove metadata dir and unregister package. | ||||
| 	 */ | ||||
| 	if ((rv = remove_pkg_metadata(pkgname, version, pkgver, | ||||
| 	    prop_string_cstring_nocopy(xhp->rootdir))) != 0) { | ||||
| 	    xhp->rootdir)) != 0) { | ||||
| 		xbps_set_cb_state(XBPS_STATE_PURGE_FAIL, | ||||
| 		    rv, pkgname, version, | ||||
| 		    "%s: [purge] failed to remove metadata files: %s", | ||||
|   | ||||
| @@ -53,8 +53,7 @@ xbps_register_pkg(prop_dictionary_t pkgrd) | ||||
| 	assert(prop_object_type(pkgrd) == PROP_TYPE_DICTIONARY); | ||||
|  | ||||
| 	xhp = xbps_handle_get(); | ||||
| 	plist = xbps_xasprintf("%s/%s/%s", | ||||
| 	    prop_string_cstring_nocopy(xhp->rootdir), | ||||
| 	plist = xbps_xasprintf("%s/%s/%s", xhp->rootdir, | ||||
| 	    XBPS_META_PATH, XBPS_REGPKGDB); | ||||
| 	if (plist == NULL) | ||||
| 		return ENOMEM; | ||||
| @@ -172,8 +171,7 @@ xbps_unregister_pkg(const char *pkgname, const char *version) | ||||
| 	xbps_set_cb_state(XBPS_STATE_UNREGISTER, 0, pkgname, version, NULL); | ||||
|  | ||||
| 	xhp = xbps_handle_get(); | ||||
| 	plist = xbps_xasprintf("%s/%s/%s", | ||||
| 	    prop_string_cstring_nocopy(xhp->rootdir), | ||||
| 	plist = xbps_xasprintf("%s/%s/%s", xhp->rootdir, | ||||
| 	    XBPS_META_PATH, XBPS_REGPKGDB); | ||||
| 	if (plist == NULL) { | ||||
| 		rv = ENOMEM; | ||||
|   | ||||
| @@ -110,8 +110,7 @@ xbps_remove_pkg_files(prop_dictionary_t dict, | ||||
|  | ||||
| 	while ((obj = prop_object_iterator_next(iter))) { | ||||
| 		prop_dictionary_get_cstring_nocopy(obj, "file", &file); | ||||
| 		path = xbps_xasprintf("%s/%s", | ||||
| 		    prop_string_cstring_nocopy(xhp->rootdir), file); | ||||
| 		path = xbps_xasprintf("%s/%s", xhp->rootdir, file); | ||||
| 		if (path == NULL) { | ||||
| 			rv = ENOMEM; | ||||
| 			break; | ||||
| @@ -224,13 +223,12 @@ xbps_remove_pkg(const char *pkgname, const char *version, bool update) | ||||
| 		return rv; | ||||
| 	} | ||||
|  | ||||
| 	if (chdir(prop_string_cstring_nocopy(xhp->rootdir)) == -1) { | ||||
| 	if (chdir(xhp->rootdir) == -1) { | ||||
| 		rv = errno; | ||||
| 		xbps_set_cb_state(XBPS_STATE_REMOVE_FAIL, | ||||
| 		    rv, pkgname, version, | ||||
| 		   "%s: [remove] failed to chdir to rootdir `%s': %s", | ||||
| 		    pkgver, prop_string_cstring_nocopy(xhp->rootdir), | ||||
| 		    strerror(rv)); | ||||
| 		    pkgver, xhp->rootdir, strerror(rv)); | ||||
| 		free(buf); | ||||
| 		free(pkgver); | ||||
| 		return rv; | ||||
|   | ||||
| @@ -109,8 +109,7 @@ xbps_requiredby_pkg_remove(const char *pkgname) | ||||
| 	assert(pkgname != NULL); | ||||
|  | ||||
| 	xhp = xbps_handle_get(); | ||||
| 	plist = xbps_xasprintf("%s/%s/%s", | ||||
| 	    prop_string_cstring_nocopy(xhp->rootdir), | ||||
| 	plist = xbps_xasprintf("%s/%s/%s", xhp->rootdir, | ||||
| 	    XBPS_META_PATH, XBPS_REGPKGDB); | ||||
| 	if (plist == NULL) | ||||
| 		return ENOMEM; | ||||
|   | ||||
| @@ -179,8 +179,7 @@ xbps_set_pkg_state_installed(const char *pkgname, | ||||
| 	assert(pkgname != NULL); | ||||
| 	xhp = xbps_handle_get(); | ||||
|  | ||||
| 	metadir = xbps_xasprintf("%s/%s", | ||||
| 	    prop_string_cstring_nocopy(xhp->rootdir), XBPS_META_PATH); | ||||
| 	metadir = xbps_xasprintf("%s/%s", xhp->rootdir, XBPS_META_PATH); | ||||
| 	if (metadir == NULL) | ||||
| 		return ENOMEM; | ||||
| 	plist = xbps_xasprintf("%s/%s", metadir, XBPS_REGPKGDB); | ||||
|   | ||||
| @@ -96,7 +96,7 @@ extract_metafile(struct archive *ar, | ||||
| 		return ENOMEM; | ||||
| 	version = xbps_pkg_version(pkgver); | ||||
|  | ||||
| 	buf = xbps_xasprintf(".%s/metadata/%s/%s", | ||||
| 	buf = xbps_xasprintf("%s/metadata/%s/%s", | ||||
| 	    XBPS_META_PATH, pkgname, file); | ||||
| 	if (buf == NULL) { | ||||
| 		free(pkgname); | ||||
| @@ -133,7 +133,7 @@ remove_metafile(const char *file, const char *pkgver) | ||||
| 		return ENOMEM; | ||||
| 	version = xbps_pkg_version(pkgver); | ||||
|  | ||||
| 	buf = xbps_xasprintf(".%s/metadata/%s/%s", | ||||
| 	buf = xbps_xasprintf("%s/metadata/%s/%s", | ||||
| 	    XBPS_META_PATH, pkgname, file); | ||||
| 	if (buf == NULL) { | ||||
| 		free(pkgname); | ||||
| @@ -193,12 +193,11 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar) | ||||
| 		xucd->entry_total_count = 0; | ||||
| 	} | ||||
|  | ||||
| 	if (chdir(prop_string_cstring_nocopy(xhp->rootdir)) == -1) { | ||||
| 	if (chdir(xhp->rootdir) == -1) { | ||||
| 		xbps_set_cb_state(XBPS_STATE_UNPACK_FAIL, | ||||
| 		    errno, pkgname, version, | ||||
| 		    "%s: [unpack] failed to chdir to rootdir `%s': %s", | ||||
| 		    pkgver, prop_string_cstring_nocopy(xhp->rootdir), | ||||
| 		    strerror(errno)); | ||||
| 		    pkgver, xhp->rootdir, strerror(errno)); | ||||
| 		rv = errno; | ||||
| 		goto out; | ||||
| 	} | ||||
| @@ -245,7 +244,7 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar) | ||||
| 			 * Extract the INSTALL script first to execute | ||||
| 			 * the pre install target. | ||||
| 			 */ | ||||
| 			buf = xbps_xasprintf(".%s/metadata/%s/INSTALL", | ||||
| 			buf = xbps_xasprintf("%s/metadata/%s/INSTALL", | ||||
| 			    XBPS_META_PATH, pkgname); | ||||
| 			if (buf == NULL) { | ||||
| 				rv = ENOMEM; | ||||
| @@ -469,7 +468,7 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar) | ||||
| 	 * On pkgs that set the preserve keyword or while installing | ||||
| 	 * new packages, do not check for obsolete files. | ||||
| 	 */ | ||||
| 	pkgfilesd = xbps_xasprintf(".%s/metadata/%s/%s", | ||||
| 	pkgfilesd = xbps_xasprintf("%s/metadata/%s/%s", | ||||
| 	    XBPS_META_PATH, pkgname, XBPS_PKGFILES); | ||||
| 	if (pkgfilesd == NULL) { | ||||
| 		rv = ENOMEM; | ||||
| @@ -484,12 +483,11 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar) | ||||
| 	if (prop_object_type(old_filesd) == PROP_TYPE_DICTIONARY) { | ||||
| 		rv = xbps_remove_obsoletes(pkgname, version, | ||||
| 		    pkgver, old_filesd, filesd); | ||||
| 		prop_object_release(old_filesd); | ||||
| 		if (rv != 0) { | ||||
| 			prop_object_release(old_filesd); | ||||
| 			rv = errno; | ||||
| 			goto out; | ||||
| 		} | ||||
| 		prop_object_release(old_filesd); | ||||
| 	} else if (errno && errno != ENOENT) { | ||||
| 		rv = errno; | ||||
| 		goto out; | ||||
| @@ -498,7 +496,7 @@ out1: | ||||
| 	/* | ||||
| 	 * Create pkg metadata directory. | ||||
| 	 */ | ||||
| 	buf = xbps_xasprintf(".%s/metadata/%s", XBPS_META_PATH, pkgname); | ||||
| 	buf = xbps_xasprintf("%s/metadata/%s", XBPS_META_PATH, pkgname); | ||||
| 	if (buf == NULL) { | ||||
| 		rv = ENOMEM; | ||||
| 		goto out; | ||||
|   | ||||
| @@ -224,8 +224,7 @@ xbps_dictionary_from_metadata_plist(const char *pkgname, | ||||
| 	xhp = xbps_handle_get(); | ||||
|  | ||||
| 	savedpkgname = pkgname; | ||||
| 	plistf = xbps_xasprintf("%s/%s/metadata/%s/%s", | ||||
| 	    prop_string_cstring_nocopy(xhp->rootdir), | ||||
| 	plistf = xbps_xasprintf("%s/%s/metadata/%s/%s", xhp->rootdir, | ||||
| 	    XBPS_META_PATH, savedpkgname, plist); | ||||
| 	if (plistf == NULL) | ||||
| 		return NULL; | ||||
| @@ -237,7 +236,7 @@ xbps_dictionary_from_metadata_plist(const char *pkgname, | ||||
| 			prop_dictionary_get_cstring_nocopy(pkgd, | ||||
| 			    "pkgname", &savedpkgname); | ||||
| 			plistf = xbps_xasprintf("%s/%s/metadata/%s/%s", | ||||
| 			    prop_string_cstring_nocopy(xhp->rootdir), | ||||
| 			    xhp->rootdir, | ||||
| 			    XBPS_META_PATH, savedpkgname, plist); | ||||
| 			prop_object_release(pkgd); | ||||
| 			if (plistf == NULL) | ||||
|   | ||||
| @@ -121,48 +121,45 @@ static const char * | ||||
| find_virtualpkg_user_in_conf(const char *vpkg, bool bypattern) | ||||
| { | ||||
| 	const struct xbps_handle *xhp; | ||||
| 	prop_object_iterator_t iter; | ||||
| 	prop_object_t obj; | ||||
| 	const char *vpkgver, *pkg = NULL; | ||||
| 	char *vpkgname = NULL; | ||||
| 	size_t i, j, cnt; | ||||
|  | ||||
| 	xhp = xbps_handle_get(); | ||||
| 	if (prop_object_type(xhp->virtualpkgs_array) != PROP_TYPE_ARRAY) { | ||||
| 		xbps_dbg_printf("%s: invalid virtualpkgs_array " | ||||
| 		    "type\n", __func__); | ||||
| 	if (xhp->cfg == NULL) | ||||
| 		return NULL; | ||||
|  | ||||
| 	if ((cnt = cfg_size(xhp->cfg, "virtual-package")) == 0) { | ||||
| 		/* no virtual packages configured */ | ||||
| 		return NULL; | ||||
| 	} | ||||
|  | ||||
| 	if ((iter = prop_array_iterator(xhp->virtualpkgs_array)) == NULL) | ||||
| 		return NULL; | ||||
|  | ||||
| 	while ((obj = prop_object_iterator_next(iter)) != NULL) { | ||||
| 		if (!prop_dictionary_get_cstring_nocopy(obj, | ||||
| 		    "virtual-pkgver", &vpkgver)) | ||||
| 			continue; | ||||
|  | ||||
|                 if (bypattern) { | ||||
| 			if (xbps_pkgpattern_match(vpkgver, vpkg)) { | ||||
| 				prop_dictionary_get_cstring_nocopy(obj, | ||||
| 				    "target-pkgpattern", &pkg); | ||||
| 				break; | ||||
| 			} | ||||
| 		} else { | ||||
| 	for (i = 0; i < cnt; i++) { | ||||
| 		cfg_t *sec = cfg_getnsec(xhp->cfg, "virtual-package", i); | ||||
| 		for (j = 0; j < cfg_size(sec, "targets"); j++) { | ||||
| 			vpkgver = cfg_getnstr(sec, "targets", j); | ||||
| 			vpkgname = xbps_pkg_name(vpkgver); | ||||
| 			if (vpkgname == NULL) | ||||
| 				break; | ||||
|  | ||||
| 			if (strcmp(vpkg, vpkgname) == 0) { | ||||
| 				free(vpkgname); | ||||
| 				prop_dictionary_get_cstring_nocopy(obj, | ||||
| 				    "target-pkgpattern", &pkg); | ||||
| 				break; | ||||
| 			if (bypattern) { | ||||
| 				if (!xbps_pkgpattern_match(vpkgver, vpkg)) { | ||||
| 					free(vpkgname); | ||||
| 					continue; | ||||
| 				} | ||||
| 			} else { | ||||
| 				if (strcmp(vpkg, vpkgname)) { | ||||
| 					free(vpkgname); | ||||
| 					continue; | ||||
| 				} | ||||
| 			} | ||||
| 			/* virtual package matched in conffile */ | ||||
| 			pkg = cfg_title(sec); | ||||
| 			xbps_dbg_printf("matched vpkg in conf `%s' for %s\n", | ||||
| 			    pkg, vpkg); | ||||
| 			free(vpkgname); | ||||
| 			break; | ||||
| 		} | ||||
| 	} | ||||
| 	prop_object_iterator_release(iter); | ||||
|  | ||||
| 	return pkg; | ||||
| } | ||||
|  | ||||
| @@ -171,31 +168,16 @@ find_virtualpkg_user_in_array(prop_array_t array, | ||||
| 			      const char *str, | ||||
| 			      bool bypattern) | ||||
| { | ||||
| 	prop_object_t obj = NULL; | ||||
| 	prop_object_iterator_t iter; | ||||
| 	const char *virtualpkg; | ||||
| 	const char *vpkgname; | ||||
|  | ||||
| 	assert(prop_object_type(array) == PROP_TYPE_ARRAY); | ||||
| 	assert(str != NULL); | ||||
|  | ||||
| 	virtualpkg = find_virtualpkg_user_in_conf(str, bypattern); | ||||
| 	if (virtualpkg == NULL) | ||||
| 	vpkgname = find_virtualpkg_user_in_conf(str, bypattern); | ||||
| 	if (vpkgname == NULL) | ||||
| 		return NULL; | ||||
|  | ||||
| 	iter = prop_array_iterator(array); | ||||
| 	if (iter == NULL) | ||||
| 		return NULL; | ||||
|  | ||||
| 	while ((obj = prop_object_iterator_next(iter))) { | ||||
| 		/* | ||||
| 		 * force pattern match because virtualpkg is | ||||
| 		 * always a pkgpattern. | ||||
| 		 */ | ||||
| 		if (xbps_match_virtual_pkg_in_dict(obj, virtualpkg, true)) | ||||
| 			break; | ||||
| 	} | ||||
| 	prop_object_iterator_release(iter); | ||||
| 	return obj; | ||||
| 	return find_pkg_in_array(array, vpkgname, false, false); | ||||
| } | ||||
|  | ||||
| static prop_dictionary_t | ||||
|   | ||||
| @@ -66,8 +66,7 @@ xbps_regpkgdb_dictionary_init(struct xbps_handle *xhp) | ||||
| 	if (regpkgdb_initialized) | ||||
| 		return 0; | ||||
|  | ||||
| 	plist = xbps_xasprintf("%s/%s/%s", | ||||
| 	    prop_string_cstring_nocopy(xhp->rootdir), | ||||
| 	plist = xbps_xasprintf("%s/%s/%s", xhp->rootdir, | ||||
| 	    XBPS_META_PATH, XBPS_REGPKGDB); | ||||
| 	if (plist == NULL) | ||||
| 		return ENOMEM; | ||||
|   | ||||
| @@ -74,10 +74,8 @@ check_repo_arch(const char *uri) | ||||
| } | ||||
|  | ||||
| int HIDDEN | ||||
| xbps_repository_pool_init(void) | ||||
| xbps_repository_pool_init(const struct xbps_handle *xhp) | ||||
| { | ||||
| 	prop_string_t obj; | ||||
| 	struct xbps_handle *xhp; | ||||
| 	struct repository_pool *rpool; | ||||
| 	size_t i, ntotal = 0, nmissing = 0, repocnt = 0; | ||||
| 	const char *repouri; | ||||
| @@ -87,17 +85,11 @@ xbps_repository_pool_init(void) | ||||
|  | ||||
| 	if (repolist_initialized) | ||||
| 		return 0; | ||||
|  | ||||
| 	xhp = xbps_handle_get(); | ||||
| 	if (prop_object_type(xhp->repos_array) != PROP_TYPE_ARRAY) | ||||
| 	else if (xhp->cfg == NULL) | ||||
| 		return ENOTSUP; | ||||
|  | ||||
| 	if (prop_array_count(xhp->repos_array) == 0) | ||||
| 		return ENOTSUP; | ||||
|  | ||||
| 	for (i = 0; i < prop_array_count(xhp->repos_array); i++) { | ||||
| 		obj = prop_array_get(xhp->repos_array, i); | ||||
| 		repouri = prop_string_cstring_nocopy(obj); | ||||
| 	for (i = 0; i < cfg_size(xhp->cfg, "repositories"); i++) { | ||||
| 		repouri = cfg_getnstr(xhp->cfg, "repositories", i); | ||||
| 		/* | ||||
| 		 * Check that we do not register duplicate repositories. | ||||
| 		 */ | ||||
| @@ -156,19 +148,11 @@ xbps_repository_pool_init(void) | ||||
| 			goto out; | ||||
| 		} | ||||
|  | ||||
| 		rpool->rpi->rpi_uri = prop_string_cstring(obj); | ||||
| 		if (rpool->rpi->rpi_uri == NULL) { | ||||
| 			rv = errno; | ||||
| 			free(rpool->rpi); | ||||
| 			free(rpool); | ||||
| 			free(plist); | ||||
| 			goto out; | ||||
| 		} | ||||
| 		rpool->rpi->rpi_uri = repouri; | ||||
| 		rpool->rpi->rpi_repod = | ||||
| 		    prop_dictionary_internalize_from_zfile(plist); | ||||
| 		if (rpool->rpi->rpi_repod == NULL) { | ||||
| 			rv = errno; | ||||
| 			free(rpool->rpi->rpi_uri); | ||||
| 			free(rpool->rpi); | ||||
| 			free(rpool); | ||||
| 			free(plist); | ||||
| @@ -190,7 +174,6 @@ xbps_repository_pool_init(void) | ||||
| 	} | ||||
|  | ||||
| 	repolist_initialized = true; | ||||
| 	prop_object_release(xhp->repos_array); | ||||
| 	xbps_dbg_printf("[rpool] initialized ok.\n"); | ||||
| out: | ||||
| 	if (rv != 0)  | ||||
| @@ -213,7 +196,6 @@ xbps_repository_pool_release(void) | ||||
| 		xbps_dbg_printf("[rpool] unregistered repository '%s'\n", | ||||
| 		    rpool->rpi->rpi_uri); | ||||
| 		prop_object_release(rpool->rpi->rpi_repod); | ||||
| 		free(rpool->rpi->rpi_uri); | ||||
| 		free(rpool->rpi); | ||||
| 		free(rpool); | ||||
| 		rpool = NULL; | ||||
| @@ -223,22 +205,17 @@ xbps_repository_pool_release(void) | ||||
| } | ||||
|  | ||||
| int | ||||
| xbps_repository_pool_sync(void) | ||||
| xbps_repository_pool_sync(const struct xbps_handle *xhp) | ||||
| { | ||||
| 	const struct xbps_handle *xhp; | ||||
| 	const char *repouri; | ||||
| 	size_t i; | ||||
| 	int rv; | ||||
|  | ||||
| 	xhp = xbps_handle_get(); | ||||
| 	if (xhp->repos_array == NULL) | ||||
| 	if (xhp->cfg == NULL) | ||||
| 		return ENOTSUP; | ||||
|  | ||||
| 	if (prop_array_count(xhp->repos_array) == 0) | ||||
| 		return ENOTSUP; | ||||
|  | ||||
| 	for (i = 0; i < prop_array_count(xhp->repos_array); i++) { | ||||
| 		prop_array_get_cstring_nocopy(xhp->repos_array, i, &repouri); | ||||
| 	for (i = 0; i < cfg_size(xhp->cfg, "repositories"); i++) { | ||||
| 		repouri = cfg_getnstr(xhp->cfg, "repositories", i); | ||||
| 		/* | ||||
| 		 * Check if repository doesn't match our architecture. | ||||
| 		 */ | ||||
| @@ -266,6 +243,7 @@ xbps_repository_pool_foreach( | ||||
| 		int (*fn)(struct repository_pool_index *, void *, bool *), | ||||
| 		void *arg) | ||||
| { | ||||
| 	const struct xbps_handle *xhp = xbps_handle_get(); | ||||
| 	struct repository_pool *rpool, *rpool_new; | ||||
| 	int rv = 0; | ||||
| 	bool done = false; | ||||
| @@ -274,7 +252,7 @@ xbps_repository_pool_foreach( | ||||
| 	/* | ||||
| 	 * Initialize repository pool. | ||||
| 	 */ | ||||
| 	if ((rv = xbps_repository_pool_init()) != 0) { | ||||
| 	if ((rv = xbps_repository_pool_init(xhp)) != 0) { | ||||
| 		if (rv == ENOTSUP) { | ||||
| 			xbps_dbg_printf("[rpool] empty repository list.\n"); | ||||
| 		} else if (rv != ENOENT && rv != ENOTSUP) { | ||||
|   | ||||
| @@ -117,8 +117,7 @@ xbps_repository_sync_pkg_index(const char *uri) | ||||
| 	/* | ||||
| 	 * Create metadir if necessary. | ||||
| 	 */ | ||||
| 	metadir = xbps_xasprintf("%s/%s", | ||||
| 	    prop_string_cstring_nocopy(xhp->rootdir), XBPS_META_PATH); | ||||
| 	metadir = xbps_xasprintf("%s/%s", xhp->rootdir, XBPS_META_PATH); | ||||
| 	if (metadir == NULL) { | ||||
| 		rv = -1; | ||||
| 		goto out; | ||||
| @@ -151,7 +150,7 @@ xbps_repository_sync_pkg_index(const char *uri) | ||||
| 	 * Full path to repository directory to store the index.plist file. | ||||
| 	 */ | ||||
| 	lrepodir = xbps_xasprintf("%s/%s/%s", | ||||
| 	    prop_string_cstring_nocopy(xhp->rootdir), XBPS_META_PATH, uri_fixedp); | ||||
| 	    xhp->rootdir, XBPS_META_PATH, uri_fixedp); | ||||
| 	if (lrepodir == NULL) { | ||||
| 		rv = -1; | ||||
| 		goto out; | ||||
|   | ||||
| @@ -124,13 +124,11 @@ download_binpkgs(struct xbps_handle *xhp, prop_object_iterator_t iter) | ||||
| 		/* | ||||
| 		 * Create cachedir. | ||||
| 		 */ | ||||
| 		if (xbps_mkpath(prop_string_cstring_nocopy(xhp->cachedir), | ||||
| 		    0755) == -1) { | ||||
| 		if (xbps_mkpath(xhp->cachedir, 0755) == -1) { | ||||
| 			xbps_set_cb_state(XBPS_STATE_DOWNLOAD_FAIL, | ||||
| 			    errno, pkgname, version, | ||||
| 			    "%s: [trans] cannot create cachedir `%s': %s", | ||||
| 			    pkgver, prop_string_cstring_nocopy(xhp->cachedir), | ||||
| 			    strerror(errno)); | ||||
| 			    pkgver, xhp->cachedir, strerror(errno)); | ||||
| 			free(binfile); | ||||
| 			rv = errno; | ||||
| 			break; | ||||
| @@ -142,8 +140,7 @@ download_binpkgs(struct xbps_handle *xhp, prop_object_iterator_t iter) | ||||
| 		/* | ||||
| 		 * Fetch binary package. | ||||
| 		 */ | ||||
| 		rv = xbps_fetch_file(binfile, | ||||
| 		    prop_string_cstring_nocopy(xhp->cachedir), false, NULL); | ||||
| 		rv = xbps_fetch_file(binfile, xhp->cachedir, false, NULL); | ||||
| 		if (rv == -1) { | ||||
| 			xbps_set_cb_state(XBPS_STATE_DOWNLOAD_FAIL, | ||||
| 			    errno, pkgname, version, | ||||
|   | ||||
| @@ -213,12 +213,12 @@ get_pkg_index_remote_plist(const char *uri) | ||||
| 	if (uri_fixed == NULL) | ||||
| 		return NULL; | ||||
|  | ||||
| 	if (prop_string_equals_cstring(xhp->rootdir, "/")) { | ||||
| 	if (strcmp(xhp->rootdir, "/") == 0) { | ||||
| 		repodir = xbps_xasprintf("%s/%s/%s", | ||||
| 		    XBPS_META_PATH, uri_fixed, XBPS_PKGINDEX); | ||||
| 	} else { | ||||
| 		repodir = xbps_xasprintf("%s/%s/%s/%s", | ||||
| 		    prop_string_cstring_nocopy(xhp->rootdir), | ||||
| 		    xhp->rootdir, | ||||
| 		    XBPS_META_PATH, uri_fixed, XBPS_PKGINDEX); | ||||
| 	} | ||||
| 	free(uri_fixed); | ||||
| @@ -254,8 +254,7 @@ 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", | ||||
| 	    prop_string_cstring_nocopy(xhp->cachedir), filen); | ||||
| 	lbinpkg = xbps_xasprintf("%s/%s", xhp->cachedir, filen); | ||||
| 	if (lbinpkg == NULL) | ||||
| 		return NULL; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user