Replaced config/system {repo,preserve,virtualpkg}.d with a single directory.

See the NEWS file for more information.
This commit is contained in:
Juan RP 2014-11-06 09:58:04 +01:00
parent 578c3add0c
commit 5b522109f7
38 changed files with 278 additions and 277 deletions

View File

@ -1,6 +1,6 @@
-include config.mk
SUBDIRS = include lib bin etc data
SUBDIRS = include lib bin data
ifdef BUILD_API_DOCS
SUBDIRS += doc

19
NEWS
View File

@ -1,5 +1,24 @@
xbps-0.42 (???):
* utils: the -C/--config option now expects a path to a directory storing
configuration files; if first character is not '/' it will be treated as
relative to rootdir.
* <sysconfdir>/xbps/xbps.conf is not longer installed, in fact there are no files
installed anymore to sysconfdir. The xbps.conf file with everything commented out
is now installed to <sharedir>/xbps.d/xbps.conf just as example.
* Replaced config/system {preserve,repo,virtualpkg}.d directories with a single
xbps.d directory that may contain configuration files of all kinds:
general options, repositories, virtual packages, and preserved files.
By default set to <sysconfdir>/xbps.d and <sharedir>/xbps.d:
- /usr/local/etc/xbps.d <- configuration directory
- /usr/local/share/xbps.d <- system configuration directory
Files bearing the same filename in the configuration directory override
those available in the system configuration directory.
* Virtual packages are now collected directly from pkgdb, that means
that installed packages do not need to have a virtualpkg configuration
file in the system virtualpkg.d directory.

View File

