Fixed a regression in vpkgs and improve xbps.d(5) virtualpkg declarations.

See the NEWS file for more information.
This commit is contained in:
Juan RP 2014-12-31 08:51:45 +01:00
parent a1be41fac5
commit eee895c6d8
6 changed files with 84 additions and 46 deletions

10
NEWS
View File

@ -1,5 +1,15 @@
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,
and fallback to -fstack-protector-all otherwise.

View File

@ -1,4 +1,4 @@
.Dd December 23, 2014
.Dd December 30, 2014
.Dt XBPS-D 5
.Sh NAME
.Nm xbps.d
@ -84,12 +84,12 @@ archive is expected, example:
Sets the default root directory.
.It Sy syslog=true|false
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
components delimited by a colon, example:
.Pp
.Bl -tag -compact -width virtualpkg=cron-daemon-1.0_1:dcron
.It Sy virtualpkg=cron-daemon-1.0_1:dcron
.Bl -tag -compact -width virtualpkg=cron-daemon:dcron
.It Sy virtualpkg=cron-daemon:dcron
Any request to the
.Ar cron-daemon
virtual package will be resolved to the
@ -98,9 +98,10 @@ real package.
.El
.Pp
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
.Em package name .
.Em package name
to match the real package.
.El
.Sh ENVIRONMENT
.Bl -tag -width XBPS_TARGET_ARCH

View File

@ -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 *);
xbps_dictionary_t HIDDEN xbps_archive_get_dictionary(struct archive *,
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 *,
const char *, bool);

View File

@ -212,7 +212,7 @@ xbps_pkgdb_update(struct xbps_handle *xhp, bool flush)
return cached_rv;
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 ||
!xbps_dictionary_equals(xhp->pkgdb, pkgdb_storage)) {
/* flush dictionary to storage */
@ -227,7 +227,7 @@ xbps_pkgdb_update(struct xbps_handle *xhp, bool flush)
cached_rv = 0;
}
/* 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)
xhp->pkgdb = xbps_dictionary_create();
else
@ -341,7 +341,7 @@ generate_full_revdeps_tree(struct xbps_handle *xhp)
if (curpkgname == NULL)
curpkgname = xbps_pkg_name(pkgdep);
assert(curpkgname);
vpkgname = vpkg_user_conf(xhp, curpkgname, false);
vpkgname = vpkg_user_conf(xhp, curpkgname);
if (vpkgname == NULL)
vpkgname = curpkgname;

View File

@ -121,16 +121,12 @@ xbps_find_virtualpkg_in_array(struct xbps_handle *x,
{
xbps_dictionary_t pkgd;
const char *vpkg;
bool bypattern = false;
assert(x);
assert(xbps_object_type(a) == XBPS_TYPE_ARRAY);
assert(s);
if (xbps_pkgpattern_version(s))
bypattern = true;
if ((vpkg = vpkg_user_conf(x, s, bypattern))) {
if ((vpkg = vpkg_user_conf(x, s))) {
if ((pkgd = get_pkg_in_array(a, vpkg, trans, true)))
return pkgd;
}
@ -193,17 +189,16 @@ match_pkg_by_pattern(xbps_dictionary_t repod, const char *p)
}
const char HIDDEN *
vpkg_user_conf(struct xbps_handle *xhp,
const char *vpkg,
bool bypattern)
vpkg_user_conf(struct xbps_handle *xhp, const char *vpkg)
{
xbps_object_t obj;
xbps_object_iterator_t iter;
xbps_string_t rpkg;
const char *vpkgver, *pkg = NULL;
char *vpkgname = NULL, *tmp;
const char *pkg = NULL;
bool found = false;
/* init pkgdb just in case to detect vpkgs */
(void)xbps_pkgdb_init(xhp);
if (xhp->vpkgd == NULL)
return NULL;
@ -211,36 +206,35 @@ vpkg_user_conf(struct xbps_handle *xhp,
assert(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);
pkg = xbps_string_cstring_nocopy(rpkg);
tmp = NULL;
if (strchr(vpkgver, '_') == NULL) {
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);
if (xbps_pkgpattern_version(vpkg_conf)) {
if (!xbps_pkgpattern_match(vpkg_conf, vpkg)) {
continue;
}
} 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);
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",
vpkg, pkg, vpkgver);
#endif
free(vpkgname);
vpkg, pkg, vpkg_conf);
found = true;
break;
}
@ -258,13 +252,9 @@ xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp,
xbps_object_iterator_t iter;
xbps_dictionary_t pkgd = NULL;
const char *vpkg;
bool bypattern = false;
if (xbps_pkgpattern_version(pkg))
bypattern = true;
/* Try matching vpkg from configuration files */
vpkg = vpkg_user_conf(xhp, pkg, bypattern);
vpkg = vpkg_user_conf(xhp, pkg);
if (vpkg != NULL) {
if (xbps_pkgpattern_version(vpkg))
pkgd = match_pkg_by_pattern(d, vpkg);

View File

@ -123,9 +123,46 @@ vpkg02_body() {
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_add_test_case vpkg00
atf_add_test_case vpkg01
atf_add_test_case vpkg02
atf_add_test_case vpkg03
}