Get rid of system virtualpkg.d support (<prefix>/share/xbps/virtualpkg.d).

Binary packages do not need to provide those virtualpkg configuration files
anymore; all vpkg info is now collected from pkgdb.
This commit is contained in:
Juan RP 2014-11-04 11:17:27 +01:00
parent 59781f4e91
commit 595136704e
6 changed files with 79 additions and 21 deletions

5
NEWS
View File

@ -1,5 +1,10 @@
xbps-0.42 (???):
* Get rid of system virtualpkg.d configuration files stored at
<prefix>/share/xbps/virtualpkg.d) and collect all virtual packages
directly from pkgdb. Virtual package overrides can still be defined
at <sysconfdir>/xbps/virtualpkg.d.
* xbps-{install,remove}: implemented a column/wide output mode
as requested in #63 (https://github.com/voidlinux/xbps/issues/63).
If the terminal has enough columns it will use this and falling back

View File

@ -48,7 +48,7 @@
*
* This header documents the full API for the XBPS Library.
*/
#define XBPS_API_VERSION "20141024"
#define XBPS_API_VERSION "20141104"
#ifndef XBPS_VERSION
#define XBPS_VERSION "UNSET"
@ -94,12 +94,6 @@
*/
#define XBPS_VPKG_PATH XBPS_SYSCONF_PATH "/virtualpkg.d"
/**
* @def XBPS_SYS_VPKG_PATH
* System virtualpkg PATH to store virtualpkg configuration files.
*/
#define XBPS_SYS_VPKG_PATH XBPS_SYSDEFCONF_PATH "/virtualpkg.d"
/**
* @def XBPS_REPOD_PATH
* Configuration directory to store repository configuration files.

View File

@ -298,6 +298,8 @@ parse_dir(struct xbps_handle *xhp, const char *cwd, const char *dir, const char
char *ext, ldir[PATH_MAX], conf[PATH_MAX];
int i, n, rv = 0;
if (dir == NULL)
goto stage2;
/*
* Read all configuration files stored in the system
* foo.d directory.
@ -344,6 +346,9 @@ parse_dir(struct xbps_handle *xhp, const char *cwd, const char *dir, const char
return rv;
stage2:
if (confdir == NULL)
return rv;
/*
* Read all configuration files stored in the configuration foo.d directory.
*/
@ -443,7 +448,7 @@ xbps_init(struct xbps_handle *xhp)
free(buf);
}
/* process virtualpkg.d dirs */
if ((rv = parse_dir(xhp, cwd, XBPS_SYS_VPKG_PATH, XBPS_VPKG_PATH, true)) != 0)
if ((rv = parse_dir(xhp, cwd, NULL, XBPS_VPKG_PATH, true)) != 0)
return rv;
/* process repo.d dirs */

View File