@ -211,12 +211,10 @@ rcv_init(rcv_t *rcv, const char *prog)
rcv->have_vars = 0;
rcv->ptr = rcv->input = NULL;
if (rcv->xbps_conf != NULL) {
strncpy(rcv->xhp.conffile, rcv->xbps_conf, sizeof(rcv->xhp.conffile)-1);
rcv->xhp.conffile[sizeof(rcv->xhp.conffile)-1] = '\0';
xbps_strlcpy(rcv->xhp.confdir, rcv->xbps_conf, sizeof(rcv->xhp.confdir));
}
if (rcv->rootdir != NULL) {
strncpy(rcv->xhp.rootdir, rcv->rootdir, sizeof(rcv->xhp.rootdir)-1);
rcv->xhp.rootdir[sizeof(rcv->xhp.rootdir)-1] = '\0';
xbps_strlcpy(rcv->xhp.rootdir, rcv->rootdir, sizeof(rcv->xhp.rootdir));
}
if (xbps_init(&rcv->xhp) != 0)
abort();
@ -507,11 +505,12 @@ rcv_find_conf(rcv_t *rcv)
}
static bool
check_reverts(const char *repover, const map_item_t reverts) {
check_reverts(const char *repover, const map_item_t reverts)
{
bool rv = false;
char *sreverts, *p;
if(reverts.v.len == 0)
if (reverts.v.len == 0)
return rv;
sreverts = calloc(reverts.v.len+1, sizeof(char));
@ -523,14 +522,14 @@ check_reverts(const char *repover, const map_item_t reverts) {
* Check if it's the first character or the previous character is a
* whitespace.
*/
if(p > sreverts && !isspace(p[-1]))
if (p > sreverts && !isspace(p[-1]))
continue;
p += strlen(repover);
/*
* Check if it's the last character or if the next character is a
* whitespace
*/
if(isspace(*p) || *p == '\0') {
if (isspace(*p) || *p == '\0') {
rv = true;
break;
}

View File

@ -1,4 +1,4 @@
.Dd September 30, 2014
.Dd November 5, 2014
.Dt XBPS-CHECKVERS 8
.Sh NAME
.Nm xbps-checkvers
@ -24,8 +24,10 @@ tree. The
argument sets extra packages to process with the outdated ones (only processed if missing).
.Sh OPTIONS
.Bl -tag -width -x
.It Fl C, Fl -config Ar file
Specifies a full path to the XBPS configuration file.
.It Fl C, Fl -config Ar dir
Specifies a path to the XBPS configuration directory.
If the first character is not '\/' then it's a relative path of
.Ar rootdir .
.It Fl D, Fl -distdir Ar dir
Specifies a full path to the void-packages repository. By default set to
.Nm ~/void-packages .

View File

@ -480,7 +480,7 @@ main(int argc, char **argv)
/* Initialize libxbps */
memset(&xh, 0, sizeof(xh));
if (rootdir != NULL)
strncpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
if ((rv = xbps_init(&xh)) != 0)
die("failed to initialize libxbps: %s", strerror(rv));

View File

@ -44,8 +44,8 @@ usage(bool fail)
"Usage: xbps-install [OPTIONS] [PKGNAME...]\n\n"
"OPTIONS\n"
" -A --automatic Set automatic installation mode\n"
" -C --config <file> Full path to configuration file\n"
" -c --cachedir <dir> Full path to cachedir\n"
" -C --config <dir> Path to confdir (xbps.d)\n"
" -c --cachedir <dir> Path to cachedir\n"
" -d --debug Debug mode shown to stderr\n"
" -f --force Force package re-installation\n"
" If specified twice, all files will be\n"
@ -110,12 +110,12 @@ main(int argc, char **argv)
};
struct xbps_handle xh;
struct xferstat xfer;
const char *rootdir, *cachedir, *conffile;
const char *rootdir, *cachedir, *confdir;
int i, c, flags, rv, fflag = 0;
bool syncf, yes, reinstall, drun, update;
int maxcols;
rootdir = cachedir = conffile = NULL;
rootdir = cachedir = confdir = NULL;
flags = rv = 0;
syncf = yes = reinstall = drun = update = false;
@ -127,7 +127,7 @@ main(int argc, char **argv)
flags |= XBPS_FLAG_INSTALL_AUTO;
break;
case 'C':
conffile = optarg;
confdir = optarg;
break;
case 'c':
cachedir = optarg;
@ -187,11 +187,11 @@ main(int argc, char **argv)
xh.fetch_cb = fetch_file_progress_cb;
xh.fetch_cb_data = &xfer;
if (rootdir)
strncpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
if (cachedir)
strncpy(xh.cachedir, cachedir, sizeof(xh.cachedir));
if (conffile)
strncpy(xh.conffile, conffile, sizeof(xh.conffile));
xbps_strlcpy(xh.cachedir, cachedir, sizeof(xh.cachedir));
if (confdir)
xbps_strlcpy(xh.confdir, confdir, sizeof(xh.confdir));
xh.flags = flags;
if (flags & XBPS_FLAG_VERBOSE)
xh.unpack_cb = unpack_progress_cb;

View File

@ -1,4 +1,4 @@
.Dd September 30, 2014
.Dd November 5, 2014
.Dt XBPS-INSTALL 8
.Sh NAME
.Nm xbps-install
@ -59,10 +59,14 @@ The first repository matching the package expression wins.
.It Fl A, Fl -automatic
Enables automatic installation mode, i.e. package will be treated as orphan
if no package is depending on it directly.
.It Fl C, Fl -config Ar file
Specifies a full path to the XBPS configuration file.
.It Fl C, Fl -config Ar dir
Specifies a path to the XBPS configuration directory.
If the first character is not '\/' then it's a relative path of
.Ar rootdir .
.It Fl c, Fl -cachedir Ar dir
Specifies a full path to the cache directory, where binary packages are stored.
Specifies a path to the cache directory, where binary packages are stored.
If the first character is not '\/' then it's a relative path of
.Ar rootdir .
.It Fl d, Fl -debug
Enables extra debugging shown to stderr.
.It Fl f, Fl -force
@ -111,8 +115,8 @@ the native architecture).
.El
.Sh FILES
.Bl -tag -width /var/db/xbps/.<pkgname>-files.plist
.It Ar /etc/xbps/xbps.conf
Default configuration file.
.It Ar /etc/xbps.d
Default configuration directory.
.It Ar /var/db/xbps/.<pkgname>-files.plist
Package files metadata.
.It Ar /var/db/xbps/pkgdb-0.38.plist

View File

@ -41,7 +41,7 @@ usage(bool fail)
"Usage: xbps-pkgdb [OPTIONS] [PKGNAME...]\n\n"
"OPTIONS\n"
" -a --all Process all packages\n"
" -C --config <file> Full path to configuration file\n"
" -C --config <dir> Path to confdir (xbps.d)\n"
" -d --debug Debug mode shown to stderr\n"
" -h --help Print usage help\n"
" -m --mode <auto|manual|hold|unhold> Change PKGNAME to this mode\n"
@ -92,7 +92,7 @@ main(int argc, char **argv)
{ NULL, 0, NULL, 0 }
};
struct xbps_handle xh;
const char *conffile = NULL, *rootdir = NULL, *instmode = NULL;
const char *confdir = NULL, *rootdir = NULL, *instmode = NULL;
int c, i, rv, flags = 0;
bool update_format = false, all = false;
@ -102,7 +102,7 @@ main(int argc, char **argv)
all = true;
break;
case 'C':
conffile = optarg;
confdir = optarg;
break;
case 'd':
flags |= XBPS_FLAG_DEBUG;
@ -136,9 +136,9 @@ main(int argc, char **argv)
memset(&xh, 0, sizeof(xh));
if (rootdir)
strncpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
if (conffile)
strncpy(xh.conffile, conffile, sizeof(xh.conffile));
xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
if (confdir)
xbps_strlcpy(xh.confdir, confdir, sizeof(xh.confdir));
xh.flags = flags;
if ((rv = xbps_init(&xh)) != 0) {

View File

@ -1,4 +1,4 @@
.Dd September 30, 2014
.Dd November 5, 2014
.Dt XBPS-PKGDB 8
.Sh NAME
.Nm xbps-pkgdb
@ -36,8 +36,10 @@ Updates the pkgdb format to the latest version.
.Bl -tag -width -x
.It Fl a, Fl -all
Process all registered packages, regardless of its state.
.It Fl C, Fl -config Ar file
Specifies a full path to the XBPS configuration file.
.It Fl C, Fl -config Ar dir
Specifies a path to the XBPS configuration directory.
If the first character is not '\/' then it's a relative path of
.Ar rootdir .
.It Fl d, Fl -debug
Enables extra debugging shown to stderr.
.It Fl h, Fl -help
@ -67,8 +69,8 @@ Shows the XBPS version.
.El
.Sh FILES
.Bl -tag -width /var/db/xbps/.<pkgname>-files.plist
.It Ar /etc/xbps/xbps.conf
Default configuration file.
.It Ar /etc/xbps.d
Default configuration directory.
.It Ar /var/db/xbps/.<pkgname>-files.plist
Package files metadata.
.It Ar /var/db/xbps/pkgdb-0.38.plist

View File

@ -77,7 +77,7 @@ list_pkgs_in_dict(struct xbps_handle *xhp _unused,
assert(out);
snprintf(out, lpc->maxcols - 3,
"%s %s", tmp, short_desc);
strncat(out, "...\n", lpc->maxcols);
xbps_strlcat(out, "...\n", sizeof(*out));
printf("%s", out);
free(out);
} else {

View File

@ -38,8 +38,8 @@ usage(bool fail)
fprintf(stdout,
"Usage: xbps-query [OPTIONS] MODE [ARGUMENTS]\n"
"\nOPTIONS\n"
" -C --config <file> Full path to configuration file\n"
" -c --cachedir <dir> Full path to cachedir\n"
" -C --config <dir> Path to confdir (xbps.d)\n"
" -c --cachedir <dir> Path to cachedir\n"
" -d --debug Debug mode shown to stderr\n"
" -h --help Print help usage\n"
" -p --property PROP[,...] Show properties for PKGNAME\n"
@ -99,13 +99,13 @@ main(int argc, char **argv)
{ NULL, 0, NULL, 0 },
};
struct xbps_handle xh;
const char *pkg, *rootdir, *cachedir, *conffile, *props;
const char *pkg, *rootdir, *cachedir, *confdir, *props;
int c, flags, rv;
bool list_pkgs, list_repos, orphans, own;
bool list_manual, list_hold, show_prop, show_files, show_deps, show_rdeps;
bool show, pkg_search, regex, repo_mode, opmode, fulldeptree;
rootdir = cachedir = conffile = props = pkg = NULL;
rootdir = cachedir = confdir = props = pkg = NULL;
flags = rv = c = 0;
list_pkgs = list_repos = list_hold = orphans = pkg_search = own = false;
list_manual = show_prop = show_files = false;
@ -117,7 +117,7 @@ main(int argc, char **argv)
while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
switch (c) {
case 'C':
conffile = optarg;
confdir = optarg;
break;
case 'c':
cachedir = optarg;
@ -214,11 +214,11 @@ main(int argc, char **argv)
* Initialize libxbps.
*/
if (rootdir)
strncpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
if (cachedir)
strncpy(xh.cachedir, cachedir, sizeof(xh.cachedir));
if (conffile)
strncpy(xh.conffile, conffile, sizeof(xh.conffile));
xbps_strlcpy(xh.cachedir, cachedir, sizeof(xh.cachedir));
if (confdir)
xbps_strlcpy(xh.confdir, confdir, sizeof(xh.confdir));
xh.flags = flags;

View File

@ -68,7 +68,7 @@ print_results(struct xbps_handle *xhp, struct search_data *sd)
for (unsigned int i = 0; i < xbps_array_count(sd->results); i++) {
xbps_array_get_cstring_nocopy(sd->results, i, &pkgver);
xbps_array_get_cstring_nocopy(sd->results, i+1, &desc);
strncpy(tmp, pkgver, sizeof(tmp));
xbps_strlcpy(tmp, pkgver, sizeof(tmp));
for (j = strlen(tmp); j < tlen; j++)
tmp[j] = ' ';
@ -84,7 +84,7 @@ print_results(struct xbps_handle *xhp, struct search_data *sd)
assert(out);
snprintf(out, sd->maxcols-3, "%s %s %s",
inststr, tmp, desc);
strncat(out, "...\n", sd->maxcols);
xbps_strlcat(out, "...\n", sizeof(*out));
printf("%s", out);
free(out);
} else {

View File

@ -1,4 +1,4 @@
.Dd September 30, 2014
.Dd November 5, 2014
.Dt XBPS-QUERY 8
.Sh NAME
.Nm xbps-query
@ -53,10 +53,14 @@ Example:
The first repository matching the package expression wins.
.Sh OPTIONS
.Bl -tag -width -x
.It Fl C, Fl -config Ar file
Specifies a full path to the XBPS configuration file.
.It Fl C, Fl -config Ar dir
Specifies a path to the XBPS configuration directory.
If the first character is not '\/' then it's a relative path of
.Ar rootdir .
.It Fl c, Fl -cachedir Ar dir
Specifies a full path to the cache directory, where binary packages are stored.
Specifies a path to the cache directory, where binary packages are stored.
If the first character is not '\/' then it's a relative path of
.Ar rootdir .
.It Fl d, Fl -debug
Enables extra debugging shown to stderr.
.It Fl h, Fl -help
@ -224,8 +228,8 @@ the native architecture).
.El
.Sh FILES
.Bl -tag -width /var/db/xbps/.<pkgname>-files.plist
.It Ar /etc/xbps/xbps.conf
Default configuration file.
.It Ar /etc/xbps.d
Default configuration directory.
.It Ar /var/db/xbps/.<pkgname>-files.plist
Package files metadata.
.It Ar /var/db/xbps/pkgdb-0.38.plist

View File

@ -40,7 +40,7 @@ usage(bool fail)
"Usage: xbps-reconfigure [OPTIONS] [PKGNAME...]\n\n"
"OPTIONS\n"
" -a --all Process all packages\n"
" -C --config <file> Full path to configuration file\n"
" -C --config <dir> Path to confdir (xbps.d)\n"
" -d --debug Debug mode shown to stderr\n"
" -f --force Force reconfiguration\n"
" -h --help Print usage help\n"
@ -104,7 +104,7 @@ main(int argc, char **argv)
{ NULL, 0, NULL, 0 }
};
struct xbps_handle xh;
const char *conffile = NULL, *rootdir = NULL;
const char *confdir = NULL, *rootdir = NULL;
int c, i, rv, flags = 0;
bool all = false;
@ -114,7 +114,7 @@ main(int argc, char **argv)
all = true;
break;
case 'C':
conffile = optarg;
confdir = optarg;
break;
case 'd':
flags |= XBPS_FLAG_DEBUG;
@ -146,9 +146,9 @@ main(int argc, char **argv)
memset(&xh, 0, sizeof(xh));
xh.state_cb = state_cb;
if (rootdir)
strncpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
if (conffile)
strncpy(xh.conffile, conffile, sizeof(xh.conffile));
xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
if (confdir)
xbps_strlcpy(xh.confdir, confdir, sizeof(xh.confdir));
xh.flags = flags;

View File

@ -1,4 +1,4 @@
.Dd September 30, 2014
.Dd November 5, 2014
.Dt XBPS-RECONFIGURE 8
.Sh NAME
.Nm xbps-reconfigure
@ -35,8 +35,10 @@ option is specified.
.Bl -tag -width -x
.It Fl a, Fl -all
Configures all packages.
.It Fl C, Fl -config Ar file
Specifies a full path to the XBPS configuration file.
.It Fl C, Fl -config Ar dir
Specifies a path to the XBPS configuration directory.
If the first character is not '\/' then it's a relative path of
.Ar rootdir .
.It Fl d, Fl -debug
Enables extra debugging shown to stderr.
.It Fl f, Fl -force
@ -44,7 +46,7 @@ Forcefully reconfigure package even if it was configured previously.
.It Fl h, Fl -help
Show the help usage.
.It Fl r, Fl -rootdir Ar dir
Specifies a full path for the target root directory.
Specifies a path for the target root directory.
.It Fl v, Fl -verbose
Enables verbose messages.
.It Fl V, Fl -version
@ -52,8 +54,8 @@ Shows the XBPS version.
.El
.Sh FILES
.Bl -tag -width /var/db/xbps/.<pkgname>-files.plist
.It Ar /etc/xbps/xbps.conf
Default configuration file.
.It Ar /etc/xbps.d
Default configuration directory.
.It Ar /var/db/xbps/.<pkgname>.plist
Package files metadata.
.It Ar /var/db/xbps/pkgdb-0.38.plist

View File

@ -45,8 +45,8 @@ usage(bool fail)
fprintf(stdout,
"Usage: xbps-remove [OPTIONS] [PKGNAME...]\n\n"
"OPTIONS\n"
" -C --config <file> Full path to configuration file\n"
" -c --cachedir <dir> Full path to cachedir\n"
" -C --config <dir> Path to confdir (xbps.d)\n"
" -c --cachedir <dir> Path to cachedir\n"
" -d --debug Debug mode shown to stderr\n"
" -F --force-revdeps Force package removal even with revdeps\n"
" -f --force Force package files removal\n"
@ -181,13 +181,13 @@ main(int argc, char **argv)
{ NULL, 0, NULL, 0 }
};
struct xbps_handle xh;
const char *rootdir, *cachedir, *conffile;
const char *rootdir, *cachedir, *confdir;
int c, flags, rv;
bool yes, drun, recursive, ignore_revdeps, clean_cache;
bool orphans, reqby_force;
int maxcols;
rootdir = cachedir = conffile = NULL;
rootdir = cachedir = confdir = NULL;
flags = rv = 0;
drun = recursive = ignore_revdeps = clean_cache = false;
reqby_force = yes = orphans = false;
@ -195,7 +195,7 @@ main(int argc, char **argv)
while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
switch (c) {
case 'C':
conffile = optarg;
confdir = optarg;
break;
case 'c':
cachedir = optarg;
@ -251,11 +251,11 @@ main(int argc, char **argv)
memset(&xh, 0, sizeof(xh));
xh.state_cb = state_cb_rm;
if (rootdir)
strncpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
if (cachedir)
strncpy(xh.cachedir, cachedir, sizeof(xh.cachedir));
if (conffile)
strncpy(xh.conffile, conffile, sizeof(xh.conffile));
xbps_strlcpy(xh.cachedir, cachedir, sizeof(xh.cachedir));
if (confdir)
xbps_strlcpy(xh.confdir, confdir, sizeof(xh.confdir));
xh.flags = flags;

View File

@ -1,4 +1,4 @@
.Dd September 30, 2014
.Dd November 5, 2014
.Dt XBPS-REMOVE 8
.Sh NAME
.Nm xbps-remove
@ -58,10 +58,14 @@ Package metadata file is removed.
Package is unregistered from package database.
.Sh OPTIONS
.Bl -tag -width -x
.It Fl C, Fl -config Ar file
Specifies a full path to the XBPS configuration file.
.It Fl C, Fl -config Ar dir
Specifies a path to the XBPS configuration directory.
If the first character is not '\/' then it's a relative path of
.Ar rootdir .
.It Fl c, Fl -cachedir Ar dir
Specifies a full path to the cache directory, where binary packages are stored.
Specifies a path to the cache directory, where binary packages are stored.
If the first character is not '\/' then it's a relative path of
.Ar rootdir .
.It Fl d, Fl -debug
Enables extra debugging shown to stderr.
.It Fl F, Fl -force-revdeps
@ -92,8 +96,8 @@ Shows the XBPS version.
.El
.Sh FILES
.Bl -tag -width /var/db/xbps/.<pkgname>-files.plist
.It Ar /etc/xbps/xbps.conf
Default configuration file.
.It Ar /etc/xbps.d
Default configuration directory.
.It Ar /var/db/xbps/.<pkgname>-files.plist
Package files metadata.
.It Ar /var/db/xbps/pkgdb-0.38.plist

View File

@ -103,14 +103,14 @@ main(int argc, char **argv)
xbps_dictionary_t dict;
struct xbps_handle xh;
struct xferstat xfer;
const char *version, *rootdir = NULL, *conffile = NULL;
const char *version, *rootdir = NULL, *confdir = NULL;
char *pkgname, *hash, *filename;
int flags = 0, c, rv = 0;
while ((c = getopt(argc, argv, "C:dr:V")) != -1) {
switch (c) {
case 'C':
conffile = optarg;
confdir = optarg;
break;
case 'r':
/* To specify the root directory */
@ -146,9 +146,9 @@ main(int argc, char **argv)
xh.fetch_cb = fetch_file_progress_cb;
xh.fetch_cb_data = &xfer;
if (rootdir)
strncpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
if (conffile)
strncpy(xh.conffile, conffile, sizeof(xh.conffile));
xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
if (confdir)
xbps_strlcpy(xh.confdir, confdir, sizeof(xh.confdir));
if ((rv = xbps_init(&xh)) != 0) {
xbps_error_printf("xbps-uhelper: failed to "
"initialize libxbps: %s.\n", strerror(rv));

6
configure vendored
View File

@ -61,7 +61,7 @@ for x; do
--host) HOST=$var;;
--target) TARGET=$var;;
--includedir) INCLUDEDIR=$var;;
--sysconfdir) ETCDIR=$var;;
--sysconfdir) SYSCONFDIR=$var;;
--localstatedir) LOCALSTATEDIR=$var;;
--libdir) LIBDIR=$var;;
--datadir|--infodir) ;; # ignore autotools
@ -86,7 +86,6 @@ done
: ${SHAREDIR:=${EPREFIX}/share}
: ${MANDIR:=${EPREFIX}/share/man}
: ${INCLUDEDIR:=${EPREFIX}/include}
: ${ETCDIR:=${PREFIX}/etc}
: ${PKGCONFIGDIR:=${LIBDIR}/pkgconfig}
: ${TESTSDIR:=${EPREFIX}/tests}
: ${LOCALSTATEDIR:=/var}
@ -154,7 +153,7 @@ echo "PKGCONFIGDIR ?= $PKGCONFIGDIR" >>$CONFIG_MK
echo "TESTSDIR ?= $TESTSDIR" >>$CONFIG_MK
echo "DBDIR ?= $DBDIR" >>$CONFIG_MK
ETCDIR="${ETCDIR}/xbps"
ETCDIR="${SYSCONFDIR}/xbps.d"
echo "ETCDIR ?= $ETCDIR" >>$CONFIG_MK
[ -z "$DEBUG" ] && DEBUG=no
@ -186,6 +185,7 @@ echo "CFLAGS = -O2 -pthread" >>$CONFIG_MK
echo "LDFLAGS = -L\$(TOPDIR)/lib" >>$CONFIG_MK
echo "CPPFLAGS = -I. -I\$(TOPDIR) -I\$(TOPDIR)/include" >>$CONFIG_MK
echo "CPPFLAGS += -DXBPS_SYSCONF_PATH=\\\"${ETCDIR}\\\"" >>$CONFIG_MK
echo "CPPFLAGS += -DXBPS_SYSDEFCONF_PATH=\\\"${SHAREDIR}/xbps.d\\\"" >>$CONFIG_MK
echo "CPPFLAGS += -DXBPS_VERSION=\\\"${VERSION}\\\"" >>$CONFIG_MK
echo "CPPFLAGS += -D_unused=\"__attribute__((__unused__))\"" >>$CONFIG_MK

