New configuration schemas changes, round 3.

struct xbps_handle::conffile has been renamed to confdir, and it now
expects the path to a directory, where the configuration files are
stored.

Change xbps-bin(8) and xbps-repo(8) along with its manpages to mention
that -C expects a directory.
This commit is contained in:
Juan RP
2011-10-17 15:11:54 +02:00
parent c285afebdc
commit 931a03b806
9 changed files with 94 additions and 46 deletions

4
NEWS
View File

@ -1,5 +1,9 @@
xbps-0.10.0 (???): xbps-0.10.0 (???):
* xbps-bin(8), xbps-repo(8): the -C flag now expects a path to a
directory where the configuration files (conf.plist and
repositories.plist) are stored.
* New configuration scheme for virtual packages as defined in * New configuration scheme for virtual packages as defined in
http://code.google.com/p/xbps/issues/detail?id=12 http://code.google.com/p/xbps/issues/detail?id=12

View File

@ -185,12 +185,12 @@ main(int argc, char **argv)
struct xferstat xfer; struct xferstat xfer;
struct list_pkgver_cb lpc; struct list_pkgver_cb lpc;
struct sigaction sa; struct sigaction sa;
const char *rootdir, *cachedir, *conffile; const char *rootdir, *cachedir, *confdir;
int i , c, flags, rv; int i , c, flags, rv;
bool yes, purge, debug, force_rm_with_deps, recursive_rm; bool yes, purge, debug, force_rm_with_deps, recursive_rm;
bool install_auto, install_manual, show_download_pkglist_url; bool install_auto, install_manual, show_download_pkglist_url;
rootdir = cachedir = conffile = NULL; rootdir = cachedir = confdir = NULL;
flags = rv = 0; flags = rv = 0;
yes = purge = force_rm_with_deps = recursive_rm = debug = false; yes = purge = force_rm_with_deps = recursive_rm = debug = false;
install_auto = install_manual = show_download_pkglist_url = false; install_auto = install_manual = show_download_pkglist_url = false;
@ -201,7 +201,7 @@ main(int argc, char **argv)
install_auto = true; install_auto = true;
break; break;
case 'C': case 'C':
conffile = optarg; confdir = optarg;
break; break;
case 'c': case 'c':
cachedir = optarg; cachedir = optarg;
@ -290,8 +290,8 @@ main(int argc, char **argv)
xhp->rootdir = prop_string_create_cstring(rootdir); xhp->rootdir = prop_string_create_cstring(rootdir);
if (cachedir) if (cachedir)
xhp->cachedir = prop_string_create_cstring(cachedir); xhp->cachedir = prop_string_create_cstring(cachedir);
if (conffile) if (confdir)
xhp->conffile = prop_string_create_cstring(conffile); xhp->confdir = prop_string_create_cstring(confdir);
xhp->flags = flags; xhp->flags = flags;
xhp->install_reason_manual = install_manual; xhp->install_reason_manual = install_manual;

View File

