xbps_init() now sets rootdir, cachedir and flags.
That means that the following functions were removed: - xbps_set_{cachedir,flags,rootdir}. - xbps_get_{cachedir,flags,rootdir}. With this change fixed an obvious typo that made -c argument to not work, and now the cache directory is an absolute path not relative to rootdir.
This commit is contained in:
@@ -91,6 +91,7 @@ out:
|
||||
int
|
||||
xbps_check_pkg_integrity(const char *pkgname)
|
||||
{
|
||||
const struct xbps_handle *xhp;
|
||||
prop_dictionary_t pkgd, propsd = NULL, filesd = NULL;
|
||||
prop_array_t array;
|
||||
prop_object_t obj;
|
||||
@@ -101,6 +102,7 @@ xbps_check_pkg_integrity(const char *pkgname)
|
||||
bool broken = false, files_broken = false;
|
||||
|
||||
assert(pkgname != NULL);
|
||||
xhp = xbps_handle_get();
|
||||
|
||||
pkgd = xbps_find_pkg_dict_installed(pkgname, false);
|
||||
if (pkgd == NULL) {
|
||||
@@ -158,8 +160,7 @@ xbps_check_pkg_integrity(const char *pkgname)
|
||||
}
|
||||
while ((obj = prop_object_iterator_next(iter))) {
|
||||
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
|
||||
path = xbps_xasprintf("%s/%s",
|
||||
xbps_get_rootdir(), file);
|
||||
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
|
||||
if (path == NULL) {
|
||||
prop_object_iterator_release(iter);
|
||||
rv = errno;
|
||||
@@ -209,8 +210,7 @@ xbps_check_pkg_integrity(const char *pkgname)
|
||||
}
|
||||
while ((obj = prop_object_iterator_next(iter))) {
|
||||
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
|
||||
path = xbps_xasprintf("%s/%s",
|
||||
xbps_get_rootdir(), file);
|
||||
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
|
||||
if (path == NULL) {
|
||||
prop_object_iterator_release(iter);
|
||||
rv = ENOMEM;
|
||||
|
@@ -71,6 +71,7 @@ match_files_by_pattern(prop_dictionary_t pkg_filesd, prop_dictionary_keysym_t ke
|
||||
int
|
||||
find_files_in_packages(const char *pattern)
|
||||
{
|
||||
const struct xbps_handle *xhp;
|
||||
prop_dictionary_t pkg_filesd;
|
||||
prop_array_t files_keys;
|
||||
DIR *dirp;
|
||||
@@ -79,7 +80,8 @@ find_files_in_packages(const char *pattern)
|
||||
int rv = 0;
|
||||
unsigned int i, count;
|
||||
|
||||
path = xbps_xasprintf("%s/%s/metadata", xbps_get_rootdir(),
|
||||
xhp = xbps_handle_get();
|
||||
path = xbps_xasprintf("%s/%s/metadata", xhp->rootdir,
|
||||
XBPS_META_PATH);
|
||||
if (path == NULL)
|
||||
return -1;
|
||||
|
@@ -93,16 +93,14 @@ check_binpkg_hash(const char *path,
|
||||
static int
|
||||
download_package_list(prop_object_iterator_t iter, bool only_show)
|
||||
{
|
||||
const struct xbps_handle *xhp;
|
||||
prop_object_t obj;
|
||||
const char *pkgver, *repoloc, *filename, *cachedir, *sha256;
|
||||
const char *pkgver, *repoloc, *filename, *sha256;
|
||||
char *binfile;
|
||||
int rv = 0;
|
||||
bool cksum;
|
||||
|
||||
cachedir = xbps_get_cachedir();
|
||||
if (cachedir == NULL)
|
||||
return EINVAL;
|
||||
|
||||
xhp = xbps_handle_get();
|
||||
again:
|
||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
||||
cksum = false;
|
||||
@@ -141,12 +139,12 @@ again:
|
||||
free(binfile);
|
||||
continue;
|
||||
}
|
||||
if (xbps_mkpath(__UNCONST(cachedir), 0755) == -1) {
|
||||
if (xbps_mkpath(xhp->cachedir, 0755) == -1) {
|
||||
free(binfile);
|
||||
return errno;
|
||||
}
|
||||
printf("Downloading %s binary package ...\n", pkgver);
|
||||
rv = xbps_fetch_file(binfile, cachedir, false, NULL);
|
||||
rv = xbps_fetch_file(binfile, xhp->cachedir, false, NULL);
|
||||
if (rv == -1) {
|
||||
xbps_error_printf("xbps-bin: couldn't download `%s'\n",
|
||||
filename);
|
||||
@@ -374,13 +372,15 @@ xbps_update_pkg(const char *pkgname)
|
||||
static int
|
||||
exec_transaction(struct transaction *trans)
|
||||
{
|
||||
const struct xbps_handle *xhp;
|
||||
prop_dictionary_t instpkgd;
|
||||
prop_object_t obj;
|
||||
const char *pkgname, *version, *pkgver, *instver, *filen, *tract;
|
||||
int flags = xbps_get_flags(), rv = 0;
|
||||
int rv = 0;
|
||||
bool update, preserve, autoinst;
|
||||
pkg_state_t state;
|
||||
|
||||
xhp = xbps_handle_get();
|
||||
/*
|
||||
* Only show the URLs to download the binary packages.
|
||||
*/
|
||||
@@ -497,7 +497,7 @@ exec_transaction(struct transaction *trans)
|
||||
"(%s)\n", pkgver, strerror(rv));
|
||||
return rv;
|
||||
}
|
||||
if ((flags & XBPS_FLAG_VERBOSE) == 0)
|
||||
if ((xhp->flags & XBPS_FLAG_VERBOSE) == 0)
|
||||
printf("\n");
|
||||
/*
|
||||
* Register binary package.
|
||||
|
@@ -191,17 +191,19 @@ main(int argc, char **argv)
|
||||
struct xbps_fetch_progress_data xfpd;
|
||||
struct list_pkgver_cb lpc;
|
||||
struct sigaction sa;
|
||||
const char *rootdir, *cachedir;
|
||||
int i , c, flags, rv;
|
||||
bool yes, purge, with_debug, force_rm_with_deps, recursive_rm;
|
||||
bool show_download_pkglist_url = false;
|
||||
|
||||
rootdir = cachedir = NULL;
|
||||
flags = rv = 0;
|
||||
yes = purge = force_rm_with_deps = recursive_rm = with_debug = false;
|
||||
|
||||
while ((c = getopt(argc, argv, "VcdDFfpRr:vy")) != -1) {
|
||||
while ((c = getopt(argc, argv, "Vc:dDFfpRr:vy")) != -1) {
|
||||
switch (c) {
|
||||
case 'c':
|
||||
xbps_set_cachedir(optarg);
|
||||
cachedir = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
with_debug = true;
|
||||
@@ -223,7 +225,7 @@ main(int argc, char **argv)
|
||||
break;
|
||||
case 'r':
|
||||
/* To specify the root directory */
|
||||
xbps_set_rootdir(optarg);
|
||||
rootdir = optarg;
|
||||
break;
|
||||
case 'v':
|
||||
flags |= XBPS_FLAG_VERBOSE;
|
||||
@@ -246,9 +248,6 @@ main(int argc, char **argv)
|
||||
if (argc < 1)
|
||||
usage();
|
||||
|
||||
if (flags != 0)
|
||||
xbps_set_flags(flags);
|
||||
|
||||
/*
|
||||
* Register a signal handler to clean up resources used by libxbps.
|
||||
*/
|
||||
@@ -270,6 +269,9 @@ main(int argc, char **argv)
|
||||
else
|
||||
xh.xbps_unpack_cb = unpack_progress_cb_percentage;
|
||||
xh.xupd = &xupd;
|
||||
xh.rootdir = rootdir;
|
||||
xh.cachedir = cachedir;
|
||||
xh.flags = flags;
|
||||
xbps_init(&xh);
|
||||
|
||||
if ((dict = xbps_regpkgdb_dictionary_get()) == NULL) {
|
||||
|
@@ -7,7 +7,7 @@
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "XBPS\-BIN" "8" "02/05/2011" "\ \&" "\ \&"
|
||||
.TH "XBPS\-BIN" "8" "02/21/2011" "\ \&" "\ \&"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * set default formatting
|
||||
.\" -----------------------------------------------------------------
|
||||
@@ -31,13 +31,7 @@ The xbps\-bin(8) command is used to handle binary packages created for the XBPS
|
||||
\fB\-c\fR \fIcachedir\fR
|
||||
.RS 4
|
||||
Sets the cache directory to store downloaded binary packages from remote repositories\&. By default it\(cqs set to
|
||||
\fI/var/cache/xbps\fR
|
||||
and it\(cqs always relative to the
|
||||
\fIroot directory\fR\&. So if you use a
|
||||
\fIrootdir\fR
|
||||
of
|
||||
\fI/blah\fR, it will become
|
||||
\fI/blah/cachedir\fR\&.
|
||||
\fI/var/cache/xbps\fR\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-d\fR
|
||||
|
@@ -442,9 +442,10 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
prop_dictionary_t plistd, confd = NULL;
|
||||
struct xbps_handle xh;
|
||||
FILE *f = NULL;
|
||||
char *outfile = NULL;
|
||||
const char *conf_file = NULL;
|
||||
const char *conf_file = NULL, *rootdir = NULL;
|
||||
int c;
|
||||
bool revdeps = false;
|
||||
|
||||
@@ -468,7 +469,7 @@ main(int argc, char **argv)
|
||||
break;
|
||||
case 'r':
|
||||
/* Set different rootdir. */
|
||||
xbps_set_rootdir(optarg);
|
||||
rootdir = optarg;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
@@ -482,6 +483,11 @@ main(int argc, char **argv)
|
||||
if (argc != 1)
|
||||
usage();
|
||||
|
||||
/* Initialize libxbps */
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
xh.rootdir = rootdir;
|
||||
xbps_init(&xh);
|
||||
|
||||
/*
|
||||
* Output file will be <pkgname>.dot if not specified.
|
||||
*/
|
||||
|
@@ -80,22 +80,23 @@ main(int argc, char **argv)
|
||||
struct xbps_handle xh;
|
||||
struct xbps_fetch_progress_data xfpd;
|
||||
prop_dictionary_t pkgd;
|
||||
char *root;
|
||||
const char *rootdir, *cachedir;
|
||||
int c, rv = 0;
|
||||
bool with_debug = false;
|
||||
|
||||
while ((c = getopt(argc, argv, "Vcdr:")) != -1) {
|
||||
rootdir = cachedir = NULL;
|
||||
|
||||
while ((c = getopt(argc, argv, "Vc:dr:")) != -1) {
|
||||
switch (c) {
|
||||
case 'c':
|
||||
xbps_set_cachedir(optarg);
|
||||
cachedir = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
with_debug = true;
|
||||
break;
|
||||
case 'r':
|
||||
/* To specify the root directory */
|
||||
root = optarg;
|
||||
xbps_set_rootdir(root);
|
||||
rootdir = optarg;
|
||||
break;
|
||||
case 'V':
|
||||
printf("%s\n", XBPS_RELVER);
|
||||
@@ -119,6 +120,8 @@ main(int argc, char **argv)
|
||||
xh.with_debug = with_debug;
|
||||
xh.xbps_fetch_cb = fetch_file_progress_cb;
|
||||
xh.xfpd = &xfpd;
|
||||
xh.rootdir = rootdir;
|
||||
xh.cachedir = cachedir;
|
||||
xbps_init(&xh);
|
||||
|
||||
if ((rv = xbps_repository_pool_init()) != 0) {
|
||||
|
@@ -163,11 +163,13 @@ unregister_repository(const char *uri)
|
||||
int
|
||||
register_repository(const char *uri)
|
||||
{
|
||||
const struct xbps_handle *xhp;
|
||||
struct repoinfo *rpi = NULL;
|
||||
const char *idxstr = NULL;
|
||||
char *metadir, *plist;
|
||||
int rv = 0;
|
||||
|
||||
xhp = xbps_handle_get();
|
||||
if ((idxstr = sanitize_url(uri)) == NULL)
|
||||
return errno;
|
||||
|
||||
@@ -189,7 +191,7 @@ register_repository(const char *uri)
|
||||
/*
|
||||
* Create metadir if necessary.
|
||||
*/
|
||||
metadir = xbps_xasprintf("%s/%s", xbps_get_rootdir(),
|
||||
metadir = xbps_xasprintf("%s/%s", xhp->rootdir,
|
||||
XBPS_META_PATH);
|
||||
if (metadir == NULL)
|
||||
return errno;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
.TH "XBPS\-REPO" "8" "05/02/2011" "\ \&" "\ \&"
|
||||
.TH "XBPS\-REPO" "8" "02/21/2011" "\ \&" "\ \&"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * set default formatting
|
||||
.\" -----------------------------------------------------------------
|
||||
@@ -24,14 +24,7 @@ The xbps\-repo(8) command is used to handle local or remote binary package repos
|
||||
Sets the
|
||||
\fIcache\fR
|
||||
directory to store downloaded binary packages from remote repositories\&. By default it\(cqs set to
|
||||
\fI/var/cache/xbps\fR
|
||||
and it\(cqs always relative to the
|
||||
\fIroot\fR
|
||||
directory\&. So if you use a
|
||||
\fIrootdir\fR
|
||||
of
|
||||
\fI/blah\fR, it will become
|
||||
\fI/blah/cachedir\fR\&.
|
||||
\fI/var/cache/xbps\fR\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-d\fR
|
||||
|
@@ -109,7 +109,7 @@ main(int argc, char **argv)
|
||||
struct xbps_handle xh;
|
||||
struct xbps_fetch_progress_data xfpd;
|
||||
prop_dictionary_t dict;
|
||||
const char *version;
|
||||
const char *version, *rootdir = NULL;
|
||||
char *plist, *pkgname, *pkgver, *in_chroot_env, *hash;
|
||||
bool debug = false, in_chroot = false;
|
||||
int i, c, rv = 0;
|
||||
@@ -118,7 +118,7 @@ main(int argc, char **argv)
|
||||
switch (c) {
|
||||
case 'r':
|
||||
/* To specify the root directory */
|
||||
xbps_set_rootdir(optarg);
|
||||
rootdir = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
debug = true;
|
||||
@@ -145,9 +145,10 @@ main(int argc, char **argv)
|
||||
xh.with_debug = debug;
|
||||
xh.xbps_fetch_cb = fetch_file_progress_cb;
|
||||
xh.xfpd = &xfpd;
|
||||
xh.rootdir = rootdir;
|
||||
xbps_init(&xh);
|
||||
|
||||
plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(),
|
||||
plist = xbps_xasprintf("%s/%s/%s", rootdir,
|
||||
XBPS_META_PATH, XBPS_REGPKGDB);
|
||||
if (plist == NULL) {
|
||||
fprintf(stderr,
|
||||
|
Reference in New Issue
Block a user