View File

@ -15,21 +15,23 @@ install:
install -m644 $(PCFILE) $(DESTDIR)$(PKGCONFIGDIR)
install -d $(DESTDIR)/$(DBDIR)/keys
install -m644 *.plist $(DESTDIR)/$(DBDIR)/keys
install -d $(DESTDIR)/$(PREFIX)/share/xbps/repo.d
install -m644 repod-main.conf $(DESTDIR)/$(PREFIX)/share/xbps/repo.d/00-main.conf
install -d $(DESTDIR)/$(PREFIX)/share/zsh/site-functions
install -m644 _xbps* $(DESTDIR)/$(PREFIX)/share/zsh/site-functions
install -d $(DESTDIR)/$(PREFIX)/share/bash-completion/completions
install -m644 xbps.bash $(DESTDIR)/$(PREFIX)/share/bash-completion/completions/xbps
install -d $(DESTDIR)/$(SHAREDIR)/xbps.d
install -m644 repod-main.conf $(DESTDIR)/$(SHAREDIR)/xbps.d/00-repository-main.conf
install -m644 xbps.conf $(DESTDIR)/$(SHAREDIR)/xbps.d/xbps.conf
install -d $(DESTDIR)/$(SHAREDIR)/zsh/site-functions
install -m644 _xbps* $(DESTDIR)/$(SHAREDIR)/zsh/site-functions
install -d $(DESTDIR)/$(SHAREDIR)/bash-completion/completions
install -m644 xbps.bash $(DESTDIR)/$(SHAREDIR)/bash-completion/completions/xbps
for file in xbps-checkvers xbps-create xbps-dgraph xbps-install \
xbps-pkgdb xbps-query xbps-reconfigure xbps-remove xbps-rindex; do \
ln -sf xbps $(DESTDIR)/$(PREFIX)/share/bash-completion/completions/$$file; \
ln -sf xbps $(DESTDIR)/$(SHAREDIR)/bash-completion/completions/$$file; \
done
.PHONY: uninstall
uninstall:
-rm -f $(DESTDIR)$(PKGCONFIGDIR)/$(PCFILE)
-rm -f $(DESTDIR)$(PREFIX)/share/xbps/repo.d/main.conf
-rm -f $(DESTDIR)$(SHAREDIR)/xbps.d/00-repository-main.conf
-rm -f $(DESTDIR)$(SHAREDIR)/xbps.d/xbps.conf
.PHONY: clean