@ -1,4 +1,4 @@
.TH "XBPS\-BIN" "8" "07/28/2011" "\ \&" "\ \&" .TH "XBPS\-BIN" "8" "17/10/2011" "\ \&" "\ \&"
.\" ----------------------------------------------------------------- .\" -----------------------------------------------------------------
.\" * set default formatting .\" * set default formatting
.\" ----------------------------------------------------------------- .\" -----------------------------------------------------------------
@ -28,9 +28,10 @@ Use of this option takes effect in the \fIautoupdate\fR, \fIinstall\fR and
matched. matched.
.RE .RE
.PP .PP
\fB\-C\fR \fIconffile\fR \fB\-C\fR \fIconfdir\fR
.RS 4 .RS 4
Full path to the \fIxbps-conf.plist\fR plist configuration file. Full path to the XBPS configuration directory where the configuration files are available\&.
By default it\(cqs set to \fIETCDIR/xbps\fR\&.
.RE .RE
.PP .PP
\fB\-c\fR \fIcachedir\fR \fB\-c\fR \fIcachedir\fR
@ -287,6 +288,7 @@ The package is fully installed, that means it was unpacked and configured correc
.RE .RE
.PP .PP
\fBhalf\-unpacked\fR \fBhalf\-unpacked\fR
.RS 4
The package was being unpacked but didn't finish properly for unknown reasons. The package was being unpacked but didn't finish properly for unknown reasons.
.RE .RE
.PP .PP
@ -302,11 +304,16 @@ The package has been removed but configuration files and its metadata directory
.PP .PP
.SH "FILES" .SH "FILES"
.PP .PP
\fB/etc/xbps-conf.plist\fR \fB/etc/xbps/conf.plist\fR
.RS 4 .RS 4
Default XBPS configuration file\&. Default XBPS configuration file\&.
.RE .RE
.PP .PP
\fB/etc/xbps/repositories.plist\fR
.RS 4
Defaults XBPS repositories configuration file\&.
.RE
.PP
\fB/var/db/xbps\fR \fB/var/db/xbps\fR
.RS 4 .RS 4
xbps global metadata directory\&. xbps global metadata directory\&.

View File

@ -90,16 +90,16 @@ main(int argc, char **argv)
struct xbps_handle *xhp; struct xbps_handle *xhp;
struct xferstat xfer; struct xferstat xfer;
prop_dictionary_t pkgd; prop_dictionary_t pkgd;
const char *rootdir, *cachedir, *conffile; const char *rootdir, *cachedir, *confdir;
int c, rv = 0; int c, rv = 0;
bool debug = false; bool debug = false;
rootdir = cachedir = conffile = NULL; rootdir = cachedir = confdir = NULL;
while ((c = getopt(argc, argv, "C:c:dr:V")) != -1) { while ((c = getopt(argc, argv, "C:c:dr:V")) != -1) {
switch (c) { switch (c) {
case 'C': case 'C':
conffile = optarg; confdir = optarg;
break; break;
case 'c': case 'c':
cachedir = optarg; cachedir = optarg;
@ -143,8 +143,8 @@ main(int argc, char **argv)
xhp->rootdir = prop_string_create_cstring(rootdir); xhp->rootdir = prop_string_create_cstring(rootdir);
if (cachedir) if (cachedir)
xhp->cachedir = prop_string_create_cstring(cachedir); xhp->cachedir = prop_string_create_cstring(cachedir);
if (conffile) if (confdir)
xhp->conffile = prop_string_create_cstring(conffile); xhp->confdir = prop_string_create_cstring(confdir);
if ((rv = xbps_init(xhp)) != 0) { if ((rv = xbps_init(xhp)) != 0) {
xbps_error_printf("xbps-repo: couldn't initialize library: %s\n", xbps_error_printf("xbps-repo: couldn't initialize library: %s\n",

View File

@ -1,4 +1,4 @@
.TH "XBPS\-REPO" "8" "07/23/2011" "\ \&" "\ \&" .TH "XBPS\-REPO" "8" "17/10/2011" "\ \&" "\ \&"
.\" ----------------------------------------------------------------- .\" -----------------------------------------------------------------
.\" * set default formatting .\" * set default formatting
.\" ----------------------------------------------------------------- .\" -----------------------------------------------------------------
@ -19,9 +19,10 @@ xbps-repo \- XBPS command for binary package repositories
The xbps\-repo(8) command is used to handle local or remote binary package repositories in the \fBXBPS binary package system\fR\&. You can use it to create a package index for a local repository, list repositories, search for packages and show information about a binary package in repository pool\&. The xbps\-repo(8) command is used to handle local or remote binary package repositories in the \fBXBPS binary package system\fR\&. You can use it to create a package index for a local repository, list repositories, search for packages and show information about a binary package in repository pool\&.
.SH "OPTIONS" .SH "OPTIONS"
.PP .PP
\fB\-C\fR \fIconffile\fR \fB\-C\fR \fIconfdir\fR
.RS 4 .RS 4
Full path to the \fIxbps-conf.plist\fR plist configuration file. Full path to the XBPS configuration directory where the configuration files are available\&.
By default it\(cqs set to \fIETCDIR/xbps\fR\&.
.RE .RE
.PP .PP
\fB\-c\fR \fIcachedir\fR \fB\-c\fR \fIcachedir\fR
@ -123,11 +124,16 @@ Syncs the package index file for all registered remote repositories\&. The new f
.RE .RE
.SH "FILES" .SH "FILES"
.PP .PP
\fB/etc/xbps-conf.plist\fR \fB/etc/xbps/conf.plist\fR
.RS 4 .RS 4
Default XBPS configuration file\&. Default XBPS configuration file\&.
.RE .RE
.PP .PP
\fB/etc/xbps/repositories.plist\fR
.RS 4
Default XBPS repositories configuration file\&.
.RE
.PP
\fB/var/db/xbps/<remoterepodir>/pkg\-index\&.plist\fR \fB/var/db/xbps/<remoterepodir>/pkg\-index\&.plist\fR
.RS 4 .RS 4
Remote repository package index file\&. Remote repository package index file\&.

View File

@ -113,7 +113,7 @@ main(int argc, char **argv)
struct xbps_handle *xhp; struct xbps_handle *xhp;
struct xferstat xfer; struct xferstat xfer;
prop_dictionary_t dict; prop_dictionary_t dict;
const char *version, *rootdir = NULL, *conffile = NULL; const char *version, *rootdir = NULL, *confdir = NULL;
char *plist, *pkgname, *pkgver, *in_chroot_env, *hash; char *plist, *pkgname, *pkgver, *in_chroot_env, *hash;
bool debug = false, in_chroot = false; bool debug = false, in_chroot = false;
int i, c, rv = 0; int i, c, rv = 0;
@ -121,7 +121,7 @@ main(int argc, char **argv)
while ((c = getopt(argc, argv, "C:dr:V")) != -1) { while ((c = getopt(argc, argv, "C:dr:V")) != -1) {
switch (c) { switch (c) {
case 'C': case 'C':
conffile = optarg; confdir = optarg;
break; break;
case 'r': case 'r':
/* To specify the root directory */ /* To specify the root directory */
@ -158,8 +158,8 @@ main(int argc, char **argv)
xhp->xfcd->cookie = &xfer; xhp->xfcd->cookie = &xfer;
if (rootdir) if (rootdir)
xhp->rootdir = prop_string_create_cstring(rootdir); xhp->rootdir = prop_string_create_cstring(rootdir);
if (conffile) if (confdir)
xhp->conffile = prop_string_create_cstring(conffile); xhp->confdir = prop_string_create_cstring(confdir);
if ((rv = xbps_init(xhp)) != 0) { if ((rv = xbps_init(xhp)) != 0) {
xbps_error_printf("xbps-uhelper: failed to " xbps_error_printf("xbps-uhelper: failed to "

View File

@ -55,7 +55,7 @@
*/ */
#define XBPS_PKGINDEX_VERSION "1.2" #define XBPS_PKGINDEX_VERSION "1.2"
#define XBPS_API_VERSION "20111017-1" #define XBPS_API_VERSION "20111017-2"
#define XBPS_VERSION "0.10.0" #define XBPS_VERSION "0.10.0"
/** /**
@ -468,11 +468,11 @@ struct xbps_handle {
*/ */
prop_string_t cachedir; prop_string_t cachedir;
/** /**
* @var conffile * @var confdir
* *
* Full path to the XBPS_CONF_PLIST configuration file. * Full path to the XBPS_SYSCONF_PATH directory.
*/ */
prop_string_t conffile; prop_string_t confdir;
/** /**
* @private fetch_timeout * @private fetch_timeout
* *

View File

@ -37,25 +37,36 @@
* @brief Initialization of virtual package settings. * @brief Initialization of virtual package settings.
*/ */
#define _VPKGDIR XBPS_SYSCONF_PATH "/" XBPS_VIRTUALPKGD_PATH
void HIDDEN void HIDDEN
xbps_init_virtual_pkgs(struct xbps_handle *xh) xbps_init_virtual_pkgs(struct xbps_handle *xh)
{ {
struct dirent *dp; struct dirent *dp;
DIR *dirp; DIR *dirp;
prop_dictionary_t vpkgd; prop_dictionary_t vpkgd;
prop_string_t vpkgdir;
char *vpkgfile; char *vpkgfile;
if (prop_object_type(xh->confdir) != PROP_TYPE_STRING) {
vpkgdir = prop_string_create_cstring(XBPS_SYSCONF_PATH);
prop_string_append_cstring(vpkgdir, "/");
prop_string_append_cstring(vpkgdir, XBPS_VIRTUALPKGD_PATH);
} else {
vpkgdir = prop_string_copy(xh->confdir);
prop_string_append_cstring(vpkgdir, "/");
prop_string_append_cstring(vpkgdir, XBPS_VIRTUALPKGD_PATH);
}
/* /*
* Internalize all plist files from _VPKGDIR and add them * Internalize all plist files from vpkgdir and add them
* into xhp->virtualpkgs_array. * into xhp->virtualpkgs_array.
*/ */
dirp = opendir(_VPKGDIR); dirp = opendir(prop_string_cstring_nocopy(vpkgdir));
if (dirp == NULL) { if (dirp == NULL) {
xbps_dbg_printf("%s: cannot access to %s for virtual " xbps_dbg_printf("%s: cannot access to %s for virtual "
"packages: %s\n", __func__, _VPKGDIR, "packages: %s\n", __func__,
prop_string_cstring_nocopy(vpkgdir),
strerror(errno)); strerror(errno));
prop_object_release(vpkgdir);
return; return;
} }
while ((dp = readdir(dirp)) != NULL) { while ((dp = readdir(dirp)) != NULL) {
@ -66,7 +77,8 @@ xbps_init_virtual_pkgs(struct xbps_handle *xh)
if (strstr(dp->d_name, ".plist") == NULL) if (strstr(dp->d_name, ".plist") == NULL)
continue; continue;
vpkgfile = xbps_xasprintf("%s/%s", _VPKGDIR, dp->d_name); vpkgfile = xbps_xasprintf("%s/%s",
prop_string_cstring_nocopy(vpkgdir), dp->d_name);
if (vpkgfile == NULL) { if (vpkgfile == NULL) {
(void)closedir(dirp); (void)closedir(dirp);
xbps_dbg_printf("%s: failed to alloc mem for %s\n", xbps_dbg_printf("%s: failed to alloc mem for %s\n",
@ -96,4 +108,5 @@ xbps_init_virtual_pkgs(struct xbps_handle *xh)
__func__, dp->d_name); __func__, dp->d_name);
} }
(void)closedir(dirp); (void)closedir(dirp);
prop_object_release(vpkgdir);
} }

View File

@ -49,6 +49,7 @@ int
xbps_init(struct xbps_handle *xh) xbps_init(struct xbps_handle *xh)
{ {
prop_dictionary_t confd; prop_dictionary_t confd;
prop_string_t conffile = NULL, repofile = NULL;
const char *conf_rootdir = NULL, *conf_cachedir = NULL; const char *conf_rootdir = NULL, *conf_cachedir = NULL;
uint16_t fetch_cache_conn = 0, fetch_cache_conn_host = 0; uint16_t fetch_cache_conn = 0, fetch_cache_conn_host = 0;
int rv; int rv;
@ -58,18 +59,29 @@ xbps_init(struct xbps_handle *xh)
xhp = xh; xhp = xh;
debug = xhp->debug; debug = xhp->debug;
/* If conffile not set, defaults to XBPS_SYSCONF_PATH */ /* If confdir not set, defaults to XBPS_SYSCONF_PATH */
if (prop_object_type(xhp->conffile) != PROP_TYPE_STRING) if (prop_object_type(xhp->confdir) != PROP_TYPE_STRING) {
xhp->conffile = prop_string_create_cstring(_CONFFILE); conffile = prop_string_create_cstring(_CONFFILE);
repofile = prop_string_create_cstring(_REPOFILE);
} else {
conffile = prop_string_copy(xhp->confdir);
prop_string_append_cstring(conffile, "/");
prop_string_append_cstring(conffile, XBPS_CONF_PLIST);
repofile = prop_string_copy(xhp->confdir);
prop_string_append_cstring(repofile, "/");
prop_string_append_cstring(repofile, XBPS_CONF_REPOS_PLIST);
}
/* /*
* Internalize the XBPS_CONF_REPOS_PLIST array. * Internalize the XBPS_CONF_REPOS_PLIST array.
*/ */
xhp->repos_array = prop_array_internalize_from_file(_REPOFILE); xhp->repos_array =
prop_array_internalize_from_file(prop_string_cstring_nocopy(repofile));
/* /*
* Internalize the XBPS_CONF_PLIST dictionary. * Internalize the XBPS_CONF_PLIST dictionary.
*/ */
confd = prop_dictionary_internalize_from_file( confd = prop_dictionary_internalize_from_file(
prop_string_cstring_nocopy(xhp->conffile)); prop_string_cstring_nocopy(conffile));
if (confd == NULL) { if (confd == NULL) {
if (errno != ENOENT) { if (errno != ENOENT) {
xbps_dbg_printf("%s: cannot internalize conf " xbps_dbg_printf("%s: cannot internalize conf "
@ -140,11 +152,15 @@ xbps_init(struct xbps_handle *xh)
xbps_dbg_printf("cachedir: %s\n", xbps_dbg_printf("cachedir: %s\n",
prop_string_cstring_nocopy(xhp->cachedir)); prop_string_cstring_nocopy(xhp->cachedir));
xbps_dbg_printf("conffile: %s\n", xbps_dbg_printf("conffile: %s\n",
prop_string_cstring_nocopy(xhp->conffile)); prop_string_cstring_nocopy(conffile));
xbps_dbg_printf("repofile: %s\n", _REPOFILE); xbps_dbg_printf("repofile: %s\n",
xbps_dbg_printf("fetch_cache_conn: %zu\n", fetch_cache_conn); prop_string_cstring_nocopy(repofile));
xbps_dbg_printf("fetch_cacche_conn_host: %zu\n", fetch_cache_conn_host); xbps_dbg_printf("fetch_cache_conn: %zu\n",
xbps_dbg_printf("fetch_timeout: %zu\n", xhp->fetch_timeout); fetch_cache_conn);
xbps_dbg_printf("fetch_cacche_conn_host: %zu\n",
fetch_cache_conn_host);
xbps_dbg_printf("fetch_timeout: %zu\n",
xhp->fetch_timeout);
/* /*
* Initialize regpkgdb dictionary. * Initialize regpkgdb dictionary.
@ -157,12 +173,12 @@ xbps_init(struct xbps_handle *xh)
return rv; return rv;
} }
} }
/* We don't need the confd dictionary internalized anymore */
if (prop_object_type(confd) == PROP_TYPE_DICTIONARY) if (prop_object_type(confd) == PROP_TYPE_DICTIONARY)
prop_object_release(confd); prop_object_release(confd);
/* We don't need the conffile string anymore */ if (prop_object_type(conffile) == PROP_TYPE_STRING)
if (prop_object_type(xh->conffile) == PROP_TYPE_STRING) prop_object_release(conffile);
prop_object_release(xh->conffile); if (prop_object_type(repofile) == PROP_TYPE_STRING)
prop_object_release(repofile);
/* Initialize virtual package settings */ /* Initialize virtual package settings */
xbps_init_virtual_pkgs(xhp); xbps_init_virtual_pkgs(xhp);
@ -179,6 +195,8 @@ xbps_end(struct xbps_handle *xh)
if (xh == NULL) if (xh == NULL)
return; return;
if (prop_object_type(xh->confdir) == PROP_TYPE_STRING)
prop_object_release(xh->confdir);
if (prop_object_type(xh->rootdir) == PROP_TYPE_STRING) if (prop_object_type(xh->rootdir) == PROP_TYPE_STRING)
prop_object_release(xh->rootdir); prop_object_release(xh->rootdir);
if (prop_object_type(xh->cachedir) == PROP_TYPE_STRING) if (prop_object_type(xh->cachedir) == PROP_TYPE_STRING)