New configuration scheme changes, round 2 (virtual pkgs).
- XBPS now expects to read individual virtual pkg settings from .plist files in PREFIX/etc/xbps/virtualpkg.d.wants. This really implements the missing part in issue #12 in googlecode: http://code.google.com/p/xbps/issues/detail?id=12
This commit is contained in:
parent
5642ffa86e
commit
08f7169eff
13
NEWS
13
NEWS
@ -1,5 +1,18 @@
|
||||
xbps-0.10.0 (???):
|
||||
|
||||
* New configuration scheme for virtual packages as defined in
|
||||
http://code.google.com/p/xbps/issues/detail?id=12
|
||||
|
||||
XBPS now reads all plist files in PREFIX/etc/xbps/virtualpkg.d.wants
|
||||
directory with settings for the wanted virtual packages.
|
||||
|
||||
* New configuration scheme as defined in
|
||||
http://code.google.com/p/xbps/issues/detail?id=12
|
||||
|
||||
A directory to store XBPS configuration files is now used, by default
|
||||
set to PREFIX/etc/xbps. Configuration options are now set via
|
||||
conf.plist, and repositories in repositories.plist.
|
||||
|
||||
* It is possible now to reinstall packages that provide virtual packages
|
||||
and put it back the original package, such as jpeg <-> libjpeg-turbo
|
||||
multiple times, without loosing important objects set when the
|
||||
|
@ -55,7 +55,7 @@
|
||||
*/
|
||||
#define XBPS_PKGINDEX_VERSION "1.2"
|
||||
|
||||
#define XBPS_API_VERSION "20111017"
|
||||
#define XBPS_API_VERSION "20111017-1"
|
||||
#define XBPS_VERSION "0.10.0"
|
||||
|
||||
/**
|
||||
@ -388,7 +388,7 @@ struct xbps_handle {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
prop_dictionary_t virtualpkg_dictionary;
|
||||
prop_array_t virtualpkgs_array;
|
||||
/**
|
||||
* @private repos_array
|
||||
*
|
||||
|
@ -198,6 +198,11 @@ prop_dictionary_t HIDDEN
|
||||
xbps_find_virtualpkg_conf_in_dict_by_pattern(prop_dictionary_t,
|
||||
const char *,
|
||||
const char *);
|
||||
/**
|
||||
* @private
|
||||
* From lib/init_virtual_pkgs.c
|
||||
*/
|
||||
void HIDDEN xbps_init_virtual_pkgs(struct xbps_handle *);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@ -45,7 +45,7 @@ OBJS += transaction_dictionary.o transaction_sortdeps.o
|
||||
OBJS += download.o fexec.o humanize_number.o plist.o
|
||||
OBJS += plist_archive_entry.o plist_find.o plist_match.o plist_remove.o
|
||||
OBJS += plist_fetch.o util.o util_hash.o mkpath.o initend.o
|
||||
OBJS += regpkgdb_dictionary.o match.o dewey.o
|
||||
OBJS += regpkgdb_dictionary.o match.o dewey.o init_virtualpkgs.o
|
||||
OBJS += repository_findpkg.o repository_finddeps.o
|
||||
OBJS += repository_pool.o repository_pool_find.o repository_sync_index.o
|
||||
OBJS += $(COMPAT_SRCS)
|
||||
|
99
lib/init_virtualpkgs.c
Normal file
99
lib/init_virtualpkgs.c
Normal file
@ -0,0 +1,99 @@
|
||||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#define _VPKGDIR XBPS_SYSCONF_PATH "/" XBPS_VIRTUALPKGD_PATH
|
||||
|
||||
void HIDDEN
|
||||
xbps_init_virtual_pkgs(struct xbps_handle *xh)
|
||||
{
|
||||
struct dirent *dp;
|
||||
DIR *dirp;
|
||||
prop_dictionary_t vpkgd;
|
||||
char *vpkgfile;
|
||||
|
||||
/*
|
||||
* Internalize all plist files from _VPKGDIR and add them
|
||||
* into xhp->virtualpkgs_array.
|
||||
*/
|
||||
dirp = opendir(_VPKGDIR);
|
||||
if (dirp == NULL) {
|
||||
xbps_dbg_printf("%s: cannot access to %s for virtual "
|
||||
"packages: %s\n", __func__, _VPKGDIR,
|
||||
strerror(errno));
|
||||
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", _VPKGDIR, dp->d_name);
|
||||
if (vpkgfile == NULL) {
|
||||
(void)closedir(dirp);
|
||||
xbps_dbg_printf("%s: failed to alloc mem for %s\n",
|
||||
__func__, dp->d_name);
|
||||
continue;
|
||||
}
|
||||
vpkgd = prop_dictionary_internalize_from_file(vpkgfile);
|
||||
free(vpkgfile);
|
||||
|
||||
if (vpkgd == NULL) {
|
||||
xbps_dbg_printf("%s: failed to internalize %s: %s\n",
|
||||
__func__, dp->d_name, strerror(errno));
|
||||
(void)closedir(dirp);
|
||||
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("%s: failed to add %s virtualpkg "
|
||||
"dictionary!\n", __func__, dp->d_name);
|
||||
prop_object_release(vpkgd);
|
||||
(void)closedir(dirp);
|
||||
continue;
|
||||
}
|
||||
xbps_dbg_printf("%s: added virtualpkg from: %s\n",
|
||||
__func__, dp->d_name);
|
||||
}
|
||||
(void)closedir(dirp);
|
||||
}
|
@ -164,6 +164,9 @@ xbps_init(struct xbps_handle *xh)
|
||||
if (prop_object_type(xh->conffile) == PROP_TYPE_STRING)
|
||||
prop_object_release(xh->conffile);
|
||||
|
||||
/* Initialize virtual package settings */
|
||||
xbps_init_virtual_pkgs(xhp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -180,6 +183,8 @@ xbps_end(struct xbps_handle *xh)
|
||||
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->xfcd != NULL)
|
||||
free(xh->xfcd);
|
||||
if (xh->xucd != NULL)
|
||||
|
@ -127,11 +127,10 @@ find_virtualpkg_user_in_conf(const char *vpkg, bool bypattern)
|
||||
char *vpkgname = NULL;
|
||||
|
||||
xhp = xbps_handle_get();
|
||||
if (xhp->virtualpkg_dictionary == NULL)
|
||||
if (prop_object_type(xhp->virtualpkgs_array) != PROP_TYPE_ARRAY)
|
||||
return NULL;
|
||||
|
||||
if ((iter = xbps_array_iter_from_dict(xhp->virtualpkg_dictionary,
|
||||
"virtual-packages")) == NULL)
|
||||
if ((iter = prop_array_iterator(xhp->virtualpkgs_array)) == NULL)
|
||||
return NULL;
|
||||
|
||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user