View File

@ -18,14 +18,6 @@
# The `repository' keyword defines a repository. A complete URL or absolute
# path to a local directory can be used.
#
# The default system repository directory "<rootdir>/usr/share/xbps/repo.d"
# contains the system repository configuration files.
#
# Files on that system directory can be overrided in "<rootdir>/etc/xbps/repo.d"
# bearing the same file name, i.e:
#
# - /etc/xbps/repo.d/main.conf overrides /usr/share/xbps/repo.d/main.conf
#
# Local or remote repositories are accepted.
#
# - Local repositories expect an absolute path to the directory that stores
@ -37,8 +29,11 @@
# to the tail of the list.
#
# The "repository" keyword can be used to include additional repositories in
# addition to the files available in /etc/xbps/repo.d/*.conf and
# /usr/share/xbps/repo.d/*.conf.
# addition to the files available in /etc/xbps.d/*.conf and
# /usr/share/xbps.d/*.conf.
#
# syntax: <protocol>://<url>[:<port>]/<doc> [remote]
# syntax: <abspath> [local]
#
# Example:
# repository=http://foo.example.org/dir
@ -65,9 +60,6 @@
# specified files. Files must be specified with absolute pathnames or via
# file globbing.
#
# The system preserve directory is set to <rootdir>/usr/share/xbps/preserve.d.
# The configuration preserve 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.
#
@ -85,9 +77,6 @@
# 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.
#

