New configuration file via confuse: xbps.conf.
This commit is contained in:
8
NEWS
8
NEWS
@ -1,9 +1,13 @@
|
|||||||
xbps-0.11.0 (???):
|
xbps-0.11.0 (???):
|
||||||
|
|
||||||
|
* New shared configuration file via libconfuse that replaces the
|
||||||
|
plist configuration files: xbps.conf. That means that libxbps
|
||||||
|
now requires confuse >= 2.7 available at
|
||||||
|
http://www.nongnu.org/confuse/.
|
||||||
|
|
||||||
* Support for syslog logging common operations, such as install, update,
|
* Support for syslog logging common operations, such as install, update,
|
||||||
remove and purge via LOG_NOTICE, and errors with LOG_ERR.
|
remove and purge via LOG_NOTICE, and errors with LOG_ERR.
|
||||||
By default we enable this in configuration file `conf.plist', set the
|
By default it's always enabled, can be disabled thru the conf file.
|
||||||
boolean `syslog-enabled' key to false to disable.
|
|
||||||
|
|
||||||
* xbps-repo(8): new target: pkg-list [index]. This target will list all
|
* xbps-repo(8): new target: pkg-list [index]. This target will list all
|
||||||
packages from repository with index [index]. If optional argument
|
packages from repository with index [index]. If optional argument
|
||||||
|
1
README
1
README
@ -6,6 +6,7 @@ To build this you'll need:
|
|||||||
- zlib (development package with static libs)
|
- zlib (development package with static libs)
|
||||||
- openssl (development package with static libs)
|
- openssl (development package with static libs)
|
||||||
- libarchive >= 2.8.0 (development package with static libs)
|
- libarchive >= 2.8.0 (development package with static libs)
|
||||||
|
- confuse >= 2.7 (development package with static libs)
|
||||||
|
|
||||||
Optionally to build the API documentation:
|
Optionally to build the API documentation:
|
||||||
|
|
||||||
|
@ -73,8 +73,7 @@ check_pkg_autoinstall(prop_dictionary_t pkgd_regpkgdb,
|
|||||||
reqby = prop_dictionary_get(pkgd_regpkgdb, "requiredby");
|
reqby = prop_dictionary_get(pkgd_regpkgdb, "requiredby");
|
||||||
if (((prop_object_type(reqby) == PROP_TYPE_ARRAY)) &&
|
if (((prop_object_type(reqby) == PROP_TYPE_ARRAY)) &&
|
||||||
((prop_array_count(reqby) > 0) && !autoinst)) {
|
((prop_array_count(reqby) > 0) && !autoinst)) {
|
||||||
path = xbps_xasprintf("%s/%s/%s",
|
path = xbps_xasprintf("%s/%s/%s", xhp->rootdir,
|
||||||
prop_string_cstring_nocopy(xhp->rootdir),
|
|
||||||
XBPS_META_PATH, XBPS_REGPKGDB);
|
XBPS_META_PATH, XBPS_REGPKGDB);
|
||||||
assert(path != NULL);
|
assert(path != NULL);
|
||||||
|
|
||||||
|
@ -72,8 +72,7 @@ check_pkg_files(prop_dictionary_t pkgd_regpkgdb,
|
|||||||
|
|
||||||
while ((obj = prop_object_iterator_next(iter))) {
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
|
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
|
||||||
path = xbps_xasprintf("%s/%s",
|
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
|
||||||
prop_string_cstring_nocopy(xhp->rootdir), file);
|
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
prop_object_iterator_release(iter);
|
prop_object_iterator_release(iter);
|
||||||
return -1;
|
return -1;
|
||||||
@ -122,8 +121,7 @@ check_pkg_files(prop_dictionary_t pkgd_regpkgdb,
|
|||||||
|
|
||||||
while ((obj = prop_object_iterator_next(iter))) {
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
|
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
|
||||||
path = xbps_xasprintf("%s/%s",
|
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
|
||||||
prop_string_cstring_nocopy(xhp->rootdir), file);
|
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
prop_object_iterator_release(iter);
|
prop_object_iterator_release(iter);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -56,8 +56,7 @@ write_pkgd_to_regpkgdb(prop_dictionary_t pkgd,
|
|||||||
"packages array: %s", pkgn, strerror(errno));
|
"packages array: %s", pkgn, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
path = xbps_xasprintf("%s/%s/%s",
|
path = xbps_xasprintf("%s/%s/%s", xhp->rootdir,
|
||||||
prop_string_cstring_nocopy(xhp->rootdir),
|
|
||||||
XBPS_META_PATH, XBPS_REGPKGDB);
|
XBPS_META_PATH, XBPS_REGPKGDB);
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -76,8 +76,7 @@ check_pkg_symlinks(prop_dictionary_t pkgd_regpkgdb,
|
|||||||
"empty target object!\n", pkgname, file);
|
"empty target object!\n", pkgname, file);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
path = xbps_xasprintf("%s/%s",
|
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
|
||||||
prop_string_cstring_nocopy(xhp->rootdir), file);
|
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -90,9 +89,9 @@ check_pkg_symlinks(prop_dictionary_t pkgd_regpkgdb,
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(path);
|
free(path);
|
||||||
if (!prop_string_equals_cstring(xhp->rootdir, "/") &&
|
if (strcmp(xhp->rootdir, "/") &&
|
||||||
strstr(buf, prop_string_cstring_nocopy(xhp->rootdir)))
|
strstr(buf, xhp->rootdir))
|
||||||
path = buf + prop_string_size(xhp->rootdir);
|
path = buf + strlen(xhp->rootdir);
|
||||||
else
|
else
|
||||||
path = buf;
|
path = buf;
|
||||||
|
|
||||||
|
@ -81,8 +81,7 @@ find_files_in_packages(const char *pattern)
|
|||||||
unsigned int i, count;
|
unsigned int i, count;
|
||||||
|
|
||||||
xhp = xbps_handle_get();
|
xhp = xbps_handle_get();
|
||||||
path = xbps_xasprintf("%s/%s/metadata",
|
path = xbps_xasprintf("%s/%s/metadata", xhp->rootdir, XBPS_META_PATH);
|
||||||
prop_string_cstring_nocopy(xhp->rootdir), XBPS_META_PATH);
|
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -66,12 +66,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, *confdir, *option;
|
const char *rootdir, *cachedir, *conffile, *option;
|
||||||
int i, c, flags, rv;
|
int i, c, flags, rv;
|
||||||
bool yes, purge, debug, reqby_force, force_rm_with_deps, recursive_rm;
|
bool yes, purge, debug, reqby_force, 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 = confdir = option = NULL;
|
rootdir = cachedir = conffile = option = NULL;
|
||||||
flags = rv = 0;
|
flags = rv = 0;
|
||||||
reqby_force = yes = purge = force_rm_with_deps = false;
|
reqby_force = yes = purge = force_rm_with_deps = false;
|
||||||
recursive_rm = debug = false;
|
recursive_rm = debug = false;
|
||||||
@ -83,7 +83,7 @@ main(int argc, char **argv)
|
|||||||
install_auto = true;
|
install_auto = true;
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
confdir = optarg;
|
conffile = optarg;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
cachedir = optarg;
|
cachedir = optarg;
|
||||||
@ -155,7 +155,7 @@ main(int argc, char **argv)
|
|||||||
sigaction(SIGQUIT, &sa, NULL);
|
sigaction(SIGQUIT, &sa, NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize stuff for libxbps.
|
* Initialize libxbps.
|
||||||
*/
|
*/
|
||||||
xhp = xbps_handle_alloc();
|
xhp = xbps_handle_alloc();
|
||||||
if (xhp == NULL) {
|
if (xhp == NULL) {
|
||||||
@ -166,25 +166,20 @@ main(int argc, char **argv)
|
|||||||
xhp->state_cb = state_cb;
|
xhp->state_cb = state_cb;
|
||||||
xhp->fetch_cb = fetch_file_progress_cb;
|
xhp->fetch_cb = fetch_file_progress_cb;
|
||||||
xhp->fetch_cb_data = &xfer;
|
xhp->fetch_cb_data = &xfer;
|
||||||
|
xhp->rootdir = rootdir;
|
||||||
|
xhp->cachedir = cachedir;
|
||||||
|
xhp->conffile = conffile;
|
||||||
|
xhp->flags = flags;
|
||||||
|
xhp->install_reason_manual = install_manual;
|
||||||
|
xhp->install_reason_auto = install_auto;
|
||||||
if (flags & XBPS_FLAG_VERBOSE)
|
if (flags & XBPS_FLAG_VERBOSE)
|
||||||
xhp->unpack_cb = unpack_progress_cb_verbose;
|
xhp->unpack_cb = unpack_progress_cb_verbose;
|
||||||
else
|
else
|
||||||
xhp->unpack_cb = unpack_progress_cb;
|
xhp->unpack_cb = unpack_progress_cb;
|
||||||
|
|
||||||
if (rootdir)
|
|
||||||
xhp->rootdir = prop_string_create_cstring(rootdir);
|
|
||||||
if (cachedir)
|
|
||||||
xhp->cachedir = prop_string_create_cstring(cachedir);
|
|
||||||
if (confdir)
|
|
||||||
xhp->confdir = prop_string_create_cstring(confdir);
|
|
||||||
|
|
||||||
xhp->flags = flags;
|
|
||||||
xhp->install_reason_manual = install_manual;
|
|
||||||
xhp->install_reason_auto = install_auto;
|
|
||||||
|
|
||||||
if ((rv = xbps_init(xhp)) != 0) {
|
if ((rv = xbps_init(xhp)) != 0) {
|
||||||
xbps_error_printf("xbps-bin: couldn't initialize library: %s\n",
|
xbps_error_printf("xbps-bin: couldn't initialize library: %s\n",
|
||||||
strerror(errno));
|
strerror(rv));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbdata)
|
|||||||
if (xhp->syslog_enabled)
|
if (xhp->syslog_enabled)
|
||||||
syslog(LOG_NOTICE, "Installed `%s-%s' successfully "
|
syslog(LOG_NOTICE, "Installed `%s-%s' successfully "
|
||||||
"(rootdir: %s).", xscd->pkgname, xscd->version,
|
"(rootdir: %s).", xscd->pkgname, xscd->version,
|
||||||
prop_string_cstring_nocopy(xhp->rootdir));
|
xhp->rootdir);
|
||||||
break;
|
break;
|
||||||
case XBPS_STATE_UPDATE_DONE:
|
case XBPS_STATE_UPDATE_DONE:
|
||||||
printf("Updated `%s' to `%s' successfully.\n",
|
printf("Updated `%s' to `%s' successfully.\n",
|
||||||
@ -115,7 +115,7 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbdata)
|
|||||||
if (xhp->syslog_enabled)
|
if (xhp->syslog_enabled)
|
||||||
syslog(LOG_NOTICE, "Updated `%s' to `%s' successfully "
|
syslog(LOG_NOTICE, "Updated `%s' to `%s' successfully "
|
||||||
"(rootdir: %s).", xscd->pkgname, xscd->version,
|
"(rootdir: %s).", xscd->pkgname, xscd->version,
|
||||||
prop_string_cstring_nocopy(xhp->rootdir));
|
xhp->rootdir);
|
||||||
break;
|
break;
|
||||||
case XBPS_STATE_REMOVE_DONE:
|
case XBPS_STATE_REMOVE_DONE:
|
||||||
printf("Removed `%s-%s' successfully.\n",
|
printf("Removed `%s-%s' successfully.\n",
|
||||||
@ -123,7 +123,7 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbdata)
|
|||||||
if (xhp->syslog_enabled)
|
if (xhp->syslog_enabled)
|
||||||
syslog(LOG_NOTICE, "Removed `%s-%s' successfully "
|
syslog(LOG_NOTICE, "Removed `%s-%s' successfully "
|
||||||
"(rootdir: %s).", xscd->pkgname, xscd->version,
|
"(rootdir: %s).", xscd->pkgname, xscd->version,
|
||||||
prop_string_cstring_nocopy(xhp->rootdir));
|
xhp->rootdir);
|
||||||
break;
|
break;
|
||||||
case XBPS_STATE_PURGE_DONE:
|
case XBPS_STATE_PURGE_DONE:
|
||||||
printf("Purged `%s-%s' successfully.\n",
|
printf("Purged `%s-%s' successfully.\n",
|
||||||
@ -131,7 +131,7 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbdata)
|
|||||||
if (xhp->syslog_enabled)
|
if (xhp->syslog_enabled)
|
||||||
syslog(LOG_NOTICE, "Purged `%s-%s' successfully "
|
syslog(LOG_NOTICE, "Purged `%s-%s' successfully "
|
||||||
"(rootdir: %s).", xscd->pkgname, xscd->version,
|
"(rootdir: %s).", xscd->pkgname, xscd->version,
|
||||||
prop_string_cstring_nocopy(xhp->rootdir));
|
xhp->rootdir);
|
||||||
break;
|
break;
|
||||||
/* errors */
|
/* errors */
|
||||||
case XBPS_STATE_UNPACK_FAIL:
|
case XBPS_STATE_UNPACK_FAIL:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
.TH "XBPS\-BIN" "8" "03/12/2011" "\ \&" "\ \&"
|
.TH "XBPS\-BIN" "8" "15/12/2011" "\ \&" "\ \&"
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
.\" * set default formatting
|
.\" * set default formatting
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
@ -28,10 +28,10 @@ Use of this option takes effect in the \fIautoupdate\fR, \fIinstall\fR and
|
|||||||
matched.
|
matched.
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
\fB\-C\fR \fIconfdir\fR
|
\fB\-C\fR \fIconffile\fR
|
||||||
.RS 4
|
.RS 4
|
||||||
Full path to the XBPS configuration directory where the configuration files are available\&.
|
Full path to the XBPS configuration file\&.
|
||||||
By default it\(cqs set to \fIETCDIR/xbps\fR\&.
|
By default it\(cqs set to \fIETCDIR/xbps/xbps.conf\fR\&.
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
\fB\-c\fR \fIcachedir\fR
|
\fB\-c\fR \fIcachedir\fR
|
||||||
|
@ -446,7 +446,7 @@ main(int argc, char **argv)
|
|||||||
FILE *f = NULL;
|
FILE *f = NULL;
|
||||||
char *outfile = NULL;
|
char *outfile = NULL;
|
||||||
const char *conf_file = NULL, *rootdir = NULL;
|
const char *conf_file = NULL, *rootdir = NULL;
|
||||||
int c;
|
int c, rv;
|
||||||
bool revdeps = false;
|
bool revdeps = false;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "c:gRr:o:")) != -1) {
|
while ((c = getopt(argc, argv, "c:gRr:o:")) != -1) {
|
||||||
@ -487,10 +487,9 @@ main(int argc, char **argv)
|
|||||||
xhp = xbps_handle_alloc();
|
xhp = xbps_handle_alloc();
|
||||||
if (xhp == NULL)
|
if (xhp == NULL)
|
||||||
die("failed to allocate resources");
|
die("failed to allocate resources");
|
||||||
if (rootdir)
|
xhp->rootdir = rootdir;
|
||||||
xhp->rootdir = prop_string_create_cstring(rootdir);
|
if ((rv = xbps_init(xhp)) != 0)
|
||||||
if (xbps_init(xhp))
|
die("failed to initialize libxbps: %s", strerror(rv));
|
||||||
die("failed to initialize libxbps");
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Output file will be <pkgname>.dot if not specified.
|
* Output file will be <pkgname>.dot if not specified.
|
||||||
|
@ -56,16 +56,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, *confdir, *option;
|
const char *rootdir, *cachedir, *conffile, *option;
|
||||||
int c, rv = 0;
|
int c, rv = 0;
|
||||||
bool debug = false;
|
bool debug = false;
|
||||||
|
|
||||||
rootdir = cachedir = confdir = option = NULL;
|
rootdir = cachedir = conffile = option = NULL;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "C:c:do:r:V")) != -1) {
|
while ((c = getopt(argc, argv, "C:c:do:r:V")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'C':
|
case 'C':
|
||||||
confdir = optarg;
|
conffile = optarg;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
cachedir = optarg;
|
cachedir = optarg;
|
||||||
@ -107,16 +107,13 @@ main(int argc, char **argv)
|
|||||||
xhp->state_cb = state_cb;
|
xhp->state_cb = state_cb;
|
||||||
xhp->fetch_cb = fetch_file_progress_cb;
|
xhp->fetch_cb = fetch_file_progress_cb;
|
||||||
xhp->fetch_cb_data = &xfer;
|
xhp->fetch_cb_data = &xfer;
|
||||||
if (rootdir)
|
xhp->rootdir = rootdir;
|
||||||
xhp->rootdir = prop_string_create_cstring(rootdir);
|
xhp->cachedir = cachedir;
|
||||||
if (cachedir)
|
xhp->conffile = conffile;
|
||||||
xhp->cachedir = prop_string_create_cstring(cachedir);
|
|
||||||
if (confdir)
|
|
||||||
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",
|
||||||
strerror(errno));
|
strerror(rv));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +235,7 @@ main(int argc, char **argv)
|
|||||||
if (argc != 1)
|
if (argc != 1)
|
||||||
usage(xhp);
|
usage(xhp);
|
||||||
|
|
||||||
rv = xbps_repository_pool_sync();
|
rv = xbps_repository_pool_sync(xhp);
|
||||||
if (rv == ENOTSUP) {
|
if (rv == ENOTSUP) {
|
||||||
xbps_error_printf("xbps-repo: no repositories "
|
xbps_error_printf("xbps-repo: no repositories "
|
||||||
"currently registered!\n");
|
"currently registered!\n");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
.TH "XBPS\-REPO" "8" "03/12/2011" "\ \&" "\ \&"
|
.TH "XBPS\-REPO" "8" "15/12/2011" "\ \&" "\ \&"
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
.\" * set default formatting
|
.\" * set default formatting
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
@ -19,10 +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 \fIconfdir\fR
|
\fB\-C\fR \fIconffile\fR
|
||||||
.RS 4
|
.RS 4
|
||||||
Full path to the XBPS configuration directory where the configuration files are available\&.
|
Full path to the XBPS configuration file\&.
|
||||||
By default it\(cqs set to \fIETCDIR/xbps\fR\&.
|
By default it\(cqs set to \fIETCDIR/xbps/xbps.conf\fR\&.
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
\fB\-c\fR \fIcachedir\fR
|
\fB\-c\fR \fIcachedir\fR
|
||||||
|
@ -150,7 +150,7 @@ main(int argc, char **argv)
|
|||||||
(strcasecmp(argv[0], "version") == 0) ||
|
(strcasecmp(argv[0], "version") == 0) ||
|
||||||
(strcasecmp(argv[0], "fetch") == 0)) {
|
(strcasecmp(argv[0], "fetch") == 0)) {
|
||||||
/*
|
/*
|
||||||
* Initialize the callbacks and debug in libxbps.
|
* Initialize libxbps.
|
||||||
*/
|
*/
|
||||||
xhp = xbps_handle_alloc();
|
xhp = xbps_handle_alloc();
|
||||||
if (xhp == NULL) {
|
if (xhp == NULL) {
|
||||||
@ -160,14 +160,12 @@ main(int argc, char **argv)
|
|||||||
xhp->debug = debug;
|
xhp->debug = debug;
|
||||||
xhp->fetch_cb = fetch_file_progress_cb;
|
xhp->fetch_cb = fetch_file_progress_cb;
|
||||||
xhp->fetch_cb_data = &xfer;
|
xhp->fetch_cb_data = &xfer;
|
||||||
if (rootdir)
|
xhp->rootdir = rootdir;
|
||||||
xhp->rootdir = prop_string_create_cstring(rootdir);
|
xhp->conffile = confdir;
|
||||||
if (confdir)
|
|
||||||
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 "
|
||||||
"initialize libxbps.\n");
|
"initialize libxbps: %s.\n", strerror(rv));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
configure
vendored
15
configure
vendored
@ -530,6 +530,21 @@ else
|
|||||||
>>$CONFIG_MK
|
>>$CONFIG_MK
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# confuse >= 2.7 with pkg-config support is required.
|
||||||
|
#
|
||||||
|
printf "Checking for confuse via pkg-config ..."
|
||||||
|
if ! $PKGCONFIG_BIN --exists libconfuse; then
|
||||||
|
echo "libconfuse.pc not found, exiting."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "found version $($PKGCONFIG_BIN --modversion libconfuse)."
|
||||||
|
echo "CFLAGS += $($PKGCONFIG_BIN --cflags libconfuse)" >>$CONFIG_MK
|
||||||
|
echo "LDFLAGS += $($PKGCONFIG_BIN --libs libconfuse)" >>$CONFIG_MK
|
||||||
|
echo "STATIC_LIBS += $($PKGCONFIG_BIN --libs --static libconfuse)" \
|
||||||
|
>>$CONFIG_MK
|
||||||
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# OpenSSL libssl with pkg-config support is required.
|
# OpenSSL libssl with pkg-config support is required.
|
||||||
#
|
#
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
-include ../config.mk
|
-include ../config.mk
|
||||||
|
|
||||||
CONF_FILES = conf.plist repositories.plist
|
CONF_FILES = xbps.conf
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all:
|
all:
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<!-- Default root directory, defaults to / -->
|
|
||||||
<key>root-directory</key>
|
|
||||||
<string>/</string>
|
|
||||||
|
|
||||||
<!-- Default cache directory to store downloaded binary packages.
|
|
||||||
If string begins with '/' it will be treated as full path,
|
|
||||||
otherwise it will be treated as relative to the root-directory. -->
|
|
||||||
<key>cache-directory</key>
|
|
||||||
<string>var/cache/xbps</string>
|
|
||||||
|
|
||||||
<!-- Default global limit of cached connections when fetching -->
|
|
||||||
<key>fetch-cache-connections</key>
|
|
||||||
<integer>10</integer>
|
|
||||||
|
|
||||||
<!-- Default per-host limit of cached connections when fetching -->
|
|
||||||
<key>fetch-cache-connections-per-host</key>
|
|
||||||
<integer>6</integer>
|
|
||||||
|
|
||||||
<!-- Default timeout limit for connections, in seconds. -->
|
|
||||||
<key>fetch-timeout-connection</key>
|
|
||||||
<integer>30</integer>
|
|
||||||
|
|
||||||
<!-- Enable syslog messages, set the value to false to disable. -->
|
|
||||||
<key>syslog-enabled</key>
|
|
||||||
<true/>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
@ -1,25 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<array>
|
|
||||||
<!--
|
|
||||||
You can specify here your list of repositories, the first
|
|
||||||
repository that contains a package will be used for most
|
|
||||||
targets in xbps-bin(8) and xbps-repo(8), with the exception
|
|
||||||
for updating on which all repositories will be looked at and
|
|
||||||
the newest version will be choosen.
|
|
||||||
|
|
||||||
Optionally a non default HTTP port can also be specified such as:
|
|
||||||
http://foo.local:8080/xbps-repo
|
|
||||||
|
|
||||||
The order matters, and the top-most matching a package pattern
|
|
||||||
or name will be used.
|
|
||||||
|
|
||||||
By default we use the official "public" repositories. You can add
|
|
||||||
your own repositories by specifying the path (without the trailing
|
|
||||||
'/' character) to the directory where the index.plist file is stored.
|
|
||||||
-->
|
|
||||||
<string>http://xbps.nopcode.org/repos/current/x86_64</string>
|
|
||||||
<string>http://xbps.nopcode.org/repos/current/noarch</string>
|
|
||||||
</array>
|
|
||||||
</plist>
|
|
62
etc/xbps.conf
Normal file
62
etc/xbps.conf
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
# Configuration file for XBPS.
|
||||||
|
# ============================
|
||||||
|
#
|
||||||
|
# Root directory.
|
||||||
|
#rootdir = /
|
||||||
|
#
|
||||||
|
# Cache directory to store downloaded binary packages.
|
||||||
|
# If string begins with '/' it will be treated as full path,
|
||||||
|
# otherwise it will be treated as relative to the root-directory.
|
||||||
|
#cachedir = var/cache/xbps
|
||||||
|
#
|
||||||
|
# Default global limit of cached connections when fetching files.
|
||||||
|
#fetch-cache-connections = 10
|
||||||
|
#
|
||||||
|
# Default per-host limit of cached connections when fetching files.
|
||||||
|
#fetch-cache-connections-per-host = 3
|
||||||
|
#
|
||||||
|
# Default timeout limit for connections, in seconds.
|
||||||
|
#fetch-timeout-connection = 30
|
||||||
|
#
|
||||||
|
# Enable syslog messages, set the value to false or 0 to disable.
|
||||||
|
#syslog = true
|
||||||
|
|
||||||
|
# Repositories.
|
||||||
|
#
|
||||||
|
# You can specify here your list of repositories, the first
|
||||||
|
# repository that contains a package will be used for most
|
||||||
|
# targets in xbps-bin(8) and xbps-repo(8), with the exception
|
||||||
|
# for updating on which all repositories will be looked at and
|
||||||
|
# the newest version will be choosen.
|
||||||
|
#
|
||||||
|
# Optionally a non default HTTP port can also be specified such as:
|
||||||
|
# http://foo.local:8080/xbps-repo
|
||||||
|
#
|
||||||
|
# The order matters, and the top-most matching a package pattern
|
||||||
|
# or name will be used.
|
||||||
|
#
|
||||||
|
# By default we use the official "public" repositories. You can add
|
||||||
|
# your own repositories by specifying the path (without the trailing
|
||||||
|
# '/' character) to the directory where the index.plist file is stored.
|
||||||
|
#
|
||||||
|
# Repositories not matching the host architecture are simply ignored.
|
||||||
|
#
|
||||||
|
repositories = {
|
||||||
|
http://xbps.goodluckwith.us/binpkgs/i686,
|
||||||
|
http://xbps.goodluckwith.us/binpkgs/noarch,
|
||||||
|
http://xbps.goodluckwith.us/binpkgs/nonfree/i686,
|
||||||
|
/mnt/xbps_builder/host/binpkgs/x86_64,
|
||||||
|
/mnt/xbps_builder/host/binpkgs/noarch,
|
||||||
|
/mnt/xbps_builder/host/binpkgs/nonfree/x86_64
|
||||||
|
}
|
||||||
|
|
||||||
|
# Virtual packages.
|
||||||
|
#
|
||||||
|
# The following syntax is used:
|
||||||
|
# virtual-package <realpkgname> { targets = <virtualpkgname-version> }
|
||||||
|
#
|
||||||
|
# If a package supports multiple virtual packages these can be
|
||||||
|
# specified in the 'targets' option such as:
|
||||||
|
#
|
||||||
|
# virtual-package foo { targets = blah-0, baz-1, ... }
|
||||||
|
#
|
@ -33,6 +33,7 @@
|
|||||||
#include <archive.h>
|
#include <archive.h>
|
||||||
#include <archive_entry.h>
|
#include <archive_entry.h>
|
||||||
#include <prop/proplib.h>
|
#include <prop/proplib.h>
|
||||||
|
#include <confuse.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
# define __BEGIN_DECLS extern "C" {
|
# define __BEGIN_DECLS extern "C" {
|
||||||
@ -55,7 +56,7 @@
|
|||||||
*/
|
*/
|
||||||
#define XBPS_PKGINDEX_VERSION "1.3"
|
#define XBPS_PKGINDEX_VERSION "1.3"
|
||||||
|
|
||||||
#define XBPS_API_VERSION "20111206"
|
#define XBPS_API_VERSION "20111215"
|
||||||
#define XBPS_VERSION "0.11.0"
|
#define XBPS_VERSION "0.11.0"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,13 +71,13 @@
|
|||||||
* @def XBPS_META_PATH
|
* @def XBPS_META_PATH
|
||||||
* Default root PATH to store metadata info.
|
* Default root PATH to store metadata info.
|
||||||
*/
|
*/
|
||||||
#define XBPS_META_PATH "/var/db/xbps"
|
#define XBPS_META_PATH "var/db/xbps"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def XBPS_CACHE_PATH
|
* @def XBPS_CACHE_PATH
|
||||||
* Default cache PATH to store downloaded binpkgs.
|
* Default cache PATH to store downloaded binpkgs.
|
||||||
*/
|
*/
|
||||||
#define XBPS_CACHE_PATH "/var/cache/xbps"
|
#define XBPS_CACHE_PATH "var/cache/xbps"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def XBPS_REGPKGDB
|
* @def XBPS_REGPKGDB
|
||||||
@ -115,20 +116,7 @@
|
|||||||
* @def XBPS_CONF_PLIST
|
* @def XBPS_CONF_PLIST
|
||||||
* Filename for the XBPS plist configuration file.
|
* Filename for the XBPS plist configuration file.
|
||||||
*/
|
*/
|
||||||
#define XBPS_CONF_PLIST "conf.plist"
|
#define XBPS_CONF_DEF XBPS_SYSCONF_PATH "/xbps.conf"
|
||||||
|
|
||||||
/**
|
|
||||||
* @def XBPS_CONF_REPOS_PLIST
|
|
||||||
* Filename for the XBPS repositories plist configuration file.
|
|
||||||
*/
|
|
||||||
#define XBPS_CONF_REPOS_PLIST "repositories.plist"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @def XBPS_VIRTUALPKGD_PATH
|
|
||||||
* Default directory to load virtualpkg plist files, by default set
|
|
||||||
* to XBPS_SYSCONF_PATH + "/" + XBPS_VIRTUALPKGD_PATH.
|
|
||||||
*/
|
|
||||||
#define XBPS_VIRTUALPKGD_PATH "virtualpkg.d.wants"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def XBPS_FLAG_VERBOSE
|
* @def XBPS_FLAG_VERBOSE
|
||||||
@ -153,6 +141,24 @@
|
|||||||
*/
|
*/
|
||||||
#define XBPS_FLAG_FORCE_REMOVE_FILES 0x00000004
|
#define XBPS_FLAG_FORCE_REMOVE_FILES 0x00000004
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @def XBPS_FETCH_CACHECONN
|
||||||
|
* Default (global) limit of cached connections used in libfetch.
|
||||||
|
*/
|
||||||
|
#define XBPS_FETCH_CACHECONN 6
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @def XBPS_FETCH_CACHECONN_HOST
|
||||||
|
* Default (per host) limit of cached connections used in libfetch.
|
||||||
|
*/
|
||||||
|
#define XBPS_FETCH_CACHECONN_HOST 2
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @def XBPS_FETCH_TIMEOUT
|
||||||
|
* Default timeout limit (in seconds) to wait for stalled connections.
|
||||||
|
*/
|
||||||
|
#define XBPS_FETCH_TIMEOUT 30
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
void xbps_dbg_printf(const char *, ...);
|
void xbps_dbg_printf(const char *, ...);
|
||||||
@ -411,14 +417,7 @@ struct xbps_handle {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
prop_array_t virtualpkgs_array;
|
cfg_t *cfg;
|
||||||
/**
|
|
||||||
* @private repos_array
|
|
||||||
*
|
|
||||||
* Internalized proplib array from XBPS_CONF_REPOS_PLIST file.
|
|
||||||
* Used internally by xbps_init(), do not use it.
|
|
||||||
*/
|
|
||||||
prop_array_t repos_array;
|
|
||||||
/**
|
/**
|
||||||
* @var regpkgdb_dictionary.
|
* @var regpkgdb_dictionary.
|
||||||
*
|
*
|
||||||
@ -474,20 +473,20 @@ struct xbps_handle {
|
|||||||
* Root directory for all operations in XBPS. If NULL,
|
* Root directory for all operations in XBPS. If NULL,
|
||||||
* by default it's set to /.
|
* by default it's set to /.
|
||||||
*/
|
*/
|
||||||
prop_string_t rootdir;
|
const char *rootdir;
|
||||||
/**
|
/**
|
||||||
* @var cachedir
|
* @var cachedir
|
||||||
*
|
*
|
||||||
* Cache directory to store downloaded binary packages.
|
* Cache directory to store downloaded binary packages.
|
||||||
* If NULL default value in \a XBPS_CACHE_PATH is used.
|
* If NULL default value in \a XBPS_CACHE_PATH is used.
|
||||||
*/
|
*/
|
||||||
prop_string_t cachedir;
|
const char *cachedir;
|
||||||
/**
|
/**
|
||||||
* @var confdir
|
* @var confdir
|
||||||
*
|
*
|
||||||
* Full path to the XBPS_SYSCONF_PATH directory.
|
* Full path to the XBPS_SYSCONF_PATH directory.
|
||||||
*/
|
*/
|
||||||
prop_string_t confdir;
|
const char *conffile;
|
||||||
/**
|
/**
|
||||||
* @private fetch_timeout
|
* @private fetch_timeout
|
||||||
*
|
*
|
||||||
@ -1292,7 +1291,7 @@ struct repository_pool_index {
|
|||||||
*
|
*
|
||||||
* URI string associated with repository.
|
* URI string associated with repository.
|
||||||
*/
|
*/
|
||||||
char *rpi_uri;
|
const char *rpi_uri;
|
||||||
/**
|
/**
|
||||||
* @var rpi_index
|
* @var rpi_index
|
||||||
*
|
*
|
||||||
@ -1308,7 +1307,7 @@ struct repository_pool_index {
|
|||||||
* @return 0 on success, ENOTSUP if no repositories were found in
|
* @return 0 on success, ENOTSUP if no repositories were found in
|
||||||
* the configuration file.
|
* the configuration file.
|
||||||
*/
|
*/
|
||||||
int xbps_repository_pool_sync(void);
|
int xbps_repository_pool_sync(const struct xbps_handle *xhp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates over the repository pool and executes the \a fn function
|
* Iterates over the repository pool and executes the \a fn function
|
||||||
|
@ -59,20 +59,6 @@
|
|||||||
#define HIDDEN
|
#define HIDDEN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
|
||||||
* @def XBPS_FETCH_CACHECONN
|
|
||||||
*
|
|
||||||
* Default (global) limit of cached connections used in libfetch.
|
|
||||||
*/
|
|
||||||
#define XBPS_FETCH_CACHECONN 6
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @def XBPS_FETCH_CACHECONN_HOST
|
|
||||||
*
|
|
||||||
* Default (per host) limit of cached connections used in libfetch.
|
|
||||||
*/
|
|
||||||
#define XBPS_FETCH_CACHECONN_HOST 2
|
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,7 +78,7 @@ void HIDDEN xbps_regpkgdb_dictionary_release(void);
|
|||||||
* @private
|
* @private
|
||||||
* From lib/repository_pool.c
|
* From lib/repository_pool.c
|
||||||
*/
|
*/
|
||||||
int HIDDEN xbps_repository_pool_init(void);
|
int HIDDEN xbps_repository_pool_init(const struct xbps_handle *);
|
||||||
void HIDDEN xbps_repository_pool_release(void);
|
void HIDDEN xbps_repository_pool_release(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,10 +46,10 @@ OBJS += package_remove.o package_remove_obsoletes.o package_state.o
|
|||||||
OBJS += package_unpack.o package_requiredby.o package_register.o
|
OBJS += package_unpack.o package_requiredby.o package_register.o
|
||||||
OBJS += package_purge.o transaction_commit.o transaction_package_replace.o
|
OBJS += package_purge.o transaction_commit.o transaction_package_replace.o
|
||||||
OBJS += transaction_dictionary.o transaction_sortdeps.o transaction_ops.o
|
OBJS += transaction_dictionary.o transaction_sortdeps.o transaction_ops.o
|
||||||
OBJS += download.o
|
OBJS += download.o initend.o
|
||||||
OBJS += plist.o plist_archive_entry.o plist_find.o plist_match.o
|
OBJS += plist.o plist_archive_entry.o plist_find.o plist_match.o
|
||||||
OBJS += plist_remove.o plist_fetch.o util.o util_hash.o
|
OBJS += plist_remove.o plist_fetch.o util.o util_hash.o
|
||||||
OBJS += initend.o regpkgdb_dictionary.o init_virtualpkgs.o
|
OBJS += regpkgdb_dictionary.o
|
||||||
OBJS += repository_finddeps.o cb_util.o
|
OBJS += repository_finddeps.o cb_util.o
|
||||||
OBJS += repository_pool.o repository_pool_find.o repository_sync_index.o
|
OBJS += repository_pool.o repository_pool_find.o repository_sync_index.o
|
||||||
OBJS += $(EXTOBJS) $(COMPAT_SRCS)
|
OBJS += $(EXTOBJS) $(COMPAT_SRCS)
|
||||||
|
@ -111,12 +111,7 @@ xbps_fetch_file(const char *uri,
|
|||||||
fetchLastErrCode = 0;
|
fetchLastErrCode = 0;
|
||||||
|
|
||||||
xhp = xbps_handle_get();
|
xhp = xbps_handle_get();
|
||||||
|
|
||||||
if (xhp->fetch_timeout != 0)
|
|
||||||
fetchTimeout = xhp->fetch_timeout;
|
fetchTimeout = xhp->fetch_timeout;
|
||||||
else
|
|
||||||
fetchTimeout = 30; /* 30s if not set in configuration file. */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the filename specified in URI argument.
|
* Get the filename specified in URI argument.
|
||||||
*/
|
*/
|
||||||
|
@ -1,111 +0,0 @@
|
|||||||
/*-
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
void HIDDEN
|
|
||||||
xbps_init_virtual_pkgs(struct xbps_handle *xh)
|
|
||||||
{
|
|
||||||
struct dirent *dp;
|
|
||||||
DIR *dirp;
|
|
||||||
prop_dictionary_t vpkgd;
|
|
||||||
prop_string_t vpkgdir;
|
|
||||||
char *vpkgfile;
|
|
||||||
|
|
||||||
assert(xh != NULL);
|
|
||||||
|
|
||||||
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
|
|
||||||
* into xhp->virtualpkgs_array.
|
|
||||||
*/
|
|
||||||
dirp = opendir(prop_string_cstring_nocopy(vpkgdir));
|
|
||||||
if (dirp == NULL) {
|
|
||||||
xbps_dbg_printf("[init_virtualpkgs] cannot access "
|
|
||||||
"to %s for virtual packages: %s\n",
|
|
||||||
prop_string_cstring_nocopy(vpkgdir),
|
|
||||||
strerror(errno));
|
|
||||||
prop_object_release(vpkgdir);
|
|
||||||
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",
|
|
||||||
prop_string_cstring_nocopy(vpkgdir), dp->d_name);
|
|
||||||
if (vpkgfile == NULL) {
|
|
||||||
xbps_dbg_printf("[init_virtualpkgs] failed to "
|
|
||||||
"alloc mem for %s\n", dp->d_name);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
vpkgd = prop_dictionary_internalize_from_file(vpkgfile);
|
|
||||||
free(vpkgfile);
|
|
||||||
|
|
||||||
if (vpkgd == NULL) {
|
|
||||||
xbps_dbg_printf("[init_virtualpkgs] failed to "
|
|
||||||
"internalize %s: %s\n",
|
|
||||||
dp->d_name, strerror(errno));
|
|
||||||
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("[init_virtualpkgs] failed to add %s "
|
|
||||||
"virtuapkg dictionary!\n", dp->d_name);
|
|
||||||
prop_object_release(vpkgd);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
xbps_dbg_printf("[init_virtualpkgs] registered virtualpkg "
|
|
||||||
"'%s'\n", dp->d_name);
|
|
||||||
}
|
|
||||||
(void)closedir(dirp);
|
|
||||||
prop_object_release(vpkgdir);
|
|
||||||
}
|
|
205
lib/initend.c
205
lib/initend.c
@ -42,129 +42,115 @@
|
|||||||
static bool debug;
|
static bool debug;
|
||||||
static struct xbps_handle *xhp;
|
static struct xbps_handle *xhp;
|
||||||
|
|
||||||
#define _CONFFILE XBPS_SYSCONF_PATH "/" XBPS_CONF_PLIST
|
static int
|
||||||
#define _REPOFILE XBPS_SYSCONF_PATH "/" XBPS_CONF_REPOS_PLIST
|
cb_validate_virtual(cfg_t *cfg, cfg_opt_t *opt)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i = 0; i < cfg_size(cfg, "virtual-package"); i++) {
|
||||||
|
cfg_t *sec = cfg_opt_getnsec(opt, i);
|
||||||
|
if (cfg_getstr(sec, "targets") == 0) {
|
||||||
|
cfg_error(cfg, "targets must be set for "
|
||||||
|
"virtual-package %s", cfg_title(sec));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
xbps_init(struct xbps_handle *xh)
|
xbps_init(struct xbps_handle *xh)
|
||||||
{
|
{
|
||||||
prop_dictionary_t confd;
|
cfg_opt_t vpkg_opts[] = {
|
||||||
prop_string_t conffile = NULL, repofile = NULL;
|
CFG_STR_LIST((char *)"targets", NULL, CFGF_NONE),
|
||||||
const char *conf_rootdir = NULL, *conf_cachedir = NULL;
|
CFG_END()
|
||||||
uint16_t fetch_cache_conn = 0, fetch_cache_conn_host = 0;
|
};
|
||||||
int rv;
|
cfg_opt_t opts[] = {
|
||||||
|
/* Defaults if not set in configuration file */
|
||||||
|
CFG_STR((char *)"rootdir", (char *)"/", CFGF_NONE),
|
||||||
|
CFG_STR((char *)"cachedir", (char *)XBPS_CACHE_PATH, CFGF_NONE),
|
||||||
|
CFG_INT((char *)"fetch-cache-connections",
|
||||||
|
XBPS_FETCH_CACHECONN, CFGF_NONE),
|
||||||
|
CFG_INT((char *)"fetch-cache-connections-per-host",
|
||||||
|
XBPS_FETCH_CACHECONN_HOST, CFGF_NONE),
|
||||||
|
CFG_INT((char *)"fetch-timeout-connection",
|
||||||
|
XBPS_FETCH_TIMEOUT, CFGF_NONE),
|
||||||
|
CFG_BOOL((char *)"syslog", true, CFGF_NONE),
|
||||||
|
CFG_STR_LIST((char *)"repositories", NULL, CFGF_MULTI),
|
||||||
|
CFG_SEC((char *)"virtual-package",
|
||||||
|
vpkg_opts, CFGF_MULTI|CFGF_TITLE),
|
||||||
|
CFG_FUNC((char *)"include", &cfg_include),
|
||||||
|
CFG_END()
|
||||||
|
};
|
||||||
|
int rv, cc, cch;
|
||||||
|
|
||||||
assert(xh != NULL);
|
assert(xh != NULL);
|
||||||
|
|
||||||
xhp = xh;
|
xhp = xh;
|
||||||
debug = xhp->debug;
|
debug = xhp->debug;
|
||||||
|
|
||||||
/* If confdir not set, defaults to XBPS_SYSCONF_PATH */
|
if (xhp->conffile == NULL)
|
||||||
if (prop_object_type(xhp->confdir) != PROP_TYPE_STRING) {
|
xhp->conffile = XBPS_CONF_DEF;
|
||||||
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);
|
/* parse configuration file */
|
||||||
prop_string_append_cstring(repofile, "/");
|
xhp->cfg = cfg_init(opts, CFGF_NOCASE);
|
||||||
prop_string_append_cstring(repofile, XBPS_CONF_REPOS_PLIST);
|
cfg_set_validate_func(xhp->cfg, "virtual-package", &cb_validate_virtual);
|
||||||
}
|
|
||||||
/*
|
if ((rv = cfg_parse(xhp->cfg, xhp->conffile)) != CFG_SUCCESS) {
|
||||||
* Internalize the XBPS_CONF_REPOS_PLIST array.
|
if (rv == CFG_PARSE_ERROR) {
|
||||||
*/
|
|
||||||
xhp->repos_array =
|
|
||||||
prop_array_internalize_from_file(prop_string_cstring_nocopy(repofile));
|
|
||||||
/*
|
|
||||||
* Internalize the XBPS_CONF_PLIST dictionary.
|
|
||||||
*/
|
|
||||||
confd = prop_dictionary_internalize_from_file(
|
|
||||||
prop_string_cstring_nocopy(conffile));
|
|
||||||
if (confd == NULL) {
|
|
||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
xbps_dbg_printf("%s: cannot internalize conf "
|
/*
|
||||||
"dictionary: %s\n", strerror(errno));
|
* Don't error out if config file not found.
|
||||||
|
* We'll use defaults without any repo or
|
||||||
|
* virtual packages.
|
||||||
|
*/
|
||||||
xbps_end(xh);
|
xbps_end(xh);
|
||||||
return errno;
|
return rv;
|
||||||
}
|
}
|
||||||
xbps_dbg_printf("%s: conf_dictionary not internalized.\n",
|
errno = 0;
|
||||||
__func__);
|
} else if (rv == CFG_PARSE_ERROR) {
|
||||||
} else {
|
|
||||||
/*
|
/*
|
||||||
* Get defaults from configuration file.
|
* Parser error from configuration file.
|
||||||
*/
|
*/
|
||||||
prop_dictionary_get_cstring_nocopy(confd,
|
xbps_end(xh);
|
||||||
"root-directory", &conf_rootdir);
|
return ENOTSUP;
|
||||||
prop_dictionary_get_cstring_nocopy(confd,
|
}
|
||||||
"cache-directory", &conf_cachedir);
|
|
||||||
prop_dictionary_get_uint16(confd,
|
|
||||||
"fetch-cache-connections", &fetch_cache_conn);
|
|
||||||
prop_dictionary_get_uint16(confd,
|
|
||||||
"fetch-cache-connections-per-host", &fetch_cache_conn_host);
|
|
||||||
prop_dictionary_get_uint16(confd,
|
|
||||||
"fetch-timeout-connection", &xhp->fetch_timeout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Client supplied values in xbps_handle will be choosen over the
|
* Respect client setting in struct xbps_handle for {root,cache}dir;
|
||||||
* same values in configuration file. If not specified, use defaults.
|
* otherwise use values from configuration file or defaults if unset.
|
||||||
*/
|
*/
|
||||||
if (prop_object_type(xhp->rootdir) != PROP_TYPE_STRING) {
|
if (xhp->rootdir == NULL) {
|
||||||
if (conf_rootdir != NULL)
|
if (xhp->cfg == NULL)
|
||||||
xhp->rootdir = prop_string_create_cstring(conf_rootdir);
|
xhp->rootdir = "/";
|
||||||
else {
|
else
|
||||||
/* If rootdir not set, defaults to '/' */
|
xhp->rootdir = cfg_getstr(xhp->cfg, "rootdir");
|
||||||
xhp->rootdir = prop_string_create_cstring("/");
|
|
||||||
}
|
}
|
||||||
|
if (xhp->cachedir == NULL) {
|
||||||
|
if (xhp->cfg == NULL)
|
||||||
|
xhp->cachedir = XBPS_CACHE_PATH;
|
||||||
|
else
|
||||||
|
xhp->cachedir = cfg_getstr(xhp->cfg, "cachedir");
|
||||||
}
|
}
|
||||||
if (prop_object_type(xhp->cachedir) != PROP_TYPE_STRING) {
|
if (xhp->cfg == NULL) {
|
||||||
if (conf_cachedir != NULL) {
|
xhp->syslog_enabled = true;
|
||||||
if (conf_cachedir[0] == '/') {
|
xhp->fetch_timeout = XBPS_FETCH_TIMEOUT;
|
||||||
/* full path */
|
cc = XBPS_FETCH_CACHECONN;
|
||||||
xhp->cachedir =
|
cch = XBPS_FETCH_CACHECONN_HOST;
|
||||||
prop_string_create_cstring(conf_cachedir);
|
|
||||||
} else {
|
} else {
|
||||||
/* relative to rootdir */
|
xhp->syslog_enabled = cfg_getbool(xhp->cfg, "syslog");
|
||||||
xhp->cachedir = prop_string_copy(xhp->rootdir);
|
xhp->fetch_timeout = cfg_getint(xhp->cfg, "fetch-timeout-connection");
|
||||||
prop_string_append_cstring(
|
cc = cfg_getint(xhp->cfg, "fetch-cache-connections");
|
||||||
xhp->cachedir, "/");
|
cch = cfg_getint(xhp->cfg, "fetch-cache-connections-per-host");
|
||||||
prop_string_append_cstring(
|
|
||||||
xhp->cachedir, conf_cachedir);
|
|
||||||
}
|
}
|
||||||
} else {
|
xbps_fetch_set_cache_connection(cc, cch);
|
||||||
/* If cachedir not set, defaults to XBPS_CACHE_PATH */
|
|
||||||
xhp->cachedir =
|
|
||||||
prop_string_create_cstring(XBPS_CACHE_PATH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fetch_cache_conn == 0)
|
|
||||||
fetch_cache_conn = XBPS_FETCH_CACHECONN;
|
|
||||||
if (fetch_cache_conn_host == 0)
|
|
||||||
fetch_cache_conn_host = XBPS_FETCH_CACHECONN_HOST;
|
|
||||||
|
|
||||||
xbps_fetch_set_cache_connection(fetch_cache_conn,
|
|
||||||
fetch_cache_conn_host);
|
|
||||||
|
|
||||||
xbps_dbg_printf("rootdir: %s\n",
|
|
||||||
prop_string_cstring_nocopy(xhp->rootdir));
|
|
||||||
xbps_dbg_printf("cachedir: %s\n",
|
|
||||||
prop_string_cstring_nocopy(xhp->cachedir));
|
|
||||||
xbps_dbg_printf("conffile: %s\n",
|
|
||||||
prop_string_cstring_nocopy(conffile));
|
|
||||||
xbps_dbg_printf("repofile: %s\n",
|
|
||||||
prop_string_cstring_nocopy(repofile));
|
|
||||||
xbps_dbg_printf("fetch_cache_conn: %zu\n",
|
|
||||||
fetch_cache_conn);
|
|
||||||
xbps_dbg_printf("fetch_cache_conn_host: %zu\n",
|
|
||||||
fetch_cache_conn_host);
|
|
||||||
xbps_dbg_printf("fetch_timeout: %zu\n",
|
|
||||||
xhp->fetch_timeout);
|
|
||||||
|
|
||||||
prop_dictionary_get_bool(confd, "syslog-enabled", &xhp->syslog_enabled);
|
|
||||||
xbps_dbg_printf("syslog logging: %d\n", xhp->syslog_enabled);
|
|
||||||
|
|
||||||
|
xbps_dbg_printf("rootdir=%s\n", xhp->rootdir);
|
||||||
|
xbps_dbg_printf("cachedir=%s\n", xhp->cachedir);
|
||||||
|
xbps_dbg_printf("fetch-timeout=%u\n", xhp->fetch_timeout);
|
||||||
|
xbps_dbg_printf("fetch-cacheconn=%u\n", cc);
|
||||||
|
xbps_dbg_printf("fetch-cacheconn-host=%u\n", cch);
|
||||||
|
xbps_dbg_printf("syslog=%u\n", xhp->syslog_enabled);
|
||||||
/*
|
/*
|
||||||
* Initialize regpkgdb dictionary.
|
* Initialize regpkgdb dictionary.
|
||||||
*/
|
*/
|
||||||
@ -173,18 +159,9 @@ xbps_init(struct xbps_handle *xh)
|
|||||||
xbps_dbg_printf("%s: couldn't initialize "
|
xbps_dbg_printf("%s: couldn't initialize "
|
||||||
"regpkgdb: %s\n", strerror(rv));
|
"regpkgdb: %s\n", strerror(rv));
|
||||||
xbps_end(xh);
|
xbps_end(xh);
|
||||||
return rv;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (prop_object_type(confd) == PROP_TYPE_DICTIONARY)
|
|
||||||
prop_object_release(confd);
|
|
||||||
if (prop_object_type(conffile) == PROP_TYPE_STRING)
|
|
||||||
prop_object_release(conffile);
|
|
||||||
if (prop_object_type(repofile) == PROP_TYPE_STRING)
|
|
||||||
prop_object_release(repofile);
|
|
||||||
|
|
||||||
/* Initialize virtual package settings */
|
|
||||||
xbps_init_virtual_pkgs(xhp);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -198,14 +175,8 @@ xbps_end(struct xbps_handle *xh)
|
|||||||
|
|
||||||
if (xh == NULL)
|
if (xh == NULL)
|
||||||
return;
|
return;
|
||||||
if (prop_object_type(xh->confdir) == PROP_TYPE_STRING)
|
if (xh->cfg != NULL)
|
||||||
prop_object_release(xh->confdir);
|
cfg_free(xh->cfg);
|
||||||
if (prop_object_type(xh->rootdir) == PROP_TYPE_STRING)
|
|
||||||
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);
|
|
||||||
|
|
||||||
free(xh);
|
free(xh);
|
||||||
xh = NULL;
|
xh = NULL;
|
||||||
|
@ -128,12 +128,11 @@ xbps_configure_pkg(const char *pkgname,
|
|||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chdir(prop_string_cstring_nocopy(xhp->rootdir)) == -1) {
|
if (chdir(xhp->rootdir) == -1) {
|
||||||
xbps_set_cb_state(XBPS_STATE_CONFIGURE_FAIL, errno,
|
xbps_set_cb_state(XBPS_STATE_CONFIGURE_FAIL, errno,
|
||||||
pkgname, lver,
|
pkgname, lver,
|
||||||
"%s: [configure] failed to chdir to rootdir `%s': %s",
|
"%s: [configure] failed to chdir to rootdir `%s': %s",
|
||||||
pkgver, prop_string_cstring_nocopy(xhp->rootdir),
|
pkgver, xhp->rootdir, strerror(errno));
|
||||||
strerror(errno));
|
|
||||||
free(buf);
|
free(buf);
|
||||||
free(pkgver);
|
free(pkgver);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
@ -188,16 +188,15 @@ xbps_purge_pkg(const char *pkgname, bool check_state)
|
|||||||
/*
|
/*
|
||||||
* Execute the purge action in REMOVE script (if found).
|
* Execute the purge action in REMOVE script (if found).
|
||||||
*/
|
*/
|
||||||
if (chdir(prop_string_cstring_nocopy(xhp->rootdir)) == -1) {
|
if (chdir(xhp->rootdir) == -1) {
|
||||||
rv = errno;
|
rv = errno;
|
||||||
xbps_set_cb_state(XBPS_STATE_PURGE_FAIL,
|
xbps_set_cb_state(XBPS_STATE_PURGE_FAIL,
|
||||||
rv, pkgname, version,
|
rv, pkgname, version,
|
||||||
"%s: [purge] failed to chdir to rootdir `%s': %s",
|
"%s: [purge] failed to chdir to rootdir `%s': %s",
|
||||||
pkgver, prop_string_cstring_nocopy(xhp->rootdir),
|
pkgver, xhp->rootdir, strerror(rv));
|
||||||
strerror(rv));
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
buf = xbps_xasprintf(".%s/metadata/%s/REMOVE", XBPS_META_PATH, pkgname);
|
buf = xbps_xasprintf("%s/metadata/%s/REMOVE", XBPS_META_PATH, pkgname);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
rv = ENOMEM;
|
rv = ENOMEM;
|
||||||
return rv;
|
return rv;
|
||||||
@ -221,7 +220,7 @@ xbps_purge_pkg(const char *pkgname, bool check_state)
|
|||||||
* Remove metadata dir and unregister package.
|
* Remove metadata dir and unregister package.
|
||||||
*/
|
*/
|
||||||
if ((rv = remove_pkg_metadata(pkgname, version, pkgver,
|
if ((rv = remove_pkg_metadata(pkgname, version, pkgver,
|
||||||
prop_string_cstring_nocopy(xhp->rootdir))) != 0) {
|
xhp->rootdir)) != 0) {
|
||||||
xbps_set_cb_state(XBPS_STATE_PURGE_FAIL,
|
xbps_set_cb_state(XBPS_STATE_PURGE_FAIL,
|
||||||
rv, pkgname, version,
|
rv, pkgname, version,
|
||||||
"%s: [purge] failed to remove metadata files: %s",
|
"%s: [purge] failed to remove metadata files: %s",
|
||||||
|
@ -53,8 +53,7 @@ xbps_register_pkg(prop_dictionary_t pkgrd)
|
|||||||
assert(prop_object_type(pkgrd) == PROP_TYPE_DICTIONARY);
|
assert(prop_object_type(pkgrd) == PROP_TYPE_DICTIONARY);
|
||||||
|
|
||||||
xhp = xbps_handle_get();
|
xhp = xbps_handle_get();
|
||||||
plist = xbps_xasprintf("%s/%s/%s",
|
plist = xbps_xasprintf("%s/%s/%s", xhp->rootdir,
|
||||||
prop_string_cstring_nocopy(xhp->rootdir),
|
|
||||||
XBPS_META_PATH, XBPS_REGPKGDB);
|
XBPS_META_PATH, XBPS_REGPKGDB);
|
||||||
if (plist == NULL)
|
if (plist == NULL)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
@ -172,8 +171,7 @@ xbps_unregister_pkg(const char *pkgname, const char *version)
|
|||||||
xbps_set_cb_state(XBPS_STATE_UNREGISTER, 0, pkgname, version, NULL);
|
xbps_set_cb_state(XBPS_STATE_UNREGISTER, 0, pkgname, version, NULL);
|
||||||
|
|
||||||
xhp = xbps_handle_get();
|
xhp = xbps_handle_get();
|
||||||
plist = xbps_xasprintf("%s/%s/%s",
|
plist = xbps_xasprintf("%s/%s/%s", xhp->rootdir,
|
||||||
prop_string_cstring_nocopy(xhp->rootdir),
|
|
||||||
XBPS_META_PATH, XBPS_REGPKGDB);
|
XBPS_META_PATH, XBPS_REGPKGDB);
|
||||||
if (plist == NULL) {
|
if (plist == NULL) {
|
||||||
rv = ENOMEM;
|
rv = ENOMEM;
|
||||||
|
@ -110,8 +110,7 @@ xbps_remove_pkg_files(prop_dictionary_t dict,
|
|||||||
|
|
||||||
while ((obj = prop_object_iterator_next(iter))) {
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
|
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
|
||||||
path = xbps_xasprintf("%s/%s",
|
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
|
||||||
prop_string_cstring_nocopy(xhp->rootdir), file);
|
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
rv = ENOMEM;
|
rv = ENOMEM;
|
||||||
break;
|
break;
|
||||||
@ -224,13 +223,12 @@ xbps_remove_pkg(const char *pkgname, const char *version, bool update)
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chdir(prop_string_cstring_nocopy(xhp->rootdir)) == -1) {
|
if (chdir(xhp->rootdir) == -1) {
|
||||||
rv = errno;
|
rv = errno;
|
||||||
xbps_set_cb_state(XBPS_STATE_REMOVE_FAIL,
|
xbps_set_cb_state(XBPS_STATE_REMOVE_FAIL,
|
||||||
rv, pkgname, version,
|
rv, pkgname, version,
|
||||||
"%s: [remove] failed to chdir to rootdir `%s': %s",
|
"%s: [remove] failed to chdir to rootdir `%s': %s",
|
||||||
pkgver, prop_string_cstring_nocopy(xhp->rootdir),
|
pkgver, xhp->rootdir, strerror(rv));
|
||||||
strerror(rv));
|
|
||||||
free(buf);
|
free(buf);
|
||||||
free(pkgver);
|
free(pkgver);
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -109,8 +109,7 @@ xbps_requiredby_pkg_remove(const char *pkgname)
|
|||||||
assert(pkgname != NULL);
|
assert(pkgname != NULL);
|
||||||
|
|
||||||
xhp = xbps_handle_get();
|
xhp = xbps_handle_get();
|
||||||
plist = xbps_xasprintf("%s/%s/%s",
|
plist = xbps_xasprintf("%s/%s/%s", xhp->rootdir,
|
||||||
prop_string_cstring_nocopy(xhp->rootdir),
|
|
||||||
XBPS_META_PATH, XBPS_REGPKGDB);
|
XBPS_META_PATH, XBPS_REGPKGDB);
|
||||||
if (plist == NULL)
|
if (plist == NULL)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
|
@ -179,8 +179,7 @@ xbps_set_pkg_state_installed(const char *pkgname,
|
|||||||
assert(pkgname != NULL);
|
assert(pkgname != NULL);
|
||||||
xhp = xbps_handle_get();
|
xhp = xbps_handle_get();
|
||||||
|
|
||||||
metadir = xbps_xasprintf("%s/%s",
|
metadir = xbps_xasprintf("%s/%s", xhp->rootdir, XBPS_META_PATH);
|
||||||
prop_string_cstring_nocopy(xhp->rootdir), XBPS_META_PATH);
|
|
||||||
if (metadir == NULL)
|
if (metadir == NULL)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
plist = xbps_xasprintf("%s/%s", metadir, XBPS_REGPKGDB);
|
plist = xbps_xasprintf("%s/%s", metadir, XBPS_REGPKGDB);
|
||||||
|
@ -96,7 +96,7 @@ extract_metafile(struct archive *ar,
|
|||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
version = xbps_pkg_version(pkgver);
|
version = xbps_pkg_version(pkgver);
|
||||||
|
|
||||||
buf = xbps_xasprintf(".%s/metadata/%s/%s",
|
buf = xbps_xasprintf("%s/metadata/%s/%s",
|
||||||
XBPS_META_PATH, pkgname, file);
|
XBPS_META_PATH, pkgname, file);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
free(pkgname);
|
free(pkgname);
|
||||||
@ -133,7 +133,7 @@ remove_metafile(const char *file, const char *pkgver)
|
|||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
version = xbps_pkg_version(pkgver);
|
version = xbps_pkg_version(pkgver);
|
||||||
|
|
||||||
buf = xbps_xasprintf(".%s/metadata/%s/%s",
|
buf = xbps_xasprintf("%s/metadata/%s/%s",
|
||||||
XBPS_META_PATH, pkgname, file);
|
XBPS_META_PATH, pkgname, file);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
free(pkgname);
|
free(pkgname);
|
||||||
@ -193,12 +193,11 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
|||||||
xucd->entry_total_count = 0;
|
xucd->entry_total_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chdir(prop_string_cstring_nocopy(xhp->rootdir)) == -1) {
|
if (chdir(xhp->rootdir) == -1) {
|
||||||
xbps_set_cb_state(XBPS_STATE_UNPACK_FAIL,
|
xbps_set_cb_state(XBPS_STATE_UNPACK_FAIL,
|
||||||
errno, pkgname, version,
|
errno, pkgname, version,
|
||||||
"%s: [unpack] failed to chdir to rootdir `%s': %s",
|
"%s: [unpack] failed to chdir to rootdir `%s': %s",
|
||||||
pkgver, prop_string_cstring_nocopy(xhp->rootdir),
|
pkgver, xhp->rootdir, strerror(errno));
|
||||||
strerror(errno));
|
|
||||||
rv = errno;
|
rv = errno;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -245,7 +244,7 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
|||||||
* Extract the INSTALL script first to execute
|
* Extract the INSTALL script first to execute
|
||||||
* the pre install target.
|
* the pre install target.
|
||||||
*/
|
*/
|
||||||
buf = xbps_xasprintf(".%s/metadata/%s/INSTALL",
|
buf = xbps_xasprintf("%s/metadata/%s/INSTALL",
|
||||||
XBPS_META_PATH, pkgname);
|
XBPS_META_PATH, pkgname);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
rv = ENOMEM;
|
rv = ENOMEM;
|
||||||
@ -469,7 +468,7 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
|||||||
* On pkgs that set the preserve keyword or while installing
|
* On pkgs that set the preserve keyword or while installing
|
||||||
* new packages, do not check for obsolete files.
|
* new packages, do not check for obsolete files.
|
||||||
*/
|
*/
|
||||||
pkgfilesd = xbps_xasprintf(".%s/metadata/%s/%s",
|
pkgfilesd = xbps_xasprintf("%s/metadata/%s/%s",
|
||||||
XBPS_META_PATH, pkgname, XBPS_PKGFILES);
|
XBPS_META_PATH, pkgname, XBPS_PKGFILES);
|
||||||
if (pkgfilesd == NULL) {
|
if (pkgfilesd == NULL) {
|
||||||
rv = ENOMEM;
|
rv = ENOMEM;
|
||||||
@ -484,12 +483,11 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
|||||||
if (prop_object_type(old_filesd) == PROP_TYPE_DICTIONARY) {
|
if (prop_object_type(old_filesd) == PROP_TYPE_DICTIONARY) {
|
||||||
rv = xbps_remove_obsoletes(pkgname, version,
|
rv = xbps_remove_obsoletes(pkgname, version,
|
||||||
pkgver, old_filesd, filesd);
|
pkgver, old_filesd, filesd);
|
||||||
if (rv != 0) {
|
|
||||||
prop_object_release(old_filesd);
|
prop_object_release(old_filesd);
|
||||||
|
if (rv != 0) {
|
||||||
rv = errno;
|
rv = errno;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
prop_object_release(old_filesd);
|
|
||||||
} else if (errno && errno != ENOENT) {
|
} else if (errno && errno != ENOENT) {
|
||||||
rv = errno;
|
rv = errno;
|
||||||
goto out;
|
goto out;
|
||||||
@ -498,7 +496,7 @@ out1:
|
|||||||
/*
|
/*
|
||||||
* Create pkg metadata directory.
|
* Create pkg metadata directory.
|
||||||
*/
|
*/
|
||||||
buf = xbps_xasprintf(".%s/metadata/%s", XBPS_META_PATH, pkgname);
|
buf = xbps_xasprintf("%s/metadata/%s", XBPS_META_PATH, pkgname);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
rv = ENOMEM;
|
rv = ENOMEM;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -224,8 +224,7 @@ xbps_dictionary_from_metadata_plist(const char *pkgname,
|
|||||||
xhp = xbps_handle_get();
|
xhp = xbps_handle_get();
|
||||||
|
|
||||||
savedpkgname = pkgname;
|
savedpkgname = pkgname;
|
||||||
plistf = xbps_xasprintf("%s/%s/metadata/%s/%s",
|
plistf = xbps_xasprintf("%s/%s/metadata/%s/%s", xhp->rootdir,
|
||||||
prop_string_cstring_nocopy(xhp->rootdir),
|
|
||||||
XBPS_META_PATH, savedpkgname, plist);
|
XBPS_META_PATH, savedpkgname, plist);
|
||||||
if (plistf == NULL)
|
if (plistf == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -237,7 +236,7 @@ xbps_dictionary_from_metadata_plist(const char *pkgname,
|
|||||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||||
"pkgname", &savedpkgname);
|
"pkgname", &savedpkgname);
|
||||||
plistf = xbps_xasprintf("%s/%s/metadata/%s/%s",
|
plistf = xbps_xasprintf("%s/%s/metadata/%s/%s",
|
||||||
prop_string_cstring_nocopy(xhp->rootdir),
|
xhp->rootdir,
|
||||||
XBPS_META_PATH, savedpkgname, plist);
|
XBPS_META_PATH, savedpkgname, plist);
|
||||||
prop_object_release(pkgd);
|
prop_object_release(pkgd);
|
||||||
if (plistf == NULL)
|
if (plistf == NULL)
|
||||||
|
@ -121,48 +121,45 @@ static const char *
|
|||||||
find_virtualpkg_user_in_conf(const char *vpkg, bool bypattern)
|
find_virtualpkg_user_in_conf(const char *vpkg, bool bypattern)
|
||||||
{
|
{
|
||||||
const struct xbps_handle *xhp;
|
const struct xbps_handle *xhp;
|
||||||
prop_object_iterator_t iter;
|
|
||||||
prop_object_t obj;
|
|
||||||
const char *vpkgver, *pkg = NULL;
|
const char *vpkgver, *pkg = NULL;
|
||||||
char *vpkgname = NULL;
|
char *vpkgname = NULL;
|
||||||
|
size_t i, j, cnt;
|
||||||
|
|
||||||
xhp = xbps_handle_get();
|
xhp = xbps_handle_get();
|
||||||
if (prop_object_type(xhp->virtualpkgs_array) != PROP_TYPE_ARRAY) {
|
if (xhp->cfg == NULL)
|
||||||
xbps_dbg_printf("%s: invalid virtualpkgs_array "
|
return NULL;
|
||||||
"type\n", __func__);
|
|
||||||
|
if ((cnt = cfg_size(xhp->cfg, "virtual-package")) == 0) {
|
||||||
|
/* no virtual packages configured */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((iter = prop_array_iterator(xhp->virtualpkgs_array)) == NULL)
|
for (i = 0; i < cnt; i++) {
|
||||||
return NULL;
|
cfg_t *sec = cfg_getnsec(xhp->cfg, "virtual-package", i);
|
||||||
|
for (j = 0; j < cfg_size(sec, "targets"); j++) {
|
||||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
vpkgver = cfg_getnstr(sec, "targets", j);
|
||||||
if (!prop_dictionary_get_cstring_nocopy(obj,
|
|
||||||
"virtual-pkgver", &vpkgver))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (bypattern) {
|
|
||||||
if (xbps_pkgpattern_match(vpkgver, vpkg)) {
|
|
||||||
prop_dictionary_get_cstring_nocopy(obj,
|
|
||||||
"target-pkgpattern", &pkg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
vpkgname = xbps_pkg_name(vpkgver);
|
vpkgname = xbps_pkg_name(vpkgver);
|
||||||
if (vpkgname == NULL)
|
if (vpkgname == NULL)
|
||||||
break;
|
break;
|
||||||
|
if (bypattern) {
|
||||||
if (strcmp(vpkg, vpkgname) == 0) {
|
if (!xbps_pkgpattern_match(vpkgver, vpkg)) {
|
||||||
|
free(vpkgname);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (strcmp(vpkg, vpkgname)) {
|
||||||
|
free(vpkgname);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* virtual package matched in conffile */
|
||||||
|
pkg = cfg_title(sec);
|
||||||
|
xbps_dbg_printf("matched vpkg in conf `%s' for %s\n",
|
||||||
|
pkg, vpkg);
|
||||||
free(vpkgname);
|
free(vpkgname);
|
||||||
prop_dictionary_get_cstring_nocopy(obj,
|
|
||||||
"target-pkgpattern", &pkg);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
free(vpkgname);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
prop_object_iterator_release(iter);
|
|
||||||
|
|
||||||
return pkg;
|
return pkg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,31 +168,16 @@ find_virtualpkg_user_in_array(prop_array_t array,
|
|||||||
const char *str,
|
const char *str,
|
||||||
bool bypattern)
|
bool bypattern)
|
||||||
{
|
{
|
||||||
prop_object_t obj = NULL;
|
const char *vpkgname;
|
||||||
prop_object_iterator_t iter;
|
|
||||||
const char *virtualpkg;
|
|
||||||
|
|
||||||
assert(prop_object_type(array) == PROP_TYPE_ARRAY);
|
assert(prop_object_type(array) == PROP_TYPE_ARRAY);
|
||||||
assert(str != NULL);
|
assert(str != NULL);
|
||||||
|
|
||||||
virtualpkg = find_virtualpkg_user_in_conf(str, bypattern);
|
vpkgname = find_virtualpkg_user_in_conf(str, bypattern);
|
||||||
if (virtualpkg == NULL)
|
if (vpkgname == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
iter = prop_array_iterator(array);
|
return find_pkg_in_array(array, vpkgname, false, false);
|
||||||
if (iter == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
while ((obj = prop_object_iterator_next(iter))) {
|
|
||||||
/*
|
|
||||||
* force pattern match because virtualpkg is
|
|
||||||
* always a pkgpattern.
|
|
||||||
*/
|
|
||||||
if (xbps_match_virtual_pkg_in_dict(obj, virtualpkg, true))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
prop_object_iterator_release(iter);
|
|
||||||
return obj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static prop_dictionary_t
|
static prop_dictionary_t
|
||||||
|
@ -66,8 +66,7 @@ xbps_regpkgdb_dictionary_init(struct xbps_handle *xhp)
|
|||||||
if (regpkgdb_initialized)
|
if (regpkgdb_initialized)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
plist = xbps_xasprintf("%s/%s/%s",
|
plist = xbps_xasprintf("%s/%s/%s", xhp->rootdir,
|
||||||
prop_string_cstring_nocopy(xhp->rootdir),
|
|
||||||
XBPS_META_PATH, XBPS_REGPKGDB);
|
XBPS_META_PATH, XBPS_REGPKGDB);
|
||||||
if (plist == NULL)
|
if (plist == NULL)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
|
@ -74,10 +74,8 @@ check_repo_arch(const char *uri)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int HIDDEN
|
int HIDDEN
|
||||||
xbps_repository_pool_init(void)
|
xbps_repository_pool_init(const struct xbps_handle *xhp)
|
||||||
{
|
{
|
||||||
prop_string_t obj;
|
|
||||||
struct xbps_handle *xhp;
|
|
||||||
struct repository_pool *rpool;
|
struct repository_pool *rpool;
|
||||||
size_t i, ntotal = 0, nmissing = 0, repocnt = 0;
|
size_t i, ntotal = 0, nmissing = 0, repocnt = 0;
|
||||||
const char *repouri;
|
const char *repouri;
|
||||||
@ -87,17 +85,11 @@ xbps_repository_pool_init(void)
|
|||||||
|
|
||||||
if (repolist_initialized)
|
if (repolist_initialized)
|
||||||
return 0;
|
return 0;
|
||||||
|
else if (xhp->cfg == NULL)
|
||||||
xhp = xbps_handle_get();
|
|
||||||
if (prop_object_type(xhp->repos_array) != PROP_TYPE_ARRAY)
|
|
||||||
return ENOTSUP;
|
return ENOTSUP;
|
||||||
|
|
||||||
if (prop_array_count(xhp->repos_array) == 0)
|
for (i = 0; i < cfg_size(xhp->cfg, "repositories"); i++) {
|
||||||
return ENOTSUP;
|
repouri = cfg_getnstr(xhp->cfg, "repositories", i);
|
||||||
|
|
||||||
for (i = 0; i < prop_array_count(xhp->repos_array); i++) {
|
|
||||||
obj = prop_array_get(xhp->repos_array, i);
|
|
||||||
repouri = prop_string_cstring_nocopy(obj);
|
|
||||||
/*
|
/*
|
||||||
* Check that we do not register duplicate repositories.
|
* Check that we do not register duplicate repositories.
|
||||||
*/
|
*/
|
||||||
@ -156,19 +148,11 @@ xbps_repository_pool_init(void)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
rpool->rpi->rpi_uri = prop_string_cstring(obj);
|
rpool->rpi->rpi_uri = repouri;
|
||||||
if (rpool->rpi->rpi_uri == NULL) {
|
|
||||||
rv = errno;
|
|
||||||
free(rpool->rpi);
|
|
||||||
free(rpool);
|
|
||||||
free(plist);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
rpool->rpi->rpi_repod =
|
rpool->rpi->rpi_repod =
|
||||||
prop_dictionary_internalize_from_zfile(plist);
|
prop_dictionary_internalize_from_zfile(plist);
|
||||||
if (rpool->rpi->rpi_repod == NULL) {
|
if (rpool->rpi->rpi_repod == NULL) {
|
||||||
rv = errno;
|
rv = errno;
|
||||||
free(rpool->rpi->rpi_uri);
|
|
||||||
free(rpool->rpi);
|
free(rpool->rpi);
|
||||||
free(rpool);
|
free(rpool);
|
||||||
free(plist);
|
free(plist);
|
||||||
@ -190,7 +174,6 @@ xbps_repository_pool_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
repolist_initialized = true;
|
repolist_initialized = true;
|
||||||
prop_object_release(xhp->repos_array);
|
|
||||||
xbps_dbg_printf("[rpool] initialized ok.\n");
|
xbps_dbg_printf("[rpool] initialized ok.\n");
|
||||||
out:
|
out:
|
||||||
if (rv != 0)
|
if (rv != 0)
|
||||||
@ -213,7 +196,6 @@ xbps_repository_pool_release(void)
|
|||||||
xbps_dbg_printf("[rpool] unregistered repository '%s'\n",
|
xbps_dbg_printf("[rpool] unregistered repository '%s'\n",
|
||||||
rpool->rpi->rpi_uri);
|
rpool->rpi->rpi_uri);
|
||||||
prop_object_release(rpool->rpi->rpi_repod);
|
prop_object_release(rpool->rpi->rpi_repod);
|
||||||
free(rpool->rpi->rpi_uri);
|
|
||||||
free(rpool->rpi);
|
free(rpool->rpi);
|
||||||
free(rpool);
|
free(rpool);
|
||||||
rpool = NULL;
|
rpool = NULL;
|
||||||
@ -223,22 +205,17 @@ xbps_repository_pool_release(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
xbps_repository_pool_sync(void)
|
xbps_repository_pool_sync(const struct xbps_handle *xhp)
|
||||||
{
|
{
|
||||||
const struct xbps_handle *xhp;
|
|
||||||
const char *repouri;
|
const char *repouri;
|
||||||
size_t i;
|
size_t i;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
xhp = xbps_handle_get();
|
if (xhp->cfg == NULL)
|
||||||
if (xhp->repos_array == NULL)
|
|
||||||
return ENOTSUP;
|
return ENOTSUP;
|
||||||
|
|
||||||
if (prop_array_count(xhp->repos_array) == 0)
|
for (i = 0; i < cfg_size(xhp->cfg, "repositories"); i++) {
|
||||||
return ENOTSUP;
|
repouri = cfg_getnstr(xhp->cfg, "repositories", i);
|
||||||
|
|
||||||
for (i = 0; i < prop_array_count(xhp->repos_array); i++) {
|
|
||||||
prop_array_get_cstring_nocopy(xhp->repos_array, i, &repouri);
|
|
||||||
/*
|
/*
|
||||||
* Check if repository doesn't match our architecture.
|
* Check if repository doesn't match our architecture.
|
||||||
*/
|
*/
|
||||||
@ -266,6 +243,7 @@ xbps_repository_pool_foreach(
|
|||||||
int (*fn)(struct repository_pool_index *, void *, bool *),
|
int (*fn)(struct repository_pool_index *, void *, bool *),
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
|
const struct xbps_handle *xhp = xbps_handle_get();
|
||||||
struct repository_pool *rpool, *rpool_new;
|
struct repository_pool *rpool, *rpool_new;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
@ -274,7 +252,7 @@ xbps_repository_pool_foreach(
|
|||||||
/*
|
/*
|
||||||
* Initialize repository pool.
|
* Initialize repository pool.
|
||||||
*/
|
*/
|
||||||
if ((rv = xbps_repository_pool_init()) != 0) {
|
if ((rv = xbps_repository_pool_init(xhp)) != 0) {
|
||||||
if (rv == ENOTSUP) {
|
if (rv == ENOTSUP) {
|
||||||
xbps_dbg_printf("[rpool] empty repository list.\n");
|
xbps_dbg_printf("[rpool] empty repository list.\n");
|
||||||
} else if (rv != ENOENT && rv != ENOTSUP) {
|
} else if (rv != ENOENT && rv != ENOTSUP) {
|
||||||
|
@ -117,8 +117,7 @@ xbps_repository_sync_pkg_index(const char *uri)
|
|||||||
/*
|
/*
|
||||||
* Create metadir if necessary.
|
* Create metadir if necessary.
|
||||||
*/
|
*/
|
||||||
metadir = xbps_xasprintf("%s/%s",
|
metadir = xbps_xasprintf("%s/%s", xhp->rootdir, XBPS_META_PATH);
|
||||||
prop_string_cstring_nocopy(xhp->rootdir), XBPS_META_PATH);
|
|
||||||
if (metadir == NULL) {
|
if (metadir == NULL) {
|
||||||
rv = -1;
|
rv = -1;
|
||||||
goto out;
|
goto out;
|
||||||
@ -151,7 +150,7 @@ xbps_repository_sync_pkg_index(const char *uri)
|
|||||||
* Full path to repository directory to store the index.plist file.
|
* Full path to repository directory to store the index.plist file.
|
||||||
*/
|
*/
|
||||||
lrepodir = xbps_xasprintf("%s/%s/%s",
|
lrepodir = xbps_xasprintf("%s/%s/%s",
|
||||||
prop_string_cstring_nocopy(xhp->rootdir), XBPS_META_PATH, uri_fixedp);
|
xhp->rootdir, XBPS_META_PATH, uri_fixedp);
|
||||||
if (lrepodir == NULL) {
|
if (lrepodir == NULL) {
|
||||||
rv = -1;
|
rv = -1;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -124,13 +124,11 @@ download_binpkgs(struct xbps_handle *xhp, prop_object_iterator_t iter)
|
|||||||
/*
|
/*
|
||||||
* Create cachedir.
|
* Create cachedir.
|
||||||
*/
|
*/
|
||||||
if (xbps_mkpath(prop_string_cstring_nocopy(xhp->cachedir),
|
if (xbps_mkpath(xhp->cachedir, 0755) == -1) {
|
||||||
0755) == -1) {
|
|
||||||
xbps_set_cb_state(XBPS_STATE_DOWNLOAD_FAIL,
|
xbps_set_cb_state(XBPS_STATE_DOWNLOAD_FAIL,
|
||||||
errno, pkgname, version,
|
errno, pkgname, version,
|
||||||
"%s: [trans] cannot create cachedir `%s': %s",
|
"%s: [trans] cannot create cachedir `%s': %s",
|
||||||
pkgver, prop_string_cstring_nocopy(xhp->cachedir),
|
pkgver, xhp->cachedir, strerror(errno));
|
||||||
strerror(errno));
|
|
||||||
free(binfile);
|
free(binfile);
|
||||||
rv = errno;
|
rv = errno;
|
||||||
break;
|
break;
|
||||||
@ -142,8 +140,7 @@ download_binpkgs(struct xbps_handle *xhp, prop_object_iterator_t iter)
|
|||||||
/*
|
/*
|
||||||
* Fetch binary package.
|
* Fetch binary package.
|
||||||
*/
|
*/
|
||||||
rv = xbps_fetch_file(binfile,
|
rv = xbps_fetch_file(binfile, xhp->cachedir, false, NULL);
|
||||||
prop_string_cstring_nocopy(xhp->cachedir), false, NULL);
|
|
||||||
if (rv == -1) {
|
if (rv == -1) {
|
||||||
xbps_set_cb_state(XBPS_STATE_DOWNLOAD_FAIL,
|
xbps_set_cb_state(XBPS_STATE_DOWNLOAD_FAIL,
|
||||||
errno, pkgname, version,
|
errno, pkgname, version,
|
||||||
|
@ -213,12 +213,12 @@ get_pkg_index_remote_plist(const char *uri)
|
|||||||
if (uri_fixed == NULL)
|
if (uri_fixed == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (prop_string_equals_cstring(xhp->rootdir, "/")) {
|
if (strcmp(xhp->rootdir, "/") == 0) {
|
||||||
repodir = xbps_xasprintf("%s/%s/%s",
|
repodir = xbps_xasprintf("%s/%s/%s",
|
||||||
XBPS_META_PATH, uri_fixed, XBPS_PKGINDEX);
|
XBPS_META_PATH, uri_fixed, XBPS_PKGINDEX);
|
||||||
} else {
|
} else {
|
||||||
repodir = xbps_xasprintf("%s/%s/%s/%s",
|
repodir = xbps_xasprintf("%s/%s/%s/%s",
|
||||||
prop_string_cstring_nocopy(xhp->rootdir),
|
xhp->rootdir,
|
||||||
XBPS_META_PATH, uri_fixed, XBPS_PKGINDEX);
|
XBPS_META_PATH, uri_fixed, XBPS_PKGINDEX);
|
||||||
}
|
}
|
||||||
free(uri_fixed);
|
free(uri_fixed);
|
||||||
@ -254,8 +254,7 @@ xbps_path_from_repository_uri(prop_dictionary_t pkg_repod, const char *repoloc)
|
|||||||
/*
|
/*
|
||||||
* First check if binpkg is available in cachedir.
|
* First check if binpkg is available in cachedir.
|
||||||
*/
|
*/
|
||||||
lbinpkg = xbps_xasprintf("%s/%s",
|
lbinpkg = xbps_xasprintf("%s/%s", xhp->cachedir, filen);
|
||||||
prop_string_cstring_nocopy(xhp->cachedir), filen);
|
|
||||||
if (lbinpkg == NULL)
|
if (lbinpkg == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user