libxbps: added support to "inject" vpkg config files at initialization time.
This commit is contained in:
parent
4f9ff2746e
commit
a311294f0a
7
NEWS
7
NEWS
@ -1,5 +1,12 @@
|
||||
xbps-0.18 (???):
|
||||
|
||||
* The virtual package configuration files are now read dynamically
|
||||
by libxbps at initialization time from default configuration directory:
|
||||
<rootdir>/etc/xbps/virtualpkg.d. Only files that end in ".conf" will
|
||||
be processed by libxbps.
|
||||
|
||||
* The rootdir (with -r, --rootdir) can now be specified as relative path.
|
||||
|
||||
* Structured pkg metadata stored on disk, and added new functionality:
|
||||
|
||||
- A single plist containing pkg properties, files and
|
||||
|
@ -56,7 +56,7 @@
|
||||
*/
|
||||
#define XBPS_PKGINDEX_VERSION "1.5"
|
||||
|
||||
#define XBPS_API_VERSION "20121119"
|
||||
#define XBPS_API_VERSION "20121119-1"
|
||||
|
||||
#ifndef XBPS_VERSION
|
||||
#define XBPS_VERSION "UNSET"
|
||||
|
@ -23,12 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#include "xbps_api_impl.h"
|
||||
|
||||
@ -69,6 +71,51 @@ set_metadir(struct xbps_handle *xh)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
config_inject_vpkgs(struct xbps_handle *xh)
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
char *ext, *vpkgdir;
|
||||
FILE *fp;
|
||||
|
||||
if (strcmp(xh->rootdir, "/"))
|
||||
vpkgdir = xbps_xasprintf("%s/etc/xbps/virtualpkg.d",
|
||||
xh->rootdir);
|
||||
else
|
||||
vpkgdir = strdup("/etc/xbps/virtualpkg.d");
|
||||
|
||||
if ((dirp = opendir(vpkgdir)) == NULL) {
|
||||
xbps_dbg_printf(xh, "config: failed to open %s: %s\n",
|
||||
vpkgdir, strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
while ((dp = readdir(dirp)) != NULL) {
|
||||
if ((strcmp(dp->d_name, "..") == 0) ||
|
||||
(strcmp(dp->d_name, ".") == 0))
|
||||
continue;
|
||||
/* only process .conf files, ignore something else */
|
||||
if ((ext = strrchr(dp->d_name, '.')) == NULL)
|
||||
continue;
|
||||
if (strcmp(ext, ".conf") == 0) {
|
||||
char *path;
|
||||
|
||||
path = xbps_xasprintf("%s/%s", vpkgdir, dp->d_name);
|
||||
fp = fopen(path, "r");
|
||||
assert(fp);
|
||||
free(path);
|
||||
if (cfg_parse_fp(xh->cfg, fp) != 0) {
|
||||
xbps_error_printf("Failed to parse "
|
||||
"vpkg conf file %s:\n", dp->d_name);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
closedir(dirp);
|
||||
free(vpkgdir);
|
||||
}
|
||||
|
||||
static int
|
||||
cb_validate_virtual(cfg_t *cfg, cfg_opt_t *opt)
|
||||
{
|
||||
@ -156,6 +203,7 @@ xbps_init(struct xbps_handle *xhp)
|
||||
return ENOTSUP;
|
||||
}
|
||||
}
|
||||
|
||||
xbps_dbg_printf(xhp, "Configuration file: %s\n",
|
||||
xhp->conffile ? xhp->conffile : "not found");
|
||||
/*
|
||||
@ -216,6 +264,9 @@ xbps_init(struct xbps_handle *xhp)
|
||||
if (xhp->flags & XBPS_FLAG_SYSLOG)
|
||||
syslog_enabled = true;
|
||||
|
||||
/* Inject virtual packages from virtualpkg.d files */
|
||||
config_inject_vpkgs(xhp);
|
||||
|
||||
xbps_fetch_set_cache_connection(cc, cch);
|
||||
|
||||
xbps_dbg_printf(xhp, "Rootdir=%s\n", xhp->rootdir);
|
||||
|
Loading…
Reference in New Issue
Block a user