View File

@ -1,21 +0,0 @@
-include ../config.mk
CONF_FILES = xbps.conf
.PHONY: all
all:
.PHONY: install
install:
install -d $(DESTDIR)$(ETCDIR)
for f in $(CONF_FILES); do \
if [ ! -f $(DESTDIR)$(ETCDIR)/$$f ]; then \
install -m644 $$f $(DESTDIR)$(ETCDIR); \
fi; \
done
.PHONY: uninstall
uninstall:
.PHONY: clean
clean:

View File

@ -48,7 +48,7 @@
*
* This header documents the full API for the XBPS Library.
*/
#define XBPS_API_VERSION "20141104"
#define XBPS_API_VERSION "20141105"
#ifndef XBPS_VERSION
#define XBPS_VERSION "UNSET"
@ -68,12 +68,12 @@
* @def XBPS_SYSCONF_PATH
* Default configuration PATH to find XBPS_CONF_PLIST.
*/
#define XBPS_SYSDIR "/xbps"
#define XBPS_SYSDIR "/xbps.d"
#ifndef XBPS_SYSCONF_PATH
# define XBPS_SYSCONF_PATH "/etc" XBPS_SYSDIR
#endif
#ifndef XBPS_SYSDEFCONF_PATH
# define XBPS_SYSDEFCONF_PATH "usr/share" XBPS_SYSDIR
# define XBPS_SYSDEFCONF_PATH "/usr/share" XBPS_SYSDIR
#endif
/**
@ -88,42 +88,6 @@
*/
#define XBPS_CACHE_PATH "var/cache/xbps"
/**
* @def XBPS_VPKG_PATH
* Configuration virtualpkg directory to store virtualpkg configuration files.
*/
#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.
*/
#define XBPS_REPOD_PATH XBPS_SYSCONF_PATH "/repo.d"
/**
* @def XBPS_SYS_REPOD_PATH
* System directory to store repository configuration files.
*/
#define XBPS_SYS_REPOD_PATH XBPS_SYSDEFCONF_PATH "/repo.d"
/**
* @def XBPS_PRESERVED_PATH
* Configuration directory to store preserve configuration files.
*/
#define XBPS_PRESERVED_PATH XBPS_SYSCONF_PATH "/preserve.d"
/**
* @def XBPS_SYS_PRESERVED_PATH
* System directory to store preserve configuration files.
*/
#define XBPS_SYS_PRESERVED_PATH XBPS_SYSDEFCONF_PATH "/preserve.d"
/**
* @def XBPS_PKGDB
* Filename for the package database.
@ -160,12 +124,6 @@
*/
#define XBPS_REPOIDX_META "index-meta.plist"
/**
* @def XBPS_CONF_DEF
* Filename for the XBPS plist configuration file.
*/
#define XBPS_CONF_DEF XBPS_SYSCONF_PATH "/xbps.conf"
/**
* @def XBPS_FLAG_VERBOSE
* Verbose flag that can be used in the function callbacks to alter
@ -586,11 +544,11 @@ struct xbps_handle {
*/
const char *target_arch;
/**
* @var conffile
* @var confdir
*
* Full path to the xbps configuration file.
* Full path to the xbps configuration directory.
*/
char conffile[XBPS_MAXPATH];
char confdir[XBPS_MAXPATH];
/**
* @var rootdir
*
@ -1834,7 +1792,8 @@ bool xbps_pkg_arch_match(struct xbps_handle *xhp,
* @return A negative number is returned on error, 0 otherwise.
*/
int xbps_humanize_number(char *buf, int64_t bytes);
size_t xbps_strlcat(char *dest, const char *src, size_t siz);
size_t xbps_strlcpy(char *dest, const char *src, size_t siz);
/**
* Tests if pkgver is reverted by pkg
*

View File

@ -45,7 +45,7 @@
#pragma clang diagnostic ignored "-Wformat-nonliteral"
#endif
static int parse_file(struct xbps_handle *, const char *, const char *, bool, bool);
static int parse_file(struct xbps_handle *, const char *, const char *, bool);
/**
* @file lib/initend.c
@ -191,14 +191,14 @@ parse_option(char *buf, char **k, char **v)
}
static int
parse_files_glob(struct xbps_handle *xhp, const char *cwd, const char *path, bool nested, bool vpkgconf)
parse_files_glob(struct xbps_handle *xhp, const char *cwd, const char *path, bool nested)
{
glob_t globbuf;
int rv = 0;
glob(path, 0, NULL, &globbuf);
for (size_t i = 0; i < globbuf.gl_pathc; i++) {
if ((rv = parse_file(xhp, cwd, globbuf.gl_pathv[i], nested, vpkgconf)) != 0)
if ((rv = parse_file(xhp, cwd, globbuf.gl_pathv[i], nested)) != 0)
break;
}
globfree(&globbuf);
@ -207,7 +207,7 @@ parse_files_glob(struct xbps_handle *xhp, const char *cwd, const char *path, boo
}
static int
parse_file(struct xbps_handle *xhp, const char *cwd, const char *path, bool nested, bool vpkgconf)
parse_file(struct xbps_handle *xhp, const char *cwd, const char *path, bool nested)
{
FILE *fp;
char tmppath[XBPS_MAXPATH] = {0};
@ -222,9 +222,7 @@ parse_file(struct xbps_handle *xhp, const char *cwd, const char *path, bool nest
return rv;
}
if (!vpkgconf) {
xbps_dbg_printf(xhp, "Parsing configuration file: %s\n", path);
}
xbps_dbg_printf(xhp, "Parsing configuration file: %s\n", path);
while ((nread = getline(&line, &len, fp)) != -1) {
char *p, *k, *v;
@ -281,7 +279,7 @@ parse_file(struct xbps_handle *xhp, const char *cwd, const char *path, bool nest
xbps_dbg_printf(xhp, "cannot chdir to %s: %s\n", cfcwd, strerror(rv));
return rv;
}
if ((rv = parse_files_glob(xhp, cwd, v, true, false)) != 0)
if ((rv = parse_files_glob(xhp, cwd, v, true)) != 0)
break;
}
@ -292,10 +290,10 @@ parse_file(struct xbps_handle *xhp, const char *cwd, const char *path, bool nest
}
static int
parse_dir(struct xbps_handle *xhp, const char *cwd, const char *dir, const char *confdir, bool vpkg)
parse_dir(struct xbps_handle *xhp, const char *cwd, const char *dir, const char *confdir)
{
struct dirent **namelist;
char *ext, ldir[PATH_MAX], conf[PATH_MAX];
char *ext, conf[PATH_MAX];
int i, n, rv = 0;
if (dir == NULL)
@ -304,11 +302,9 @@ parse_dir(struct xbps_handle *xhp, const char *cwd, const char *dir, const char
* Read all configuration files stored in the system
* foo.d directory.
*/
snprintf(ldir, sizeof(ldir), "%s/%s",
strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", dir);
xbps_dbg_printf(xhp, "Processing system directory: %s\n", ldir);
xbps_dbg_printf(xhp, "Processing system directory: %s\n", dir);
if ((n = scandir(ldir, &namelist, 0, alphasort)) < 0)
if ((n = scandir(dir, &namelist, 0, alphasort)) < 0)
goto stage2;
for (i = 0; i < n; i++) {
@ -323,20 +319,20 @@ parse_dir(struct xbps_handle *xhp, const char *cwd, const char *dir, const char
continue;
}
if (strcmp(ext, ".conf") && strcmp(ext, ".vpkg")) {
xbps_dbg_printf(xhp, "%s: ignoring %s\n", ldir, namelist[i]->d_name);
xbps_dbg_printf(xhp, "%s: ignoring %s\n", dir, namelist[i]->d_name);
free(namelist[i]);
continue;
}
/* if the same file exists in configuration directory, ignore it */
snprintf(conf, sizeof(conf), "%s/%s/%s", xhp->rootdir, confdir, namelist[i]->d_name);
snprintf(conf, sizeof(conf), "%s/%s", confdir, namelist[i]->d_name);
if (access(conf, R_OK) == 0) {
xbps_dbg_printf(xhp, "%s: ignoring %s (exists in confdir)\n", ldir, namelist[i]->d_name);
xbps_dbg_printf(xhp, "%s: ignoring %s (exists in confdir)\n", dir, namelist[i]->d_name);
free(namelist[i]);
continue;
}
/* parse conf file */
snprintf(conf, sizeof(conf), "%s/%s", ldir, namelist[i]->d_name);
if ((rv = parse_file(xhp, cwd, conf, false, vpkg)) != 0) {
snprintf(conf, sizeof(conf), "%s/%s", dir, namelist[i]->d_name);
if ((rv = parse_file(xhp, cwd, conf, false)) != 0) {
free(namelist[i]);
break;
}
@ -352,11 +348,9 @@ stage2:
/*
* Read all configuration files stored in the configuration foo.d directory.
*/
snprintf(ldir, sizeof(ldir), "%s%s",
strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", confdir);
xbps_dbg_printf(xhp, "Processing configuration directory: %s\n", ldir);
xbps_dbg_printf(xhp, "Processing configuration directory: %s\n", confdir);
if ((n = scandir(ldir, &namelist, 0, alphasort)) < 0)
if ((n = scandir(confdir, &namelist, 0, alphasort)) < 0)
return 0;
for (i = 0; i < n; i++) {
@ -371,13 +365,13 @@ stage2:
continue;
}
if (strcmp(ext, ".conf") && strcmp(ext, ".vpkg")) {
xbps_dbg_printf(xhp, "%s: ignoring %s\n", ldir, namelist[i]->d_name);
xbps_dbg_printf(xhp, "%s: ignoring %s\n", confdir, namelist[i]->d_name);
free(namelist[i]);
continue;
}
/* parse conf file */
snprintf(conf, sizeof(conf), "%s/%s", ldir, namelist[i]->d_name);
if ((rv = parse_file(xhp, cwd, conf, false, vpkg)) != 0) {
snprintf(conf, sizeof(conf), "%s/%s", confdir, namelist[i]->d_name);
if ((rv = parse_file(xhp, cwd, conf, false)) != 0) {
free(namelist[i]);
break;
}
@ -391,7 +385,7 @@ int
xbps_init(struct xbps_handle *xhp)
{
struct utsname un;
char cwd[PATH_MAX-1], *buf;
char cwd[PATH_MAX-1], sysconfdir[XBPS_MAXPATH], *buf;
const char *repodir, *native_arch;
int rv;
@ -401,14 +395,6 @@ xbps_init(struct xbps_handle *xhp)
if (getcwd(cwd, sizeof(cwd)) == NULL)
return ENOTSUP;
/* set conffile */
if (xhp->conffile[0] == '\0') {
snprintf(xhp->conffile, sizeof(xhp->conffile), XBPS_CONF_DEF);
} else {
buf = strdup(xhp->conffile);
snprintf(xhp->conffile, sizeof(xhp->conffile), "%s/%s", cwd, buf);
free(buf);
}
/* Set rootdir */
if (xhp->rootdir[0] == '\0') {
xhp->rootdir[0] = '/';
@ -418,11 +404,7 @@ xbps_init(struct xbps_handle *xhp)
snprintf(xhp->rootdir, sizeof(xhp->rootdir), "%s/%s", cwd, buf);
free(buf);
}
/* parse configuration file */
xbps_dbg_printf(xhp, "%s\n", XBPS_RELVER);
if ((rv = parse_file(xhp, cwd, xhp->conffile, false, false)) != 0) {
xbps_dbg_printf(xhp, "Using built-in defaults\n");
}
/* Set cachedir */
if (xhp->cachedir[0] == '\0') {
snprintf(xhp->cachedir, sizeof(xhp->cachedir),
@ -447,17 +429,22 @@ xbps_init(struct xbps_handle *xhp)
"%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", buf);
free(buf);
}
/* process virtualpkg.d dirs */
if ((rv = parse_dir(xhp, cwd, XBPS_SYS_VPKG_PATH, XBPS_VPKG_PATH, true)) != 0)
return rv;
/* process repo.d dirs */
if ((rv = parse_dir(xhp, cwd, XBPS_SYS_REPOD_PATH, XBPS_REPOD_PATH, false)) != 0)
return rv;
/* process preserve.d dirs */
if ((rv = parse_dir(xhp, cwd, XBPS_SYS_PRESERVED_PATH, XBPS_PRESERVED_PATH, false)) != 0)
return rv;
/* set confdir */
if (xhp->confdir[0] == '\0') {
snprintf(xhp->confdir, sizeof(xhp->confdir),
"%s%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "",
XBPS_SYSCONF_PATH);
} else if (xhp->confdir[0] != '/') {
/* relative path */
buf = strdup(xhp->confdir);
snprintf(xhp->confdir, sizeof(xhp->confdir),
"%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", buf);
free(buf);
}
/* set sysconfdir */
snprintf(sysconfdir, sizeof(sysconfdir),
"%s%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "",
XBPS_SYSDEFCONF_PATH);
xhp->target_arch = getenv("XBPS_TARGET_ARCH");
if ((native_arch = getenv("XBPS_ARCH")) != NULL) {
@ -470,9 +457,15 @@ xbps_init(struct xbps_handle *xhp)
xbps_fetch_set_cache_connection(XBPS_FETCH_CACHECONN, XBPS_FETCH_CACHECONN_HOST);
/* process xbps.d */
if ((rv = parse_dir(xhp, cwd, sysconfdir, xhp->confdir)) != 0)
return rv;
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, "confdir=%s\n", xhp->confdir);
xbps_dbg_printf(xhp, "sysconfdir=%s\n", sysconfdir);
xbps_dbg_printf(xhp, "syslog=%s\n", xhp->flags & XBPS_FLAG_DISABLE_SYSLOG ? "false" : "true");
xbps_dbg_printf(xhp, "Architecture: %s\n", xhp->native_arch);
xbps_dbg_printf(xhp, "Target Architecture: %s\n", xhp->target_arch);

View File

@ -98,7 +98,7 @@ xbps_pkg_exec_buffer(struct xbps_handle *xhp,
rv = xbps_file_exec(xhp, fpath, action, pkgname, version,
update ? "yes" : "no",
xhp->conffile, xhp->native_arch, NULL);
"no", xhp->native_arch, NULL);
free(pkgname);
out:

View File

@ -273,7 +273,6 @@ xbps_transaction_remove_pkg(struct xbps_handle *xhp,
xbps_array_t pkgs, orphans, orphans_pkg, reqby;
xbps_object_t obj;
const char *pkgver;
unsigned int count;
int rv = 0;
assert(pkgname != NULL);
@ -305,9 +304,8 @@ xbps_transaction_remove_pkg(struct xbps_handle *xhp,
if (xbps_object_type(orphans) != XBPS_TYPE_ARRAY)
return EINVAL;
count = xbps_array_count(orphans);
while (count--) {
obj = xbps_array_get(orphans, count);
for (unsigned int i = 0; i < xbps_array_count(orphans); i++) {
obj = xbps_array_get(orphans, i);
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
xbps_dictionary_set_cstring_nocopy(obj, "transaction", "remove");
if ((rv = xbps_transaction_store(xhp, pkgs, obj, false)) != 0)
@ -353,11 +351,10 @@ xbps_transaction_autoremove_pkgs(struct xbps_handle *xhp)
xbps_array_t orphans, pkgs;
xbps_object_t obj;
const char *pkgver;
unsigned int count;
int rv = 0;
orphans = xbps_find_pkg_orphans(xhp, NULL);
if ((count = xbps_array_count(orphans)) == 0) {
if (xbps_array_count(orphans) == 0) {
/* no orphans? we are done */
rv = ENOENT;
goto out;
@ -372,8 +369,8 @@ xbps_transaction_autoremove_pkgs(struct xbps_handle *xhp)
/*
* Add pkg orphan dictionary into the transaction pkgs queue.
*/
while (count--) {
obj = xbps_array_get(orphans, count);
for (unsigned int i = 0; i < xbps_array_count(orphans); i++) {
obj = xbps_array_get(orphans, i);
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
xbps_dictionary_set_cstring_nocopy(obj,
"transaction", "remove");

View File

@ -423,6 +423,18 @@ xbps_humanize_number(char *buf, int64_t bytes)
HN_AUTOSCALE, HN_DECIMAL|HN_NOSPACE);
}
size_t
xbps_strlcat(char *dest, const char *src, size_t siz)
{
return strlcat(dest, src, siz);
}
size_t
xbps_strlcpy(char *dest, const char *src, size_t siz)
{
return strlcpy(dest, src, siz);
}
/*
* Check if pkg is explicitly marked to replace a specific installed version.
*/

View File

@ -3,6 +3,6 @@ TOPDIR = ../../../..
TESTSSUBDIR = xbps/libxbps/config
TEST = config_test
EXTRA_FILES = Kyuafile xbps.conf xbps_nomatch.conf 1.include.conf 2.include.conf
EXTRA_FILES = Kyuafile xbps.cf xbps_nomatch.cf 1.include.cf 2.include.cf
include $(TOPDIR)/mk/test.mk

View File

@ -25,6 +25,8 @@
*/
#include <atf-c.h>
#include <xbps.h>
#include <stdlib.h>
#include <limits.h>
ATF_TC(config_include_test);
ATF_TC_HEAD(config_include_test, tc)
@ -36,19 +38,40 @@ ATF_TC_BODY(config_include_test, tc)
{
struct xbps_handle xh;
const char *tcsdir;
char *buf, *buf2, pwd[PATH_MAX];
/* get test source dir */
tcsdir = atf_tc_get_config_var(tc, "srcdir");
/* change dir to make sure relative paths won't match */
ATF_REQUIRE_EQ(chdir("/"), 0);
memset(&xh, 0, sizeof(xh));
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
strncpy(xh.metadir, tcsdir, sizeof(xh.metadir));
snprintf(xh.conffile, sizeof(xh.conffile), "%s/xbps.conf", tcsdir);
buf = getcwd(pwd, sizeof(pwd));
xbps_strlcpy(xh.rootdir, pwd, sizeof(xh.rootdir));
xbps_strlcpy(xh.metadir, pwd, sizeof(xh.metadir));
snprintf(xh.confdir, sizeof(xh.confdir), "%s/xbps.d", pwd);
ATF_REQUIRE_EQ(xbps_mkpath(xh.confdir, 0755), 0);
buf = xbps_xasprintf("%s/xbps.cf", tcsdir);
buf2 = xbps_xasprintf("%s/xbps.d/xbps.conf", pwd);
ATF_REQUIRE_EQ(symlink(buf, buf2), 0);
free(buf);
free(buf2);
buf = xbps_xasprintf("%s/1.include.cf", tcsdir);
buf2 = xbps_xasprintf("%s/xbps.d/1.include.conf", pwd);
ATF_REQUIRE_EQ(symlink(buf, buf2), 0);
free(buf);
free(buf2);
buf = xbps_xasprintf("%s/2.include.cf", tcsdir);
buf2 = xbps_xasprintf("%s/xbps.d/2.include.conf", pwd);
ATF_REQUIRE_EQ(symlink(buf, buf2), 0);
free(buf);
free(buf2);
xh.flags = XBPS_FLAG_DEBUG;
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
/* should contain both repositories defined in [12].include.conf */
ATF_REQUIRE_EQ(xbps_array_count(xh.repositories), 2);
}
@ -64,16 +87,26 @@ ATF_TC_BODY(config_include_nomatch_test, tc)
{
struct xbps_handle xh;
const char *tcsdir;
char *buf, *buf2, pwd[PATH_MAX];
/* get test source dir */
tcsdir = atf_tc_get_config_var(tc, "srcdir");
/* change dir to make sure relative paths won't match */
ATF_REQUIRE_EQ(chdir("/"), 0);
memset(&xh, 0, sizeof(xh));
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
strncpy(xh.metadir, tcsdir, sizeof(xh.metadir));
strncpy(xh.conffile, "/xbps_nomatch.conf", sizeof(xh.conffile));
buf = getcwd(pwd, sizeof(pwd));
xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir));
snprintf(xh.confdir, sizeof(xh.confdir), "%s/xbps.d", pwd);
ATF_REQUIRE_EQ(xbps_mkpath(xh.confdir, 0755), 0);
buf = xbps_xasprintf("%s/xbps_nomatch.cf", tcsdir);
buf2 = xbps_xasprintf("%s/xbps.d/nomatch.conf", pwd);
ATF_REQUIRE_EQ(symlink(buf, buf2), 0);
free(buf);
free(buf2);
xh.flags = XBPS_FLAG_DEBUG;
ATF_REQUIRE_EQ(xbps_init(&xh), 0);

View File

@ -78,8 +78,7 @@ ATF_TC_BODY(find_pkg_obsoletes_test, tc)
tcsdir = atf_tc_get_config_var(tc, "srcdir");
memset(&xh, 0, sizeof(xh));
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
strncpy(xh.conffile, "/tmp/unexistent.conf", sizeof(xh.conffile));
xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
d1 = create_dict("files", "/etc/foo.conf");

View File

@ -62,8 +62,8 @@ ATF_TC_BODY(find_pkg_orphans_test, tc)
tcsdir = atf_tc_get_config_var(tc, "srcdir");
memset(&xh, 0, sizeof(xh));
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
strncpy(xh.metadir, tcsdir, sizeof(xh.metadir));
xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir));
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
a = xbps_array_create();
@ -99,8 +99,8 @@ ATF_TC_BODY(find_all_orphans_test, tc)
tcsdir = atf_tc_get_config_var(tc, "srcdir");
memset(&xh, 0, sizeof(xh));
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
strncpy(xh.metadir, tcsdir, sizeof(xh.metadir));
xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir));
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
pstr = xbps_string_create();

View File

@ -42,8 +42,8 @@ ATF_TC_BODY(pkgdb_get_pkg_test, tc)
tcsdir = atf_tc_get_config_var(tc, "srcdir");
memset(&xh, 0, sizeof(xh));
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
strncpy(xh.metadir, tcsdir, sizeof(xh.metadir));
xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir));
xh.flags = XBPS_FLAG_DEBUG;
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
@ -84,8 +84,8 @@ ATF_TC_BODY(pkgdb_get_virtualpkg_test, tc)
tcsdir = atf_tc_get_config_var(tc, "srcdir");
memset(&xh, 0, sizeof(xh));
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
strncpy(xh.metadir, tcsdir, sizeof(xh.metadir));
xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir));
xh.flags = XBPS_FLAG_DEBUG;
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
@ -129,8 +129,8 @@ ATF_TC_BODY(pkgdb_get_pkg_revdeps_test, tc)
tcsdir = atf_tc_get_config_var(tc, "srcdir");
memset(&xh, 0, sizeof(xh));
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
strncpy(xh.metadir, tcsdir, sizeof(xh.metadir));
xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir));
xh.flags = XBPS_FLAG_DEBUG;
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
@ -162,8 +162,8 @@ ATF_TC_BODY(pkgdb_pkg_reverts_test, tc)
tcsdir = atf_tc_get_config_var(tc, "srcdir");
memset(&xh, 0, sizeof(xh));
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
strncpy(xh.metadir, tcsdir, sizeof(xh.metadir));
xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir));
xh.flags = XBPS_FLAG_DEBUG;
ATF_REQUIRE_EQ(xbps_init(&xh), 0);