@ -116,6 +116,59 @@ xbps_pkgdb_unlock(struct xbps_handle *xhp)
pkgdb_fd = -1;
}
static int
pkgdb_map_vpkgs(struct xbps_handle *xhp)
{
xbps_object_iterator_t iter;
xbps_object_t obj;
int rv = 0;
if (!xbps_dictionary_count(xhp->pkgdb))
return 0;
if (xhp->vpkgd == NULL) {
xhp->vpkgd = xbps_dictionary_create();
assert(xhp->vpkgd);
}
/*
* This maps all pkgs that have virtualpkgs in pkgdb.
*/
iter = xbps_dictionary_iterator(xhp->pkgdb);
assert(iter);
while ((obj = xbps_object_iterator_next(iter))) {
xbps_array_t provides;
xbps_dictionary_t pkgd;
const char *pkgver;
char *pkgname;
pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj);
provides = xbps_dictionary_get(pkgd, "provides");
if (provides == NULL)
continue;
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
pkgname = xbps_pkg_name(pkgver);
for (unsigned int i = 0; i < xbps_array_count(provides); i++) {
const char *vpkg;
xbps_array_get_cstring_nocopy(provides, i, &vpkg);
if (!xbps_dictionary_set_cstring(xhp->vpkgd, vpkg, pkgname)) {
xbps_dbg_printf(xhp, "%s: set_cstring vpkg "
"%s pkgname %s\n", __func__, vpkg, pkgname);
rv = EINVAL;
} else {
xbps_dbg_printf(xhp, "[pkgdb] added vpkg %s for %s\n",
vpkg, pkgname);
}
}
free(pkgname);
}
xbps_object_iterator_release(iter);
return rv;
}
int HIDDEN
xbps_pkgdb_init(struct xbps_handle *xhp)
{
@ -139,6 +192,10 @@ xbps_pkgdb_init(struct xbps_handle *xhp)
return rv;
}
if ((rv = pkgdb_map_vpkgs(xhp)) != 0) {
xbps_dbg_printf(xhp, "[pkgdb] pkgdb_map_vpkgs %s\n", strerror(rv));
return rv;
}
xbps_dbg_printf(xhp, "[pkgdb] initialized ok.\n");
return 0;
@ -252,30 +309,33 @@ xbps_pkgdb_get_virtualpkg(struct xbps_handle *xhp, const char *vpkg)
static void
generate_full_revdeps_tree(struct xbps_handle *xhp)
{
xbps_array_t rundeps, pkg;
xbps_dictionary_t pkgd;
xbps_object_t obj;
xbps_object_iterator_t iter;
const char *pkgver, *pkgdep, *vpkgname;
char *curpkgname;
bool alloc;
if (xhp->pkgdb_revdeps)
return;
xhp->pkgdb_revdeps = xbps_dictionary_create();
assert(xhp->pkgdb_revdeps);
iter = xbps_dictionary_iterator(xhp->pkgdb);
assert(iter);
while ((obj = xbps_object_iterator_next(iter))) {
xbps_array_t rundeps;
xbps_dictionary_t pkgd;
pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj);
rundeps = xbps_dictionary_get(pkgd, "run_depends");
if (!xbps_array_count(rundeps))
continue;
for (unsigned int i = 0; i < xbps_array_count(rundeps); i++) {
alloc = false;
xbps_array_t pkg;
const char *pkgdep, *pkgver, *vpkgname;
char *curpkgname;
bool alloc = false;
xbps_array_get_cstring_nocopy(rundeps, i, &pkgdep);
curpkgname = xbps_pkgpattern_name(pkgdep);
if (curpkgname == NULL)

View File

@ -134,7 +134,7 @@ ATF_TC_BODY(pkgdb_get_pkg_revdeps_test, tc)
xh.flags = XBPS_FLAG_DEBUG;
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
res = xbps_pkgdb_get_pkg_revdeps(&xh, "mixed");
res = xbps_pkgdb_get_pkg_revdeps(&xh, "virtual-mixed");
ATF_REQUIRE_EQ(xbps_object_type(res), XBPS_TYPE_ARRAY);
pstr = xbps_string_create();

View File

@ -51,8 +51,6 @@ vpkg01_head() {
vpkg01_body() {
mkdir some_repo
mkdir -p pkg_{A,B,C,D}/usr/bin
mkdir -p pkg_C/usr/share/xbps/virtualpkg.d
echo "virtualpkg=A-1.0_1:C" > pkg_C/usr/share/xbps/virtualpkg.d/C.conf
cd some_repo
xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A
atf_check_equal $? 0
@ -103,13 +101,9 @@ vpkg02_body() {
cd some_repo
mkdir -p pkg_gawk/usr/share/xbps/virtualpkg.d
echo "virtualpkg=awk-1.0_1:gawk" > pkg_gawk/usr/share/xbps/virtualpkg.d/gawk.conf
xbps-create -A noarch -n gawk-1.1_1 -s "gawk pkg" --provides "awk-1.0_1" --replaces "awk>=0" ../pkg_gawk
atf_check_equal $? 0
mkdir -p pkg_busybox/usr/share/xbps/virtualpkg.d
echo "virtualpkg=awk-1.0_1:busybox" > pkg_busybox/usr/share/xbps/virtualpkg.d/busybox.conf
xbps-create -A noarch -n busybox-1.0_1 -s "busybox awk" --provides "awk-1.0_1" --replaces "awk>=0" ../pkg_busybox
atf_check_equal $? 0