Added support for system/config virtualpkg.d directories.
The system virtualpkg directory set to <rootdir>/usr/share/xbps/virtualpkg.d contains virtualpkg configuration files (.conf/.vpkg) that can be overrided by the admin in <rootdir>/etc/xbps/virtualpkg.d bearing the same file name. This obsoletes the "virtualpkgdir" keyword support from the xbps configuration file.
This commit is contained in:
parent
387987b146
commit
776865b548
14
NEWS
14
NEWS
@ -1,11 +1,19 @@
|
||||
xbps-0.37 (???):
|
||||
|
||||
* Added support for system and configuration virtualpkg directories.
|
||||
|
||||
The system virtualpkg directory set to <rootdir>/usr/share/xbps/virtualpkg.d contains
|
||||
virtualpkg configuration files (.conf/.vpkg) that can be overrided by the admin
|
||||
in <rootdir>/etc/xbps/virtualpkg.d bearing the same file name.
|
||||
|
||||
This obsoletes the "virtualpkgdir" keyword support from the xbps configuration file.
|
||||
|
||||
* Added support for system and configuration repository directories, as
|
||||
explained in GH #39 (https://github.com/voidlinux/xbps/issues/39).
|
||||
|
||||
The system repository directory set to <prefix>/share/xbps/repo.d contains
|
||||
system repository configuration files (.conf) that can be overrided by the admin
|
||||
in <sysconfdir>/xbps/repo.d bearing the same file name.
|
||||
The system repository directory set to <rootdir>/usr/share/xbps/repo.d contains
|
||||
repository configuration files (.conf) that can be overrided by the admin
|
||||
in <rootdir>/etc/xbps/repo.d bearing the same file name.
|
||||
|
||||
* xbps-create(8): new option `-t, --tags` to specify a list of tags
|
||||
(categories) the package should be part of. This is just for metadata
|
||||
|
@ -60,16 +60,15 @@ syslog=true
|
||||
# separated by a dash, i.e 'foo-1.0_1".
|
||||
# - <realpkgname> means a real package name (without any version).
|
||||
#
|
||||
# The system virtualpkg directory is set to <rootdir>/usr/share/xbps/virtualpkg.d.
|
||||
# The configuration virtualpkg directory is set to <rootdir>/etc/xbps/virtualpkg.d.
|
||||
#
|
||||
# Files bearing the same name in the configuration directory override the
|
||||
# ones from the system directory.
|
||||
#
|
||||
# By default we prefer the `dcron` package as default cron daemon.
|
||||
virtualpkg=cron-daemon-0_1:dcron
|
||||
|
||||
# Sets the virtual package directory looking for .vpkg files with
|
||||
# virtual package settings (by using the `virtualpkg' keyword).
|
||||
#
|
||||
# If starts with / it's an absolute path, otherwise it's relative to rootdir.
|
||||
# By default it's set to <rootdir>/etc/xbps/virtualpkg.d.
|
||||
#virtualpkgdir=etc/xbps/virtualpkg.d
|
||||
|
||||
# You can also include additional files by using the "include" keyword.
|
||||
# This expects an absolute path to a file.
|
||||
#include=/path/to/another/file.conf
|
||||
|
@ -48,7 +48,7 @@
|
||||
*
|
||||
* This header documents the full API for the XBPS Library.
|
||||
*/
|
||||
#define XBPS_API_VERSION "20140530"
|
||||
#define XBPS_API_VERSION "20140531"
|
||||
|
||||
#ifndef XBPS_VERSION
|
||||
#define XBPS_VERSION "UNSET"
|
||||
@ -578,14 +578,6 @@ struct xbps_handle {
|
||||
* If unset, defaults to \a XBPS_CACHE_PATH (relative to rootdir).
|
||||
*/
|
||||
char metadir[XBPS_MAXPATH-1];
|
||||
/**
|
||||
* @var virtualpkgdir
|
||||
*
|
||||
* Virtual packages directory, with configuration files to override
|
||||
* system virtual packages.
|
||||
* If unset, defaults to \a XBPS_VPKG_PATH (relative to rootdir).
|
||||
*/
|
||||
char virtualpkgdir[XBPS_MAXPATH-1];
|
||||
/**
|
||||
* @var native_arch
|
||||
*
|
||||
|
@ -122,7 +122,6 @@ parse_option(char *buf, char **k, char **v)
|
||||
"cachedir",
|
||||
"syslog",
|
||||
"repository",
|
||||
"virtualpkgdir",
|
||||
"virtualpkg",
|
||||
"include"
|
||||
};
|
||||
@ -233,10 +232,6 @@ parse_file(struct xbps_handle *xhp, const char *path, bool nested, bool vpkgconf
|
||||
xbps_dbg_printf(xhp, "%s: cachedir set to %s\n",
|
||||
path, v);
|
||||
snprintf(xhp->cachedir, sizeof(xhp->cachedir), "%s", v);
|
||||
} else if (strcmp(k, "virtualpkgdir") == 0) {
|
||||
xbps_dbg_printf(xhp, "%s: virtualpkgdir set to %s\n",
|
||||
path, v);
|
||||
snprintf(xhp->virtualpkgdir, sizeof(xhp->virtualpkgdir), "%s", v);
|
||||
} else if (strcmp(k, "syslog") == 0) {
|
||||
if (strcasecmp(v, "true") == 0) {
|
||||
xhp->syslog = true;
|
||||
@ -277,33 +272,76 @@ parse_vpkgdir(struct xbps_handle *xhp)
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
char *ext;
|
||||
char *ext, vpkgdir[PATH_MAX], conf[PATH_MAX];
|
||||
int rv = 0;
|
||||
|
||||
if ((dirp = opendir(xhp->virtualpkgdir)) == NULL)
|
||||
return 0;
|
||||
|
||||
xbps_dbg_printf(xhp, "Processing virtualpkg directory: %s\n", xhp->virtualpkgdir);
|
||||
/*
|
||||
* Read all vpkg configuration files stored in the system
|
||||
* virtualpkg.d directory.
|
||||
*/
|
||||
snprintf(vpkgdir, sizeof(vpkgdir), "%s/%s",
|
||||
strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", XBPS_SYS_VPKG_PATH);
|
||||
xbps_dbg_printf(xhp, "Processing system virtualpkg.d directory: %s\n", vpkgdir);
|
||||
if ((dirp = opendir(vpkgdir)) == NULL)
|
||||
goto stage2;
|
||||
|
||||
while ((dp = readdir(dirp)) != NULL) {
|
||||
if ((strcmp(dp->d_name, "..") == 0) ||
|
||||
(strcmp(dp->d_name, ".") == 0))
|
||||
continue;
|
||||
/* only process .vpkg files, ignore something else */
|
||||
/* only process .vpkg/.conf files, ignore something else */
|
||||
if ((ext = strrchr(dp->d_name, '.')) == NULL)
|
||||
continue;
|
||||
if (strcmp(ext, ".vpkg") == 0) {
|
||||
char *path;
|
||||
|
||||
path = xbps_xasprintf("%s/%s", xhp->virtualpkgdir, dp->d_name);
|
||||
if ((rv = parse_file(xhp, path, false, true)) != 0) {
|
||||
free(path);
|
||||
break;
|
||||
if (strcmp(ext, ".conf") && strcmp(ext, ".vpkg")) {
|
||||
xbps_dbg_printf(xhp, "%s: ignoring %s\n", vpkgdir, dp->d_name);
|
||||
continue;
|
||||
}
|
||||
free(path);
|
||||
/* if the same file exists in configuration directory, ignore it */
|
||||
snprintf(conf, sizeof(conf), "%s/%s/%s", xhp->rootdir, XBPS_VPKG_PATH, dp->d_name);
|
||||
if (access(conf, R_OK) == 0) {
|
||||
xbps_dbg_printf(xhp, "%s: ignoring %s (exists in confdir)\n", vpkgdir, dp->d_name);
|
||||
continue;
|
||||
}
|
||||
/* parse vpkg conf file */
|
||||
snprintf(conf, sizeof(conf), "%s/%s", vpkgdir, dp->d_name);
|
||||
if ((rv = parse_file(xhp, conf, false, true)) != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
closedir(dirp);
|
||||
if (rv != 0)
|
||||
return rv;
|
||||
|
||||
stage2:
|
||||
/*
|
||||
* Read all vpkg configuration files stored in the configuration
|
||||
* virtualpkg.d directory.
|
||||
*/
|
||||
snprintf(vpkgdir, sizeof(vpkgdir), "%s%s",
|
||||
strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", XBPS_VPKG_PATH);
|
||||
xbps_dbg_printf(xhp, "Processing configuration virtualpkg.d directory: %s\n", vpkgdir);
|
||||
if ((dirp = opendir(vpkgdir)) == NULL)
|
||||
return 0;
|
||||
|
||||
while ((dp = readdir(dirp)) != NULL) {
|
||||
if ((strcmp(dp->d_name, "..") == 0) ||
|
||||
(strcmp(dp->d_name, ".") == 0))
|
||||
continue;
|
||||
/* only process .vpkg/.conf files, ignore something else */
|
||||
if ((ext = strrchr(dp->d_name, '.')) == NULL)
|
||||
continue;
|
||||
if (strcmp(ext, ".conf") && strcmp(ext, ".vpkg")) {
|
||||
xbps_dbg_printf(xhp, "%s: ignoring %s\n", vpkgdir, dp->d_name);
|
||||
continue;
|
||||
}
|
||||
/* parse vpkg conf file */
|
||||
snprintf(conf, sizeof(conf), "%s/%s", vpkgdir, dp->d_name);
|
||||
if ((rv = parse_file(xhp, conf, false, true)) != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
closedir(dirp);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -361,7 +399,7 @@ stage2:
|
||||
snprintf(repodir, sizeof(repodir), "%s%s",
|
||||
strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", XBPS_REPOD_PATH);
|
||||
xbps_dbg_printf(xhp, "Processing configuration repo.d directory: %s\n", repodir);
|
||||
if ((dirp = opendir(XBPS_REPOD_PATH)) == NULL)
|
||||
if ((dirp = opendir(repodir)) == NULL)
|
||||
return 0;
|
||||
|
||||
while ((dp = readdir(dirp)) != NULL) {
|
||||
@ -446,23 +484,11 @@ xbps_init(struct xbps_handle *xhp)
|
||||
"%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", buf);
|
||||
free(buf);
|
||||
}
|
||||
/* Set virtualpkgdir */
|
||||
if (xhp->virtualpkgdir[0] == '\0') {
|
||||
snprintf(xhp->virtualpkgdir, sizeof(xhp->virtualpkgdir),
|
||||
"%s%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "",
|
||||
XBPS_VPKG_PATH);
|
||||
} else if (xhp->virtualpkgdir[0] != '/') {
|
||||
/* relative path */
|
||||
buf = strdup(xhp->virtualpkgdir);
|
||||
snprintf(xhp->virtualpkgdir, sizeof(xhp->virtualpkgdir),
|
||||
"%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", buf);
|
||||
free(buf);
|
||||
}
|
||||
/* parse virtualpkg */
|
||||
/* process virtualpkg.d dirs */
|
||||
if ((rv = parse_vpkgdir(xhp)))
|
||||
return rv;
|
||||
|
||||
/* parse repodirs */
|
||||
/* process repo.d dirs */
|
||||
if ((rv = parse_repodir(xhp)) != 0)
|
||||
return rv;
|
||||
|
||||
@ -480,7 +506,6 @@ xbps_init(struct xbps_handle *xhp)
|
||||
xbps_dbg_printf(xhp, "rootdir=%s\n", xhp->rootdir);
|
||||
xbps_dbg_printf(xhp, "metadir=%s\n", xhp->metadir);
|
||||
xbps_dbg_printf(xhp, "cachedir=%s\n", xhp->cachedir);
|
||||
xbps_dbg_printf(xhp, "virtualpkgdir=%s\n", xhp->virtualpkgdir);
|
||||
xbps_dbg_printf(xhp, "syslog=%s\n", xhp->syslog ? "true" : "false");
|
||||
xbps_dbg_printf(xhp, "Architecture: %s\n", xhp->native_arch);
|
||||
xbps_dbg_printf(xhp, "Target Architecture: %s\n", xhp->target_arch);
|
||||
|
Loading…
Reference in New Issue
Block a user