View File

@ -19,12 +19,13 @@ tc1_body() {
cd ..
mkdir -p root/usr/bin
mkdir -p root/xbps.d
echo "modified blahblah" > root/usr/bin/blah
echo "modified foofoo" > root/usr/bin/foo
echo "preserve=/usr/bin/*" > foo.conf
echo "preserve=/usr/bin/*" > root/xbps.d/foo.conf
xbps-install -C foo.conf -r root --repository=$PWD/some_repo -yd A
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -yd A
atf_check_equal $? 0
rv=1
@ -53,15 +54,16 @@ tc2_body() {
cd ..
mkdir -p root/usr/bin
mkdir -p root/xbps.d
echo "modified blahblah" > root/usr/bin/blah
echo "modified foofoo" > root/usr/bin/foo
printf "preserve=/usr/bin/blah\npreserve=/usr/bin/foo\n" > foo.conf
printf "preserve=/usr/bin/blah\npreserve=/usr/bin/foo\n" > root/xbps.d/foo.conf
echo "foo.conf" >&2
cat foo.conf >&2
xbps-install -C foo.conf -r root --repository=$PWD/some_repo -yd A
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -yd A
atf_check_equal $? 0
rv=1

View File

@ -41,7 +41,7 @@ script_nargs_body() {
rval=0
xbps-reconfigure -C empty.conf -r root -f A 2>out
out="$(cat out)"
expected="post A 1.0_1 no $(pwd)/empty.conf $(uname -m)"
expected="post A 1.0_1 no no $(uname -m)"
if [ "$out" != "$expected" ]; then
echo "out: '$out'"
echo "expected: '$expected'"
@ -75,7 +75,7 @@ script_arch_body() {
rval=0
XBPS_ARCH=foo xbps-reconfigure -C empty.conf -r root -f A 2>out
out="$(cat out)"
expected="post A 1.0_1 no $(pwd)/empty.conf foo"
expected="post A 1.0_1 no no foo"
if [ "$out" != "$expected" ]; then
echo "out: '$out'"
echo "expected: '$expected'"