Fixed a regression in vpkgs and improve xbps.d(5) virtualpkg declarations.
See the NEWS file for more information.
This commit is contained in:
		
							
								
								
									
										10
									
								
								NEWS
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								NEWS
									
									
									
									
									
								
							@@ -1,5 +1,15 @@
 | 
				
			|||||||
xbps-0.43 (???):
 | 
					xbps-0.43 (???):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 * xbps.d(5): the "virtualpkg" keyword now accepts pkgnames in the first component,
 | 
				
			||||||
 | 
					   to match any virtual package version. Example:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						`virtualpkg=foo:bar`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   would match any version of the virtual package `foo' to be resolved as `bar'.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 * libxbps: when resolving virtual packages in repositories, make sure to initialize
 | 
				
			||||||
 | 
					   pkgdb to match any virtualpkg declared there. Regression introduced in 0.42.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 * configure: build with -fstack-protector-strong if supported by the compiler,
 | 
					 * configure: build with -fstack-protector-strong if supported by the compiler,
 | 
				
			||||||
   and fallback to -fstack-protector-all otherwise.
 | 
					   and fallback to -fstack-protector-all otherwise.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
.Dd December 23, 2014
 | 
					.Dd December 30, 2014
 | 
				
			||||||
.Dt XBPS-D 5
 | 
					.Dt XBPS-D 5
 | 
				
			||||||
.Sh NAME
 | 
					.Sh NAME
 | 
				
			||||||
.Nm xbps.d
 | 
					.Nm xbps.d
 | 
				
			||||||
@@ -84,12 +84,12 @@ archive is expected, example:
 | 
				
			|||||||
Sets the default root directory.
 | 
					Sets the default root directory.
 | 
				
			||||||
.It Sy syslog=true|false
 | 
					.It Sy syslog=true|false
 | 
				
			||||||
Enables or disables syslog logging. Enabled by default.
 | 
					Enables or disables syslog logging. Enabled by default.
 | 
				
			||||||
.It Sy virtualpkg=vpkgver:pkgname
 | 
					.It Sy virtualpkg=[vpkgname|vpkgver]:pkgname
 | 
				
			||||||
Declares a virtual package. A virtual package declaration is composed by two
 | 
					Declares a virtual package. A virtual package declaration is composed by two
 | 
				
			||||||
components delimited by a colon, example:
 | 
					components delimited by a colon, example:
 | 
				
			||||||
.Pp
 | 
					.Pp
 | 
				
			||||||
.Bl -tag -compact -width virtualpkg=cron-daemon-1.0_1:dcron
 | 
					.Bl -tag -compact -width virtualpkg=cron-daemon:dcron
 | 
				
			||||||
.It Sy virtualpkg=cron-daemon-1.0_1:dcron
 | 
					.It Sy virtualpkg=cron-daemon:dcron
 | 
				
			||||||
Any request to the
 | 
					Any request to the
 | 
				
			||||||
.Ar cron-daemon
 | 
					.Ar cron-daemon
 | 
				
			||||||
virtual package will be resolved to the
 | 
					virtual package will be resolved to the
 | 
				
			||||||
@@ -98,9 +98,10 @@ real package.
 | 
				
			|||||||
.El
 | 
					.El
 | 
				
			||||||
.Pp
 | 
					.Pp
 | 
				
			||||||
The first component expects a
 | 
					The first component expects a
 | 
				
			||||||
.Em virtual package name and its version component .
 | 
					.Em virtual package name and optionally its version component .
 | 
				
			||||||
The second component expects a
 | 
					The second component expects a
 | 
				
			||||||
.Em package name .
 | 
					.Em package name
 | 
				
			||||||
 | 
					to match the real package.
 | 
				
			||||||
.El
 | 
					.El
 | 
				
			||||||
.Sh ENVIRONMENT
 | 
					.Sh ENVIRONMENT
 | 
				
			||||||
