xbps_init() now sets rootdir, cachedir and flags.
That means that the following functions were removed:
	- xbps_set_{cachedir,flags,rootdir}.
	- xbps_get_{cachedir,flags,rootdir}.
With this change fixed an obvious typo that made -c argument to not work,
and now the cache directory is an absolute path not relative to rootdir.
			
			
This commit is contained in:
		@@ -91,6 +91,7 @@ out:
 | 
			
		||||
int
 | 
			
		||||
xbps_check_pkg_integrity(const char *pkgname)
 | 
			
		||||
{
 | 
			
		||||
	const struct xbps_handle *xhp;
 | 
			
		||||
	prop_dictionary_t pkgd, propsd = NULL, filesd = NULL;
 | 
			
		||||
	prop_array_t array;
 | 
			
		||||
	prop_object_t obj;
 | 
			
		||||
@@ -101,6 +102,7 @@ xbps_check_pkg_integrity(const char *pkgname)
 | 
			
		||||
	bool broken = false, files_broken = false;
 | 
			
		||||
 | 
			
		||||
	assert(pkgname != NULL);
 | 
			
		||||
	xhp = xbps_handle_get();
 | 
			
		||||
 | 
			
		||||
	pkgd = xbps_find_pkg_dict_installed(pkgname, false);
 | 
			
		||||
	if (pkgd == NULL) {
 | 
			
		||||
@@ -158,8 +160,7 @@ xbps_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",
 | 
			
		||||
			    xbps_get_rootdir(), file);
 | 
			
		||||
			path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
 | 
			
		||||
			if (path == NULL) {
 | 
			
		||||
				prop_object_iterator_release(iter);
 | 
			
		||||
				rv = errno;
 | 
			
		||||
@@ -209,8 +210,7 @@ xbps_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",
 | 
			
		||||
			    xbps_get_rootdir(), file);
 | 
			
		||||
			path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
 | 
			
		||||
			if (path == NULL) {
 | 
			
		||||
				prop_object_iterator_release(iter);
 | 
			
		||||
				rv = ENOMEM;
 | 
			
		||||
 
 | 
			
		||||
@@ -71,6 +71,7 @@ match_files_by_pattern(prop_dictionary_t pkg_filesd, prop_dictionary_keysym_t ke
 | 
			
		||||
int
 | 
			
		||||
find_files_in_packages(const char *pattern)
 | 
			
		||||
{
 | 
			
		||||
	const struct xbps_handle *xhp;
 | 
			
		||||
	prop_dictionary_t pkg_filesd;
 | 
			
		||||
	prop_array_t files_keys;
 | 
			
		||||
	DIR *dirp;
 | 
			
		||||
@@ -79,7 +80,8 @@ find_files_in_packages(const char *pattern)
 | 
			
		||||
	int rv = 0;
 | 
			
		||||
	unsigned int i, count;
 | 
			
		||||
 | 
			
		||||
	path = xbps_xasprintf("%s/%s/metadata", xbps_get_rootdir(),
 | 
			
		||||
	xhp = xbps_handle_get();
 | 
			
		||||
	path = xbps_xasprintf("%s/%s/metadata", xhp->rootdir,
 | 
			
		||||
	    XBPS_META_PATH);
 | 
			
		||||
	if (path == NULL)
 | 
			
		||||
		return -1;
 | 
			
		||||
 
 | 
			
		||||
@@ -93,16 +93,14 @@ check_binpkg_hash(const char *path,
 | 
			
		||||
static int
 | 
			
		||||
download_package_list(prop_object_iterator_t iter, bool only_show)
 | 
			
		||||
{
 | 
			
		||||
	const struct xbps_handle *xhp;
 | 
			
		||||
	prop_object_t obj;
 | 
			
		||||
	const char *pkgver, *repoloc, *filename, *cachedir, *sha256;
 | 
			
		||||
	const char *pkgver, *repoloc, *filename, *sha256;
 | 
			
		||||
	char *binfile;
 | 
			
		||||
	int rv = 0;
 | 
			
		||||
	bool cksum;
 | 
			
		||||
 | 
			
		||||
	cachedir = xbps_get_cachedir();
 | 
			
		||||
	if (cachedir == NULL)
 | 
			
		||||
		return EINVAL;
 | 
			
		||||
 | 
			
		||||
	xhp = xbps_handle_get();
 | 
			
		||||
again:
 | 
			
		||||
	while ((obj = prop_object_iterator_next(iter)) != NULL) {
 | 
			
		||||
		cksum = false;
 | 
			
		||||
@@ -141,12 +139,12 @@ again:
 | 
			
		||||
			free(binfile);
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
		if (xbps_mkpath(__UNCONST(cachedir), 0755) == -1) {
 | 
			
		||||
		if (xbps_mkpath(xhp->cachedir, 0755) == -1) {
 | 
			
		||||
			free(binfile);
 | 
			
		||||
			return errno;
 | 
			
		||||
		}
 | 
			
		||||
		printf("Downloading %s binary package ...\n", pkgver);
 | 
			
		||||
		rv = xbps_fetch_file(binfile, cachedir, false, NULL);
 | 
			
		||||
		rv = xbps_fetch_file(binfile, xhp->cachedir, false, NULL);
 | 
			
		||||
		if (rv == -1) {
 | 
			
		||||
			xbps_error_printf("xbps-bin: couldn't download `%s'\n",
 | 
			
		||||
			    filename);
 | 
			
		||||
@@ -374,13 +372,15 @@ xbps_update_pkg(const char *pkgname)
 | 
			
		||||
static int
 | 
			
		||||
exec_transaction(struct transaction *trans)
 | 
			
		||||
{
 | 
			
		||||
	const struct xbps_handle *xhp;
 | 
			
		||||
	prop_dictionary_t instpkgd;
 | 
			
		||||
	prop_object_t obj;
 | 
			
		||||
	const char *pkgname, *version, *pkgver, *instver, *filen, *tract;
 | 
			
		||||
	int flags = xbps_get_flags(), rv = 0;
 | 
			
		||||
	int rv = 0;
 | 
			
		||||
	bool update, preserve, autoinst;
 | 
			
		||||
	pkg_state_t state;
 | 
			
		||||
 | 
			
		||||
	xhp = xbps_handle_get();
 | 
			
		||||
	/*
 | 
			
		||||
	 * Only show the URLs to download the binary packages.
 | 
			
		||||
	 */
 | 
			
		||||
@@ -497,7 +497,7 @@ exec_transaction(struct transaction *trans)
 | 
			
		||||
			    "(%s)\n", pkgver, strerror(rv));
 | 
			
		||||
			return rv;
 | 
			
		||||
		}
 | 
			
		||||
		if ((flags & XBPS_FLAG_VERBOSE) == 0)
 | 
			
		||||
		if ((xhp->flags & XBPS_FLAG_VERBOSE) == 0)
 | 
			
		||||
			printf("\n");
 | 
			
		||||
		/*
 | 
			
		||||
		 * Register binary package.
 | 
			
		||||
 
 | 
			
		||||
@@ -191,17 +191,19 @@ main(int argc, char **argv)
 | 
			
		||||
	struct xbps_fetch_progress_data xfpd;
 | 
			
		||||
	struct list_pkgver_cb lpc;
 | 
			
		||||
	struct sigaction sa;
 | 
			
		||||
	const char *rootdir, *cachedir;
 | 
			
		||||
	int i , c, flags, rv;
 | 
			
		||||
	bool yes, purge, with_debug, force_rm_with_deps, recursive_rm;
 | 
			
		||||
	bool show_download_pkglist_url = false;
 | 
			
		||||
 | 
			
		||||
	rootdir = cachedir = NULL;
 | 
			
		||||
	flags = rv = 0;
 | 
			
		||||
	yes = purge = force_rm_with_deps = recursive_rm = with_debug = false;
 | 
			
		||||
 | 
			
		||||
	while ((c = getopt(argc, argv, "VcdDFfpRr:vy")) != -1) {
 | 
			
		||||
	while ((c = getopt(argc, argv, "Vc:dDFfpRr:vy")) != -1) {
 | 
			
		||||
		switch (c) {
 | 
			
		||||
		case 'c':
 | 
			
		||||
			xbps_set_cachedir(optarg);
 | 
			
		||||
			cachedir = optarg;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'd':
 | 
			
		||||
			with_debug = true;
 | 
			
		||||
@@ -223,7 +225,7 @@ main(int argc, char **argv)
 | 
			
		||||
			break;
 | 
			
		||||
		case 'r':
 | 
			
		||||
			/* To specify the root directory */
 | 
			
		||||
			xbps_set_rootdir(optarg);
 | 
			
		||||
			rootdir = optarg;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'v':
 | 
			
		||||
			flags |= XBPS_FLAG_VERBOSE;
 | 
			
		||||
@@ -246,9 +248,6 @@ main(int argc, char **argv)
 | 
			
		||||
	if (argc < 1)
 | 
			
		||||
		usage();
 | 
			
		||||
 | 
			
		||||
	if (flags != 0)
 | 
			
		||||
		xbps_set_flags(flags);
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * Register a signal handler to clean up resources used by libxbps.
 | 
			
		||||
	 */
 | 
			
		||||
@@ -270,6 +269,9 @@ main(int argc, char **argv)
 | 
			
		||||
	else
 | 
			
		||||
		xh.xbps_unpack_cb = unpack_progress_cb_percentage;
 | 
			
		||||
	xh.xupd = &xupd;
 | 
			
		||||
	xh.rootdir = rootdir;
 | 
			
		||||
	xh.cachedir = cachedir;
 | 
			
		||||
	xh.flags = flags;
 | 
			
		||||
	xbps_init(&xh);
 | 
			
		||||
 | 
			
		||||
	if ((dict = xbps_regpkgdb_dictionary_get()) == NULL) {
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@
 | 
			
		||||
.\"    Source: \ \&
 | 
			
		||||
.\"  Language: English
 | 
			
		||||
.\"
 | 
			
		||||
.TH "XBPS\-BIN" "8" "02/05/2011" "\ \&" "\ \&"
 | 
			
		||||
.TH "XBPS\-BIN" "8" "02/21/2011" "\ \&" "\ \&"
 | 
			
		||||
.\" -----------------------------------------------------------------
 | 
			
		||||
.\" * set default formatting
 | 
			
		||||
.\" -----------------------------------------------------------------
 | 
			
		||||
@@ -31,13 +31,7 @@ The xbps\-bin(8) command is used to handle binary packages created for the XBPS
 | 
			
		||||
\fB\-c\fR \fIcachedir\fR
 | 
			
		||||
.RS 4
 | 
			
		||||
Sets the cache directory to store downloaded binary packages from remote repositories\&. By default it\(cqs set to
 | 
			
		||||
\fI/var/cache/xbps\fR
 | 
			
		||||
and it\(cqs always relative to the
 | 
			
		||||
\fIroot directory\fR\&. So if you use a
 | 
			
		||||
\fIrootdir\fR
 | 
			
		||||
of
 | 
			
		||||
\fI/blah\fR, it will become
 | 
			
		||||
\fI/blah/cachedir\fR\&.
 | 
			
		||||
\fI/var/cache/xbps\fR\&.
 | 
			
		||||
.RE
 | 
			
		||||
.PP
 | 
			
		||||
\fB\-d\fR
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user