.Bl -tag -width XBPS_TARGET_ARCH
 | 
					.Bl -tag -width XBPS_TARGET_ARCH
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -148,7 +148,7 @@ void HIDDEN xbps_pkg_find_conflicts(struct xbps_handle *, xbps_array_t,
 | 
				
			|||||||
char HIDDEN *xbps_archive_get_file(struct archive *, struct archive_entry *);
 | 
					char HIDDEN *xbps_archive_get_file(struct archive *, struct archive_entry *);
 | 
				
			||||||
xbps_dictionary_t HIDDEN xbps_archive_get_dictionary(struct archive *,
 | 
					xbps_dictionary_t HIDDEN xbps_archive_get_dictionary(struct archive *,
 | 
				
			||||||
		struct archive_entry *);
 | 
							struct archive_entry *);
 | 
				
			||||||
const char HIDDEN *vpkg_user_conf(struct xbps_handle *, const char *, bool);
 | 
					const char HIDDEN *vpkg_user_conf(struct xbps_handle *, const char *);
 | 
				
			||||||
xbps_array_t HIDDEN xbps_get_pkg_fulldeptree(struct xbps_handle *,
 | 
					xbps_array_t HIDDEN xbps_get_pkg_fulldeptree(struct xbps_handle *,
 | 
				
			||||||
		const char *, bool);
 | 
							const char *, bool);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -212,7 +212,7 @@ xbps_pkgdb_update(struct xbps_handle *xhp, bool flush)
 | 
				
			|||||||
		return cached_rv;
 | 
							return cached_rv;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (xhp->pkgdb && flush) {
 | 
						if (xhp->pkgdb && flush) {
 | 
				
			||||||
		pkgdb_storage = xbps_dictionary_internalize_from_zfile(xhp->pkgdb_plist);
 | 
							pkgdb_storage = xbps_dictionary_internalize_from_file(xhp->pkgdb_plist);
 | 
				
			||||||
		if (pkgdb_storage == NULL ||
 | 
							if (pkgdb_storage == NULL ||
 | 
				
			||||||
		    !xbps_dictionary_equals(xhp->pkgdb, pkgdb_storage)) {
 | 
							    !xbps_dictionary_equals(xhp->pkgdb, pkgdb_storage)) {
 | 
				
			||||||
			/* flush dictionary to storage */
 | 
								/* flush dictionary to storage */
 | 
				
			||||||
@@ -227,7 +227,7 @@ xbps_pkgdb_update(struct xbps_handle *xhp, bool flush)
 | 
				
			|||||||
		cached_rv = 0;
 | 
							cached_rv = 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	/* update copy in memory */
 | 
						/* update copy in memory */
 | 
				
			||||||
	if ((xhp->pkgdb = xbps_dictionary_internalize_from_zfile(xhp->pkgdb_plist)) == NULL) {
 | 
						if ((xhp->pkgdb = xbps_dictionary_internalize_from_file(xhp->pkgdb_plist)) == NULL) {
 | 
				
			||||||
		if (errno == ENOENT)
 | 
							if (errno == ENOENT)
 | 
				
			||||||
			xhp->pkgdb = xbps_dictionary_create();
 | 
								xhp->pkgdb = xbps_dictionary_create();
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
@@ -341,7 +341,7 @@ generate_full_revdeps_tree(struct xbps_handle *xhp)
 | 
				
			|||||||
			if (curpkgname == NULL)
 | 
								if (curpkgname == NULL)
 | 
				
			||||||
				curpkgname = xbps_pkg_name(pkgdep);
 | 
									curpkgname = xbps_pkg_name(pkgdep);
 | 
				
			||||||
			assert(curpkgname);
 | 
								assert(curpkgname);
 | 
				
			||||||
			vpkgname = vpkg_user_conf(xhp, curpkgname, false);
 | 
								vpkgname = vpkg_user_conf(xhp, curpkgname);
 | 
				
			||||||
			if (vpkgname == NULL)
 | 
								if (vpkgname == NULL)
 | 
				
			||||||
				vpkgname = curpkgname;
 | 
									vpkgname = curpkgname;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -121,16 +121,12 @@ xbps_find_virtualpkg_in_array(struct xbps_handle *x,
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	xbps_dictionary_t pkgd;
 | 
						xbps_dictionary_t pkgd;
 | 
				
			||||||
	const char *vpkg;
 | 
						const char *vpkg;
 | 
				
			||||||
	bool bypattern = false;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	assert(x);
 | 
						assert(x);
 | 
				
			||||||
	assert(xbps_object_type(a) == XBPS_TYPE_ARRAY);
 | 
						assert(xbps_object_type(a) == XBPS_TYPE_ARRAY);
 | 
				
			||||||
	assert(s);
 | 
						assert(s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (xbps_pkgpattern_version(s))
 | 
						if ((vpkg = vpkg_user_conf(x, s))) {
 | 
				
			||||||
		bypattern = true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if ((vpkg = vpkg_user_conf(x, s, bypattern))) {
 | 
					 | 
				
			||||||
		if ((pkgd = get_pkg_in_array(a, vpkg, trans, true)))
 | 
							if ((pkgd = get_pkg_in_array(a, vpkg, trans, true)))
 | 
				
			||||||
			return pkgd;
 | 
								return pkgd;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -193,17 +189,16 @@ match_pkg_by_pattern(xbps_dictionary_t repod, const char *p)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char HIDDEN *
 | 
					const char HIDDEN *
 | 
				
			||||||
vpkg_user_conf(struct xbps_handle *xhp,
 | 
					vpkg_user_conf(struct xbps_handle *xhp, const char *vpkg)
 | 
				
			||||||
	       const char *vpkg,
 | 
					 | 
				
			||||||
	       bool bypattern)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	xbps_object_t obj;
 | 
						xbps_object_t obj;
 | 
				
			||||||
	xbps_object_iterator_t iter;
 | 
						xbps_object_iterator_t iter;
 | 
				
			||||||
	xbps_string_t rpkg;
 | 
						const char *pkg = NULL;
 | 
				
			||||||
	const char *vpkgver, *pkg = NULL;
 | 
					 | 
				
			||||||
	char *vpkgname = NULL, *tmp;
 | 
					 | 
				
			||||||
	bool found = false;
 | 
						bool found = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* init pkgdb just in case to detect vpkgs */
 | 
				
			||||||
 | 
						(void)xbps_pkgdb_init(xhp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (xhp->vpkgd == NULL)
 | 
						if (xhp->vpkgd == NULL)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -211,36 +206,35 @@ vpkg_user_conf(struct xbps_handle *xhp,
 | 
				
			|||||||
	assert(iter);
 | 
						assert(iter);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	while ((obj = xbps_object_iterator_next(iter))) {
 | 
						while ((obj = xbps_object_iterator_next(iter))) {
 | 
				
			||||||
		vpkgver = xbps_dictionary_keysym_cstring_nocopy(obj);
 | 
							xbps_string_t rpkg;
 | 
				
			||||||
 | 
							const char *vpkg_conf;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							vpkg_conf = xbps_dictionary_keysym_cstring_nocopy(obj);
 | 
				
			||||||
		rpkg = xbps_dictionary_get_keysym(xhp->vpkgd, obj);
 | 
							rpkg = xbps_dictionary_get_keysym(xhp->vpkgd, obj);
 | 
				
			||||||
		pkg = xbps_string_cstring_nocopy(rpkg);
 | 
							pkg = xbps_string_cstring_nocopy(rpkg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		tmp = NULL;
 | 
							if (xbps_pkgpattern_version(vpkg_conf)) {
 | 
				
			||||||
		if (strchr(vpkgver, '_') == NULL) {
 | 
								if (!xbps_pkgpattern_match(vpkg_conf, vpkg)) {
 | 
				
			||||||
			tmp = xbps_xasprintf("%s_1", vpkgver);
 | 
					 | 
				
			||||||
			vpkgname = xbps_pkg_name(tmp);
 | 
					 | 
				
			||||||
			free(tmp);
 | 
					 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			vpkgname = xbps_pkg_name(vpkgver);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (vpkgname == NULL)
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		if (bypattern) {
 | 
					 | 
				
			||||||
			if (!xbps_pkgpattern_match(vpkgver, vpkg)) {
 | 
					 | 
				
			||||||
				free(vpkgname);
 | 
					 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			if (strcmp(vpkg, vpkgname)) {
 | 
								if (xbps_pkg_version(vpkg_conf)) {
 | 
				
			||||||
 | 
									char *vpkgname = xbps_pkg_name(vpkg_conf);
 | 
				
			||||||
 | 
									assert(vpkgname);
 | 
				
			||||||
 | 
									if (strcmp(vpkg, vpkgname)) {
 | 
				
			||||||
 | 
										free(vpkgname);
 | 
				
			||||||
 | 
										continue;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
				free(vpkgname);
 | 
									free(vpkgname);
 | 
				
			||||||
				continue;
 | 
								} else {
 | 
				
			||||||
 | 
									/* assume a correct pkgname */
 | 
				
			||||||
 | 
									if (strcmp(vpkg, vpkg_conf)) {
 | 
				
			||||||
 | 
										continue;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
#ifdef FULLDEBUG
 | 
					 | 
				
			||||||
		xbps_dbg_printf(xhp, "matched vpkg `%s' with `%s (provides %s)`\n",
 | 
							xbps_dbg_printf(xhp, "matched vpkg `%s' with `%s (provides %s)`\n",
 | 
				
			||||||
		    vpkg, pkg, vpkgver);
 | 
							    vpkg, pkg, vpkg_conf);
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		free(vpkgname);
 | 
					 | 
				
			||||||
		found = true;
 | 
							found = true;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -258,13 +252,9 @@ xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp,
 | 
				
			|||||||
	xbps_object_iterator_t iter;
 | 
						xbps_object_iterator_t iter;
 | 
				
			||||||
	xbps_dictionary_t pkgd = NULL;
 | 
						xbps_dictionary_t pkgd = NULL;
 | 
				
			||||||
	const char *vpkg;
 | 
						const char *vpkg;
 | 
				
			||||||
	bool bypattern = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (xbps_pkgpattern_version(pkg))
 | 
					 | 
				
			||||||
		bypattern = true;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Try matching vpkg from configuration files */
 | 
						/* Try matching vpkg from configuration files */
 | 
				
			||||||
	vpkg = vpkg_user_conf(xhp, pkg, bypattern);
 | 
						vpkg = vpkg_user_conf(xhp, pkg);
 | 
				
			||||||
	if (vpkg != NULL) {
 | 
						if (vpkg != NULL) {
 | 
				
			||||||
		if (xbps_pkgpattern_version(vpkg))
 | 
							if (xbps_pkgpattern_version(vpkg))
 | 
				
			||||||
			pkgd = match_pkg_by_pattern(d, vpkg);
 | 
								pkgd = match_pkg_by_pattern(d, vpkg);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -123,9 +123,46 @@ vpkg02_body() {
 | 
				
			|||||||
	atf_check_equal $out $exp
 | 
						atf_check_equal $out $exp
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					atf_test_case vpkg03
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					vpkg03_head() {
 | 
				
			||||||
 | 
						atf_set "descr" "Tests for virtual pkgs: provider in configuration file"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					vpkg03_body() {
 | 
				
			||||||
 | 
						mkdir some_repo
 | 
				
			||||||
 | 
						mkdir -p pkg_gawk
 | 
				
			||||||
 | 
						cd some_repo
 | 
				
			||||||
 | 
						xbps-create -A noarch -n gawk-1.0_1 -s "gawk pkg" ../pkg_gawk
 | 
				
			||||||
 | 
						atf_check_equal $? 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						xbps-rindex -d -a $PWD/*.xbps
 | 
				
			||||||
 | 
						atf_check_equal $? 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cd ..
 | 
				
			||||||
 | 
						xbps-install -C empty.conf -r root --repository=$PWD/some_repo -dy gawk
 | 
				
			||||||
 | 
						atf_check_equal $? 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						mkdir -p root/xbps.d
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						echo "virtualpkg=awk:gawk" > root/xbps.d/awk.conf
 | 
				
			||||||
 | 
						out=$(xbps-query -C xbps.d -r root --repository=$PWD/some_repo -ppkgver awk)
 | 
				
			||||||
 | 
						exp="gawk-1.0_1"
 | 
				
			||||||
 | 
						echo "out: $out"
 | 
				
			||||||
 | 
						echo "exp: $exp"
 | 
				
			||||||
 | 
						atf_check_equal $out $exp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						echo "virtualpkg=awk-0_1:gawk" > root/xbps.d/awk.conf
 | 
				
			||||||
 | 
						out=$(xbps-query -C xbps.d -r root --repository=$PWD/some_repo -ppkgver awk)
 | 
				
			||||||
 | 
						exp="gawk-1.0_1"
 | 
				
			||||||
 | 
						echo "out: $out"
 | 
				
			||||||
 | 
						echo "exp: $exp"
 | 
				
			||||||
 | 
						atf_check_equal $out $exp
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
atf_init_test_cases() {
 | 
					atf_init_test_cases() {
 | 
				
			||||||
	atf_add_test_case vpkg00
 | 
						atf_add_test_case vpkg00
 | 
				
			||||||
	atf_add_test_case vpkg01
 | 
						atf_add_test_case vpkg01
 | 
				
			||||||
	atf_add_test_case vpkg02
 | 
						atf_add_test_case vpkg02
 | 
				
			||||||
 | 
						atf_add_test_case vpkg03
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user