Major API/ABI cleanup bringing performance improvements and fixes.
These are the core interfaces in the new API: rpool - Interface to interact with the repository pool. rindex - Interface to interact with repository indexes. pkgdb - Interface to interact with local packages. transaction - Interface to interact with a transaction. This also brings new repository index format, making the index file per architecture and being incompatible with previous versions. The transaction frequency flush option has been removed, and due to the nature of package states it was causing more harm than good. More changes coming soon, but the API shall remain stable from now on.
This commit is contained in:
@ -419,7 +419,7 @@ create_dot_graph(struct xbps_handle *xhp,
|
||||
* list file, aka XBPS_META_PATH/XBPS_PKGDB.
|
||||
*/
|
||||
if (revdeps) {
|
||||
regpkgd = xbps_find_pkg_dict_installed(xhp, pkgn, false);
|
||||
regpkgd = xbps_pkgdb_get_pkg(xhp, pkgn);
|
||||
if (regpkgd == NULL)
|
||||
die("cannot find '%s' dictionary on %s!",
|
||||
pkgn, XBPS_PKGDB);
|
||||
@ -510,7 +510,7 @@ main(int argc, char **argv)
|
||||
/*
|
||||
* Internalize the plist file of the target installed package.
|
||||
*/
|
||||
plistd = xbps_metadir_get_pkgd(&xh, argv[0]);
|
||||
plistd = xbps_pkgdb_get_pkg_metadata(&xh, argv[0]);
|
||||
if (plistd == NULL)
|
||||
die("cannot internalize %s metadata file", argv[0]);
|
||||
|
||||
|
@ -45,22 +45,14 @@ bool yesno(const char *, ...);
|
||||
bool noyes(const char *, ...);
|
||||
|
||||
/* from fetch_cb.c */
|
||||
void fetch_file_progress_cb(struct xbps_handle *,
|
||||
struct xbps_fetch_cb_data *,
|
||||
void *);
|
||||
void fetch_file_progress_cb(struct xbps_fetch_cb_data *, void *);
|
||||
|
||||
/* from state_cb.c */
|
||||
void state_cb(struct xbps_handle *,
|
||||
struct xbps_state_cb_data *,
|
||||
void *);
|
||||
void state_cb(struct xbps_state_cb_data *, void *);
|
||||
|
||||
/* from unpack_cb.c */
|
||||
void unpack_progress_cb_verbose(struct xbps_handle *,
|
||||
struct xbps_unpack_cb_data *,
|
||||
void *);
|
||||
void unpack_progress_cb(struct xbps_handle *,
|
||||
struct xbps_unpack_cb_data *,
|
||||
void *);
|
||||
void unpack_progress_cb_verbose(struct xbps_unpack_cb_data *, void *);
|
||||
void unpack_progress_cb(struct xbps_unpack_cb_data *, void *);
|
||||
|
||||
/* From util.c */
|
||||
void print_package_line(const char *, size_t, bool);
|
||||
|
@ -150,15 +150,11 @@ stat_display(struct xbps_fetch_cb_data *xfpd, void *cbdata)
|
||||
}
|
||||
|
||||
void
|
||||
fetch_file_progress_cb(struct xbps_handle *xhp,
|
||||
struct xbps_fetch_cb_data *xfpd,
|
||||
void *cbdata)
|
||||
fetch_file_progress_cb(struct xbps_fetch_cb_data *xfpd, void *cbdata)
|
||||
{
|
||||
struct xferstat *xfer = cbdata;
|
||||
char size[8];
|
||||
|
||||
(void)xhp;
|
||||
|
||||
if (xfpd->cb_start) {
|
||||
/* start transfer stats */
|
||||
get_time(&xfer->start);
|
||||
|
@ -31,9 +31,7 @@
|
||||
#include "defs.h"
|
||||
|
||||
void
|
||||
state_cb(struct xbps_handle *xhp,
|
||||
struct xbps_state_cb_data *xscd,
|
||||
void *cbdata)
|
||||
state_cb(struct xbps_state_cb_data *xscd, void *cbdata)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
const char *version;
|
||||
@ -41,7 +39,7 @@ state_cb(struct xbps_handle *xhp,
|
||||
|
||||
(void)cbdata;
|
||||
|
||||
if (xhp->flags & XBPS_FLAG_SYSLOG) {
|
||||
if (xscd->xhp->flags & XBPS_FLAG_SYSLOG) {
|
||||
syslog_enabled = true;
|
||||
openlog("xbps-install", LOG_CONS, LOG_USER);
|
||||
}
|
||||
@ -88,7 +86,7 @@ state_cb(struct xbps_handle *xhp,
|
||||
/* empty */
|
||||
break;
|
||||
case XBPS_STATE_UPDATE:
|
||||
pkgd = xbps_find_pkg_dict_installed(xhp, xscd->arg0, false);
|
||||
pkgd = xbps_pkgdb_get_pkg(xscd->xhp, xscd->arg0);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "version", &version);
|
||||
printf("%s-%s: updating to %s ...\n", xscd->arg0,
|
||||
version, xscd->arg1);
|
||||
@ -96,7 +94,7 @@ state_cb(struct xbps_handle *xhp,
|
||||
/* success */
|
||||
case XBPS_STATE_REMOVE_FILE:
|
||||
case XBPS_STATE_REMOVE_FILE_OBSOLETE:
|
||||
if (xhp->flags & XBPS_FLAG_VERBOSE)
|
||||
if (xscd->xhp->flags & XBPS_FLAG_VERBOSE)
|
||||
printf("%s\n", xscd->desc);
|
||||
else {
|
||||
printf("%s\n", xscd->desc);
|
||||
@ -109,7 +107,7 @@ state_cb(struct xbps_handle *xhp,
|
||||
if (syslog_enabled)
|
||||
syslog(LOG_NOTICE, "Installed `%s-%s' successfully "
|
||||
"(rootdir: %s).", xscd->arg0, xscd->arg1,
|
||||
xhp->rootdir);
|
||||
xscd->xhp->rootdir);
|
||||
break;
|
||||
case XBPS_STATE_UPDATE_DONE:
|
||||
printf("%s-%s: updated successfully.\n",
|
||||
@ -117,7 +115,7 @@ state_cb(struct xbps_handle *xhp,
|
||||
if (syslog_enabled)
|
||||
syslog(LOG_NOTICE, "Updated `%s' to `%s' successfully "
|
||||
"(rootdir: %s).", xscd->arg0, xscd->arg1,
|
||||
xhp->rootdir);
|
||||
xscd->xhp->rootdir);
|
||||
break;
|
||||
case XBPS_STATE_REMOVE_DONE:
|
||||
printf("%s-%s: removed successfully.\n",
|
||||
@ -125,7 +123,7 @@ state_cb(struct xbps_handle *xhp,
|
||||
if (syslog_enabled)
|
||||
syslog(LOG_NOTICE, "Removed `%s-%s' successfully "
|
||||
"(rootdir: %s).", xscd->arg0, xscd->arg1,
|
||||
xhp->rootdir);
|
||||
xscd->xhp->rootdir);
|
||||
break;
|
||||
/* errors */
|
||||
case XBPS_STATE_UNPACK_FAIL:
|
||||
@ -154,7 +152,7 @@ state_cb(struct xbps_handle *xhp,
|
||||
syslog(LOG_ERR, "%s", xscd->desc);
|
||||
break;
|
||||
default:
|
||||
xbps_dbg_printf(xhp,
|
||||
xbps_dbg_printf(xscd->xhp,
|
||||
"unknown state %d\n", xscd->state);
|
||||
break;
|
||||
}
|
||||
|
@ -30,11 +30,8 @@
|
||||
#include "defs.h"
|
||||
|
||||
void
|
||||
unpack_progress_cb_verbose(struct xbps_handle *xhp,
|
||||
struct xbps_unpack_cb_data *xpd,
|
||||
void *cbdata)
|
||||
unpack_progress_cb_verbose(struct xbps_unpack_cb_data *xpd, void *cbdata)
|
||||
{
|
||||
(void)xhp;
|
||||
(void)cbdata;
|
||||
|
||||
if (xpd->entry == NULL || xpd->entry_total_count <= 0)
|
||||
@ -47,11 +44,8 @@ unpack_progress_cb_verbose(struct xbps_handle *xhp,
|
||||
}
|
||||
|
||||
void
|
||||
unpack_progress_cb(struct xbps_handle *xhp,
|
||||
struct xbps_unpack_cb_data *xpd,
|
||||
void *cbdata)
|
||||
unpack_progress_cb(struct xbps_unpack_cb_data *xpd, void *cbdata)
|
||||
{
|
||||
(void)xhp;
|
||||
(void)cbdata;
|
||||
|
||||
if (xpd->entry_total_count <= 0)
|
||||
|
@ -101,11 +101,10 @@ check_pkg_integrity(struct xbps_handle *xhp,
|
||||
/* find real pkg by name */
|
||||
opkgd = pkgd;
|
||||
if (pkgd == NULL) {
|
||||
opkgd = xbps_find_pkg_dict_installed(xhp, pkgname, false);
|
||||
opkgd = xbps_pkgdb_get_pkg(xhp, pkgname);
|
||||
if (opkgd == NULL) {
|
||||
/* find virtual pkg by name */
|
||||
opkgd = xbps_find_virtualpkg_dict_installed(xhp,
|
||||
pkgname, false);
|
||||
opkgd = xbps_pkgdb_get_virtualpkg(xhp, pkgname);
|
||||
}
|
||||
if (opkgd == NULL) {
|
||||
printf("Package %s is not installed.\n", pkgname);
|
||||
@ -115,7 +114,7 @@ check_pkg_integrity(struct xbps_handle *xhp,
|
||||
/*
|
||||
* Check for props.plist metadata file.
|
||||
*/
|
||||
propsd = xbps_metadir_get_pkgd(xhp, pkgname);
|
||||
propsd = xbps_pkgdb_get_pkg_metadata(xhp, pkgname);
|
||||
if (propsd == NULL) {
|
||||
printf("%s: unexistent metafile, converting to 0.18 "
|
||||
"format...\n", pkgname);
|
||||
|
@ -59,7 +59,7 @@ check_reqby_pkg_cb(struct xbps_handle *xhp,
|
||||
* Internalize current pkg props dictionary from its
|
||||
* installed metadata directory.
|
||||
*/
|
||||
curpkg_propsd = xbps_metadir_get_pkgd(xhp, curpkgn);
|
||||
curpkg_propsd = xbps_pkgdb_get_pkg_metadata(xhp, curpkgn);
|
||||
if (curpkg_propsd == NULL) {
|
||||
xbps_error_printf("%s: missing %s metadata file!\n",
|
||||
curpkgn, XBPS_PKGPROPS);
|
||||
@ -138,26 +138,24 @@ remove_stale_entries_in_reqby(struct xbps_handle *xhp, prop_dictionary_t pkgd)
|
||||
char *str;
|
||||
size_t i;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
|
||||
|
||||
again:
|
||||
reqby = prop_dictionary_get(pkgd, "requiredby");
|
||||
if (reqby == NULL || prop_array_count(reqby) == 0)
|
||||
return;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
|
||||
|
||||
for (i = 0; i < prop_array_count(reqby); i++) {
|
||||
prop_array_get_cstring(reqby, i, &str);
|
||||
if ((pkgd = xbps_pkgdb_get_pkgd_by_pkgver(xhp, str)) != NULL)
|
||||
if ((pkgd = xbps_pkgdb_get_pkg(xhp, str)) != NULL)
|
||||
continue;
|
||||
|
||||
if (!xbps_remove_string_from_array(xhp, reqby, str))
|
||||
fprintf(stderr, "%s: failed to remove %s from "
|
||||
"requiredby!\n", pkgver, str);
|
||||
else
|
||||
prop_array_remove(reqby, i);
|
||||
printf("%s: removed stale entry in requiredby `%s'\n",
|
||||
pkgver, str);
|
||||
|
||||
prop_dictionary_set(pkgd, "requiredby", reqby);
|
||||
free(str);
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,30 +48,22 @@ int
|
||||
check_pkg_rundeps(struct xbps_handle *xhp, const char *pkgname, void *arg)
|
||||
{
|
||||
prop_dictionary_t pkg_propsd = arg;
|
||||
prop_object_t obj;
|
||||
prop_object_iterator_t iter;
|
||||
prop_array_t array;
|
||||
size_t i;
|
||||
const char *reqpkg;
|
||||
bool test_broken = false;
|
||||
|
||||
if (!xbps_pkg_has_rundeps(pkg_propsd))
|
||||
return 0;
|
||||
|
||||
iter = xbps_array_iter_from_dict(pkg_propsd, "run_depends");
|
||||
if (iter == NULL)
|
||||
return -1;
|
||||
|
||||
while ((obj = prop_object_iterator_next(iter))) {
|
||||
reqpkg = prop_string_cstring_nocopy(obj);
|
||||
if (reqpkg == NULL) {
|
||||
prop_object_iterator_release(iter);
|
||||
return -1;
|
||||
}
|
||||
if (xbps_check_is_installed_pkg_by_pattern(xhp, reqpkg) <= 0) {
|
||||
array = prop_dictionary_get(pkg_propsd, "run_depends");
|
||||
for (i = 0; i < prop_array_count(array); i++) {
|
||||
prop_array_get_cstring_nocopy(array, i, &reqpkg);
|
||||
if (xbps_pkg_is_installed(xhp, reqpkg) <= 0) {
|
||||
xbps_error_printf("%s: dependency not satisfied: %s\n",
|
||||
pkgname, reqpkg);
|
||||
test_broken = true;
|
||||
}
|
||||
}
|
||||
prop_object_iterator_release(iter);
|
||||
return test_broken;
|
||||
}
|
||||
|
@ -158,17 +158,13 @@ list_pkgs_pkgdb(struct xbps_handle *xhp)
|
||||
}
|
||||
|
||||
static int
|
||||
repo_list_uri_cb(struct xbps_handle *xhp,
|
||||
struct xbps_rpool_index *rpi,
|
||||
void *arg,
|
||||
bool *done)
|
||||
repo_list_uri_cb(struct xbps_rindex *rpi, void *arg, bool *done)
|
||||
{
|
||||
(void)xhp;
|
||||
(void)arg;
|
||||
(void)done;
|
||||
|
||||
printf("%s (%zu packages)\n", rpi->uri,
|
||||
(size_t)prop_array_count(rpi->repo));
|
||||
(size_t)prop_dictionary_count(rpi->repod));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -187,21 +183,32 @@ repo_list(struct xbps_handle *xhp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct fflongest {
|
||||
prop_dictionary_t d;
|
||||
size_t len;
|
||||
};
|
||||
|
||||
static int
|
||||
_find_longest_pkgver_cb(struct xbps_handle *xhp,
|
||||
prop_object_t obj,
|
||||
void *arg,
|
||||
bool *loop_done)
|
||||
{
|
||||
size_t *len = arg;
|
||||
struct fflongest *ffl = arg;
|
||||
prop_dictionary_t pkgd;
|
||||
const char *pkgver;
|
||||
|
||||
(void)xhp;
|
||||
(void)loop_done;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
||||
if (*len == 0 || strlen(pkgver) > *len)
|
||||
*len = strlen(pkgver);
|
||||
if (prop_object_type(obj) == PROP_TYPE_DICT_KEYSYM)
|
||||
pkgd = prop_dictionary_get_keysym(ffl->d, obj);
|
||||
else
|
||||
pkgd = obj;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
|
||||
if (ffl->len == 0 || strlen(pkgver) > ffl->len)
|
||||
ffl->len = strlen(pkgver);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -209,16 +216,24 @@ _find_longest_pkgver_cb(struct xbps_handle *xhp,
|
||||
size_t
|
||||
find_longest_pkgver(struct xbps_handle *xhp, prop_object_t o)
|
||||
{
|
||||
size_t len = 0;
|
||||
struct fflongest ffl;
|
||||
|
||||
if (prop_object_type(o) == PROP_TYPE_ARRAY)
|
||||
(void)xbps_callback_array_iter(xhp, o,
|
||||
_find_longest_pkgver_cb, &len);
|
||||
else
|
||||
ffl.d = o;
|
||||
ffl.len = 0;
|
||||
|
||||
if (prop_object_type(o) == PROP_TYPE_DICTIONARY) {
|
||||
prop_array_t array;
|
||||
|
||||
array = prop_dictionary_all_keys(o);
|
||||
(void)xbps_callback_array_iter(xhp, array,
|
||||
_find_longest_pkgver_cb, &ffl);
|
||||
prop_object_release(array);
|
||||
} else {
|
||||
(void)xbps_pkgdb_foreach_cb(xhp,
|
||||
_find_longest_pkgver_cb, &len);
|
||||
_find_longest_pkgver_cb, &ffl);
|
||||
}
|
||||
|
||||
return len;
|
||||
return ffl.len;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -95,7 +95,7 @@ ownedby_pkgdb_cb(struct xbps_handle *xhp, prop_object_t obj, void *arg, bool *do
|
||||
(void)done;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||
pkgmetad = xbps_metadir_get_pkgd(xhp, pkgname);
|
||||
pkgmetad = xbps_pkgdb_get_pkg_metadata(xhp, pkgname);
|
||||
|
||||
files_keys = prop_dictionary_all_keys(pkgmetad);
|
||||
for (i = 0; i < prop_array_count(files_keys); i++) {
|
||||
@ -122,26 +122,21 @@ ownedby(struct xbps_handle *xhp, int npatterns, char **patterns)
|
||||
}
|
||||
|
||||
static void
|
||||
repo_match_files_by_pattern(struct xbps_handle *xhp,
|
||||
prop_dictionary_t pkg_filesd,
|
||||
repo_match_files_by_pattern(prop_dictionary_t pkgd,
|
||||
struct ffdata *ffd)
|
||||
{
|
||||
prop_array_t array;
|
||||
const char *filestr, *pkgver, *arch;
|
||||
const char *filestr, *pkgver;
|
||||
size_t i;
|
||||
int x;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(pkg_filesd, "architecture", &arch);
|
||||
if (!xbps_pkg_arch_match(xhp, arch, NULL))
|
||||
return;
|
||||
|
||||
array = prop_dictionary_get(pkg_filesd, "files");
|
||||
array = prop_dictionary_get(pkgd, "files");
|
||||
for (i = 0; i < prop_array_count(array); i++) {
|
||||
prop_array_get_cstring_nocopy(array, i, &filestr);
|
||||
for (x = 0; x < ffd->npatterns; x++) {
|
||||
if ((xbps_pkgpattern_match(filestr, ffd->patterns[x])) ||
|
||||
(strcmp(filestr, ffd->patterns[x]) == 0)) {
|
||||
prop_dictionary_get_cstring_nocopy(pkg_filesd,
|
||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
"pkgver", &pkgver);
|
||||
printf("%s: %s (%s)\n",
|
||||
pkgver, filestr, ffd->repouri);
|
||||
@ -151,22 +146,21 @@ repo_match_files_by_pattern(struct xbps_handle *xhp,
|
||||
}
|
||||
|
||||
static int
|
||||
repo_ownedby_cb(struct xbps_handle *xhp,
|
||||
struct xbps_rpool_index *rpi,
|
||||
void *arg,
|
||||
bool *done)
|
||||
repo_ownedby_cb(struct xbps_rindex *rpi, void *arg, bool *done)
|
||||
{
|
||||
prop_array_t idxfiles;
|
||||
prop_array_t allkeys;
|
||||
prop_dictionary_t pkgd, idxfiles;
|
||||
prop_dictionary_keysym_t ksym;
|
||||
struct ffdata *ffd = arg;
|
||||
char *plist;
|
||||
unsigned int i;
|
||||
|
||||
(void)done;
|
||||
|
||||
if ((plist = xbps_pkg_index_files_plist(xhp, rpi->uri)) == NULL)
|
||||
if ((plist = xbps_pkg_index_files_plist(rpi->xhp, rpi->uri)) == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
if ((idxfiles = prop_array_internalize_from_zfile(plist)) == NULL) {
|
||||
if ((idxfiles = prop_dictionary_internalize_from_zfile(plist)) == NULL) {
|
||||
free(plist);
|
||||
if (errno == ENOENT) {
|
||||
fprintf(stderr, "%s: index-files missing! "
|
||||
@ -178,11 +172,13 @@ repo_ownedby_cb(struct xbps_handle *xhp,
|
||||
free(plist);
|
||||
ffd->repouri = rpi->uri;
|
||||
|
||||
for (i = 0; i < prop_array_count(idxfiles); i++)
|
||||
repo_match_files_by_pattern(xhp,
|
||||
prop_array_get(idxfiles, i), ffd);
|
||||
allkeys = prop_dictionary_all_keys(idxfiles);
|
||||
for (i = 0; i < prop_array_count(allkeys); i++) {
|
||||
ksym = prop_array_get(allkeys, i);
|
||||
pkgd = prop_dictionary_get_keysym(idxfiles, ksym);
|
||||
repo_match_files_by_pattern(pkgd, ffd);
|
||||
}
|
||||
|
||||
prop_object_release(idxfiles);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -195,8 +191,10 @@ repo_ownedby(struct xbps_handle *xhp, int npatterns, char **patterns)
|
||||
ffd.npatterns = npatterns;
|
||||
ffd.patterns = patterns;
|
||||
|
||||
if ((rv = xbps_rpool_sync(xhp, XBPS_PKGINDEX_FILES, NULL)) != 0)
|
||||
if ((rv = xbps_rpool_sync(xhp, XBPS_PKGINDEX_FILES, NULL)) != 0) {
|
||||
fprintf(stderr, "xbps-query: failed to sync rindex "
|
||||
"files: %s\n", strerror(rv));
|
||||
return rv;
|
||||
|
||||
}
|
||||
return xbps_rpool_foreach(xhp, repo_ownedby_cb, &ffd);
|
||||
}
|
||||
|
@ -52,20 +52,17 @@ struct repo_search_data {
|
||||
};
|
||||
|
||||
static int
|
||||
repo_longest_pkgver(struct xbps_handle *xhp,
|
||||
struct xbps_rpool_index *rpi,
|
||||
void *arg,
|
||||
bool *done)
|
||||
repo_longest_pkgver(struct xbps_rindex *rpi, void *arg, bool *done)
|
||||
{
|
||||
size_t *len = arg, olen = 0;
|
||||
|
||||
(void)done;
|
||||
|
||||
if (*len == 0) {
|
||||
*len = find_longest_pkgver(xhp, rpi->repo);
|
||||
*len = find_longest_pkgver(rpi->xhp, rpi->repod);
|
||||
return 0;
|
||||
}
|
||||
olen = find_longest_pkgver(xhp, rpi->repo);
|
||||
olen = find_longest_pkgver(rpi->xhp, rpi->repod);
|
||||
if (olen > *len)
|
||||
*len = olen;
|
||||
|
||||
@ -83,47 +80,48 @@ repo_find_longest_pkgver(struct xbps_handle *xhp)
|
||||
}
|
||||
|
||||
static int
|
||||
show_pkg_namedesc(struct xbps_handle *xhp,
|
||||
prop_object_t obj,
|
||||
void *arg,
|
||||
bool *loop_done)
|
||||
repo_search_pkgs_cb(struct xbps_rindex *rpi, void *arg, bool *done)
|
||||
{
|
||||
prop_array_t allkeys;
|
||||
prop_dictionary_t pkgd;
|
||||
prop_dictionary_keysym_t ksym;
|
||||
struct repo_search_data *rsd = arg;
|
||||
const char *pkgver, *pkgname, *desc, *arch, *inststr;
|
||||
const char *pkgver, *pkgname, *desc, *inststr;
|
||||
char *tmp = NULL, *out = NULL;
|
||||
size_t x, len;
|
||||
int i;
|
||||
size_t i, j, len;
|
||||
int x;
|
||||
|
||||
(void)xhp;
|
||||
(void)loop_done;
|
||||
(void)done;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(obj, "architecture", &arch);
|
||||
if (!xbps_pkg_arch_match(xhp, arch, NULL))
|
||||
return 0;
|
||||
allkeys = prop_dictionary_all_keys(rpi->repod);
|
||||
for (i = 0; i < prop_array_count(allkeys); i++) {
|
||||
ksym = prop_array_get(allkeys, i);
|
||||
pkgd = prop_dictionary_get_keysym(rpi->repod, ksym);
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "short_desc", &desc);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "pkgname", &pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "short_desc", &desc);
|
||||
|
||||
for (i = 0; i < rsd->npatterns; i++) {
|
||||
if ((xbps_pkgpattern_match(pkgver, rsd->patterns[i]) == 1) ||
|
||||
(xbps_pkgpattern_match(desc, rsd->patterns[i]) == 1) ||
|
||||
(strcasecmp(pkgname, rsd->patterns[i]) == 0) ||
|
||||
(strcasestr(pkgver, rsd->patterns[i])) ||
|
||||
(strcasestr(desc, rsd->patterns[i]))) {
|
||||
for (x = 0; x < rsd->npatterns; x++) {
|
||||
if ((xbps_pkgpattern_match(pkgver, rsd->patterns[x])) ||
|
||||
(xbps_pkgpattern_match(desc, rsd->patterns[x])) ||
|
||||
(strcasecmp(pkgname, rsd->patterns[x]) == 0) ||
|
||||
(strcasestr(pkgver, rsd->patterns[x])) ||
|
||||
(strcasestr(desc, rsd->patterns[x]))) {
|
||||
tmp = calloc(1, rsd->pkgver_len + 1);
|
||||
assert(tmp);
|
||||
memcpy(tmp, pkgver, rsd->pkgver_len);
|
||||
for (x = strlen(tmp); x < rsd->pkgver_len; x++)
|
||||
tmp[x] = ' ';
|
||||
for (j = strlen(tmp); j < rsd->pkgver_len; j++)
|
||||
tmp[j] = ' ';
|
||||
|
||||
tmp[x] = '\0';
|
||||
if (xbps_pkgdb_get_pkgd_by_pkgver(xhp, pkgver))
|
||||
tmp[j] = '\0';
|
||||
if (xbps_pkgdb_get_pkg(rpi->xhp, pkgver))
|
||||
inststr = "[*]";
|
||||
else
|
||||
inststr = "[-]";
|
||||
|
||||
len = strlen(inststr) + strlen(tmp) + strlen(desc) + 1;
|
||||
len = strlen(inststr) + strlen(tmp) +
|
||||
strlen(desc) + 1;
|
||||
if (len > rsd->maxcols) {
|
||||
out = malloc(rsd->maxcols+1);
|
||||
assert(out);
|
||||
@ -134,24 +132,14 @@ show_pkg_namedesc(struct xbps_handle *xhp,
|
||||
printf("%s\n", out);
|
||||
free(out);
|
||||
} else {
|
||||
printf("%s %s %s\n", inststr, tmp, desc);
|
||||
printf("%s %s %s\n", inststr,
|
||||
tmp, desc);
|
||||
}
|
||||
free(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
static int
|
||||
repo_search_pkgs_cb(struct xbps_handle *xhp,
|
||||
struct xbps_rpool_index *rpi,
|
||||
void *arg,
|
||||
bool *done)
|
||||
{
|
||||
struct repo_search_data *rsd = arg;
|
||||
(void)done;
|
||||
|
||||
(void)xbps_callback_array_iter(xhp, rpi->repo, show_pkg_namedesc, rsd);
|
||||
}
|
||||
prop_object_release(allkeys);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -41,10 +41,7 @@ show_pkg_deps(struct xbps_handle *xhp, const char *pkgname)
|
||||
|
||||
assert(pkgname != NULL);
|
||||
|
||||
/*
|
||||
* Check for props.plist metadata file.
|
||||
*/
|
||||
propsd = xbps_metadir_get_pkgd(xhp, pkgname);
|
||||
propsd = xbps_pkgdb_get_pkg_metadata(xhp, pkgname);
|
||||
if (propsd == NULL)
|
||||
return ENOENT;
|
||||
|
||||
@ -55,14 +52,14 @@ show_pkg_deps(struct xbps_handle *xhp, const char *pkgname)
|
||||
}
|
||||
|
||||
int
|
||||
show_pkg_revdeps(struct xbps_handle *xhp, const char *pkgname)
|
||||
show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
int rv = 0;
|
||||
|
||||
pkgd = xbps_find_virtualpkg_dict_installed(xhp, pkgname, false);
|
||||
pkgd = xbps_pkgdb_get_virtualpkg(xhp, pkg);
|
||||
if (pkgd == NULL) {
|
||||
pkgd = xbps_find_pkg_dict_installed(xhp, pkgname, false);
|
||||
pkgd = xbps_pkgdb_get_pkg(xhp, pkg);
|
||||
if (pkgd == NULL)
|
||||
return ENOENT;
|
||||
}
|
||||
@ -77,11 +74,7 @@ repo_show_pkg_deps(struct xbps_handle *xhp, const char *pattern)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
|
||||
if (xbps_pkgpattern_version(pattern))
|
||||
pkgd = xbps_rpool_find_pkg(xhp, pattern, true, false);
|
||||
else
|
||||
pkgd = xbps_rpool_find_pkg(xhp, pattern, false, true);
|
||||
|
||||
pkgd = xbps_rpool_get_pkg(xhp, pattern);
|
||||
if (pkgd == NULL)
|
||||
return errno;
|
||||
|
||||
@ -92,20 +85,20 @@ repo_show_pkg_deps(struct xbps_handle *xhp, const char *pattern)
|
||||
}
|
||||
|
||||
static int
|
||||
repo_revdeps_cb(struct xbps_handle *xhp,
|
||||
struct xbps_rpool_index *rpi,
|
||||
void *arg,
|
||||
bool *done)
|
||||
repo_revdeps_cb(struct xbps_rindex *rpi, void *arg, bool *done)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
prop_array_t pkgdeps;
|
||||
prop_array_t allkeys, pkgdeps;
|
||||
prop_dictionary_keysym_t ksym;
|
||||
const char *pkgver, *arch, *pattern = arg;
|
||||
size_t i;
|
||||
|
||||
(void)done;
|
||||
|
||||
for (i = 0; i < prop_array_count(rpi->repo); i++) {
|
||||
pkgd = prop_array_get(rpi->repo, i);
|
||||
allkeys = prop_dictionary_all_keys(rpi->repod);
|
||||
for (i = 0; i < prop_array_count(allkeys); i++) {
|
||||
ksym = prop_array_get(allkeys, i);
|
||||
pkgd = prop_dictionary_get_keysym(rpi->repod, ksym);
|
||||
pkgdeps = prop_dictionary_get(pkgd, "run_depends");
|
||||
if (pkgdeps == NULL || prop_array_count(pkgdeps) == 0)
|
||||
continue;
|
||||
@ -113,13 +106,14 @@ repo_revdeps_cb(struct xbps_handle *xhp,
|
||||
if (xbps_match_pkgdep_in_array(pkgdeps, pattern)) {
|
||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
"architecture", &arch);
|
||||
if (xbps_pkg_arch_match(xhp, arch, NULL)) {
|
||||
if (xbps_pkg_arch_match(rpi->xhp, arch, NULL)) {
|
||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
"pkgver", &pkgver);
|
||||
printf("%s\n", pkgver);
|
||||
}
|
||||
}
|
||||
}
|
||||
prop_object_release(allkeys);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -133,7 +127,7 @@ repo_show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
|
||||
if (xbps_pkg_version(pkg))
|
||||
pkgver = pkg;
|
||||
else {
|
||||
pkgd = xbps_rpool_find_pkg(xhp, pkg, false, false);
|
||||
pkgd = xbps_rpool_get_pkg(xhp, pkg);
|
||||
if (pkgd == NULL)
|
||||
return ENOENT;
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
|
||||
|
@ -216,21 +216,20 @@ show_pkg_files(prop_dictionary_t filesd)
|
||||
|
||||
int
|
||||
show_pkg_info_from_metadir(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
const char *pkg,
|
||||
const char *option)
|
||||
{
|
||||
prop_dictionary_t d, pkgdb_d;
|
||||
const char *instdate, *pname;
|
||||
const char *instdate;
|
||||
bool autoinst;
|
||||
|
||||
d = xbps_metadir_get_pkgd(xhp, pkgname);
|
||||
if (d == NULL)
|
||||
pkgdb_d = xbps_pkgdb_get_pkg(xhp, pkg);
|
||||
if (pkgdb_d == NULL)
|
||||
return ENOENT;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(d, "pkgname", &pname);
|
||||
pkgdb_d = xbps_pkgdb_get_pkgd(xhp, pname, false);
|
||||
if (pkgdb_d == NULL)
|
||||
return EINVAL;
|
||||
d = xbps_pkgdb_get_pkg_metadata(xhp, pkg);
|
||||
if (d == NULL)
|
||||
return ENOENT;
|
||||
|
||||
if (prop_dictionary_get_cstring_nocopy(pkgdb_d,
|
||||
"install-date", &instdate))
|
||||
@ -249,12 +248,12 @@ show_pkg_info_from_metadir(struct xbps_handle *xhp,
|
||||
}
|
||||
|
||||
int
|
||||
show_pkg_files_from_metadir(struct xbps_handle *xhp, const char *pkgname)
|
||||
show_pkg_files_from_metadir(struct xbps_handle *xhp, const char *pkg)
|
||||
{
|
||||
prop_dictionary_t d;
|
||||
int rv = 0;
|
||||
|
||||
d = xbps_metadir_get_pkgd(xhp, pkgname);
|
||||
d = xbps_pkgdb_get_pkg_metadata(xhp, pkg);
|
||||
if (d == NULL)
|
||||
return ENOENT;
|
||||
|
||||
@ -270,11 +269,7 @@ repo_show_pkg_info(struct xbps_handle *xhp,
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
|
||||
if (xbps_pkgpattern_version(pattern))
|
||||
pkgd = xbps_rpool_find_pkg(xhp, pattern, true, false);
|
||||
else
|
||||
pkgd = xbps_rpool_find_pkg(xhp, pattern, false, true);
|
||||
|
||||
pkgd = xbps_rpool_get_pkg(xhp, pattern);
|
||||
if (pkgd == NULL)
|
||||
return errno;
|
||||
|
||||
@ -291,8 +286,7 @@ repo_show_pkg_files(struct xbps_handle *xhp, const char *pkg)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
|
||||
pkgd = xbps_rpool_dictionary_metadata_plist(xhp, pkg,
|
||||
"./files.plist");
|
||||
pkgd = xbps_rpool_get_pkg_plist(xhp, pkg, "./files.plist");
|
||||
if (pkgd == NULL) {
|
||||
if (errno != ENOTSUP && errno != ENOENT) {
|
||||
fprintf(stderr, "Unexpected error: %s\n",
|
||||
|
@ -51,13 +51,13 @@ usage(bool fail)
|
||||
}
|
||||
|
||||
static void
|
||||
state_cb(struct xbps_handle *xhp, struct xbps_state_cb_data *xscd, void *cbd)
|
||||
state_cb(struct xbps_state_cb_data *xscd, void *cbd)
|
||||
{
|
||||
bool syslog_enabled = false;
|
||||
|
||||
(void)cbd;
|
||||
|
||||
if (xhp->flags & XBPS_FLAG_SYSLOG) {
|
||||
if (xscd->xhp->flags & XBPS_FLAG_SYSLOG) {
|
||||
syslog_enabled = true;
|
||||
openlog("xbps-reconfigure", LOG_CONS, LOG_USER);
|
||||
}
|
||||
@ -74,7 +74,7 @@ state_cb(struct xbps_handle *xhp, struct xbps_state_cb_data *xscd, void *cbd)
|
||||
syslog(LOG_ERR, "%s", xscd->desc);
|
||||
break;
|
||||
default:
|
||||
xbps_dbg_printf(xhp,
|
||||
xbps_dbg_printf(xscd->xhp,
|
||||
"unknown state %d\n", xscd->state);
|
||||
break;
|
||||
}
|
||||
|
@ -72,28 +72,28 @@ cleanup_sighandler(int signum)
|
||||
}
|
||||
|
||||
static void
|
||||
state_cb_rm(struct xbps_handle *xhp,
|
||||
struct xbps_state_cb_data *xscd,
|
||||
void *cbdata)
|
||||
state_cb_rm(struct xbps_state_cb_data *xscd, void *cbdata)
|
||||
{
|
||||
bool syslog_enabled = false;
|
||||
|
||||
(void)cbdata;
|
||||
|
||||
if (xhp->flags & XBPS_FLAG_SYSLOG) {
|
||||
if (xscd->xhp->flags & XBPS_FLAG_SYSLOG) {
|
||||
syslog_enabled = true;
|
||||
openlog("xbps-remove", LOG_CONS, LOG_USER);
|
||||
}
|
||||
|
||||
switch (xscd->state) {
|
||||
/* notifications */
|
||||
case XBPS_STATE_UNREGISTER:
|
||||
break;
|
||||
case XBPS_STATE_REMOVE:
|
||||
printf("Removing `%s-%s' ...\n", xscd->arg0, xscd->arg1);
|
||||
break;
|
||||
/* success */
|
||||
case XBPS_STATE_REMOVE_FILE:
|
||||
case XBPS_STATE_REMOVE_FILE_OBSOLETE:
|
||||
if (xhp->flags & XBPS_FLAG_VERBOSE)
|
||||
if (xscd->xhp->flags & XBPS_FLAG_VERBOSE)
|
||||
printf("%s\n", xscd->desc);
|
||||
else {
|
||||
printf("%s\n", xscd->desc);
|
||||
@ -106,7 +106,7 @@ state_cb_rm(struct xbps_handle *xhp,
|
||||
if (syslog_enabled)
|
||||
syslog(LOG_NOTICE, "Removed `%s-%s' successfully "
|
||||
"(rootdir: %s).", xscd->arg0, xscd->arg1,
|
||||
xhp->rootdir);
|
||||
xscd->xhp->rootdir);
|
||||
break;
|
||||
/* errors */
|
||||
case XBPS_STATE_UNREGISTER_FAIL:
|
||||
@ -127,7 +127,7 @@ state_cb_rm(struct xbps_handle *xhp,
|
||||
syslog(LOG_ERR, "%s", xscd->desc);
|
||||
break;
|
||||
default:
|
||||
xbps_dbg_printf(xhp,
|
||||
xbps_dbg_printf(xscd->xhp,
|
||||
"%s-%s: unknown state %d\n",
|
||||
xscd->arg0, xscd->arg1, xscd->state);
|
||||
break;
|
||||
@ -161,7 +161,7 @@ cachedir_clean(struct xbps_handle *xhp)
|
||||
}
|
||||
/* Internalize props.plist dictionary from binary pkg */
|
||||
binpkg = xbps_xasprintf("%s/%s", xhp->cachedir, dp->d_name);
|
||||
pkg_propsd = xbps_dictionary_metadata_plist_by_url(binpkg,
|
||||
pkg_propsd = xbps_get_pkg_plist_from_binpkg(binpkg,
|
||||
"./props.plist");
|
||||
if (pkg_propsd == NULL) {
|
||||
xbps_error_printf("Failed to read from %s: %s\n",
|
||||
@ -175,7 +175,7 @@ cachedir_clean(struct xbps_handle *xhp)
|
||||
* Remove binary pkg if it's not registered in any repository
|
||||
* or if hash doesn't match.
|
||||
*/
|
||||
repo_pkgd = xbps_rpool_find_pkg_exact(xhp, pkgver);
|
||||
repo_pkgd = xbps_rpool_get_pkg(xhp, pkgver);
|
||||
if (repo_pkgd) {
|
||||
prop_dictionary_get_cstring_nocopy(repo_pkgd,
|
||||
"filename-sha256", &rsha256);
|
||||
@ -213,7 +213,7 @@ remove_pkg(struct xbps_handle *xhp, const char *pkgname, size_t cols,
|
||||
rv = xbps_transaction_remove_pkg(xhp, pkgname, recursive);
|
||||
if (rv == EEXIST) {
|
||||
/* pkg has revdeps */
|
||||
pkgd = xbps_find_pkg_dict_installed(xhp, pkgname, false);
|
||||
pkgd = xbps_pkgdb_get_pkg(xhp, pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
|
||||
reqby = prop_dictionary_get(pkgd, "requiredby");
|
||||
printf("WARNING: %s IS REQUIRED BY %u PACKAGE%s:\n\n",
|
||||
|
@ -2,7 +2,7 @@ TOPDIR = ../..
|
||||
-include $(TOPDIR)/config.mk
|
||||
|
||||
BIN = xbps-rindex
|
||||
OBJS = main.o index.o index-files.o remove-obsoletes.o common.o
|
||||
OBJS = main.o index.o remove-obsoletes.o common.o
|
||||
MAN = $(BIN).8
|
||||
|
||||
include $(TOPDIR)/mk/prog.mk
|
||||
|
@ -56,12 +56,14 @@ remove_pkg(const char *repodir, const char *arch, const char *file)
|
||||
|
||||
filepath = xbps_xasprintf("%s/%s", repodir, file);
|
||||
if (remove(filepath) == -1) {
|
||||
if (errno != ENOENT) {
|
||||
rv = errno;
|
||||
xbps_error_printf("failed to remove old binpkg `%s': %s\n",
|
||||
file, strerror(rv));
|
||||
xbps_error_printf("failed to remove old binpkg "
|
||||
"`%s': %s\n", file, strerror(rv));
|
||||
free(filepath);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
free(filepath);
|
||||
|
||||
return 0;
|
||||
|
@ -1,377 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2012 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 <stdbool.h>
|
||||
#include <errno.h>
|
||||
#include <libgen.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <xbps_api.h>
|
||||
#include "defs.h"
|
||||
|
||||
int
|
||||
index_files_clean(struct xbps_handle *xhp, const char *repodir)
|
||||
{
|
||||
prop_object_t obj;
|
||||
prop_array_t idx, idxfiles, obsoletes;
|
||||
char *plist, *plistf, *pkgver, *str;
|
||||
const char *p, *arch, *ipkgver, *iarch;
|
||||
size_t x, i;
|
||||
int rv = 0;
|
||||
bool flush = false;
|
||||
|
||||
plist = plistf = pkgver = str = NULL;
|
||||
idx = idxfiles = obsoletes = NULL;
|
||||
|
||||
/* Internalize index-files.plist if found */
|
||||
if ((plistf = xbps_pkg_index_files_plist(xhp, repodir)) == NULL)
|
||||
return EINVAL;
|
||||
if ((idxfiles = prop_array_internalize_from_zfile(plistf)) == NULL) {
|
||||
free(plistf);
|
||||
return 0;
|
||||
}
|
||||
/* Internalize index.plist */
|
||||
if ((plist = xbps_pkg_index_plist(xhp, repodir)) == NULL) {
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
if ((idx = prop_array_internalize_from_zfile(plist)) == NULL) {
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
printf("Cleaning `%s' index-files, please wait...\n", repodir);
|
||||
/*
|
||||
* Iterate over index-files array to find obsolete entries.
|
||||
*/
|
||||
obsoletes = prop_array_create();
|
||||
assert(obsoletes);
|
||||
|
||||
for (x = 0; x < prop_array_count(idxfiles); x++) {
|
||||
obj = prop_array_get(idxfiles, x);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &ipkgver);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "architecture", &iarch);
|
||||
if (xbps_find_pkg_in_array_by_pkgver(xhp, idx, ipkgver, iarch)) {
|
||||
/* pkg found, do nothing */
|
||||
continue;
|
||||
}
|
||||
str = xbps_xasprintf("%s,%s", ipkgver, iarch);
|
||||
if (!prop_array_add_cstring(obsoletes, str)) {
|
||||
free(str);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
free(str);
|
||||
}
|
||||
/*
|
||||
* Iterate over the obsoletes and array and remove entries
|
||||
* from index-files array.
|
||||
*/
|
||||
for (i = 0; i < prop_array_count(obsoletes); i++) {
|
||||
prop_array_get_cstring_nocopy(obsoletes, i, &p);
|
||||
pkgver = strdup(p);
|
||||
for (x = 0; x < strlen(p); x++) {
|
||||
if ((pkgver[x] = p[x]) == ',') {
|
||||
pkgver[x] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
arch = strchr(p, ',') + 1;
|
||||
if (!xbps_remove_pkg_from_array_by_pkgver(
|
||||
xhp, idxfiles, pkgver, arch)) {
|
||||
free(pkgver);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
printf("index-files: removed obsolete entry `%s' "
|
||||
"(%s)\n", pkgver, arch);
|
||||
free(pkgver);
|
||||
flush = true;
|
||||
}
|
||||
/* Externalize index-files array to plist when necessary */
|
||||
if (flush && !prop_array_externalize_to_zfile(idxfiles, plistf))
|
||||
rv = errno;
|
||||
|
||||
printf("index-files: %u packages registered.\n",
|
||||
prop_array_count(idxfiles));
|
||||
|
||||
out:
|
||||
if (obsoletes)
|
||||
prop_object_release(obsoletes);
|
||||
if (idx)
|
||||
prop_object_release(idx);
|
||||
if (idxfiles)
|
||||
prop_object_release(idxfiles);
|
||||
if (plist)
|
||||
free(plist);
|
||||
if (plistf)
|
||||
free(plistf);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
index_files_add(struct xbps_handle *xhp, int argc, char **argv)
|
||||
{
|
||||
prop_array_t idxfiles = NULL;
|
||||
prop_object_t obj, fileobj;
|
||||
prop_dictionary_t pkgprops, pkg_filesd, pkgd;
|
||||
prop_array_t files, pkg_cffiles, pkg_files, pkg_links;
|
||||
const char *binpkg, *pkgver, *arch, *version;
|
||||
char *plist, *repodir, *p, *pkgname;
|
||||
size_t x;
|
||||
int i, rv = 0;
|
||||
bool found, flush;
|
||||
|
||||
found = flush = false;
|
||||
plist = repodir = p = NULL;
|
||||
obj = fileobj = NULL;
|
||||
pkgprops = pkg_filesd = pkgd = NULL;
|
||||
files = NULL;
|
||||
|
||||
if ((p = strdup(argv[0])) == NULL) {
|
||||
rv = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
repodir = dirname(p);
|
||||
if ((plist = xbps_pkg_index_files_plist(xhp, repodir)) == NULL) {
|
||||
rv = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
* Internalize index-files.plist if found and process argv.
|
||||
*/
|
||||
if ((idxfiles = prop_array_internalize_from_zfile(plist)) == NULL) {
|
||||
if (errno == ENOENT) {
|
||||
idxfiles = prop_array_create();
|
||||
assert(idxfiles);
|
||||
} else {
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
found = false;
|
||||
pkgprops = xbps_dictionary_metadata_plist_by_url(argv[i],
|
||||
"./props.plist");
|
||||
if (pkgprops == NULL) {
|
||||
fprintf(stderr, "index-files: cannot internalize "
|
||||
"%s props.plist: %s\n", argv[i], strerror(errno));
|
||||
continue;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(pkgprops,
|
||||
"filename", &binpkg);
|
||||
prop_dictionary_get_cstring_nocopy(pkgprops,
|
||||
"pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring_nocopy(pkgprops,
|
||||
"architecture", &arch);
|
||||
|
||||
if (xbps_find_pkg_in_array_by_pkgver(xhp, idxfiles,
|
||||
pkgver, arch)) {
|
||||
fprintf(stderr, "index-files: skipping `%s' (%s), "
|
||||
"already registered.\n", pkgver, arch);
|
||||
prop_object_release(pkgprops);
|
||||
pkgprops = NULL;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* internalize files.plist from binary package archive */
|
||||
pkg_filesd = xbps_dictionary_metadata_plist_by_url(argv[i],
|
||||
"./files.plist");
|
||||
if (pkg_filesd == NULL) {
|
||||
prop_object_release(pkgprops);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Find out if binary pkg stored in index contain any file */
|
||||
pkg_cffiles = prop_dictionary_get(pkg_filesd, "conf_files");
|
||||
if (pkg_cffiles != NULL && prop_array_count(pkg_cffiles))
|
||||
found = true;
|
||||
else
|
||||
pkg_cffiles = NULL;
|
||||
|
||||
pkg_files = prop_dictionary_get(pkg_filesd, "files");
|
||||
if (pkg_files != NULL && prop_array_count(pkg_files))
|
||||
found = true;
|
||||
else
|
||||
pkg_files = NULL;
|
||||
|
||||
pkg_links = prop_dictionary_get(pkg_filesd, "links");
|
||||
if (pkg_links != NULL && prop_array_count(pkg_links))
|
||||
found = true;
|
||||
else
|
||||
pkg_links = NULL;
|
||||
|
||||
/* If pkg does not contain any file, ignore it */
|
||||
if (!found) {
|
||||
prop_object_release(pkgprops);
|
||||
prop_object_release(pkg_filesd);
|
||||
continue;
|
||||
}
|
||||
/* create pkg dictionary */
|
||||
if ((pkgd = prop_dictionary_create()) == NULL) {
|
||||
prop_object_release(pkgprops);
|
||||
prop_object_release(pkg_filesd);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
/* add pkgver and architecture objects into pkg dictionary */
|
||||
if (!prop_dictionary_set_cstring(pkgd, "architecture", arch)) {
|
||||
prop_object_release(pkgprops);
|
||||
prop_object_release(pkg_filesd);
|
||||
prop_object_release(pkgd);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
if (!prop_dictionary_set_cstring(pkgd, "pkgver", pkgver)) {
|
||||
prop_object_release(pkgprops);
|
||||
prop_object_release(pkg_filesd);
|
||||
prop_object_release(pkgd);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
/* add files array obj into pkg dictionary */
|
||||
if ((files = prop_array_create()) == NULL) {
|
||||
prop_object_release(pkgprops);
|
||||
prop_object_release(pkg_filesd);
|
||||
prop_object_release(pkgd);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
if (!prop_dictionary_set(pkgd, "files", files)) {
|
||||
prop_object_release(pkgprops);
|
||||
prop_object_release(pkg_filesd);
|
||||
prop_object_release(files);
|
||||
prop_object_release(pkgd);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
/* add conf_files in pkgd */
|
||||
if (pkg_cffiles != NULL) {
|
||||
for (x = 0; x < prop_array_count(pkg_cffiles); x++) {
|
||||
obj = prop_array_get(pkg_cffiles, x);
|
||||
fileobj = prop_dictionary_get(obj, "file");
|
||||
if (!prop_array_add(files, fileobj)) {
|
||||
prop_object_release(pkgprops);
|
||||
prop_object_release(pkg_filesd);
|
||||
prop_object_release(files);
|
||||
prop_object_release(pkgd);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* add files array in pkgd */
|
||||
if (pkg_files != NULL) {
|
||||
for (x = 0; x < prop_array_count(pkg_files); x++) {
|
||||
obj = prop_array_get(pkg_files, x);
|
||||
fileobj = prop_dictionary_get(obj, "file");
|
||||
if (!prop_array_add(files, fileobj)) {
|
||||
prop_object_release(pkgprops);
|
||||
prop_object_release(pkg_filesd);
|
||||
prop_object_release(files);
|
||||
prop_object_release(pkgd);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* add links array in pkgd */
|
||||
if (pkg_links != NULL) {
|
||||
for (x = 0; x < prop_array_count(pkg_links); x++) {
|
||||
obj = prop_array_get(pkg_links, x);
|
||||
fileobj = prop_dictionary_get(obj, "file");
|
||||
if (!prop_array_add(files, fileobj)) {
|
||||
prop_object_release(pkgprops);
|
||||
prop_object_release(pkg_filesd);
|
||||
prop_object_release(files);
|
||||
prop_object_release(pkgd);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* add pkgd into the index-files array */
|
||||
if (!prop_array_add(idxfiles, pkgd)) {
|
||||
prop_object_release(pkgprops);
|
||||
prop_object_release(pkg_filesd);
|
||||
prop_object_release(files);
|
||||
prop_object_release(pkgd);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
flush = true;
|
||||
printf("index-files: added `%s' (%s)\n", pkgver, arch);
|
||||
prop_object_release(pkg_filesd);
|
||||
prop_object_release(files);
|
||||
prop_object_release(pkgd);
|
||||
pkg_filesd = pkgd = NULL;
|
||||
files = NULL;
|
||||
/*
|
||||
* Remove old entry (if exists).
|
||||
*/
|
||||
pkgname = xbps_pkg_name(pkgver);
|
||||
assert(pkgname);
|
||||
version = xbps_pkg_version(pkgver);
|
||||
assert(version);
|
||||
|
||||
p = xbps_xasprintf("%s<%s", pkgname, version);
|
||||
pkgd = xbps_find_pkg_in_array_by_pattern(xhp, idxfiles, p, NULL);
|
||||
if (pkgd) {
|
||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
"pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
"architecture", &arch);
|
||||
printf("index-files: remove obsolete entry `%s' (%s)\n",
|
||||
pkgver, arch);
|
||||
xbps_remove_pkg_from_array_by_pkgver(xhp,
|
||||
idxfiles, pkgver, NULL);
|
||||
}
|
||||
prop_object_release(pkgprops);
|
||||
free(pkgname);
|
||||
}
|
||||
|
||||
if (flush && !prop_array_externalize_to_zfile(idxfiles, plist)) {
|
||||
fprintf(stderr, "failed to externalize %s: %s\n",
|
||||
plist, strerror(errno));
|
||||
rv = errno;
|
||||
}
|
||||
printf("index-files: %u packages registered.\n",
|
||||
prop_array_count(idxfiles));
|
||||
|
||||
out:
|
||||
if (p)
|
||||
free(p);
|
||||
if (plist)
|
||||
free(plist);
|
||||
if (idxfiles)
|
||||
prop_object_release(idxfiles);
|
||||
|
||||
return rv;
|
||||
}
|
@ -43,21 +43,24 @@
|
||||
int
|
||||
index_clean(struct xbps_handle *xhp, const char *repodir)
|
||||
{
|
||||
prop_array_t array;
|
||||
prop_dictionary_t pkgd;
|
||||
const char *filen, *pkgver, *arch;
|
||||
char *plist;
|
||||
size_t i, idx = 0;
|
||||
prop_array_t array, result = NULL;
|
||||
prop_dictionary_t idx, idxfiles, pkgd;
|
||||
prop_dictionary_keysym_t ksym;
|
||||
const char *filen, *pkgver, *arch, *keyname;
|
||||
char *plist, *plistf;
|
||||
size_t i;
|
||||
int rv = 0;
|
||||
bool flush = false;
|
||||
|
||||
if ((plist = xbps_pkg_index_plist(xhp, repodir)) == NULL)
|
||||
return -1;
|
||||
plist = xbps_pkg_index_plist(xhp, repodir);
|
||||
assert(plist);
|
||||
plistf = xbps_pkg_index_files_plist(xhp, repodir);
|
||||
assert(plistf);
|
||||
|
||||
array = prop_array_internalize_from_zfile(plist);
|
||||
if (array == NULL) {
|
||||
idx = prop_dictionary_internalize_from_zfile(plist);
|
||||
if (idx == NULL) {
|
||||
if (errno != ENOENT) {
|
||||
xbps_error_printf("xbps-repo: cannot read `%s': %s\n",
|
||||
fprintf(stderr, "index: cannot read `%s': %s\n",
|
||||
plist, strerror(errno));
|
||||
free(plist);
|
||||
return -1;
|
||||
@ -66,37 +69,74 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
idxfiles = prop_dictionary_internalize_from_zfile(plistf);
|
||||
if (idxfiles == NULL) {
|
||||
if (errno != ENOENT) {
|
||||
fprintf(stderr, "index: cannot read `%s': %s\n",
|
||||
plistf, strerror(errno));
|
||||
rv = -1;
|
||||
goto out;
|
||||
} else {
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
if (chdir(repodir) == -1) {
|
||||
fprintf(stderr, "cannot chdir to %s: %s\n",
|
||||
fprintf(stderr, "index: cannot chdir to %s: %s\n",
|
||||
repodir, strerror(errno));
|
||||
rv = errno;
|
||||
rv = -1;
|
||||
goto out;
|
||||
}
|
||||
printf("Cleaning `%s' index, please wait...\n", repodir);
|
||||
|
||||
again:
|
||||
for (i = idx; i < prop_array_count(array); i++) {
|
||||
pkgd = prop_array_get(array, i);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
|
||||
array = prop_dictionary_all_keys(idx);
|
||||
for (i = 0; i < prop_array_count(array); i++) {
|
||||
ksym = prop_array_get(array, i);
|
||||
pkgd = prop_dictionary_get_keysym(idx, ksym);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "filename", &filen);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch);
|
||||
if (access(filen, R_OK) == -1) {
|
||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
"pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
"architecture", &arch);
|
||||
printf("index: removed obsolete entry `%s' (%s)\n",
|
||||
pkgver, arch);
|
||||
prop_array_remove(array, i);
|
||||
if (result == NULL)
|
||||
result = prop_array_create();
|
||||
|
||||
keyname = prop_dictionary_keysym_cstring_nocopy(ksym);
|
||||
prop_array_add_cstring(result, keyname);
|
||||
flush = true;
|
||||
idx = i;
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
if (flush && !prop_array_externalize_to_zfile(array, plist)) {
|
||||
rv = errno;
|
||||
prop_object_release(array);
|
||||
|
||||
if (flush) {
|
||||
for (i = 0; i < prop_array_count(result); i++) {
|
||||
prop_array_get_cstring_nocopy(result, i, &keyname);
|
||||
prop_dictionary_remove(idx, keyname);
|
||||
prop_dictionary_remove(idxfiles, keyname);
|
||||
}
|
||||
prop_object_release(result);
|
||||
if (!prop_dictionary_externalize_to_zfile(idx, plist) &&
|
||||
!prop_dictionary_externalize_to_zfile(idxfiles, plistf)) {
|
||||
fprintf(stderr, "index: failed to externalize %s: %s\n",
|
||||
plist, strerror(errno));
|
||||
goto out;
|
||||
}
|
||||
printf("index: %u packages registered.\n", prop_array_count(array));
|
||||
}
|
||||
printf("index: %u packages registered.\n",
|
||||
prop_dictionary_count(idx));
|
||||
printf("index-files: %u packages registered.\n",
|
||||
prop_dictionary_count(idxfiles));
|
||||
out:
|
||||
if (plist)
|
||||
free(plist);
|
||||
prop_object_release(array);
|
||||
if (plistf)
|
||||
free(plistf);
|
||||
if (idx)
|
||||
prop_object_release(idx);
|
||||
if (idxfiles)
|
||||
prop_object_release(idxfiles);
|
||||
|
||||
return rv;
|
||||
}
|
||||
@ -108,15 +148,21 @@ out:
|
||||
int
|
||||
index_add(struct xbps_handle *xhp, int argc, char **argv)
|
||||
{
|
||||
prop_array_t idx = NULL;
|
||||
prop_dictionary_t newpkgd = NULL, curpkgd;
|
||||
prop_array_t filespkgar, pkg_files, pkg_links, pkg_cffiles;
|
||||
prop_dictionary_t idx, idxfiles, newpkgd, newpkgfilesd, curpkgd;
|
||||
prop_dictionary_t filespkgd;
|
||||
prop_object_t obj, fileobj;
|
||||
struct stat st;
|
||||
const char *pkgname, *version, *regver, *oldfilen, *oldpkgver;
|
||||
const char *arch, *oldarch;
|
||||
const char *pkgver, *arch, *oldarch;
|
||||
char *sha256, *filen, *repodir, *buf, *buf2;
|
||||
char *tmpfilen = NULL, *tmprepodir = NULL, *plist = NULL;
|
||||
char *tmpfilen, *tmprepodir, *plist, *plistf;
|
||||
size_t x;
|
||||
int i, ret = 0, rv = 0;
|
||||
bool flush = false;
|
||||
bool files_flush = false, found = false, flush = false;
|
||||
|
||||
idx = idxfiles = newpkgd = newpkgfilesd = curpkgd = NULL;
|
||||
tmpfilen = tmprepodir = plist = plistf = NULL;
|
||||
|
||||
if ((tmprepodir = strdup(argv[0])) == NULL) {
|
||||
rv = ENOMEM;
|
||||
@ -124,18 +170,33 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
||||
}
|
||||
repodir = dirname(tmprepodir);
|
||||
|
||||
/* Internalize plist file or create it if doesn't exist */
|
||||
/* Internalize index or create it if doesn't exist */
|
||||
if ((plist = xbps_pkg_index_plist(xhp, repodir)) == NULL)
|
||||
return -1;
|
||||
|
||||
if ((idx = prop_array_internalize_from_zfile(plist)) == NULL) {
|
||||
if ((idx = prop_dictionary_internalize_from_zfile(plist)) == NULL) {
|
||||
if (errno != ENOENT) {
|
||||
xbps_error_printf("xbps-repo: cannot read `%s': %s\n",
|
||||
fprintf(stderr, "index: cannot read `%s': %s\n",
|
||||
plist, strerror(errno));
|
||||
rv = -1;
|
||||
goto out;
|
||||
} else {
|
||||
idx = prop_array_create();
|
||||
idx = prop_dictionary_create();
|
||||
assert(idx);
|
||||
}
|
||||
}
|
||||
/* Internalize index-files or create it if doesn't exist */
|
||||
if ((plistf = xbps_pkg_index_files_plist(xhp, repodir)) == NULL)
|
||||
return -1;
|
||||
|
||||
if ((idxfiles = prop_dictionary_internalize_from_zfile(plistf)) == NULL) {
|
||||
if (errno != ENOENT) {
|
||||
fprintf(stderr, "index: cannot read `%s': %s\n",
|
||||
plistf, strerror(errno));
|
||||
rv = -1;
|
||||
goto out;
|
||||
} else {
|
||||
idxfiles = prop_dictionary_create();
|
||||
assert(idx);
|
||||
}
|
||||
}
|
||||
@ -152,28 +213,34 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
||||
/*
|
||||
* Read metadata props plist dictionary from binary package.
|
||||
*/
|
||||
newpkgd = xbps_dictionary_metadata_plist_by_url(argv[i],
|
||||
newpkgd = xbps_get_pkg_plist_from_binpkg(argv[i],
|
||||
"./props.plist");
|
||||
if (newpkgd == NULL) {
|
||||
xbps_error_printf("failed to read %s metadata for `%s',"
|
||||
fprintf(stderr, "failed to read %s metadata for `%s',"
|
||||
" skipping!\n", XBPS_PKGPROPS, argv[i]);
|
||||
free(tmpfilen);
|
||||
continue;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(newpkgd, "architecture",
|
||||
&arch);
|
||||
prop_dictionary_get_cstring_nocopy(newpkgd, "pkgver", &pkgver);
|
||||
if (!xbps_pkg_arch_match(xhp, arch, NULL)) {
|
||||
fprintf(stderr, "index: ignoring %s, unmatched "
|
||||
"arch (%s)\n", pkgver, arch);
|
||||
prop_object_release(newpkgd);
|
||||
continue;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(newpkgd, "pkgname",
|
||||
&pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(newpkgd, "version",
|
||||
&version);
|
||||
prop_dictionary_get_cstring_nocopy(newpkgd, "architecture",
|
||||
&arch);
|
||||
/*
|
||||
* Check if this package exists already in the index, but first
|
||||
* checking the version. If current package version is greater
|
||||
* than current registered package, update the index; otherwise
|
||||
* pass to the next one.
|
||||
*/
|
||||
curpkgd =
|
||||
xbps_find_pkg_in_array_by_name(xhp, idx, pkgname, NULL);
|
||||
curpkgd = prop_dictionary_get(idx, pkgname);
|
||||
if (curpkgd == NULL) {
|
||||
if (errno && errno != ENOENT) {
|
||||
prop_object_release(newpkgd);
|
||||
@ -235,18 +302,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
||||
free(tmpfilen);
|
||||
goto out;
|
||||
}
|
||||
if (!xbps_remove_pkg_from_array_by_pkgver(xhp, idx,
|
||||
buf2, oldarch)) {
|
||||
xbps_error_printf("failed to remove %s "
|
||||
"from plist index: %s\n", buf,
|
||||
strerror(errno));
|
||||
rv = errno;
|
||||
free(buf);
|
||||
free(buf2);
|
||||
prop_object_release(newpkgd);
|
||||
free(tmpfilen);
|
||||
goto out;
|
||||
}
|
||||
prop_dictionary_remove(idx, pkgname);
|
||||
free(buf2);
|
||||
printf("index: removed obsolete entry/binpkg %s.\n", buf);
|
||||
free(buf);
|
||||
@ -292,7 +348,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
||||
/*
|
||||
* Add new pkg dictionary into the index.
|
||||
*/
|
||||
if (!prop_array_add(idx, newpkgd)) {
|
||||
if (!prop_dictionary_set(idx, pkgname, newpkgd)) {
|
||||
prop_object_release(newpkgd);
|
||||
free(tmpfilen);
|
||||
rv = EINVAL;
|
||||
@ -301,23 +357,121 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
||||
flush = true;
|
||||
printf("index: added `%s-%s' (%s).\n", pkgname, version, arch);
|
||||
free(tmpfilen);
|
||||
/*
|
||||
* Add new pkg dictionary into the index-files.
|
||||
*/
|
||||
found = false;
|
||||
newpkgfilesd = xbps_get_pkg_plist_from_binpkg(argv[i],
|
||||
"./files.plist");
|
||||
if (newpkgfilesd == NULL) {
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Find out if binary pkg stored in index contain any file */
|
||||
pkg_cffiles = prop_dictionary_get(newpkgfilesd, "conf_files");
|
||||
if (pkg_cffiles != NULL && prop_array_count(pkg_cffiles))
|
||||
found = true;
|
||||
else
|
||||
pkg_cffiles = NULL;
|
||||
|
||||
pkg_files = prop_dictionary_get(newpkgfilesd, "files");
|
||||
if (pkg_files != NULL && prop_array_count(pkg_files))
|
||||
found = true;
|
||||
else
|
||||
pkg_files = NULL;
|
||||
|
||||
pkg_links = prop_dictionary_get(newpkgfilesd, "links");
|
||||
if (pkg_links != NULL && prop_array_count(pkg_links))
|
||||
found = true;
|
||||
else
|
||||
pkg_links = NULL;
|
||||
|
||||
/* If pkg does not contain any file, ignore it */
|
||||
if (!found) {
|
||||
prop_object_release(newpkgfilesd);
|
||||
prop_object_release(newpkgd);
|
||||
continue;
|
||||
}
|
||||
/* create pkg files array */
|
||||
filespkgar = prop_array_create();
|
||||
assert(filespkgar);
|
||||
|
||||
/* add conf_files in pkg files array */
|
||||
if (pkg_cffiles != NULL) {
|
||||
for (x = 0; x < prop_array_count(pkg_cffiles); x++) {
|
||||
obj = prop_array_get(pkg_cffiles, x);
|
||||
fileobj = prop_dictionary_get(obj, "file");
|
||||
prop_array_add(filespkgar, fileobj);
|
||||
}
|
||||
}
|
||||
/* add files array in pkg array */
|
||||
if (pkg_files != NULL) {
|
||||
for (x = 0; x < prop_array_count(pkg_files); x++) {
|
||||
obj = prop_array_get(pkg_files, x);
|
||||
fileobj = prop_dictionary_get(obj, "file");
|
||||
prop_array_add(filespkgar, fileobj);
|
||||
}
|
||||
}
|
||||
/* add links array in pkgd */
|
||||
if (pkg_links != NULL) {
|
||||
for (x = 0; x < prop_array_count(pkg_links); x++) {
|
||||
obj = prop_array_get(pkg_links, x);
|
||||
fileobj = prop_dictionary_get(obj, "file");
|
||||
prop_array_add(filespkgar, fileobj);
|
||||
}
|
||||
}
|
||||
prop_object_release(newpkgfilesd);
|
||||
|
||||
/* create pkg dictionary */
|
||||
filespkgd = prop_dictionary_create();
|
||||
assert(filespkgd);
|
||||
|
||||
/* add pkg files array into pkg dictionary */
|
||||
prop_dictionary_set(filespkgd, "files", filespkgar);
|
||||
prop_object_release(filespkgar);
|
||||
|
||||
/* set pkgver obj into pkg dictionary */
|
||||
prop_dictionary_set_cstring(filespkgd, "pkgver", pkgver);
|
||||
|
||||
/* add pkg dictionary into index-files */
|
||||
prop_dictionary_set(idxfiles, pkgname, filespkgd);
|
||||
prop_object_release(filespkgd);
|
||||
|
||||
printf("index-files: added `%s' (%s)\n", pkgver, arch);
|
||||
files_flush = true;
|
||||
prop_object_release(newpkgd);
|
||||
}
|
||||
|
||||
if (flush && !prop_array_externalize_to_zfile(idx, plist)) {
|
||||
xbps_error_printf("failed to externalize plist: %s\n",
|
||||
if (flush && !prop_dictionary_externalize_to_zfile(idx, plist)) {
|
||||
fprintf(stderr, "index: failed to externalize plist: %s\n",
|
||||
strerror(errno));
|
||||
rv = errno;
|
||||
rv = -1;
|
||||
goto out;
|
||||
}
|
||||
printf("index: %u packages registered.\n", prop_array_count(idx));
|
||||
if (files_flush &&
|
||||
!prop_dictionary_externalize_to_zfile(idxfiles, plistf)) {
|
||||
fprintf(stderr, "index-files: failed to externalize "
|
||||
"plist: %s\n", strerror(errno));
|
||||
rv = -1;
|
||||
goto out;
|
||||
}
|
||||
printf("index: %u packages registered.\n",
|
||||
prop_dictionary_count(idx));
|
||||
printf("index-files: %u packages registered.\n",
|
||||
prop_dictionary_count(idxfiles));
|
||||
|
||||
out:
|
||||
if (tmprepodir)
|
||||
free(tmprepodir);
|
||||
if (plist)
|
||||
free(plist);
|
||||
if (plistf)
|
||||
free(plistf);
|
||||
if (idx)
|
||||
prop_object_release(idx);
|
||||
if (idxfiles)
|
||||
prop_object_release(idxfiles);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -99,15 +99,12 @@ main(int argc, char **argv)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (add_mode) {
|
||||
if (index_add(&xh, argc - optind, argv + optind) == 0)
|
||||
rv = index_files_add(&xh, argc - optind, argv + optind);
|
||||
} else if (clean_mode) {
|
||||
if (index_clean(&xh, argv[optind]) == 0)
|
||||
rv = index_files_clean(&xh, argv[optind]);
|
||||
} else if (rm_mode) {
|
||||
if (add_mode)
|
||||
rv = index_add(&xh, argc - optind, argv + optind);
|
||||
else if (clean_mode)
|
||||
rv = index_clean(&xh, argv[optind]);
|
||||
else if (rm_mode)
|
||||
rv = remove_obsoletes(&xh, argv[optind]);
|
||||
}
|
||||
|
||||
xbps_end(&xh);
|
||||
exit(rv ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
|
@ -39,8 +39,8 @@
|
||||
int
|
||||
remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
prop_array_t idx;
|
||||
prop_dictionary_t pkgd, idx;
|
||||
struct xbps_rindex ri;
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
const char *pkgver, *arch;
|
||||
@ -50,10 +50,10 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
|
||||
if ((plist = xbps_pkg_index_plist(xhp, repodir)) == NULL)
|
||||
return -1;
|
||||
|
||||
idx = prop_array_internalize_from_zfile(plist);
|
||||
idx = prop_dictionary_internalize_from_zfile(plist);
|
||||
if (idx == NULL) {
|
||||
if (errno != ENOENT) {
|
||||
xbps_error_printf("xbps-repo: cannot read `%s': %s\n",
|
||||
fprintf(stderr, "xbps-rindex: cannot read `%s': %s\n",
|
||||
plist, strerror(errno));
|
||||
free(plist);
|
||||
return -1;
|
||||
@ -62,14 +62,19 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/* initialize repository index */
|
||||
ri.repod = idx;
|
||||
ri.uri = repodir;
|
||||
ri.xhp = xhp;
|
||||
|
||||
if (chdir(repodir) == -1) {
|
||||
fprintf(stderr, "cannot chdir to %s: %s\n",
|
||||
fprintf(stderr, "xbps-rindex: cannot chdir to %s: %s\n",
|
||||
repodir, strerror(errno));
|
||||
prop_object_release(idx);
|
||||
return errno;
|
||||
}
|
||||
if ((dirp = opendir(repodir)) == NULL) {
|
||||
fprintf(stderr, "failed to open %s: %s\n",
|
||||
fprintf(stderr, "xbps-rindex: failed to open %s: %s\n",
|
||||
repodir, strerror(errno));
|
||||
prop_object_release(idx);
|
||||
return errno;
|
||||
@ -82,12 +87,12 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
|
||||
if (strcmp(ext, ".xbps"))
|
||||
continue;
|
||||
|
||||
pkgd = xbps_dictionary_metadata_plist_by_url(dp->d_name,
|
||||
pkgd = xbps_get_pkg_plist_from_binpkg(dp->d_name,
|
||||
"./props.plist");
|
||||
if (pkgd == NULL) {
|
||||
rv = remove_pkg(repodir, arch, dp->d_name);
|
||||
if (rv != 0) {
|
||||
fprintf(stderr, "index: failed to remove "
|
||||
fprintf(stderr, "xbps-rindex: failed to remove "
|
||||
"package `%s': %s\n", dp->d_name,
|
||||
strerror(rv));
|
||||
prop_object_release(pkgd);
|
||||
@ -100,10 +105,10 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
|
||||
/*
|
||||
* If binpkg is not registered in index, remove binpkg.
|
||||
*/
|
||||
if (!xbps_find_pkg_in_array_by_pkgver(xhp, idx, pkgver, arch)) {
|
||||
if (!xbps_rindex_get_pkg(&ri, pkgver)) {
|
||||
rv = remove_pkg(repodir, arch, dp->d_name);
|
||||
if (rv != 0) {
|
||||
fprintf(stderr, "index: failed to remove "
|
||||
fprintf(stderr, "xbps-rindex: failed to remove "
|
||||
"package `%s': %s\n", dp->d_name,
|
||||
strerror(rv));
|
||||
prop_object_release(pkgd);
|
||||
|
@ -155,7 +155,7 @@ main(int argc, char **argv)
|
||||
if (argc != 2)
|
||||
usage();
|
||||
|
||||
dict = xbps_find_pkg_dict_installed(&xh, argv[1], false);
|
||||
dict = xbps_pkgdb_get_pkg(&xh, argv[1]);
|
||||
if (dict == NULL) {
|
||||
rv = errno;
|
||||
goto out;
|
||||
|
@ -21,26 +21,15 @@
|
||||
# Enable syslog messages, set the value to false or 0 to disable.
|
||||
#Syslog = true
|
||||
|
||||
# Number of packages to be processed in a transaction to trigger
|
||||
# a flush to the master package database. Set it to 0 to make it
|
||||
# only flush at required points.
|
||||
#
|
||||
#TransactionFrequencyFlush = 5
|
||||
|
||||
# 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.
|
||||
# repository matching a package expression will be used for most
|
||||
# targets in xbps-install(8) and xbps-query(8).
|
||||
#
|
||||
# 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 to the directory
|
||||
# where the plist index file (rindex.plist) is stored.
|
||||
|
@ -54,9 +54,9 @@
|
||||
* @def XBPS_PKGINDEX_VERSION
|
||||
* Current version for the repository package index format.
|
||||
*/
|
||||
#define XBPS_PKGINDEX_VERSION "1.5"
|
||||
#define XBPS_PKGINDEX_VERSION "1.6"
|
||||
|
||||
#define XBPS_API_VERSION "20121121"
|
||||
#define XBPS_API_VERSION "20121129"
|
||||
|
||||
#ifndef XBPS_VERSION
|
||||
#define XBPS_VERSION "UNSET"
|
||||
@ -206,13 +206,6 @@
|
||||
*/
|
||||
#define XBPS_FETCH_TIMEOUT 30
|
||||
|
||||
/**
|
||||
* @def XBPS_TRANS_FLUSH
|
||||
* Default number of packages to be processed in a transaction to
|
||||
* trigger a flush to the master package database XBPS_REGPKGDB.
|
||||
*/
|
||||
#define XBPS_TRANS_FLUSH 5
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/** @addtogroup initend */
|
||||
@ -312,6 +305,12 @@ typedef enum xbps_state {
|
||||
* All members are read-only and set internally by libxbps.
|
||||
*/
|
||||
struct xbps_state_cb_data {
|
||||
/**
|
||||
* @var xhp
|
||||
*
|
||||
* Pointer to our struct xbps_handle passed to xbps_init().
|
||||
*/
|
||||
struct xbps_handle *xhp;
|
||||
/**
|
||||
* @var state
|
||||
*
|
||||
@ -351,6 +350,12 @@ struct xbps_state_cb_data {
|
||||
* function callback.
|
||||
*/
|
||||
struct xbps_fetch_cb_data {
|
||||
/**
|
||||
* @var xhp
|
||||
*
|
||||
* Pointer to our struct xbps_handle passed to xbps_init().
|
||||
*/
|
||||
struct xbps_handle *xhp;
|
||||
/**
|
||||
* @var file_size
|
||||
*
|
||||
@ -404,11 +409,17 @@ struct xbps_fetch_cb_data {
|
||||
*
|
||||
* This structure is passed as argument to the unpack progress function
|
||||
* callback and its members will be updated when there's any progress.
|
||||
* All members in this struct are set internally by xbps_unpack_binary_pkg()
|
||||
* and should be used in read-only mode in the function callback.
|
||||
* The \a cookie member can be used to pass user supplied data.
|
||||
* All members in this struct are set internally by libxbps
|
||||
* and should be used in read-only mode in the supplied function
|
||||
* callback.
|
||||
*/
|
||||
struct xbps_unpack_cb_data {
|
||||
/**
|
||||
* @var xhp
|
||||
*
|
||||
* Pointer to our struct xbps_handle passed to xbps_init().
|
||||
*/
|
||||
struct xbps_handle *xhp;
|
||||
/**
|
||||
* @var pkgver
|
||||
*
|
||||
@ -490,7 +501,7 @@ struct xbps_handle {
|
||||
* Pointer to the supplifed function callback to be used
|
||||
* in the XBPS possible states.
|
||||
*/
|
||||
void (*state_cb)(struct xbps_handle *, struct xbps_state_cb_data *, void *);
|
||||
void (*state_cb)(struct xbps_state_cb_data *, void *);
|
||||
/**
|
||||
* Pointer to user supplied data to be passed as argument to
|
||||
* the \a xbps_state_cb function callback.
|
||||
@ -500,7 +511,7 @@ struct xbps_handle {
|
||||
* Pointer to the supplied function callback to be used in
|
||||
* xbps_unpack_binary_pkg().
|
||||
*/
|
||||
void (*unpack_cb)(struct xbps_handle *, struct xbps_unpack_cb_data *, void *);
|
||||
void (*unpack_cb)(struct xbps_unpack_cb_data *, void *);
|
||||
/**
|
||||
* Pointer to user supplied data to be passed as argument to
|
||||
* the \a xbps_unpack_cb function callback.
|
||||
@ -510,7 +521,7 @@ struct xbps_handle {
|
||||
* Pointer to the supplied function callback to be used in
|
||||
* xbps_fetch_file().
|
||||
*/
|
||||
void (*fetch_cb)(struct xbps_handle *, struct xbps_fetch_cb_data *, void *);
|
||||
void (*fetch_cb)(struct xbps_fetch_cb_data *, void *);
|
||||
/**
|
||||
* @var fetch_cb_data
|
||||
*
|
||||
@ -566,13 +577,6 @@ struct xbps_handle {
|
||||
* by the API from a setting in configuration file.
|
||||
*/
|
||||
uint16_t fetch_timeout;
|
||||
/**
|
||||
* @var transaction_frequency_flush
|
||||
*
|
||||
* Number of packages to be processed in a transaction to
|
||||
* trigger a flush to the master databases.
|
||||
*/
|
||||
uint16_t transaction_frequency_flush;
|
||||
/**
|
||||
* @var flags
|
||||
*
|
||||
@ -656,7 +660,6 @@ int xbps_configure_packages(struct xbps_handle *xhp, bool flush);
|
||||
/** @addtogroup download */
|
||||
/*@{*/
|
||||
|
||||
|
||||
/**
|
||||
* Download a file from a remote URL to current working directory.
|
||||
*
|
||||
@ -749,14 +752,11 @@ int xbps_pkgdb_foreach_reverse_cb(
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] pkg Package name or name-version to match.
|
||||
* @param[in] bypattern If false \a pkg must be a pkgname, otherwise a
|
||||
* package pattern, i.e `foo>=0' or `foo<1'.
|
||||
*
|
||||
* @return The matching proplib package dictionary, NULL otherwise.
|
||||
*/
|
||||
prop_dictionary_t xbps_pkgdb_get_pkgd(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern);
|
||||
prop_dictionary_t xbps_pkgdb_get_pkg(struct xbps_handle *xhp,
|
||||
const char *pkg);
|
||||
|
||||
/**
|
||||
* Returns a package dictionary from master package database (pkgdb) plist,
|
||||
@ -764,26 +764,22 @@ prop_dictionary_t xbps_pkgdb_get_pkgd(struct xbps_handle *xhp,
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] pkg Package name or name-version to match.
|
||||
* @param[in] bypattern If false \a pkg must be a pkgname, otherwise a
|
||||
* package pattern, i.e `foo>=0' or `foo<1'.
|
||||
*
|
||||
* @return The matching proplib package dictionary, NULL otherwise.
|
||||
*/
|
||||
prop_dictionary_t xbps_pkgdb_get_virtualpkgd(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern);
|
||||
prop_dictionary_t xbps_pkgdb_get_virtualpkg(struct xbps_handle *xhp,
|
||||
const char *pkg);
|
||||
|
||||
/**
|
||||
* Returns a package dictionary from master package database (pkgdb) plist,
|
||||
* matching the pkgver object in \a pkg dictionary.
|
||||
* Returns the package dictionary with all metadata info for \a pkg.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] pkgver Package name-version to match, i.e 'foo-1.0'.
|
||||
* @param[in] Package expression to match.
|
||||
*
|
||||
* @return The matching proplib package dictionary, NULL otherwise.
|
||||
* @return The matching package metadata dictionary, NULL otherwise.
|
||||
*/
|
||||
prop_dictionary_t xbps_pkgdb_get_pkgd_by_pkgver(struct xbps_handle *xhp,
|
||||
const char *pkgver);
|
||||
prop_dictionary_t xbps_pkgdb_get_pkg_metadata(struct xbps_handle *xhp,
|
||||
const char *pkg);
|
||||
|
||||
/**
|
||||
* Removes a package dictionary from master package database (pkgdb) plist,
|
||||
@ -791,16 +787,12 @@ prop_dictionary_t xbps_pkgdb_get_pkgd_by_pkgver(struct xbps_handle *xhp,
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] pkg Package name or pattern to match in a package dictionary.
|
||||
* @param[in] bypattern If false \a pkg must be a pkgname, otherwise a
|
||||
* package pattern, i.e `foo>=0' or `foo<1'.
|
||||
* @param[in] flush If true, after successful replace the pkgdb contents
|
||||
* in memory will be flushed atomically to storage.
|
||||
*
|
||||
* @return true on success, false otherwise.
|
||||
*/
|
||||
bool xbps_pkgdb_remove_pkgd(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern,
|
||||
bool xbps_pkgdb_remove_pkg(struct xbps_handle *xhp, const char *pkg,
|
||||
bool flush);
|
||||
|
||||
/**
|
||||
@ -810,17 +802,14 @@ bool xbps_pkgdb_remove_pkgd(struct xbps_handle *xhp,
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] pkgd Proplib dictionary to be added into pkgdb.
|
||||
* @param[in] pkg Package name or pattern to match in a package dictionary.
|
||||
* @param[in] bypattern If false \a pkg must be a pkgname, otherwise a
|
||||
* package pattern, i.e `foo>=0' or `foo<1'.
|
||||
* @param[in] flush If true, after successful replace the pkgdb contents in
|
||||
* memory will be flushed atomically to storage.
|
||||
*
|
||||
* @return true on success, false otherwise.
|
||||
*/
|
||||
bool xbps_pkgdb_replace_pkgd(struct xbps_handle *xhp,
|
||||
bool xbps_pkgdb_replace_pkg(struct xbps_handle *xhp,
|
||||
prop_dictionary_t pkgd,
|
||||
const char *pkg,
|
||||
bool bypattern,
|
||||
bool flush);
|
||||
|
||||
/**
|
||||
@ -840,31 +829,6 @@ int xbps_pkgdb_update(struct xbps_handle *xhp, bool flush);
|
||||
/** @addtogroup plist */
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
* Adds a proplib object into a proplib dictionary with specified key.
|
||||
* The object is always released.
|
||||
*
|
||||
* @param[in] dict Proplib dictionary to insert the object to.
|
||||
* @param[in] obj Proplib object to be inserted.
|
||||
* @param[in] key Key associated with \a obj.
|
||||
*
|
||||
* @return true on success, false otherwise and errno set appropiately.
|
||||
*/
|
||||
bool xbps_add_obj_to_dict(prop_dictionary_t dict,
|
||||
prop_object_t obj,
|
||||
const char *key);
|
||||
|
||||
/**
|
||||
* Adds a proplib object into a proplib array.
|
||||
* The object is always released.
|
||||
*
|
||||
* @param[in] array Proplib array to insert the object to.
|
||||
* @param[in] obj Proplib object to be inserted.
|
||||
*
|
||||
* @return true on success, false otherwise and xbps_errno set appropiately.
|
||||
*/
|
||||
bool xbps_add_obj_to_array(prop_array_t array, prop_object_t obj);
|
||||
|
||||
/**
|
||||
* Executes a function callback specified in \a fn with \a arg passed
|
||||
* as its argument into they array \a array.
|
||||
@ -947,132 +911,6 @@ int xbps_callback_array_iter_reverse_in_dict(struct xbps_handle *xhp,
|
||||
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *),
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Finds the proplib's dictionary associated with a package, by looking
|
||||
* it via its name in a proplib dictionary.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] dict Proplib dictionary to look for the package dictionary.
|
||||
* @param[in] key Key associated with the array that stores package's dictionary.
|
||||
* @param[in] pkgname Package name to look for.
|
||||
*
|
||||
* @return The package's proplib dictionary on success, NULL otherwise and
|
||||
* errno is set appropiately.
|
||||
*/
|
||||
prop_dictionary_t xbps_find_pkg_in_dict_by_name(struct xbps_handle *xhp,
|
||||
prop_dictionary_t dict,
|
||||
const char *key,
|
||||
const char *pkgname);
|
||||
|
||||
/**
|
||||
* Finds the proplib's dictionary associated with a package, by looking
|
||||
* at it via a package pattern in a proplib dictionary.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] dict Proplib dictionary to look for the package dictionary.
|
||||
* @param[in] key Key associated with the array storing the package's dictionary.
|
||||
* @param[in] pattern Package pattern to match.
|
||||
*
|
||||
* @return The package's proplib dictionary on success, NULL otherwise
|
||||
* and errno is set appropiately.
|
||||
*/
|
||||
prop_dictionary_t xbps_find_pkg_in_dict_by_pattern(struct xbps_handle *xhp,
|
||||
prop_dictionary_t dict,
|
||||
const char *key,
|
||||
const char *pattern);
|
||||
|
||||
/**
|
||||
* Finds the proplib's dictionary associated with a package, by matching
|
||||
* its \a pkgver object in its dictionary.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] dict Proplib dictionary to look for the package dictionary.
|
||||
* @param[in] key Key associated with the array storing the package's
|
||||
* dictionary.
|
||||
* @param[in] pkgver Package name/version to match, i.e `foo-1.0_1'.
|
||||
*
|
||||
* @return The package's proplib dictionary on success, NULL otherwise
|
||||
* and errno is set appropiately.
|
||||
*/
|
||||
prop_dictionary_t xbps_find_pkg_in_dict_by_pkgver(struct xbps_handle *xhp,
|
||||
prop_dictionary_t dict,
|
||||
const char *key,
|
||||
const char *pkgver);
|
||||
|
||||
/**
|
||||
* Finds the proplib's dictionary associated with a package, by matching
|
||||
* a pkgname in \a name on any of the virtual package in
|
||||
* the "provides" array object.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] d Proplib dictionary to look for the package dictionary.
|
||||
* @param[in] key Key associated with the array storing the package's
|
||||
* dictionary.
|
||||
* @param[in] name The virtual package name to match.
|
||||
*
|
||||
* @return The package dictionary, otherwise NULL is returned and errno
|
||||
* is set appropiately.
|
||||
* Finds a virtual package dictionary in a proplib array by matching a
|
||||
* package name.
|
||||
*/
|
||||
prop_dictionary_t xbps_find_virtualpkg_in_dict_by_name(struct xbps_handle *xhp,
|
||||
prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *name);
|
||||
|
||||
/**
|
||||
* Finds the proplib's dictionary associated with a package, by matching
|
||||
* a pkg pattern in \a pattern on any of the virtual package in
|
||||
* the "provides" array object.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] d Proplib dictionary to look for the package dictionary.
|
||||
* @param[in] key Key associated with the array storing the package's
|
||||
* dictionary.
|
||||
* @param[in] pattern The virtual package pattern to match, i.e
|
||||
* `foo>=0' or `foo<1'.
|
||||
*
|
||||
* @return The package dictionary, otherwise NULL is returned and errno
|
||||
* is set appropiately.
|
||||
*/
|
||||
prop_dictionary_t xbps_find_virtualpkg_in_dict_by_pattern(struct xbps_handle *xhp,
|
||||
prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *pattern);
|
||||
|
||||
/**
|
||||
* Finds a package's dictionary searching in the registered packages
|
||||
* database by using a package name or a package pattern.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] str Package name or package pattern.
|
||||
* @param[in] bypattern Set it to true to find the package dictionary
|
||||
* by using a package pattern. If false, \a str is assumed to be a package name.
|
||||
*
|
||||
* @return The package's dictionary on success, NULL otherwise and
|
||||
* errno is set appropiately.
|
||||
*/
|
||||
prop_dictionary_t xbps_find_pkg_dict_installed(struct xbps_handle *xhp,
|
||||
const char *str,
|
||||
bool bypattern);
|
||||
|
||||
|
||||
/**
|
||||
* Finds a virtual package's dictionary searching in the registered packages
|
||||
* database by using a package name or a package pattern.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] str Virtual package name or package pattern to match.
|
||||
* @param[in] bypattern Set it to true to find the package dictionary
|
||||
* by using a package pattern. If false, \a str is assumed to be a package name.
|
||||
*
|
||||
* @return The virtual package's dictionary on success, NULL otherwise and
|
||||
* errno is set appropiately.
|
||||
*/
|
||||
prop_dictionary_t xbps_find_virtualpkg_dict_installed(struct xbps_handle *xhp,
|
||||
const char *str,
|
||||
bool bypattern);
|
||||
|
||||
/**
|
||||
* Match a virtual package name or pattern by looking at package's
|
||||
* dictionary "provides" array object.
|
||||
@ -1102,85 +940,6 @@ bool xbps_match_virtual_pkg_in_dict(prop_dictionary_t pkgd,
|
||||
bool xbps_match_any_virtualpkg_in_rundeps(prop_array_t rundeps,
|
||||
prop_array_t provides);
|
||||
|
||||
/**
|
||||
* Finds a package dictionary in a proplib array by matching a package name.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] array The proplib array to search on.
|
||||
* @param[in] name The package name to match.
|
||||
* @param[in] targetarch If set, package will be matched against this
|
||||
* architecture.
|
||||
*
|
||||
* @return The package dictionary, otherwise NULL is returned.
|
||||
*/
|
||||
prop_dictionary_t xbps_find_pkg_in_array_by_name(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *name,
|
||||
const char *targetarch);
|
||||
|
||||
/**
|
||||
* Finds a package dictionary in a proplib array by matching a package pattern.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] array The proplib array to search on.
|
||||
* @param[in] pattern The package pattern to match, i.e `foo>=0' or `foo<1'.
|
||||
* @param[in] targetarch If set, package will be matched against this
|
||||
* architecture.
|
||||
*
|
||||
* @return The package dictionary, otherwise NULL is returned.
|
||||
*/
|
||||
prop_dictionary_t xbps_find_pkg_in_array_by_pattern(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *pattern,
|
||||
const char *targetarch);
|
||||
|
||||
/**
|
||||
* Finds a package dictionary in a proplib array by matching a \a pkgver
|
||||
* object.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] array The proplib array to search on.
|
||||
* @param[in] pkgver The package name/version to match, i.e `foo-1.0'.
|
||||
* @param[in] targetarch If set, package will be matched against this
|
||||
* architecture.
|
||||
*
|
||||
* @return The package dictionary, otherwise NULL is returned.
|
||||
*/
|
||||
prop_dictionary_t xbps_find_pkg_in_array_by_pkgver(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *pkgver,
|
||||
const char *targetarch);
|
||||
|
||||
/**
|
||||
* Finds a virtual package dictionary in a proplib array by matching a
|
||||
* package name.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] array The proplib array to search on.
|
||||
* @param[in] name The virtual package name to match.
|
||||
*
|
||||
* @return The package dictionary, otherwise NULL is returned.
|
||||
*/
|
||||
prop_dictionary_t xbps_find_virtualpkg_in_array_by_name(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *name);
|
||||
|
||||
/**
|
||||
* Finds a virtual package dictionary in a proplib array by matching a
|
||||
* package pattern.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] array The proplib array to search on.
|
||||
* @param[in] pattern The virtual package pattern to match, i.e
|
||||
* `foo>=0' or `foo<1'.
|
||||
*
|
||||
* @return The package dictionary, otherwise NULL is returned.
|
||||
*/
|
||||
prop_dictionary_t
|
||||
xbps_find_virtualpkg_in_array_by_pattern(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *pattern);
|
||||
|
||||
/**
|
||||
* Match a package name in the specified array of strings.
|
||||
*
|
||||
@ -1235,19 +994,6 @@ bool xbps_match_string_in_array(prop_array_t array, const char *val);
|
||||
prop_object_iterator_t xbps_array_iter_from_dict(prop_dictionary_t dict,
|
||||
const char *key);
|
||||
|
||||
/**
|
||||
* Returns a proplib dictionary associated with the installed package
|
||||
* \a name, by internalizing its plist file from metadir.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] name Package name of installed package.
|
||||
*
|
||||
* @return The proplib dictionary on success, NULL otherwise and
|
||||
* errno is set appropiately.
|
||||
*/
|
||||
prop_dictionary_t xbps_metadir_get_pkgd(struct xbps_handle *xhp,
|
||||
const char *name);
|
||||
|
||||
/**
|
||||
* Creates a temporary file and executes it in rootdir.
|
||||
*
|
||||
@ -1282,116 +1028,6 @@ int xbps_pkg_exec_script(struct xbps_handle *xhp,
|
||||
const char *action,
|
||||
bool update);
|
||||
|
||||
/**
|
||||
* Removes the package's proplib dictionary matching \a pkgname
|
||||
* in a proplib array.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] array Proplib array where to look for.
|
||||
* @param[in] name Package name to match in the array.
|
||||
* @param[in] targetarch If set, package will be matched against this
|
||||
* architecture.
|
||||
*
|
||||
* @return true on success, false otherwise and errno is set appropiately.
|
||||
*/
|
||||
bool xbps_remove_pkg_from_array_by_name(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *name,
|
||||
const char *targetarch);
|
||||
|
||||
/**
|
||||
* Removes the package's proplib dictionary matching the pkgver object
|
||||
* with a package pattern from \a pattern in a proplib array.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] array Proplib array where to look for.
|
||||
* @param[in] pattern Package pattern to match, i.e `foo>=0' or `foo<1'.
|
||||
* @param[in] targetarch If set, package will be matched against this
|
||||
* architecture.
|
||||
*
|
||||
* @return true on success, false otherwise and errno is set appropiately.
|
||||
*/
|
||||
bool xbps_remove_pkg_from_array_by_pattern(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *pattern,
|
||||
const char *targetarch);
|
||||
|
||||
/**
|
||||
* Removes the package's proplib dictionary matching the \a pkgver
|
||||
* object in a proplib array of dictionaries.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] array Proplib array where to look for.
|
||||
* @param[in] pkgver Package name/version to match, i.e `foo-1.0'.
|
||||
* @param[in] targetarch If set, package will be matched against this
|
||||
* architecture.
|
||||
*
|
||||
* @return true on success, false otherwise and errno is set appropiately.
|
||||
*/
|
||||
bool xbps_remove_pkg_from_array_by_pkgver(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *pkgver,
|
||||
const char *targetarch);
|
||||
|
||||
/**
|
||||
* Removes a string from a proplib's array of strings.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] array Proplib array where to look for.
|
||||
* @param[in] str String to match in the array.
|
||||
*
|
||||
* @return true on success, false otherwise and errno is set appropiately.
|
||||
*/
|
||||
bool xbps_remove_string_from_array(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *str);
|
||||
|
||||
/**
|
||||
* Removes a string from a proplib's array matched by a package name.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] array Proplib array where to look for.
|
||||
* @param[in] name Package name to match.
|
||||
*
|
||||
* @return true on success, false otherwise and errno is set appropiately.
|
||||
*/
|
||||
bool xbps_remove_pkgname_from_array(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *name);
|
||||
|
||||
/**
|
||||
* Replaces a dictionary with another dictionary in \a dict, in the
|
||||
* array \a array by matching its "pkgname" object with \a pkgname.
|
||||
*
|
||||
* @param[in] array Proplib array where to look for.
|
||||
* @param[in] dict Proplib dictionary to be added in \a array.
|
||||
* @param[in] pkgname Package name to be matched.
|
||||
*
|
||||
* @retval 0 success.
|
||||
* @retval EINVAL Dictionary couldn't be set in array.
|
||||
* @retval ENOENT No match.
|
||||
*/
|
||||
int xbps_array_replace_dict_by_name(prop_array_t array,
|
||||
prop_dictionary_t dict,
|
||||
const char *pkgname);
|
||||
|
||||
/**
|
||||
* Replaces a dictionary with another dictionary in \a dict, in
|
||||
* the array \a array by matching its pkgver object with a package pattern,
|
||||
* i.e `foo>=0' or `foo<1'.
|
||||
*
|
||||
* @param[in] array Proplib array where to look for.
|
||||
* @param[in] dict Proplib dictionary to be added in \a array.
|
||||
* @param[in] pattern Package pattern to be matched, i.e `foo>=0'.
|
||||
*
|
||||
* @retval 0 success.
|
||||
* @retval EINVAL Dictionary couldn't be set in array.
|
||||
* @retval ENOENT No match.
|
||||
*/
|
||||
int xbps_array_replace_dict_by_pattern(prop_array_t array,
|
||||
prop_dictionary_t dict,
|
||||
const char *pattern);
|
||||
|
||||
/*@}*/
|
||||
|
||||
/** @addtogroup pkg_register */
|
||||
@ -1424,9 +1060,7 @@ int xbps_register_pkg(struct xbps_handle *xhp,
|
||||
*
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
int xbps_unregister_pkg(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
const char *version,
|
||||
int xbps_unregister_pkg(struct xbps_handle *xhp, const char *pkgver,
|
||||
bool flush);
|
||||
|
||||
/*@}*/
|
||||
@ -1438,8 +1072,7 @@ int xbps_unregister_pkg(struct xbps_handle *xhp,
|
||||
* Remove an installed package.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] pkgname Package name to match.
|
||||
* @param[in] version Package version associated.
|
||||
* @param[in] pkgver Package name/version to match.
|
||||
* @param[in] update If true, some steps will be skipped. See in the
|
||||
* detailed description above for more information.
|
||||
* @param[in] soft_replace If true, some steps will be skipped. See in
|
||||
@ -1448,8 +1081,7 @@ int xbps_unregister_pkg(struct xbps_handle *xhp,
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
int xbps_remove_pkg(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
const char *version,
|
||||
const char *pkgver,
|
||||
bool update,
|
||||
bool soft_replace);
|
||||
|
||||
@ -1592,15 +1224,15 @@ int xbps_transaction_commit(struct xbps_handle *xhp);
|
||||
|
||||
/**
|
||||
* Internalizes a plist file in a binary package file stored locally or
|
||||
* remotely as specified in the URL.
|
||||
* remotely as specified in \a fname.
|
||||
*
|
||||
* @param[in] url URL to binary package file (full local or remote path).
|
||||
* @param[in] fname Full URL to binary package file (local or remote path).
|
||||
* @param[in] plistf Plist file name to internalize.
|
||||
*
|
||||
* @return An internalized proplib dictionary, otherwise NULL and
|
||||
* errno is set appropiately.
|
||||
*/
|
||||
prop_dictionary_t xbps_dictionary_metadata_plist_by_url(const char *url,
|
||||
prop_dictionary_t xbps_get_pkg_plist_from_binpkg(const char *fname,
|
||||
const char *plistf);
|
||||
|
||||
/*@}*/
|
||||
@ -1609,27 +1241,34 @@ prop_dictionary_t xbps_dictionary_metadata_plist_by_url(const char *url,
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
* @struct xbps_rpool_index xbps_api.h "xbps_api.h"
|
||||
* @brief Repository pool dictionary structure
|
||||
* @struct xbps_rindex xbps_api.h "xbps_api.h"
|
||||
* @brief Repository pool index structure
|
||||
*
|
||||
* Repository index object structure registered in a private simple queue.
|
||||
* The structure contains a dictionary and the URI associated with the
|
||||
* registered repository index.
|
||||
*/
|
||||
struct xbps_rpool_index {
|
||||
struct xbps_rindex {
|
||||
/**
|
||||
* @var repo
|
||||
* @var repod
|
||||
*
|
||||
* Internalized proplib array of the index plist file
|
||||
* Internalized proplib dictionary of the index plist file
|
||||
* associated with repository.
|
||||
*/
|
||||
prop_array_t repo;
|
||||
prop_dictionary_t repod;
|
||||
/**
|
||||
* @var uri
|
||||
*
|
||||
* URI string associated with repository.
|
||||
*/
|
||||
const char *uri;
|
||||
/**
|
||||
* @var xhp
|
||||
*
|
||||
* Pointer to our xbps_handle struct passed to xbps_rpool_foreach.
|
||||
* (read-only).
|
||||
*/
|
||||
struct xbps_handle *xhp;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1662,7 +1301,7 @@ int xbps_rpool_sync(struct xbps_handle *xhp, const char *file, const char *uri);
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
int xbps_rpool_foreach(struct xbps_handle *xhp,
|
||||
int (*fn)(struct xbps_handle *, struct xbps_rpool_index *, void *, bool *),
|
||||
int (*fn)(struct xbps_rindex *, void *, bool *),
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
@ -1671,34 +1310,13 @@ int xbps_rpool_foreach(struct xbps_handle *xhp,
|
||||
* account virtual packages, just matches real packages.
|
||||
*
|
||||
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||
* @param[in] pkg Package pattern or name.
|
||||
* @param[in] bypattern Set it to true if \a pkg is a pkgpattern (foo>=0),
|
||||
* false if it is a pkgname.
|
||||
* @param[in] best True to find the best version available in repo, false to
|
||||
* fetch the first package found matching \a pkg.
|
||||
* @param[in] pkg Package pattern, exact pkg or pkg name.
|
||||
*
|
||||
* @return The package dictionary if found, NULL otherwise.
|
||||
* @note When returned dictionary is no longer needed, you must release it
|
||||
* with prop_object_release(3).
|
||||
*/
|
||||
prop_dictionary_t xbps_rpool_find_pkg(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern,
|
||||
bool best);
|
||||
|
||||
/**
|
||||
* Finds a package dictionary in repository pool by matching its \a pkgver
|
||||
* object.
|
||||
*
|
||||
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||
* @param[in] pkgver Package name/version to match, i.e `foo-1.0'.
|
||||
*
|
||||
* @return The package dictionary if found, NULL otherwise.
|
||||
* @note When returned dictionary is no longer needed, you must release it
|
||||
* with prop_object_release(3).
|
||||
*/
|
||||
prop_dictionary_t xbps_rpool_find_pkg_exact(struct xbps_handle *xhp,
|
||||
const char *pkgver);
|
||||
prop_dictionary_t xbps_rpool_get_pkg(struct xbps_handle *xhp, const char *pkg);
|
||||
|
||||
/**
|
||||
* Finds a package dictionary in repository pool by specifying a
|
||||
@ -1706,34 +1324,13 @@ prop_dictionary_t xbps_rpool_find_pkg_exact(struct xbps_handle *xhp,
|
||||
*
|
||||
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||
* @param[in] pkg Virtual package pattern or name to match.
|
||||
* @param[in] bypattern Set it to true if \a pkg is a pkgpattern (foo>=0),
|
||||
* false if it is a pkgname.
|
||||
*
|
||||
* @return The package dictionary if found, NULL otherwise.
|
||||
* @note When returned dictionary is no longer needed, you must release it
|
||||
* with prop_object_release(3).
|
||||
*/
|
||||
prop_dictionary_t xbps_rpool_find_virtualpkg(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern);
|
||||
|
||||
/**
|
||||
* Finds a package dictionary in repository pool by specifying a
|
||||
* package pattern or a package name. Only virtual packages set in
|
||||
* configuration file will be matched.
|
||||
*
|
||||
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||
* @param[in] pkg Virtual package pattern or name to match.
|
||||
* @param[in] bypattern Set it to true if \a pkg is a pkgpattern (foo>=0),
|
||||
* false if it is a pkgname.
|
||||
*
|
||||
* @return The package dictionary if found, NULL otherwise.
|
||||
* @note When returned dictionary is no longer needed, you must release it
|
||||
* with prop_object_release(3).
|
||||
*/
|
||||
prop_dictionary_t xbps_rpool_find_virtualpkg_conf(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern);
|
||||
prop_dictionary_t xbps_rpool_get_virtualpkg(struct xbps_handle *xhp,
|
||||
const char *pkg);
|
||||
|
||||
/**
|
||||
* Iterate over the the repository pool and search for a metadata plist
|
||||
@ -1754,30 +1351,38 @@ prop_dictionary_t xbps_rpool_find_virtualpkg_conf(struct xbps_handle *xhp,
|
||||
* binary package file has been found but the plist file could not
|
||||
* be found.
|
||||
*/
|
||||
prop_dictionary_t xbps_rpool_dictionary_metadata_plist(struct xbps_handle *xhp,
|
||||
prop_dictionary_t xbps_rpool_get_pkg_plist(struct xbps_handle *xhp,
|
||||
const char *pattern,
|
||||
const char *plistf);
|
||||
|
||||
/*@}*/
|
||||
|
||||
/** @addtogroup reposync */
|
||||
/** @addtogroup rindex */
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
* Syncs the package index file for a remote repository as specified
|
||||
* by the \a uri argument (if necessary).
|
||||
* Returns a pkg dictionary from a repository index \a ri matching
|
||||
* the expression \a pkg.
|
||||
*
|
||||
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||
* @param[in] uri URI to a remote repository.
|
||||
* @param[in] plistf Plist file to sync.
|
||||
* param[in] ri Pointer to an xbps_rindex structure.
|
||||
* param[in] pkg Package expression to match in this repository index.
|
||||
*
|
||||
* @return -1 on error (errno is set appropiately), 0 if transfer was
|
||||
* not necessary (local/remote size/mtime matched) or 1 if
|
||||
* downloaded successfully.
|
||||
* @return The pkg dictionary on success, NULL otherwise.
|
||||
*/
|
||||
int xbps_repository_sync_pkg_index(struct xbps_handle *xhp,
|
||||
const char *uri,
|
||||
const char *plistf);
|
||||
prop_dictionary_t xbps_rindex_get_pkg(struct xbps_rindex *ri, const char *pkg);
|
||||
|
||||
/**
|
||||
* Returns a pkg dictionary from a repository index \a ri matching
|
||||
* the expression \a pkg. On match the first package matching the virtual
|
||||
* package expression will be returned.
|
||||
*
|
||||
* param[in] ri Pointer to an xbps_rindex structure.
|
||||
* param[in] pkg Package expression to match in this repository index.
|
||||
*
|
||||
* @return The pkg dictionary on success, NULL otherwise.
|
||||
*/
|
||||
prop_dictionary_t xbps_rindex_get_virtualpkg(struct xbps_rindex *ri,
|
||||
const char *pkg);
|
||||
|
||||
/*@}*/
|
||||
|
||||
@ -1895,22 +1500,6 @@ char *xbps_xasprintf(const char *fmt, ...);
|
||||
*/
|
||||
char *xbps_file_hash(const char *file);
|
||||
|
||||
/**
|
||||
* Returns a string with the sha256 hash for the file specified
|
||||
* by \a file in an array with key \a key in the proplib dictionary
|
||||
* \a d.
|
||||
*
|
||||
* @param[in] d Proplib dictionary to look in.
|
||||
* @param[in] key Array key to match in dictionary.
|
||||
* @param[in] file Pathname to a file.
|
||||
*
|
||||
* @return The sha256 hash string if found, NULL otherwise
|
||||
* and errno is set appropiately.
|
||||
*/
|
||||
const char *xbps_file_hash_dictionary(prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *file);
|
||||
|
||||
/**
|
||||
* Compares the sha256 hash of the file \a file with the sha256
|
||||
* string specified by \a sha256.
|
||||
@ -1924,45 +1513,16 @@ const char *xbps_file_hash_dictionary(prop_dictionary_t d,
|
||||
int xbps_file_hash_check(const char *file, const char *sha256);
|
||||
|
||||
/**
|
||||
* Checks if \a file matches the sha256 hash specified in the array
|
||||
* with key \a key in the proplib dictionary \a d.
|
||||
* Checks if a package is currently installed by matching \a pkg.
|
||||
*
|
||||
* @param[in] xhp The pointer to an xbps_handle struct.
|
||||
* @param[in] d Proplib dictionary to look in.
|
||||
* @param[in] key Proplib array key to match for file.
|
||||
* @param[in] file Pathname to a file.
|
||||
* @param[in] pkg Package name, version pattern or exact pkg to match.
|
||||
*
|
||||
* @return 0 if hash is matched, -1 on error and 1 if no match.
|
||||
*/
|
||||
int xbps_file_hash_check_dictionary(struct xbps_handle *xhp,
|
||||
prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *file);
|
||||
|
||||
/**
|
||||
* Checks if a package is currently installed by matching a package
|
||||
* pattern string.
|
||||
*
|
||||
* @param[in] xhp The pointer to an xbps_handle struct.
|
||||
* @param[in] pkg Package pattern used to find the package.
|
||||
*
|
||||
* @return -1 on error (errno set appropiately), 0 if package pattern
|
||||
* @return -1 on error (errno set appropiately), 0 if \a pkg
|
||||
* didn't match installed package, 1 if \a pkg pattern fully
|
||||
* matched installed package.
|
||||
*/
|
||||
int xbps_check_is_installed_pkg_by_pattern(struct xbps_handle *xhp,
|
||||
const char *pkg);
|
||||
|
||||
/**
|
||||
* Checks if package \a pkgname is currently installed.
|
||||
*
|
||||
* @param[in] xhp The pointer to an xbps_handle struct.
|
||||
* @param[in] pkgname Package name.
|
||||
*
|
||||
* @return True if \a pkgname is installed, false otherwise.
|
||||
*/
|
||||
bool xbps_check_is_installed_pkg_by_name(struct xbps_handle *xhp,
|
||||
const char *pkgname);
|
||||
int xbps_pkg_is_installed(struct xbps_handle *xhp, const char *pkg);
|
||||
|
||||
/**
|
||||
* Checks if the URI specified by \a uri is remote or local.
|
||||
@ -1971,24 +1531,7 @@ bool xbps_check_is_installed_pkg_by_name(struct xbps_handle *xhp,
|
||||
*
|
||||
* @return true if URI is remote, false if local.
|
||||
*/
|
||||
bool xbps_check_is_repository_uri_remote(const char *uri);
|
||||
|
||||
/**
|
||||
* Gets the full URI to a binary package file as returned by a
|
||||
* package dictionary from a repository in \a pkgd, by looking at the
|
||||
* repository location object "repository" in its dictionary.
|
||||
*
|
||||
* @param[in] xhp The pointer to an xbps_handle struct.
|
||||
* @param[in] pkgd Package dictionary stored in a transaction dictionary.
|
||||
* @param[in] repoloc Repository URL location string.
|
||||
*
|
||||
* @return A pointer to a malloc(3)ed string, NULL otherwise and
|
||||
* errno is set appropiately. The pointer should be free(3)d when it's
|
||||
* no longer needed.
|
||||
*/
|
||||
char *xbps_path_from_repository_uri(struct xbps_handle *xhp,
|
||||
prop_dictionary_t pkgd,
|
||||
const char *repoloc);
|
||||
bool xbps_repository_is_remote(const char *uri);
|
||||
|
||||
/**
|
||||
* Gets the full path to a repository package index plist file, as
|
||||
|
@ -73,7 +73,38 @@ void HIDDEN xbps_pkgdb_release(struct xbps_handle *);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* From lib/repository_pool.c
|
||||
* From lib/plist.c
|
||||
*/
|
||||
bool HIDDEN xbps_add_obj_to_dict(prop_dictionary_t,
|
||||
prop_object_t, const char *);
|
||||
bool HIDDEN xbps_add_obj_to_array(prop_array_t, prop_object_t);
|
||||
|
||||
int HIDDEN xbps_array_replace_dict_by_name(prop_array_t,
|
||||
prop_dictionary_t,
|
||||
const char *);
|
||||
int HIDDEN xbps_array_replace_dict_by_pattern(prop_array_t,
|
||||
prop_dictionary_t,
|
||||
const char *);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* From lib/plist_remove.c
|
||||
*/
|
||||
bool HIDDEN xbps_remove_pkg_from_array_by_name(prop_array_t, const char *);
|
||||
bool HIDDEN xbps_remove_pkg_from_array_by_pattern(prop_array_t, const char *);
|
||||
bool HIDDEN xbps_remove_pkg_from_array_by_pkgver(prop_array_t, const char *);
|
||||
bool HIDDEN xbps_remove_pkgname_from_array(prop_array_t, const char *);
|
||||
bool HIDDEN xbps_remove_string_from_array(prop_array_t, const char *);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* From lib/util.c
|
||||
*/
|
||||
char HIDDEN *xbps_repository_pkg_path(struct xbps_handle *, prop_dictionary_t);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* From lib/rpool.c
|
||||
*/
|
||||
int HIDDEN xbps_rpool_init(struct xbps_handle *);
|
||||
void HIDDEN xbps_rpool_release(struct xbps_handle *);
|
||||
@ -106,9 +137,10 @@ prop_dictionary_t HIDDEN
|
||||
|
||||
/**
|
||||
* @private
|
||||
* From lib/repository_finddeps.c
|
||||
* From lib/rpool_pkgdeps.c
|
||||
*/
|
||||
int HIDDEN xbps_repository_find_pkg_deps(struct xbps_handle *,
|
||||
int HIDDEN xbps_repository_find_deps(struct xbps_handle *,
|
||||
prop_array_t,
|
||||
prop_dictionary_t);
|
||||
|
||||
/**
|
||||
@ -122,20 +154,16 @@ int HIDDEN xbps_requiredby_pkg_remove(struct xbps_handle *, const char *);
|
||||
* @private
|
||||
* From lib/plist_find.c
|
||||
*/
|
||||
prop_dictionary_t HIDDEN xbps_find_pkg_in_array(prop_array_t, const char *);
|
||||
prop_dictionary_t HIDDEN
|
||||
xbps_find_virtualpkg_conf_in_array_by_name(struct xbps_handle *,
|
||||
prop_array_t,
|
||||
const char *);
|
||||
prop_dictionary_t HIDDEN
|
||||
xbps_find_virtualpkg_conf_in_array_by_pattern(struct xbps_handle *,
|
||||
prop_array_t,
|
||||
xbps_find_virtualpkg_in_array(struct xbps_handle *, prop_array_t,
|
||||
const char *);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* From lib/transaction_sortdeps.c
|
||||
*/
|
||||
int HIDDEN xbps_transaction_sort_pkg_deps(struct xbps_handle *);
|
||||
int HIDDEN xbps_transaction_sort(struct xbps_handle *);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@ -145,9 +173,19 @@ int HIDDEN xbps_transaction_init(struct xbps_handle *);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* From lib/repository_sync_index.c
|
||||
* From lib/rindex_sync.c
|
||||
*/
|
||||
char HIDDEN *xbps_get_remote_repo_string(const char *);
|
||||
int HIDDEN xbps_rindex_sync(struct xbps_handle *, const char *, const char *);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* From lib/util_hash.c
|
||||
*/
|
||||
int HIDDEN xbps_file_hash_check_dictionary(struct xbps_handle *,
|
||||
prop_dictionary_t d,
|
||||
const char *,
|
||||
const char *);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@ -155,12 +193,6 @@ char HIDDEN *xbps_get_remote_repo_string(const char *);
|
||||
*/
|
||||
int HIDDEN xbps_file_exec(struct xbps_handle *, const char *, ...);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* From lib/transaction_package_replace.c
|
||||
*/
|
||||
int HIDDEN xbps_transaction_package_replace(struct xbps_handle *);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* From lib/cb_util.c
|
||||
@ -176,13 +208,20 @@ void HIDDEN xbps_set_cb_state(struct xbps_handle *, xbps_state_t, int,
|
||||
*/
|
||||
int HIDDEN xbps_unpack_binary_pkg(struct xbps_handle *, prop_dictionary_t);
|
||||
|
||||
int HIDDEN xbps_transaction_package_replace(struct xbps_handle *);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* From lib/package_conflicts.c
|
||||
*/
|
||||
void HIDDEN xbps_pkg_find_conflicts(struct xbps_handle *, prop_dictionary_t);
|
||||
|
||||
void HIDDEN xbps_metadir_release(struct xbps_handle *);
|
||||
void HIDDEN xbps_pkg_find_conflicts(struct xbps_handle *,
|
||||
prop_array_t,
|
||||
prop_dictionary_t);
|
||||
/**
|
||||
* @private
|
||||
* From lib/rindex_get.c
|
||||
*/
|
||||
const char HIDDEN *vpkg_user_conf(struct xbps_handle *, const char *, bool);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@ -44,14 +44,14 @@ EXTOBJS += external/mkpath.o
|
||||
OBJS = package_configure.o package_config_files.o package_orphans.o
|
||||
OBJS += package_remove.o package_remove_obsoletes.o package_state.o
|
||||
OBJS += package_unpack.o package_requiredby.o package_register.o
|
||||
OBJS += package_script.o package_metadir.o
|
||||
OBJS += package_script.o
|
||||
OBJS += transaction_commit.o transaction_package_replace.o
|
||||
OBJS += transaction_dictionary.o transaction_sortdeps.o transaction_ops.o
|
||||
OBJS += download.o initend.o pkgdb.o package_conflicts.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 += repository_finddeps.o cb_util.o
|
||||
OBJS += repository_pool.o repository_pool_find.o repository_sync_index.o
|
||||
OBJS += rindex_pkgdeps.o rindex_sync.o rindex_get.o
|
||||
OBJS += rpool.o rpool_get.o cb_util.o
|
||||
OBJS += $(EXTOBJS) $(COMPAT_SRCS)
|
||||
|
||||
.PHONY: all
|
||||
|
@ -55,6 +55,7 @@ xbps_set_cb_fetch(struct xbps_handle *xhp,
|
||||
if (xhp->fetch_cb == NULL)
|
||||
return;
|
||||
|
||||
xfcd.xhp = xhp;
|
||||
xfcd.file_size = file_size;
|
||||
xfcd.file_offset = file_offset;
|
||||
xfcd.file_dloaded = file_dloaded;
|
||||
@ -62,7 +63,7 @@ xbps_set_cb_fetch(struct xbps_handle *xhp,
|
||||
xfcd.cb_start = cb_start;
|
||||
xfcd.cb_update = cb_update;
|
||||
xfcd.cb_end = cb_end;
|
||||
(*xhp->fetch_cb)(xhp, &xfcd, xhp->fetch_cb_data);
|
||||
(*xhp->fetch_cb)(&xfcd, xhp->fetch_cb_data);
|
||||
}
|
||||
|
||||
void HIDDEN
|
||||
@ -82,6 +83,7 @@ xbps_set_cb_state(struct xbps_handle *xhp,
|
||||
if (xhp->state_cb == NULL)
|
||||
return;
|
||||
|
||||
xscd.xhp = xhp;
|
||||
xscd.state = state;
|
||||
xscd.err = err;
|
||||
xscd.arg0 = arg0;
|
||||
@ -95,7 +97,7 @@ xbps_set_cb_state(struct xbps_handle *xhp,
|
||||
else
|
||||
xscd.desc = buf;
|
||||
}
|
||||
(*xhp->state_cb)(xhp, &xscd, xhp->state_cb_data);
|
||||
(*xhp->state_cb)(&xscd, xhp->state_cb_data);
|
||||
if (buf != NULL)
|
||||
free(buf);
|
||||
}
|
||||
|
@ -150,8 +150,6 @@ xbps_init(struct xbps_handle *xhp)
|
||||
XBPS_FETCH_CACHECONN_HOST, CFGF_NONE),
|
||||
CFG_INT(__UNCONST("FetchTimeoutConnection"),
|
||||
XBPS_FETCH_TIMEOUT, CFGF_NONE),
|
||||
CFG_INT(__UNCONST("TransactionFrequencyFlush"),
|
||||
XBPS_TRANS_FLUSH, CFGF_NONE),
|
||||
CFG_BOOL(__UNCONST("syslog"), true, CFGF_NONE),
|
||||
CFG_STR_LIST(__UNCONST("repositories"), NULL, CFGF_MULTI),
|
||||
CFG_STR_LIST(__UNCONST("PackagesOnHold"), NULL, CFGF_MULTI),
|
||||
@ -249,7 +247,6 @@ xbps_init(struct xbps_handle *xhp)
|
||||
if (xhp->cfg == NULL) {
|
||||
xhp->flags |= XBPS_FLAG_SYSLOG;
|
||||
xhp->fetch_timeout = XBPS_FETCH_TIMEOUT;
|
||||
xhp->transaction_frequency_flush = XBPS_TRANS_FLUSH;
|
||||
cc = XBPS_FETCH_CACHECONN;
|
||||
cch = XBPS_FETCH_CACHECONN_HOST;
|
||||
} else {
|
||||
@ -258,8 +255,6 @@ xbps_init(struct xbps_handle *xhp)
|
||||
xhp->fetch_timeout = cfg_getint(xhp->cfg, "FetchTimeoutConnection");
|
||||
cc = cfg_getint(xhp->cfg, "FetchCacheConnections");
|
||||
cch = cfg_getint(xhp->cfg, "FetchCacheConnectionsPerHost");
|
||||
xhp->transaction_frequency_flush =
|
||||
cfg_getint(xhp->cfg, "TransactionFrequencyFlush");
|
||||
}
|
||||
if (xhp->flags & XBPS_FLAG_SYSLOG)
|
||||
syslog_enabled = true;
|
||||
@ -276,8 +271,6 @@ xbps_init(struct xbps_handle *xhp)
|
||||
xbps_dbg_printf(xhp, "FetchCacheconn=%u\n", cc);
|
||||
xbps_dbg_printf(xhp, "FetchCacheconnHost=%u\n", cch);
|
||||
xbps_dbg_printf(xhp, "Syslog=%u\n", syslog_enabled);
|
||||
xbps_dbg_printf(xhp, "TransactionFrequencyFlush=%u\n",
|
||||
xhp->transaction_frequency_flush);
|
||||
xbps_dbg_printf(xhp, "Architecture: %s\n", xhp->un_machine);
|
||||
|
||||
xhp->initialized = true;
|
||||
@ -295,7 +288,6 @@ xbps_end(struct xbps_handle *xhp)
|
||||
|
||||
xbps_pkgdb_release(xhp);
|
||||
xbps_rpool_release(xhp);
|
||||
xbps_metadir_release(xhp);
|
||||
xbps_fetch_unset_cache_connection();
|
||||
|
||||
cfg_free(xhp->cfg);
|
||||
|
@ -91,7 +91,7 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
|
||||
xbps_dbg_printf(xhp, "%s-%s: processing conf_file %s\n",
|
||||
pkgname, version, entry_pname);
|
||||
|
||||
forigd = xbps_metadir_get_pkgd(xhp, pkgname);
|
||||
forigd = xbps_pkgdb_get_pkg_metadata(xhp, pkgname);
|
||||
if (forigd == NULL) {
|
||||
xbps_dbg_printf(xhp, "%s-%s: conf_file %s not currently "
|
||||
"installed\n", pkgname, version, entry_pname);
|
||||
|
@ -85,7 +85,7 @@ xbps_configure_pkg(struct xbps_handle *xhp,
|
||||
|
||||
assert(pkgname != NULL);
|
||||
|
||||
pkgd = xbps_pkgdb_get_pkgd(xhp, pkgname, false);
|
||||
pkgd = xbps_pkgdb_get_pkg(xhp, pkgname);
|
||||
if (pkgd == NULL)
|
||||
return ENOENT;
|
||||
|
||||
@ -125,8 +125,10 @@ xbps_configure_pkg(struct xbps_handle *xhp,
|
||||
"the post ACTION: %s", pkgver, strerror(rv));
|
||||
return rv;
|
||||
}
|
||||
if (state == XBPS_PKG_STATE_INSTALLED)
|
||||
if (state == XBPS_PKG_STATE_INSTALLED) {
|
||||
prop_object_release(pkgmetad);
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = xbps_set_pkg_state_installed(xhp, pkgname, version,
|
||||
XBPS_PKG_STATE_INSTALLED);
|
||||
@ -144,5 +146,7 @@ xbps_configure_pkg(struct xbps_handle *xhp,
|
||||
pkgver, strerror(rv));
|
||||
}
|
||||
}
|
||||
prop_object_release(pkgmetad);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -32,7 +32,9 @@
|
||||
#include "xbps_api_impl.h"
|
||||
|
||||
void HIDDEN
|
||||
xbps_pkg_find_conflicts(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
|
||||
xbps_pkg_find_conflicts(struct xbps_handle *xhp,
|
||||
prop_array_t unsorted,
|
||||
prop_dictionary_t pkg_repod)
|
||||
{
|
||||
prop_array_t pkg_cflicts, trans_cflicts;
|
||||
prop_dictionary_t pkgd;
|
||||
@ -52,7 +54,8 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
|
||||
/*
|
||||
* Check if current pkg conflicts with an installed package.
|
||||
*/
|
||||
if ((pkgd = xbps_pkgdb_get_pkgd(xhp, cfpkg, true))) {
|
||||
if ((pkgd = xbps_pkgdb_get_pkg(xhp, cfpkg)) ||
|
||||
(pkgd = xbps_pkgdb_get_virtualpkg(xhp, cfpkg))) {
|
||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
"pkgver", &pkgver);
|
||||
buf = xbps_xasprintf("%s conflicts with "
|
||||
@ -64,9 +67,8 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
|
||||
/*
|
||||
* Check if current pkg conflicts with any pkg in transaction.
|
||||
*/
|
||||
pkgd = xbps_find_pkg_in_dict_by_pattern(xhp, xhp->transd,
|
||||
"unsorted_deps", cfpkg);
|
||||
if (pkgd != NULL) {
|
||||
if ((pkgd = xbps_find_pkg_in_array(unsorted, cfpkg)) ||
|
||||
(pkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, cfpkg))) {
|
||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
"pkgver", &pkgver);
|
||||
buf = xbps_xasprintf("%s conflicts with "
|
||||
|
@ -1,86 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2012 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 <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "xbps_api_impl.h"
|
||||
|
||||
void HIDDEN
|
||||
xbps_metadir_release(struct xbps_handle *xhp)
|
||||
{
|
||||
if (prop_object_type(xhp->pkg_metad) == PROP_TYPE_DICTIONARY)
|
||||
prop_object_release(xhp->pkg_metad);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_metadir_get_pkgd(struct xbps_handle *xhp, const char *name)
|
||||
{
|
||||
prop_dictionary_t pkgd, d;
|
||||
const char *savedpkgname;
|
||||
char *plistf;
|
||||
|
||||
assert(xhp);
|
||||
assert(name);
|
||||
|
||||
if ((pkgd = prop_dictionary_get(xhp->pkg_metad, name)) != NULL)
|
||||
return pkgd;
|
||||
|
||||
savedpkgname = name;
|
||||
plistf = xbps_xasprintf("%s/.%s.plist", xhp->metadir, name);
|
||||
|
||||
if (access(plistf, R_OK) == -1) {
|
||||
pkgd = xbps_pkgdb_get_virtualpkgd(xhp, name, false);
|
||||
if (pkgd == NULL)
|
||||
pkgd = xbps_pkgdb_get_pkgd(xhp, name, false);
|
||||
|
||||
if (pkgd != NULL) {
|
||||
free(plistf);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
"pkgname", &savedpkgname);
|
||||
plistf = xbps_xasprintf("%s/.%s.plist",
|
||||
xhp->metadir, savedpkgname);
|
||||
}
|
||||
}
|
||||
|
||||
d = prop_dictionary_internalize_from_zfile(plistf);
|
||||
free(plistf);
|
||||
if (d == NULL) {
|
||||
xbps_dbg_printf(xhp, "cannot read %s metadata: %s\n",
|
||||
savedpkgname, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (xhp->pkg_metad == NULL)
|
||||
xhp->pkg_metad = prop_dictionary_create();
|
||||
|
||||
prop_dictionary_set(xhp->pkg_metad, name, d);
|
||||
prop_object_release(d);
|
||||
|
||||
return d;
|
||||
}
|
@ -126,7 +126,7 @@ find_orphan_pkg(struct xbps_handle *xhp,
|
||||
prop_object_iterator_release(iter);
|
||||
return EINVAL;
|
||||
}
|
||||
if (xbps_find_pkg_in_array_by_pattern(xhp, od->array, pkgdep, NULL))
|
||||
if (xbps_find_pkg_in_array(od->array, pkgdep))
|
||||
ndep++;
|
||||
if (od->orphans_user == NULL)
|
||||
continue;
|
||||
|
@ -70,7 +70,7 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd, bool flush)
|
||||
assert(desc != NULL);
|
||||
assert(pkgver != NULL);
|
||||
|
||||
pkgd = xbps_pkgdb_get_pkgd(xhp, pkgname, false);
|
||||
pkgd = xbps_pkgdb_get_pkg(xhp, pkgname);
|
||||
if (pkgd == NULL) {
|
||||
rv = ENOENT;
|
||||
goto out;
|
||||
@ -172,7 +172,7 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd, bool flush)
|
||||
prop_dictionary_remove(pkgd, "remove-and-update");
|
||||
prop_dictionary_remove(pkgd, "transaction");
|
||||
|
||||
if (!xbps_pkgdb_replace_pkgd(xhp, pkgd, pkgname, false, flush)) {
|
||||
if (!xbps_pkgdb_replace_pkg(xhp, pkgd, pkgname, flush)) {
|
||||
xbps_dbg_printf(xhp,
|
||||
"%s: failed to replace pkgd dict for %s\n",
|
||||
__func__, pkgname);
|
||||
@ -190,20 +190,18 @@ out:
|
||||
}
|
||||
|
||||
int
|
||||
xbps_unregister_pkg(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
const char *version,
|
||||
bool flush)
|
||||
xbps_unregister_pkg(struct xbps_handle *xhp, const char *pkgver, bool flush)
|
||||
{
|
||||
assert(pkgname != NULL);
|
||||
assert(xhp);
|
||||
assert(pkgver);
|
||||
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNREGISTER, 0, pkgname, version, NULL);
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNREGISTER, 0, pkgver, NULL, NULL);
|
||||
|
||||
if (!xbps_pkgdb_remove_pkgd(xhp, pkgname, false, flush)) {
|
||||
if (!xbps_pkgdb_remove_pkg(xhp, pkgver, flush)) {
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNREGISTER_FAIL,
|
||||
errno, pkgname, version,
|
||||
errno, pkgver, NULL,
|
||||
"%s: failed to unregister package: %s",
|
||||
pkgname, strerror(errno));
|
||||
pkgver, strerror(errno));
|
||||
return errno;
|
||||
}
|
||||
return 0;
|
||||
|
@ -208,25 +208,29 @@ xbps_remove_pkg_files(struct xbps_handle *xhp,
|
||||
|
||||
int
|
||||
xbps_remove_pkg(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
const char *version,
|
||||
const char *pkgver,
|
||||
bool update,
|
||||
bool soft_replace)
|
||||
{
|
||||
prop_dictionary_t pkgd = NULL;
|
||||
char *tmpname, *buf = NULL, *pkgver = NULL;
|
||||
const char *tmpver = NULL;
|
||||
char *pkgname, *buf = NULL;
|
||||
const char *version;
|
||||
int rv = 0;
|
||||
pkg_state_t state = 0;
|
||||
|
||||
assert(pkgname != NULL);
|
||||
assert(version != NULL);
|
||||
assert(xhp);
|
||||
assert(pkgver);
|
||||
|
||||
pkgname = xbps_pkg_name(pkgver);
|
||||
assert(pkgname);
|
||||
version = xbps_pkg_version(pkgver);
|
||||
assert(version);
|
||||
|
||||
if ((rv = xbps_pkg_state_installed(xhp, pkgname, &state)) != 0)
|
||||
goto out;
|
||||
|
||||
xbps_dbg_printf(xhp, "attempting to remove %s state %d\n",
|
||||
pkgname, state);
|
||||
pkgver, state);
|
||||
|
||||
if (!update)
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REMOVE, 0, pkgname, version, NULL);
|
||||
@ -274,7 +278,9 @@ xbps_remove_pkg(struct xbps_handle *xhp,
|
||||
* continue. Its files will be overwritten later in unpack phase.
|
||||
*/
|
||||
if (update) {
|
||||
free(pkgver);
|
||||
if (pkgd)
|
||||
prop_object_release(pkgd);
|
||||
free(pkgname);
|
||||
return xbps_requiredby_pkg_remove(xhp, pkgname);
|
||||
} else if (soft_replace) {
|
||||
/*
|
||||
@ -349,8 +355,8 @@ purge:
|
||||
"purge ACTION: %s", pkgver, strerror(rv));
|
||||
goto out;
|
||||
}
|
||||
prop_object_release(pkgd);
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove package metadata plist.
|
||||
*/
|
||||
@ -366,25 +372,18 @@ purge:
|
||||
/*
|
||||
* Unregister package from pkgdb.
|
||||
*/
|
||||
if ((rv = xbps_unregister_pkg(xhp, pkgname, version, true)) != 0)
|
||||
if ((rv = xbps_unregister_pkg(xhp, pkgver, true)) != 0)
|
||||
goto out;
|
||||
|
||||
xbps_dbg_printf(xhp, "[remove] unregister %s returned %d\n", pkgver, rv);
|
||||
|
||||
tmpname = xbps_pkg_name(pkgver);
|
||||
assert(tmpname);
|
||||
tmpver = xbps_pkg_version(pkgver);
|
||||
assert(tmpver);
|
||||
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_DONE,
|
||||
0, tmpname, tmpver, NULL);
|
||||
free(tmpname);
|
||||
|
||||
0, pkgname, version, NULL);
|
||||
out:
|
||||
if (buf != NULL)
|
||||
free(buf);
|
||||
if (pkgver != NULL)
|
||||
free(pkgver);
|
||||
if (pkgname != NULL)
|
||||
free(pkgname);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -66,8 +66,11 @@ again:
|
||||
for (i = 0; i < prop_array_count(array); i++) {
|
||||
found = false;
|
||||
obj = prop_array_get(array, i);
|
||||
if (prop_object_type(obj) != PROP_TYPE_DICTIONARY)
|
||||
continue;
|
||||
oldstr = prop_dictionary_get(obj, "file");
|
||||
assert(oldstr);
|
||||
if (oldstr == NULL)
|
||||
continue;
|
||||
|
||||
file = xbps_xasprintf(".%s",
|
||||
prop_string_cstring_nocopy(oldstr));
|
||||
|
@ -63,7 +63,7 @@ add_pkg_into_reqby(struct xbps_handle *xhp,
|
||||
return ENOMEM;
|
||||
|
||||
if (xbps_match_pkgname_in_array(reqby, pkgname)) {
|
||||
if (!xbps_remove_pkgname_from_array(xhp, reqby, pkgname)) {
|
||||
if (!xbps_remove_pkgname_from_array(reqby, pkgname)) {
|
||||
xbps_dbg_printf(xhp, "%s: failed to remove %s reqby entry: "
|
||||
"%s\n", __func__, pkgname, strerror(errno));
|
||||
free(pkgname);
|
||||
@ -120,10 +120,9 @@ remove_pkg_from_reqby(struct xbps_handle *xhp,
|
||||
if (reqby == NULL || prop_array_count(reqby) == 0)
|
||||
return 0;
|
||||
|
||||
if (xbps_match_pkgname_in_array(reqby, pkgname)) {
|
||||
if (!xbps_remove_pkgname_from_array(xhp, reqby, pkgname))
|
||||
if (xbps_match_pkgname_in_array(reqby, pkgname))
|
||||
if (!xbps_remove_pkgname_from_array(reqby, pkgname))
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -139,7 +138,7 @@ int HIDDEN
|
||||
xbps_requiredby_pkg_add(struct xbps_handle *xhp, prop_dictionary_t pkgd)
|
||||
{
|
||||
prop_array_t pkg_rdeps;
|
||||
prop_object_t obj, pkgd_pkgdb;
|
||||
prop_object_t obj, pkgdbd;
|
||||
prop_object_iterator_t iter;
|
||||
const char *pkgver, *str;
|
||||
int rv = 0;
|
||||
@ -161,25 +160,14 @@ xbps_requiredby_pkg_add(struct xbps_handle *xhp, prop_dictionary_t pkgd)
|
||||
rv = EINVAL;
|
||||
break;
|
||||
}
|
||||
pkgd_pkgdb = xbps_find_virtualpkg_conf_in_array_by_pattern(
|
||||
xhp, xhp->pkgdb, str);
|
||||
if (pkgd_pkgdb == NULL) {
|
||||
pkgd_pkgdb =
|
||||
xbps_find_virtualpkg_in_array_by_pattern(
|
||||
xhp, xhp->pkgdb, str);
|
||||
if (pkgd_pkgdb == NULL) {
|
||||
pkgd_pkgdb = xbps_find_pkg_in_array_by_pattern(
|
||||
xhp, xhp->pkgdb, str, NULL);
|
||||
if (pkgd_pkgdb == NULL) {
|
||||
if (((pkgdbd = xbps_find_pkg_in_array(xhp->pkgdb, str)) == NULL) &&
|
||||
((pkgdbd = xbps_find_virtualpkg_in_array(xhp, xhp->pkgdb, str)) == NULL)) {
|
||||
rv = ENOENT;
|
||||
xbps_dbg_printf(xhp,
|
||||
"%s: couldnt find `%s' "
|
||||
xbps_dbg_printf(xhp, "%s: couldnt find `%s' "
|
||||
"entry in pkgdb\n", __func__, str);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
rv = add_pkg_into_reqby(xhp, pkgd_pkgdb, pkgver);
|
||||
rv = add_pkg_into_reqby(xhp, pkgdbd, pkgver);
|
||||
if (rv != 0)
|
||||
break;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ xbps_pkg_state_installed(struct xbps_handle *xhp,
|
||||
assert(pkgname != NULL);
|
||||
assert(state != NULL);
|
||||
|
||||
pkgd = xbps_pkgdb_get_pkgd(xhp, pkgname, false);
|
||||
pkgd = xbps_pkgdb_get_pkg(xhp, pkgname);
|
||||
if (pkgd == NULL)
|
||||
return ENOENT;
|
||||
|
||||
@ -166,7 +166,7 @@ xbps_set_pkg_state_installed(struct xbps_handle *xhp,
|
||||
|
||||
assert(pkgname != NULL);
|
||||
|
||||
pkgd = xbps_pkgdb_get_pkgd(xhp, pkgname, false);
|
||||
pkgd = xbps_pkgdb_get_pkg(xhp, pkgname);
|
||||
if (pkgd == NULL) {
|
||||
pkgd = prop_dictionary_create();
|
||||
if (pkgd == NULL)
|
||||
|
@ -80,7 +80,7 @@ unpack_archive(struct xbps_handle *xhp,
|
||||
prop_dictionary_t pkg_repod,
|
||||
struct archive *ar)
|
||||
{
|
||||
prop_dictionary_t filesd = NULL, old_filesd = NULL;
|
||||
prop_dictionary_t pkg_metad = NULL, filesd = NULL, old_filesd = NULL;
|
||||
prop_array_t array, obsoletes;
|
||||
prop_object_t obj;
|
||||
prop_data_t data;
|
||||
@ -170,6 +170,7 @@ unpack_archive(struct xbps_handle *xhp,
|
||||
* Prepare unpack callback ops.
|
||||
*/
|
||||
if (xhp->unpack_cb != NULL) {
|
||||
xucd.xhp = xhp;
|
||||
xucd.pkgver = pkgver;
|
||||
xucd.entry = entry_pname;
|
||||
xucd.entry_size = entry_size;
|
||||
@ -457,7 +458,7 @@ unpack_archive(struct xbps_handle *xhp,
|
||||
} else {
|
||||
if (xhp->unpack_cb != NULL) {
|
||||
xucd.entry_extract_count++;
|
||||
(*xhp->unpack_cb)(xhp, &xucd, xhp->unpack_cb_data);
|
||||
(*xhp->unpack_cb)(&xucd, xhp->unpack_cb_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -485,7 +486,7 @@ unpack_archive(struct xbps_handle *xhp,
|
||||
* - Package upgrade.
|
||||
* - Package with "softreplace" keyword.
|
||||
*/
|
||||
old_filesd = xbps_metadir_get_pkgd(xhp, pkgname);
|
||||
old_filesd = xbps_pkgdb_get_pkg_metadata(xhp, pkgname);
|
||||
assert(prop_object_type(old_filesd) == PROP_TYPE_DICTIONARY);
|
||||
|
||||
obsoletes = xbps_find_pkg_obsoletes(xhp, old_filesd, filesd);
|
||||
@ -508,39 +509,42 @@ unpack_archive(struct xbps_handle *xhp,
|
||||
}
|
||||
|
||||
out1:
|
||||
prop_dictionary_make_immutable(pkg_repod);
|
||||
pkg_metad = prop_dictionary_copy_mutable(pkg_repod);
|
||||
|
||||
/* Add objects from XBPS_PKGFILES */
|
||||
array = prop_dictionary_get(filesd, "files");
|
||||
if (array && prop_array_count(array))
|
||||
prop_dictionary_set(pkg_repod, "files", array);
|
||||
prop_dictionary_set(pkg_metad, "files", array);
|
||||
array = prop_dictionary_get(filesd, "conf_files");
|
||||
if (array && prop_array_count(array))
|
||||
prop_dictionary_set(pkg_repod, "conf_files", array);
|
||||
prop_dictionary_set(pkg_metad, "conf_files", array);
|
||||
array = prop_dictionary_get(filesd, "links");
|
||||
if (array && prop_array_count(array))
|
||||
prop_dictionary_set(pkg_repod, "links", array);
|
||||
prop_dictionary_set(pkg_metad, "links", array);
|
||||
array = prop_dictionary_get(filesd, "dirs");
|
||||
if (array && prop_array_count(array))
|
||||
prop_dictionary_set(pkg_repod, "dirs", array);
|
||||
prop_dictionary_set(pkg_metad, "dirs", array);
|
||||
|
||||
/* Add install/remove scripts data objects */
|
||||
if (instbuf != NULL) {
|
||||
data = prop_data_create_data(instbuf, instbufsiz);
|
||||
assert(data);
|
||||
prop_dictionary_set(pkg_repod, "install-script", data);
|
||||
prop_dictionary_set(pkg_metad, "install-script", data);
|
||||
prop_object_release(data);
|
||||
free(instbuf);
|
||||
}
|
||||
if (rembuf != NULL) {
|
||||
data = prop_data_create_data(rembuf, rembufsiz);
|
||||
assert(data);
|
||||
prop_dictionary_set(pkg_repod, "remove-script", data);
|
||||
prop_dictionary_set(pkg_metad, "remove-script", data);
|
||||
prop_object_release(data);
|
||||
free(rembuf);
|
||||
}
|
||||
/* Remove unneeded objs from transaction */
|
||||
prop_dictionary_remove(pkg_repod, "remove-and-update");
|
||||
prop_dictionary_remove(pkg_repod, "transaction");
|
||||
prop_dictionary_remove(pkg_repod, "state");
|
||||
prop_dictionary_remove(pkg_metad, "remove-and-update");
|
||||
prop_dictionary_remove(pkg_metad, "transaction");
|
||||
prop_dictionary_remove(pkg_metad, "state");
|
||||
|
||||
/*
|
||||
* Externalize pkg dictionary to metadir.
|
||||
@ -554,7 +558,7 @@ out1:
|
||||
}
|
||||
}
|
||||
buf = xbps_xasprintf("%s/.%s.plist", XBPS_META_PATH, pkgname);
|
||||
if (!prop_dictionary_externalize_to_file(pkg_repod, buf)) {
|
||||
if (!prop_dictionary_externalize_to_file(pkg_metad, buf)) {
|
||||
rv = errno;
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||
errno, pkgname, version,
|
||||
@ -565,6 +569,8 @@ out1:
|
||||
}
|
||||
free(buf);
|
||||
out:
|
||||
if (prop_object_type(pkg_metad) == PROP_TYPE_DICTIONARY)
|
||||
prop_object_release(pkg_metad);
|
||||
if (prop_object_type(filesd) == PROP_TYPE_DICTIONARY)
|
||||
prop_object_release(filesd);
|
||||
|
||||
@ -575,7 +581,7 @@ int HIDDEN
|
||||
xbps_unpack_binary_pkg(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
|
||||
{
|
||||
struct archive *ar = NULL;
|
||||
const char *pkgname, *version, *repoloc, *pkgver, *fname;
|
||||
const char *pkgname, *version, *pkgver;
|
||||
char *bpkg;
|
||||
int rv = 0;
|
||||
|
||||
@ -584,17 +590,15 @@ xbps_unpack_binary_pkg(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
|
||||
prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgname", &pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(pkg_repod, "version", &version);
|
||||
prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring_nocopy(pkg_repod, "repository", &repoloc);
|
||||
prop_dictionary_get_cstring_nocopy(pkg_repod, "filename", &fname);
|
||||
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK, 0, pkgname, version, NULL);
|
||||
|
||||
bpkg = xbps_path_from_repository_uri(xhp, pkg_repod, repoloc);
|
||||
bpkg = xbps_repository_pkg_path(xhp, pkg_repod);
|
||||
if (bpkg == NULL) {
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||
errno, pkgname, version,
|
||||
"%s: [unpack] cannot determine binary package "
|
||||
"file for `%s': %s", pkgver, fname, strerror(errno));
|
||||
"file for `%s': %s", pkgver, bpkg, strerror(errno));
|
||||
return errno;
|
||||
}
|
||||
|
||||
@ -615,7 +619,7 @@ xbps_unpack_binary_pkg(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||
rv, pkgname, version,
|
||||
"%s: [unpack] failed to open binary package `%s': %s",
|
||||
pkgver, fname, strerror(rv));
|
||||
pkgver, bpkg, strerror(rv));
|
||||
free(bpkg);
|
||||
archive_read_free(ar);
|
||||
return rv;
|
||||
|
95
lib/pkgdb.c
95
lib/pkgdb.c
@ -125,6 +125,9 @@ xbps_pkgdb_release(struct xbps_handle *xhp)
|
||||
if (xhp->pkgdb == NULL)
|
||||
return;
|
||||
|
||||
if (prop_object_type(xhp->pkg_metad) == PROP_TYPE_DICTIONARY)
|
||||
prop_object_release(xhp->pkg_metad);
|
||||
|
||||
prop_object_release(xhp->pkgdb);
|
||||
xhp->pkgdb = NULL;
|
||||
xbps_dbg_printf(xhp, "[pkgdb] released ok.\n");
|
||||
@ -166,81 +169,72 @@ xbps_pkgdb_foreach_cb(struct xbps_handle *xhp,
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_pkgdb_get_pkgd(struct xbps_handle *xhp, const char *pkg, bool bypattern)
|
||||
xbps_pkgdb_get_pkg(struct xbps_handle *xhp, const char *pkg)
|
||||
{
|
||||
prop_dictionary_t pkgd = NULL;
|
||||
|
||||
if (xbps_pkgdb_init(xhp) != 0)
|
||||
return NULL;
|
||||
|
||||
if (bypattern)
|
||||
pkgd = xbps_find_pkg_in_array_by_pattern(xhp, xhp->pkgdb, pkg, NULL);
|
||||
else
|
||||
pkgd = xbps_find_pkg_in_array_by_name(xhp, xhp->pkgdb, pkg, NULL);
|
||||
|
||||
return pkgd;
|
||||
return xbps_find_pkg_in_array(xhp->pkgdb, pkg);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_pkgdb_get_virtualpkgd(struct xbps_handle *xhp,
|
||||
const char *vpkg,
|
||||
bool bypattern)
|
||||
xbps_pkgdb_get_virtualpkg(struct xbps_handle *xhp, const char *vpkg)
|
||||
{
|
||||
prop_dictionary_t pkgd = NULL;
|
||||
|
||||
if (xbps_pkgdb_init(xhp) != 0)
|
||||
return NULL;
|
||||
|
||||
if (bypattern) {
|
||||
/* first return vpkg from matching a conf file */
|
||||
pkgd = xbps_find_virtualpkg_conf_in_array_by_pattern(xhp,
|
||||
xhp->pkgdb, vpkg);
|
||||
if (pkgd != NULL)
|
||||
return pkgd;
|
||||
return xbps_find_virtualpkg_in_array(xhp, xhp->pkgdb, vpkg);
|
||||
}
|
||||
|
||||
/* ... otherwise the first one in array */
|
||||
pkgd = xbps_find_virtualpkg_in_array_by_pattern(xhp,
|
||||
xhp->pkgdb, vpkg);
|
||||
} else {
|
||||
/* first return vpkg from matching a conf file */
|
||||
pkgd = xbps_find_virtualpkg_conf_in_array_by_name(xhp,
|
||||
xhp->pkgdb, vpkg);
|
||||
if (pkgd != NULL)
|
||||
return pkgd;
|
||||
prop_dictionary_t
|
||||
xbps_pkgdb_get_pkg_metadata(struct xbps_handle *xhp, const char *pkg)
|
||||
{
|
||||
prop_dictionary_t pkgd, pkg_metad;
|
||||
const char *pkgname;
|
||||
char *plist;
|
||||
|
||||
pkgd = xbps_find_virtualpkg_in_array_by_name(xhp,
|
||||
xhp->pkgdb, vpkg);
|
||||
pkgd = xbps_pkgdb_get_pkg(xhp, pkg);
|
||||
if (pkgd == NULL)
|
||||
return NULL;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "pkgname", &pkgname);
|
||||
|
||||
if ((pkg_metad = prop_dictionary_get(xhp->pkg_metad, pkgname)) != NULL)
|
||||
return pkg_metad;
|
||||
|
||||
plist = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname);
|
||||
pkg_metad = prop_dictionary_internalize_from_zfile(plist);
|
||||
free(plist);
|
||||
|
||||
if (pkg_metad == NULL) {
|
||||
xbps_dbg_printf(xhp, "[pkgdb] cannot read %s metadata: %s\n",
|
||||
pkgname, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pkgd;
|
||||
}
|
||||
if (xhp->pkg_metad == NULL)
|
||||
xhp->pkg_metad = prop_dictionary_create();
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_pkgdb_get_pkgd_by_pkgver(struct xbps_handle *xhp, const char *pkgver)
|
||||
{
|
||||
if (xbps_pkgdb_init(xhp) != 0)
|
||||
return NULL;
|
||||
prop_dictionary_set(xhp->pkg_metad, pkgname, pkg_metad);
|
||||
prop_object_release(pkg_metad);
|
||||
|
||||
return xbps_find_pkg_in_array_by_pkgver(xhp, xhp->pkgdb, pkgver, NULL);
|
||||
return pkg_metad;
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_pkgdb_remove_pkgd(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern,
|
||||
bool flush)
|
||||
xbps_pkgdb_remove_pkg(struct xbps_handle *xhp, const char *pkg, bool flush)
|
||||
{
|
||||
bool rv = false;
|
||||
|
||||
if (xbps_pkgdb_init(xhp) != 0)
|
||||
return false;
|
||||
|
||||
if (bypattern)
|
||||
rv = xbps_remove_pkg_from_array_by_pattern(xhp,
|
||||
xhp->pkgdb, pkg, NULL);
|
||||
if (xbps_pkgpattern_version(pkg))
|
||||
rv = xbps_remove_pkg_from_array_by_pattern(xhp->pkgdb, pkg);
|
||||
else if (xbps_pkg_version(pkg))
|
||||
rv = xbps_remove_pkg_from_array_by_pkgver(xhp->pkgdb, pkg);
|
||||
else
|
||||
rv = xbps_remove_pkg_from_array_by_name(xhp,
|
||||
xhp->pkgdb, pkg, NULL);
|
||||
rv = xbps_remove_pkg_from_array_by_name(xhp->pkgdb, pkg);
|
||||
|
||||
if (!flush || !rv)
|
||||
return rv;
|
||||
@ -252,10 +246,9 @@ xbps_pkgdb_remove_pkgd(struct xbps_handle *xhp,
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_pkgdb_replace_pkgd(struct xbps_handle *xhp,
|
||||
xbps_pkgdb_replace_pkg(struct xbps_handle *xhp,
|
||||
prop_dictionary_t pkgd,
|
||||
const char *pkg,
|
||||
bool bypattern,
|
||||
bool flush)
|
||||
{
|
||||
int rv;
|
||||
@ -263,7 +256,7 @@ xbps_pkgdb_replace_pkgd(struct xbps_handle *xhp,
|
||||
if (xbps_pkgdb_init(xhp) != 0)
|
||||
return false;
|
||||
|
||||
if (bypattern)
|
||||
if (xbps_pkgpattern_version(pkg))
|
||||
rv = xbps_array_replace_dict_by_pattern(xhp->pkgdb, pkgd, pkg);
|
||||
else
|
||||
rv = xbps_array_replace_dict_by_name(xhp->pkgdb, pkgd, pkg);
|
||||
|
@ -39,7 +39,7 @@
|
||||
* These functions manipulate plist files and objects shared by almost
|
||||
* all library functions.
|
||||
*/
|
||||
bool
|
||||
bool HIDDEN
|
||||
xbps_add_obj_to_dict(prop_dictionary_t dict, prop_object_t obj,
|
||||
const char *key)
|
||||
{
|
||||
@ -57,7 +57,7 @@ xbps_add_obj_to_dict(prop_dictionary_t dict, prop_object_t obj,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
bool HIDDEN
|
||||
xbps_add_obj_to_array(prop_array_t array, prop_object_t obj)
|
||||
{
|
||||
assert(prop_object_type(array) == PROP_TYPE_ARRAY);
|
||||
@ -249,7 +249,7 @@ array_replace_dict(prop_array_t array,
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
int
|
||||
int HIDDEN
|
||||
xbps_array_replace_dict_by_name(prop_array_t array,
|
||||
prop_dictionary_t dict,
|
||||
const char *pkgname)
|
||||
@ -257,7 +257,7 @@ xbps_array_replace_dict_by_name(prop_array_t array,
|
||||
return array_replace_dict(array, dict, pkgname, false);
|
||||
}
|
||||
|
||||
int
|
||||
int HIDDEN
|
||||
xbps_array_replace_dict_by_pattern(prop_array_t array,
|
||||
prop_dictionary_t dict,
|
||||
const char *pattern)
|
||||
|
@ -119,7 +119,7 @@ open_archive(const char *url)
|
||||
struct url *u;
|
||||
struct archive *a;
|
||||
|
||||
if (!xbps_check_is_repository_uri_remote(url)) {
|
||||
if (!xbps_repository_is_remote(url)) {
|
||||
if ((a = archive_read_new()) == NULL)
|
||||
return NULL;
|
||||
|
||||
@ -146,7 +146,7 @@ open_archive(const char *url)
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_dictionary_metadata_plist_by_url(const char *url, const char *plistf)
|
||||
xbps_get_pkg_plist_from_binpkg(const char *fname, const char *plistf)
|
||||
{
|
||||
prop_dictionary_t plistd = NULL;
|
||||
struct archive *a;
|
||||
@ -154,10 +154,10 @@ xbps_dictionary_metadata_plist_by_url(const char *url, const char *plistf)
|
||||
const char *curpath, *comptype;
|
||||
int i = 0;
|
||||
|
||||
assert(url != NULL);
|
||||
assert(fname != NULL);
|
||||
assert(plistf != NULL);
|
||||
|
||||
if ((a = open_archive(url)) == NULL)
|
||||
if ((a = open_archive(fname)) == NULL)
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
|
385
lib/plist_find.c
385
lib/plist_find.c
@ -31,378 +31,89 @@
|
||||
|
||||
#include "xbps_api_impl.h"
|
||||
|
||||
/**
|
||||
* @file lib/plist_find.c
|
||||
* @brief PropertyList generic routines
|
||||
* @defgroup plist PropertyList generic functions
|
||||
*
|
||||
* These functions manipulate plist files and objects shared by almost
|
||||
* all library functions.
|
||||
*/
|
||||
static prop_dictionary_t
|
||||
find_pkg_in_array(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *str,
|
||||
bool bypattern,
|
||||
bool virtual,
|
||||
const char *targetarch)
|
||||
get_pkg_in_array(prop_array_t array, const char *str, bool virtual)
|
||||
{
|
||||
prop_object_iterator_t iter;
|
||||
prop_object_t obj = NULL;
|
||||
const char *pkgver, *dpkgn, *arch;
|
||||
bool chkarch;
|
||||
|
||||
assert(prop_object_type(array) == PROP_TYPE_ARRAY);
|
||||
assert(str != NULL);
|
||||
|
||||
iter = prop_array_iterator(array);
|
||||
if (iter == NULL)
|
||||
return NULL;
|
||||
|
||||
while ((obj = prop_object_iterator_next(iter))) {
|
||||
chkarch = prop_dictionary_get_cstring_nocopy(obj,
|
||||
"architecture", &arch);
|
||||
if (chkarch && !xbps_pkg_arch_match(xhp, arch, targetarch))
|
||||
continue;
|
||||
const char *pkgver, *dpkgn;
|
||||
size_t i;
|
||||
bool found = false;
|
||||
|
||||
for (i = 0; i < prop_array_count(array); i++) {
|
||||
obj = prop_array_get(array, i);
|
||||
if (virtual) {
|
||||
/*
|
||||
* Check if package pattern matches
|
||||
* any virtual package version in dictionary.
|
||||
*/
|
||||
if (xbps_match_virtual_pkg_in_dict(obj, str, bypattern))
|
||||
if (xbps_pkgpattern_version(str))
|
||||
found = xbps_match_virtual_pkg_in_dict(obj, str, true);
|
||||
else
|
||||
found = xbps_match_virtual_pkg_in_dict(obj, str, false);
|
||||
|
||||
if (found)
|
||||
break;
|
||||
} else if (bypattern) {
|
||||
/*
|
||||
* Check if package pattern matches the
|
||||
* pkgver string object in dictionary.
|
||||
*/
|
||||
} else if (xbps_pkgpattern_version(str)) {
|
||||
/* ,atch by pattern against pkgver */
|
||||
if (!prop_dictionary_get_cstring_nocopy(obj,
|
||||
"pkgver", &pkgver))
|
||||
continue;
|
||||
if (xbps_pkgpattern_match(pkgver, str))
|
||||
if (xbps_pkgpattern_match(pkgver, str)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
} else if (xbps_pkg_version(str)) {
|
||||
/* match by exact pkgver */
|
||||
if (!prop_dictionary_get_cstring_nocopy(obj,
|
||||
"pkgver", &pkgver))
|
||||
continue;
|
||||
if (strcmp(str, pkgver) == 0) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* match by pkgname */
|
||||
if (!prop_dictionary_get_cstring_nocopy(obj,
|
||||
"pkgname", &dpkgn))
|
||||
continue;
|
||||
if (strcmp(dpkgn, str) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
prop_object_iterator_release(iter);
|
||||
if (obj == NULL) {
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_pkg_in_array_by_name(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *name,
|
||||
const char *targetarch)
|
||||
{
|
||||
return find_pkg_in_array(xhp, array, name, false, false, targetarch);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_pkg_in_array_by_pattern(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *pattern,
|
||||
const char *targetarch)
|
||||
{
|
||||
return find_pkg_in_array(xhp, array, pattern, true, false, targetarch);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_pkg_in_array_by_pkgver(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *pkgver,
|
||||
const char *targetarch)
|
||||
{
|
||||
prop_object_iterator_t iter;
|
||||
prop_object_t obj = NULL;
|
||||
const char *rpkgver, *arch;
|
||||
bool chkarch, found = false;
|
||||
|
||||
assert(prop_object_type(array) == PROP_TYPE_ARRAY);
|
||||
assert(pkgver != NULL);
|
||||
|
||||
iter = prop_array_iterator(array);
|
||||
if (iter == NULL)
|
||||
return NULL;
|
||||
|
||||
while ((obj = prop_object_iterator_next(iter))) {
|
||||
chkarch = prop_dictionary_get_cstring_nocopy(obj,
|
||||
"architecture", &arch);
|
||||
if (!prop_dictionary_get_cstring_nocopy(obj,
|
||||
"pkgver", &rpkgver))
|
||||
continue;
|
||||
if (chkarch && !xbps_pkg_arch_match(xhp, arch, targetarch))
|
||||
continue;
|
||||
if (strcmp(pkgver, rpkgver) == 0) {
|
||||
if (strcmp(dpkgn, str) == 0) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
prop_object_iterator_release(iter);
|
||||
if (found)
|
||||
return obj;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_virtualpkg_in_array_by_name(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *name)
|
||||
{
|
||||
return find_pkg_in_array(xhp, array, name, false, true, NULL);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_virtualpkg_in_array_by_pattern(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *pattern)
|
||||
{
|
||||
return find_pkg_in_array(xhp, array, pattern, true, true, NULL);
|
||||
}
|
||||
|
||||
static const char *
|
||||
find_virtualpkg_user_in_conf(struct xbps_handle *xhp,
|
||||
const char *vpkg,
|
||||
bool bypattern)
|
||||
{
|
||||
const char *vpkgver, *pkg = NULL;
|
||||
char *vpkgname = NULL, *tmp;
|
||||
size_t i, j, cnt;
|
||||
|
||||
if (xhp->cfg == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((cnt = cfg_size(xhp->cfg, "virtual-package")) == 0) {
|
||||
/* no virtual packages configured */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < cnt; i++) {
|
||||
cfg_t *sec = cfg_getnsec(xhp->cfg, "virtual-package", i);
|
||||
for (j = 0; j < cfg_size(sec, "targets"); j++) {
|
||||
tmp = NULL;
|
||||
vpkgver = cfg_getnstr(sec, "targets", j);
|
||||
if (strchr(vpkgver, '_') == NULL) {
|
||||
tmp = xbps_xasprintf("%s_1", vpkgver);
|
||||
vpkgname = xbps_pkg_name(tmp);
|
||||
free(tmp);
|
||||
} else {
|
||||
vpkgname = xbps_pkg_name(vpkgver);
|
||||
}
|
||||
if (vpkgname == NULL)
|
||||
break;
|
||||
if (bypattern) {
|
||||
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(xhp,
|
||||
"matched vpkg in conf `%s' for %s\n",
|
||||
pkg, vpkg);
|
||||
free(vpkgname);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return pkg;
|
||||
}
|
||||
|
||||
static prop_dictionary_t
|
||||
find_virtualpkg_user_in_array(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *str,
|
||||
bool bypattern)
|
||||
{
|
||||
const char *vpkgname;
|
||||
|
||||
assert(prop_object_type(array) == PROP_TYPE_ARRAY);
|
||||
assert(str != NULL);
|
||||
|
||||
vpkgname = find_virtualpkg_user_in_conf(xhp, str, bypattern);
|
||||
if (vpkgname == NULL)
|
||||
return NULL;
|
||||
|
||||
return find_pkg_in_array(xhp, array, vpkgname, false, false, NULL);
|
||||
return found ? obj : NULL;
|
||||
}
|
||||
|
||||
prop_dictionary_t HIDDEN
|
||||
xbps_find_virtualpkg_conf_in_array_by_name(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *name)
|
||||
xbps_find_pkg_in_array(prop_array_t a, const char *s)
|
||||
{
|
||||
return find_virtualpkg_user_in_array(xhp, array, name, false);
|
||||
assert(prop_object_type(a) == PROP_TYPE_ARRAY);
|
||||
assert(s);
|
||||
|
||||
return get_pkg_in_array(a, s, false);
|
||||
}
|
||||
|
||||
prop_dictionary_t HIDDEN
|
||||
xbps_find_virtualpkg_conf_in_array_by_pattern(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *p)
|
||||
xbps_find_virtualpkg_in_array(struct xbps_handle *x,
|
||||
prop_array_t a,
|
||||
const char *s)
|
||||
{
|
||||
return find_virtualpkg_user_in_array(xhp, array, p, true);
|
||||
}
|
||||
prop_dictionary_t pkgd;
|
||||
const char *vpkg;
|
||||
bool bypattern = false;
|
||||
|
||||
static prop_dictionary_t
|
||||
find_pkg_in_dict(struct xbps_handle *xhp,
|
||||
prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *str,
|
||||
bool bypattern,
|
||||
bool virtual)
|
||||
{
|
||||
prop_array_t array;
|
||||
assert(x);
|
||||
assert(prop_object_type(a) == PROP_TYPE_ARRAY);
|
||||
assert(s);
|
||||
|
||||
assert(prop_object_type(d) == PROP_TYPE_DICTIONARY);
|
||||
assert(str != NULL);
|
||||
assert(key != NULL);
|
||||
if (xbps_pkgpattern_version(s))
|
||||
bypattern = true;
|
||||
|
||||
array = prop_dictionary_get(d, key);
|
||||
if (prop_object_type(array) != PROP_TYPE_ARRAY)
|
||||
return NULL;
|
||||
|
||||
return find_pkg_in_array(xhp, array, str, bypattern, virtual, NULL);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_pkg_in_dict_by_name(struct xbps_handle *xhp,
|
||||
prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *pkgname)
|
||||
{
|
||||
return find_pkg_in_dict(xhp, d, key, pkgname, false, false);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_pkg_in_dict_by_pattern(struct xbps_handle *xhp,
|
||||
prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *pattern)
|
||||
{
|
||||
return find_pkg_in_dict(xhp, d, key, pattern, true, false);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_pkg_in_dict_by_pkgver(struct xbps_handle *xhp,
|
||||
prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *pkgver)
|
||||
{
|
||||
prop_array_t array;
|
||||
|
||||
assert(d != NULL);
|
||||
assert(key != NULL);
|
||||
assert(pkgver != NULL);
|
||||
|
||||
array = prop_dictionary_get(d, key);
|
||||
if (array == NULL)
|
||||
return NULL;
|
||||
|
||||
return xbps_find_pkg_in_array_by_pkgver(xhp, array, pkgver, NULL);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_virtualpkg_in_dict_by_name(struct xbps_handle *xhp,
|
||||
prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *name)
|
||||
{
|
||||
return find_pkg_in_dict(xhp, d, key, name, false, true);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_virtualpkg_in_dict_by_pattern(struct xbps_handle *xhp,
|
||||
prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *pattern)
|
||||
{
|
||||
return find_pkg_in_dict(xhp, d, key, pattern, true, true);
|
||||
}
|
||||
|
||||
static prop_dictionary_t
|
||||
find_pkgd_installed(struct xbps_handle *xhp,
|
||||
const char *str,
|
||||
bool bypattern,
|
||||
bool virtual)
|
||||
{
|
||||
prop_dictionary_t pkgd = NULL;
|
||||
pkg_state_t state = 0;
|
||||
int rv;
|
||||
|
||||
assert(str != NULL);
|
||||
|
||||
if ((rv = xbps_pkgdb_init(xhp)) != 0) {
|
||||
if (rv != ENOENT) {
|
||||
xbps_dbg_printf(xhp, "%s: couldn't initialize "
|
||||
"pkgdb: %s\n", strerror(rv));
|
||||
return NULL;
|
||||
} else if (rv == ENOENT)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* try normal pkg */
|
||||
if (virtual == false) {
|
||||
pkgd = find_pkg_in_array(xhp, xhp->pkgdb, str,
|
||||
bypattern, false, NULL);
|
||||
} else {
|
||||
/* virtual pkg set by user in conf */
|
||||
pkgd = find_virtualpkg_user_in_array(xhp, xhp->pkgdb,
|
||||
str, bypattern);
|
||||
if (pkgd == NULL) {
|
||||
/* any virtual pkg in array matching pattern */
|
||||
pkgd = find_pkg_in_array(xhp, xhp->pkgdb,
|
||||
str, bypattern, true, NULL);
|
||||
}
|
||||
}
|
||||
/* pkg not found */
|
||||
if (pkgd == NULL)
|
||||
return NULL;
|
||||
|
||||
if (xbps_pkg_state_dictionary(pkgd, &state) != 0)
|
||||
return NULL;
|
||||
|
||||
switch (state) {
|
||||
case XBPS_PKG_STATE_INSTALLED:
|
||||
case XBPS_PKG_STATE_UNPACKED:
|
||||
if ((vpkg = vpkg_user_conf(x, s, bypattern))) {
|
||||
if ((pkgd = get_pkg_in_array(a, vpkg, true)))
|
||||
return pkgd;
|
||||
/* NOTREACHED */
|
||||
default:
|
||||
/* not fully installed */
|
||||
errno = ENOENT;
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_pkg_dict_installed(struct xbps_handle *xhp,
|
||||
const char *str,
|
||||
bool bypattern)
|
||||
{
|
||||
return find_pkgd_installed(xhp, str, bypattern, false);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_virtualpkg_dict_installed(struct xbps_handle *xhp,
|
||||
const char *str,
|
||||
bool bypattern)
|
||||
{
|
||||
return find_pkgd_installed(xhp, str, bypattern, true);
|
||||
return get_pkg_in_array(a, s, true);
|
||||
}
|
||||
|
@ -31,27 +31,15 @@
|
||||
|
||||
#include "xbps_api_impl.h"
|
||||
|
||||
/**
|
||||
* @file lib/plist_remove.c
|
||||
* @brief PropertyList generic routines
|
||||
* @defgroup plist PropertyList generic functions
|
||||
*
|
||||
* These functions manipulate plist files and objects shared by almost
|
||||
* all library functions.
|
||||
*/
|
||||
static bool
|
||||
remove_obj_from_array(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *str,
|
||||
int mode,
|
||||
const char *targetarch)
|
||||
remove_obj_from_array(prop_array_t array, const char *str, int mode)
|
||||
{
|
||||
prop_object_iterator_t iter;
|
||||
prop_object_t obj;
|
||||
const char *curname, *pkgdep, *arch;
|
||||
const char *curname, *pkgdep;
|
||||
char *curpkgname;
|
||||
size_t idx = 0;
|
||||
bool found = false, chkarch;
|
||||
bool found = false;
|
||||
|
||||
assert(prop_object_type(array) == PROP_TYPE_ARRAY);
|
||||
|
||||
@ -80,13 +68,6 @@ remove_obj_from_array(struct xbps_handle *xhp,
|
||||
free(curpkgname);
|
||||
} else if (mode == 2) {
|
||||
/* match by pkgname, obj is a dictionary */
|
||||
chkarch = prop_dictionary_get_cstring_nocopy(obj,
|
||||
"architecture", &arch);
|
||||
if (chkarch && !xbps_pkg_arch_match(xhp, arch,
|
||||
targetarch)) {
|
||||
idx++;
|
||||
continue;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(obj,
|
||||
"pkgname", &curname);
|
||||
if (strcmp(curname, str) == 0) {
|
||||
@ -94,13 +75,6 @@ remove_obj_from_array(struct xbps_handle *xhp,
|
||||
break;
|
||||
}
|
||||
} else if (mode == 3) {
|
||||
chkarch = prop_dictionary_get_cstring_nocopy(obj,
|
||||
"architecture", &arch);
|
||||
if (chkarch && !xbps_pkg_arch_match(xhp, arch,
|
||||
targetarch)) {
|
||||
idx++;
|
||||
continue;
|
||||
}
|
||||
/* match by pkgver, obj is a dictionary */
|
||||
prop_dictionary_get_cstring_nocopy(obj,
|
||||
"pkgver", &curname);
|
||||
@ -109,13 +83,6 @@ remove_obj_from_array(struct xbps_handle *xhp,
|
||||
break;
|
||||
}
|
||||
} else if (mode == 4) {
|
||||
chkarch = prop_dictionary_get_cstring_nocopy(obj,
|
||||
"architecture", &arch);
|
||||
if (chkarch && !xbps_pkg_arch_match(xhp, arch,
|
||||
targetarch)) {
|
||||
idx++;
|
||||
continue;
|
||||
}
|
||||
/* match by pattern, obj is a dictionary */
|
||||
prop_dictionary_get_cstring_nocopy(obj,
|
||||
"pkgver", &curname);
|
||||
@ -137,45 +104,32 @@ remove_obj_from_array(struct xbps_handle *xhp,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_remove_string_from_array(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *str)
|
||||
bool HIDDEN
|
||||
xbps_remove_string_from_array(prop_array_t array, const char *str)
|
||||
{
|
||||
return remove_obj_from_array(xhp, array, str, 0, NULL);
|
||||
return remove_obj_from_array(array, str, 0);
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_remove_pkgname_from_array(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *name)
|
||||
bool HIDDEN
|
||||
xbps_remove_pkgname_from_array(prop_array_t array, const char *str)
|
||||
{
|
||||
return remove_obj_from_array(xhp, array, name, 1, NULL);
|
||||
return remove_obj_from_array(array, str, 1);
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_remove_pkg_from_array_by_name(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *name,
|
||||
const char *targetarch)
|
||||
bool HIDDEN
|
||||
xbps_remove_pkg_from_array_by_name(prop_array_t array, const char *str)
|
||||
{
|
||||
return remove_obj_from_array(xhp, array, name, 2, targetarch);
|
||||
return remove_obj_from_array(array, str, 2);
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_remove_pkg_from_array_by_pkgver(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *pkgver,
|
||||
const char *targetarch)
|
||||
bool HIDDEN
|
||||
xbps_remove_pkg_from_array_by_pkgver(prop_array_t array, const char *str)
|
||||
{
|
||||
return remove_obj_from_array(xhp, array, pkgver, 3, targetarch);
|
||||
return remove_obj_from_array(array, str, 3);
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_remove_pkg_from_array_by_pattern(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *p,
|
||||
const char *targetarch)
|
||||
bool HIDDEN
|
||||
xbps_remove_pkg_from_array_by_pattern(prop_array_t array, const char *str)
|
||||
{
|
||||
return remove_obj_from_array(xhp, array, p, 4, targetarch);
|
||||
return remove_obj_from_array(array, str, 4);
|
||||
}
|
||||
|
@ -1,345 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2009-2012 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 <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "xbps_api_impl.h"
|
||||
|
||||
/**
|
||||
* @file lib/repository_pool_find.c
|
||||
* @brief Repository pool routines
|
||||
* @defgroup repopool Repository pool functions
|
||||
*/
|
||||
struct repo_pool_fpkg {
|
||||
prop_dictionary_t pkgd;
|
||||
const char *pattern;
|
||||
const char *bestpkgver;
|
||||
bool bypattern;
|
||||
bool exact;
|
||||
};
|
||||
|
||||
static int
|
||||
repo_find_virtualpkg_cb(struct xbps_handle *xhp,
|
||||
struct xbps_rpool_index *rpi,
|
||||
void *arg,
|
||||
bool *done)
|
||||
{
|
||||
struct repo_pool_fpkg *rpf = arg;
|
||||
|
||||
(void)xhp;
|
||||
|
||||
if (rpf->bypattern) {
|
||||
rpf->pkgd =
|
||||
xbps_find_virtualpkg_in_array_by_pattern(xhp, rpi->repo,
|
||||
rpf->pattern);
|
||||
} else {
|
||||
rpf->pkgd =
|
||||
xbps_find_virtualpkg_in_array_by_name(xhp, rpi->repo,
|
||||
rpf->pattern);
|
||||
}
|
||||
if (rpf->pkgd) {
|
||||
prop_dictionary_set_cstring_nocopy(rpf->pkgd,
|
||||
"repository", rpi->uri);
|
||||
*done = true;
|
||||
return 0;
|
||||
}
|
||||
/* not found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
repo_find_virtualpkg_conf_cb(struct xbps_handle *xhp,
|
||||
struct xbps_rpool_index *rpi,
|
||||
void *arg,
|
||||
bool *done)
|
||||
{
|
||||
struct repo_pool_fpkg *rpf = arg;
|
||||
|
||||
if (rpf->bypattern) {
|
||||
rpf->pkgd =
|
||||
xbps_find_virtualpkg_conf_in_array_by_pattern(xhp,
|
||||
rpi->repo, rpf->pattern);
|
||||
} else {
|
||||
rpf->pkgd =
|
||||
xbps_find_virtualpkg_conf_in_array_by_name(xhp,
|
||||
rpi->repo, rpf->pattern);
|
||||
}
|
||||
if (rpf->pkgd) {
|
||||
prop_dictionary_set_cstring_nocopy(rpf->pkgd,
|
||||
"repository", rpi->uri);
|
||||
*done = true;
|
||||
return 0;
|
||||
}
|
||||
/* not found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
repo_find_pkg_cb(struct xbps_handle *xhp,
|
||||
struct xbps_rpool_index *rpi,
|
||||
void *arg,
|
||||
bool *done)
|
||||
{
|
||||
struct repo_pool_fpkg *rpf = arg;
|
||||
|
||||
(void)xhp;
|
||||
|
||||
if (rpf->exact) {
|
||||
/* exact match by pkgver */
|
||||
rpf->pkgd = xbps_find_pkg_in_array_by_pkgver(xhp, rpi->repo,
|
||||
rpf->pattern, NULL);
|
||||
} else if (rpf->bypattern) {
|
||||
/* match by pkgpattern in pkgver*/
|
||||
rpf->pkgd = xbps_find_pkg_in_array_by_pattern(xhp, rpi->repo,
|
||||
rpf->pattern, NULL);
|
||||
} else {
|
||||
/* match by pkgname */
|
||||
rpf->pkgd = xbps_find_pkg_in_array_by_name(xhp, rpi->repo,
|
||||
rpf->pattern, NULL);
|
||||
}
|
||||
if (rpf->pkgd) {
|
||||
/*
|
||||
* Package dictionary found, add the "repository"
|
||||
* object with the URI.
|
||||
*/
|
||||
prop_dictionary_set_cstring_nocopy(rpf->pkgd,
|
||||
"repository", rpi->uri);
|
||||
*done = true;
|
||||
return 0;
|
||||
}
|
||||
/* Not found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
repo_find_best_pkg_cb(struct xbps_handle *xhp,
|
||||
struct xbps_rpool_index *rpi,
|
||||
void *arg,
|
||||
bool *done)
|
||||
{
|
||||
struct repo_pool_fpkg *rpf = arg;
|
||||
const char *repopkgver;
|
||||
prop_dictionary_t pkgd;
|
||||
|
||||
(void)done;
|
||||
(void)xhp;
|
||||
|
||||
if (rpf->bypattern) {
|
||||
pkgd = xbps_find_pkg_in_array_by_pattern(xhp, rpi->repo,
|
||||
rpf->pattern, NULL);
|
||||
} else {
|
||||
pkgd = xbps_find_pkg_in_array_by_name(xhp, rpi->repo,
|
||||
rpf->pattern, NULL);
|
||||
}
|
||||
if (pkgd == NULL) {
|
||||
if (errno && errno != ENOENT)
|
||||
return errno;
|
||||
|
||||
xbps_dbg_printf(xhp,
|
||||
"[rpool] Package '%s' not found in repository "
|
||||
"'%s'.\n", rpf->pattern, rpi->uri);
|
||||
return 0;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
"pkgver", &repopkgver);
|
||||
if (rpf->bestpkgver == NULL) {
|
||||
xbps_dbg_printf(xhp,
|
||||
"[rpool] Found best match '%s' (%s).\n",
|
||||
repopkgver, rpi->uri);
|
||||
rpf->pkgd = pkgd;
|
||||
prop_dictionary_set_cstring_nocopy(rpf->pkgd,
|
||||
"repository", rpi->uri);
|
||||
rpf->bestpkgver = repopkgver;
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Compare current stored version against new
|
||||
* version from current package in repository.
|
||||
*/
|
||||
if (xbps_cmpver(repopkgver, rpf->bestpkgver) == 1) {
|
||||
xbps_dbg_printf(xhp,
|
||||
"[rpool] Found best match '%s' (%s).\n",
|
||||
repopkgver, rpi->uri);
|
||||
rpf->pkgd = pkgd;
|
||||
prop_dictionary_set_cstring_nocopy(rpf->pkgd,
|
||||
"repository", rpi->uri);
|
||||
rpf->bestpkgver = repopkgver;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
BEST_PKG = 1,
|
||||
EXACT_PKG,
|
||||
VIRTUAL_PKG,
|
||||
VIRTUAL_CONF_PKG,
|
||||
REAL_PKG
|
||||
} pkg_repo_type_t;
|
||||
|
||||
static prop_dictionary_t
|
||||
repo_find_pkg(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern,
|
||||
pkg_repo_type_t type)
|
||||
{
|
||||
struct repo_pool_fpkg rpf;
|
||||
int rv = 0;
|
||||
|
||||
rpf.pattern = pkg;
|
||||
rpf.bypattern = bypattern;
|
||||
rpf.exact = false;
|
||||
rpf.pkgd = NULL;
|
||||
rpf.bestpkgver = NULL;
|
||||
|
||||
switch (type) {
|
||||
case EXACT_PKG:
|
||||
/*
|
||||
* Find exact pkg version.
|
||||
*/
|
||||
rpf.exact = true;
|
||||
rv = xbps_rpool_foreach(xhp, repo_find_pkg_cb, &rpf);
|
||||
break;
|
||||
case BEST_PKG:
|
||||
/*
|
||||
* Find best pkg version.
|
||||
*/
|
||||
rv = xbps_rpool_foreach(xhp, repo_find_best_pkg_cb, &rpf);
|
||||
break;
|
||||
case VIRTUAL_PKG:
|
||||
/*
|
||||
* Find virtual pkg.
|
||||
*/
|
||||
rv = xbps_rpool_foreach(xhp, repo_find_virtualpkg_cb, &rpf);
|
||||
break;
|
||||
case VIRTUAL_CONF_PKG:
|
||||
/*
|
||||
* Find virtual pkg as specified in configuration file.
|
||||
*/
|
||||
rv = xbps_rpool_foreach(xhp, repo_find_virtualpkg_conf_cb, &rpf);
|
||||
break;
|
||||
case REAL_PKG:
|
||||
/*
|
||||
* Find real pkg.
|
||||
*/
|
||||
rv = xbps_rpool_foreach(xhp, repo_find_pkg_cb, &rpf);
|
||||
break;
|
||||
}
|
||||
if (rv != 0) {
|
||||
errno = rv;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return rpf.pkgd;
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_rpool_find_virtualpkg(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern)
|
||||
{
|
||||
assert(pkg != NULL);
|
||||
|
||||
return repo_find_pkg(xhp, pkg, bypattern, VIRTUAL_PKG);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_rpool_find_virtualpkg_conf(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern)
|
||||
{
|
||||
assert(pkg != NULL);
|
||||
|
||||
return repo_find_pkg(xhp, pkg, bypattern, VIRTUAL_CONF_PKG);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_rpool_find_pkg(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern,
|
||||
bool best)
|
||||
{
|
||||
assert(pkg != NULL);
|
||||
|
||||
if (best)
|
||||
return repo_find_pkg(xhp, pkg, bypattern, BEST_PKG);
|
||||
|
||||
return repo_find_pkg(xhp, pkg, bypattern, REAL_PKG);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_rpool_find_pkg_exact(struct xbps_handle *xhp, const char *pkgver)
|
||||
{
|
||||
assert(pkgver != NULL);
|
||||
|
||||
return repo_find_pkg(xhp, pkgver, false, EXACT_PKG);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_rpool_dictionary_metadata_plist(struct xbps_handle *xhp,
|
||||
const char *pattern,
|
||||
const char *plistf)
|
||||
{
|
||||
prop_dictionary_t pkgd = NULL, plistd = NULL;
|
||||
const char *repoloc;
|
||||
char *url;
|
||||
|
||||
assert(pattern != NULL);
|
||||
assert(plistf != NULL);
|
||||
/*
|
||||
* Iterate over the the repository pool and search for a plist file
|
||||
* in the binary package matching `pattern'. The plist file will be
|
||||
* internalized to a proplib dictionary.
|
||||
*
|
||||
* The first repository that has it wins and the loop is stopped.
|
||||
* This will work locally and remotely, thanks to libarchive and
|
||||
* libfetch!
|
||||
*/
|
||||
if (xbps_pkgpattern_version(pattern))
|
||||
pkgd = xbps_rpool_find_pkg(xhp, pattern, true, false);
|
||||
else
|
||||
pkgd = xbps_rpool_find_pkg(xhp, pattern, false, true);
|
||||
|
||||
if (pkgd == NULL)
|
||||
goto out;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "repository", &repoloc);
|
||||
url = xbps_path_from_repository_uri(xhp, pkgd, repoloc);
|
||||
if (url == NULL) {
|
||||
errno = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
plistd = xbps_dictionary_metadata_plist_by_url(url, plistf);
|
||||
free(url);
|
||||
|
||||
out:
|
||||
if (plistd == NULL)
|
||||
errno = ENOENT;
|
||||
|
||||
return plistd;
|
||||
}
|
211
lib/rindex_get.c
Normal file
211
lib/rindex_get.c
Normal file
@ -0,0 +1,211 @@
|
||||
/*-
|
||||
* Copyright (c) 2012 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 <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "xbps_api_impl.h"
|
||||
|
||||
/**
|
||||
* @file lib/rindex_get.c
|
||||
* @brief Repository index get routines
|
||||
* @defgroup rindex_get Repository index get routines
|
||||
*/
|
||||
static prop_dictionary_t
|
||||
match_pkg_by_pkgver(prop_dictionary_t repod, const char *p)
|
||||
{
|
||||
prop_dictionary_t d = NULL;
|
||||
const char *pkgver;
|
||||
char *pkgname;
|
||||
|
||||
/* exact match by pkgver */
|
||||
if ((pkgname = xbps_pkg_name(p)) == NULL)
|
||||
return NULL;
|
||||
|
||||
d = prop_dictionary_get(repod, pkgname);
|
||||
if (d) {
|
||||
prop_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver);
|
||||
if (strcmp(pkgver, p))
|
||||
d = NULL;
|
||||
}
|
||||
|
||||
free(pkgname);
|
||||
return d;
|
||||
}
|
||||
|
||||
static prop_dictionary_t
|
||||
match_pkg_by_pattern(prop_dictionary_t repod, const char *p)
|
||||
{
|
||||
prop_dictionary_t d = NULL;
|
||||
const char *pkgver;
|
||||
char *pkgname;
|
||||
|
||||
/* match by pkgpattern in pkgver */
|
||||
if ((pkgname = xbps_pkgpattern_name(p)) == NULL) {
|
||||
if ((pkgname = xbps_pkg_name(p)))
|
||||
return match_pkg_by_pkgver(repod, p);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
d = prop_dictionary_get(repod, pkgname);
|
||||
if (d) {
|
||||
prop_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver);
|
||||
assert(pkgver);
|
||||
if (!xbps_pkgpattern_match(pkgver, p))
|
||||
d = NULL;
|
||||
}
|
||||
|
||||
free(pkgname);
|
||||
return d;
|
||||
}
|
||||
|
||||
const char HIDDEN *
|
||||
vpkg_user_conf(struct xbps_handle *xhp,
|
||||
const char *vpkg,
|
||||
bool bypattern)
|
||||
{
|
||||
const char *vpkgver, *pkg = NULL;
|
||||
char *vpkgname = NULL, *tmp;
|
||||
size_t i, j, cnt;
|
||||
|
||||
if (xhp->cfg == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((cnt = cfg_size(xhp->cfg, "virtual-package")) == 0) {
|
||||
/* no virtual packages configured */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < cnt; i++) {
|
||||
cfg_t *sec = cfg_getnsec(xhp->cfg, "virtual-package", i);
|
||||
for (j = 0; j < cfg_size(sec, "targets"); j++) {
|
||||
tmp = NULL;
|
||||
vpkgver = cfg_getnstr(sec, "targets", j);
|
||||
if (strchr(vpkgver, '_') == NULL) {
|
||||
tmp = xbps_xasprintf("%s_1", vpkgver);
|
||||
vpkgname = xbps_pkg_name(tmp);
|
||||
free(tmp);
|
||||
} else {
|
||||
vpkgname = xbps_pkg_name(vpkgver);
|
||||
}
|
||||
if (vpkgname == NULL)
|
||||
break;
|
||||
if (bypattern) {
|
||||
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(xhp,
|
||||
"matched vpkg in conf `%s' for %s\n",
|
||||
pkg, vpkg);
|
||||
free(vpkgname);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return pkg;
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_rindex_get_virtualpkg(struct xbps_rindex *rpi, const char *pkg)
|
||||
{
|
||||
prop_array_t allkeys;
|
||||
prop_dictionary_keysym_t ksym;
|
||||
prop_dictionary_t pkgd = NULL;
|
||||
const char *vpkg;
|
||||
size_t i;
|
||||
bool found = false, bypattern = false;
|
||||
|
||||
if (xbps_pkgpattern_version(pkg))
|
||||
bypattern = true;
|
||||
|
||||
/* Try matching vpkg from configuration files */
|
||||
vpkg = vpkg_user_conf(rpi->xhp, pkg, bypattern);
|
||||
if (vpkg != NULL) {
|
||||
if (xbps_pkgpattern_version(vpkg))
|
||||
pkgd = match_pkg_by_pattern(rpi->repod, vpkg);
|
||||
else if (xbps_pkg_version(vpkg))
|
||||
pkgd = match_pkg_by_pkgver(rpi->repod, vpkg);
|
||||
else
|
||||
pkgd = prop_dictionary_get(rpi->repod, vpkg);
|
||||
|
||||
if (pkgd) {
|
||||
found = true;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/* ... otherwise match the first one in dictionary */
|
||||
allkeys = prop_dictionary_all_keys(rpi->repod);
|
||||
for (i = 0; i < prop_array_count(allkeys); i++) {
|
||||
ksym = prop_array_get(allkeys, i);
|
||||
pkgd = prop_dictionary_get_keysym(rpi->repod, ksym);
|
||||
if (xbps_match_virtual_pkg_in_dict(pkgd, pkg, bypattern)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
prop_object_release(allkeys);
|
||||
|
||||
out:
|
||||
if (found) {
|
||||
prop_dictionary_set_cstring_nocopy(pkgd,
|
||||
"repository", rpi->uri);
|
||||
return pkgd;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_rindex_get_pkg(struct xbps_rindex *rpi, const char *pkg)
|
||||
{
|
||||
prop_dictionary_t pkgd = NULL;
|
||||
|
||||
if (xbps_pkgpattern_version(pkg))
|
||||
pkgd = match_pkg_by_pattern(rpi->repod, pkg);
|
||||
else if (xbps_pkg_version(pkg))
|
||||
pkgd = match_pkg_by_pkgver(rpi->repod, pkg);
|
||||
else
|
||||
pkgd = prop_dictionary_get(rpi->repod, pkg);
|
||||
|
||||
if (pkgd) {
|
||||
prop_dictionary_set_cstring_nocopy(pkgd,
|
||||
"repository", rpi->uri);
|
||||
return pkgd;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
@ -32,11 +32,10 @@
|
||||
|
||||
static int
|
||||
store_dependency(struct xbps_handle *xhp,
|
||||
prop_array_t unsorted,
|
||||
prop_dictionary_t repo_pkgd,
|
||||
pkg_state_t repo_pkg_state,
|
||||
size_t *depth)
|
||||
pkg_state_t repo_pkg_state)
|
||||
{
|
||||
prop_array_t unsorted;
|
||||
int rv;
|
||||
/*
|
||||
* Overwrite package state in dictionary with same state than the
|
||||
@ -50,27 +49,11 @@ store_dependency(struct xbps_handle *xhp,
|
||||
if (!prop_dictionary_set_bool(repo_pkgd, "automatic-install", true))
|
||||
return EINVAL;
|
||||
/*
|
||||
* Add the dictionary into the array.
|
||||
* Add the dictionary into the unsorted queue.
|
||||
*/
|
||||
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
|
||||
if (!prop_array_add(unsorted, repo_pkgd))
|
||||
return EINVAL;
|
||||
prop_array_add(unsorted, repo_pkgd);
|
||||
xbps_dbg_printf_append(xhp, "(added)\n");
|
||||
|
||||
if (xhp->flags & XBPS_FLAG_DEBUG) {
|
||||
size_t x;
|
||||
const char *repo, *pkgver;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(repo_pkgd,
|
||||
"repository", &repo);
|
||||
prop_dictionary_get_cstring_nocopy(repo_pkgd,
|
||||
"pkgver", &pkgver);
|
||||
xbps_dbg_printf(xhp, " ");
|
||||
for (x = 0; x < *depth; x++)
|
||||
xbps_dbg_printf_append(xhp, " ");
|
||||
|
||||
xbps_dbg_printf_append(xhp, "%s: added into "
|
||||
"the transaction (%s).\n", pkgver, repo);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -164,16 +147,16 @@ out:
|
||||
|
||||
static int
|
||||
find_repo_deps(struct xbps_handle *xhp,
|
||||
prop_array_t unsorted, /* array of unsorted deps */
|
||||
prop_array_t pkg_rdeps_array, /* current pkg rundeps array */
|
||||
const char *curpkg, /* current pkgver */
|
||||
size_t *depth) /* max recursion depth */
|
||||
{
|
||||
prop_dictionary_t curpkgd, tmpd;
|
||||
prop_array_t curpkgrdeps, unsorted;
|
||||
prop_array_t curpkgrdeps;
|
||||
pkg_state_t state;
|
||||
size_t i, x;
|
||||
const char *reqpkg, *pkgver_q, *reason = NULL;
|
||||
char *pkgname;
|
||||
int rv = 0;
|
||||
|
||||
if (*depth >= MAX_DEPTH)
|
||||
@ -196,17 +179,10 @@ find_repo_deps(struct xbps_handle *xhp,
|
||||
* Pass 1: check if required dependency is already installed
|
||||
* and its version is fully matched.
|
||||
*/
|
||||
if (((pkgname = xbps_pkgpattern_name(reqpkg)) == NULL) &&
|
||||
((pkgname = xbps_pkg_name(reqpkg)) == NULL)) {
|
||||
rv = EINVAL;
|
||||
xbps_dbg_printf(xhp, "failed to get "
|
||||
"pkgname from `%s'!", reqpkg);
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* Look for a real package installed...
|
||||
*/
|
||||
tmpd = xbps_find_pkg_dict_installed(xhp, pkgname, false);
|
||||
tmpd = xbps_pkgdb_get_pkg(xhp, reqpkg);
|
||||
if (tmpd == NULL) {
|
||||
if (errno && errno != ENOENT) {
|
||||
/* error */
|
||||
@ -220,11 +196,7 @@ find_repo_deps(struct xbps_handle *xhp,
|
||||
* real package not installed, try looking for
|
||||
* a virtual package instead.
|
||||
*/
|
||||
tmpd = xbps_find_virtualpkg_dict_installed(xhp,
|
||||
pkgname, false);
|
||||
}
|
||||
free(pkgname);
|
||||
if (tmpd == NULL) {
|
||||
tmpd = xbps_pkgdb_get_virtualpkg(xhp, reqpkg);
|
||||
if (errno && errno != ENOENT) {
|
||||
/* error */
|
||||
rv = errno;
|
||||
@ -233,8 +205,10 @@ find_repo_deps(struct xbps_handle *xhp,
|
||||
reqpkg, strerror(errno));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tmpd == NULL) {
|
||||
/* Required pkgdep not installed */
|
||||
xbps_dbg_printf_append(xhp, "not installed. ");
|
||||
xbps_dbg_printf_append(xhp, "not installed ");
|
||||
reason = "install";
|
||||
state = XBPS_PKG_STATE_NOT_INSTALLED;
|
||||
} else {
|
||||
@ -282,7 +256,7 @@ find_repo_deps(struct xbps_handle *xhp,
|
||||
", must be configured.\n",
|
||||
pkgver_q);
|
||||
reason = "configure";
|
||||
} else {
|
||||
} else if (state == XBPS_PKG_STATE_INSTALLED) {
|
||||
/*
|
||||
* Package matches the dependency
|
||||
* pattern and is fully installed,
|
||||
@ -304,20 +278,11 @@ find_repo_deps(struct xbps_handle *xhp,
|
||||
* Pass 2: check if required dependency has been already
|
||||
* added in the transaction dictionary.
|
||||
*/
|
||||
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
|
||||
if (((curpkgd = xbps_find_pkg_in_array_by_pattern(xhp, unsorted, reqpkg, NULL)) == NULL) &&
|
||||
((curpkgd = xbps_find_virtualpkg_conf_in_array_by_pattern(xhp, unsorted, reqpkg)) == NULL) &&
|
||||
((curpkgd = xbps_find_virtualpkg_in_array_by_pattern(xhp, unsorted, reqpkg)) == NULL)) {
|
||||
/* error matching required pkgdep */
|
||||
if (errno && errno != ENOENT) {
|
||||
rv = errno;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if ((curpkgd = xbps_find_pkg_in_array(unsorted, reqpkg)) ||
|
||||
(curpkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, reqpkg))) {
|
||||
prop_dictionary_get_cstring_nocopy(curpkgd,
|
||||
"pkgver", &pkgver_q);
|
||||
xbps_dbg_printf_append(xhp, " (%s queued "
|
||||
"in transaction).\n", pkgver_q);
|
||||
xbps_dbg_printf_append(xhp, " (%s queued)\n", pkgver_q);
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
@ -325,9 +290,8 @@ find_repo_deps(struct xbps_handle *xhp,
|
||||
* If dependency does not match add pkg into the missing
|
||||
* deps array and pass to next one.
|
||||
*/
|
||||
if (((curpkgd = xbps_rpool_find_virtualpkg_conf(xhp, reqpkg, true)) == NULL) &&
|
||||
((curpkgd = xbps_rpool_find_pkg(xhp, reqpkg, true, true)) == NULL) &&
|
||||
((curpkgd = xbps_rpool_find_virtualpkg(xhp, reqpkg, true)) == NULL)) {
|
||||
if (((curpkgd = xbps_rpool_get_pkg(xhp, reqpkg)) == NULL) &&
|
||||
((curpkgd = xbps_rpool_get_virtualpkg(xhp, reqpkg)) == NULL)) {
|
||||
/* pkg not found, there was some error */
|
||||
if (errno && errno != ENOENT) {
|
||||
xbps_dbg_printf(xhp, "failed to find pkg "
|
||||
@ -359,12 +323,12 @@ find_repo_deps(struct xbps_handle *xhp,
|
||||
/*
|
||||
* Check if package has matched conflicts.
|
||||
*/
|
||||
xbps_pkg_find_conflicts(xhp, curpkgd);
|
||||
xbps_pkg_find_conflicts(xhp, unsorted, curpkgd);
|
||||
/*
|
||||
* Package is on repo, add it into the transaction dictionary.
|
||||
*/
|
||||
prop_dictionary_set_cstring_nocopy(curpkgd, "transaction", reason);
|
||||
rv = store_dependency(xhp, curpkgd, state, depth);
|
||||
rv = store_dependency(xhp, unsorted, curpkgd, state);
|
||||
if (rv != 0) {
|
||||
xbps_dbg_printf(xhp, "store_dependency failed for "
|
||||
"`%s': %s\n", reqpkg, strerror(rv));
|
||||
@ -389,7 +353,8 @@ find_repo_deps(struct xbps_handle *xhp,
|
||||
* Recursively find rundeps for current pkg dictionary.
|
||||
*/
|
||||
(*depth)++;
|
||||
rv = find_repo_deps(xhp, curpkgrdeps, pkgver_q, depth);
|
||||
rv = find_repo_deps(xhp, unsorted, curpkgrdeps,
|
||||
pkgver_q, depth);
|
||||
if (rv != 0) {
|
||||
xbps_dbg_printf(xhp, "Error checking %s for rundeps: %s\n",
|
||||
reqpkg, strerror(rv));
|
||||
@ -402,7 +367,8 @@ find_repo_deps(struct xbps_handle *xhp,
|
||||
}
|
||||
|
||||
int HIDDEN
|
||||
xbps_repository_find_pkg_deps(struct xbps_handle *xhp,
|
||||
xbps_repository_find_deps(struct xbps_handle *xhp,
|
||||
prop_array_t unsorted,
|
||||
prop_dictionary_t repo_pkgd)
|
||||
{
|
||||
prop_array_t pkg_rdeps;
|
||||
@ -421,5 +387,5 @@ xbps_repository_find_pkg_deps(struct xbps_handle *xhp,
|
||||
* This will find direct and indirect deps, if any of them is not
|
||||
* there it will be added into the missing_deps array.
|
||||
*/
|
||||
return find_repo_deps(xhp, pkg_rdeps, pkgver, &depth);
|
||||
return find_repo_deps(xhp, unsorted, pkg_rdeps, pkgver, &depth);
|
||||
}
|
@ -59,7 +59,6 @@ xbps_get_remote_repo_string(const char *uri)
|
||||
* becomes:
|
||||
*
|
||||
* http___nocturno_local_8080_repo_x86_64
|
||||
*
|
||||
*/
|
||||
if (url->port != 0)
|
||||
p = xbps_xasprintf("%s://%s:%u%s", url->scheme,
|
||||
@ -81,10 +80,8 @@ xbps_get_remote_repo_string(const char *uri)
|
||||
* Returns -1 on error, 0 if transfer was not necessary (local/remote
|
||||
* size and/or mtime match) and 1 if downloaded successfully.
|
||||
*/
|
||||
int
|
||||
xbps_repository_sync_pkg_index(struct xbps_handle *xhp,
|
||||
const char *uri,
|
||||
const char *plistf)
|
||||
int HIDDEN
|
||||
xbps_rindex_sync(struct xbps_handle *xhp, const char *uri, const char *plistf)
|
||||
{
|
||||
prop_array_t array;
|
||||
const char *fetchstr = NULL;
|
||||
@ -95,7 +92,7 @@ xbps_repository_sync_pkg_index(struct xbps_handle *xhp,
|
||||
rpidx = uri_fixedp = lrepodir = lrepofile = NULL;
|
||||
|
||||
/* ignore non remote repositories */
|
||||
if (!xbps_check_is_repository_uri_remote(uri))
|
||||
if (!xbps_repository_is_remote(uri))
|
||||
return 0;
|
||||
|
||||
uri_fixedp = xbps_get_remote_repo_string(uri);
|
@ -42,8 +42,7 @@
|
||||
int HIDDEN
|
||||
xbps_rpool_init(struct xbps_handle *xhp)
|
||||
{
|
||||
prop_dictionary_t d = NULL;
|
||||
prop_array_t array;
|
||||
prop_dictionary_t repod, d = NULL;
|
||||
size_t i, ntotal = 0, nmissing = 0;
|
||||
const char *repouri;
|
||||
char *plist;
|
||||
@ -75,30 +74,30 @@ xbps_rpool_init(struct xbps_handle *xhp)
|
||||
nmissing++;
|
||||
continue;
|
||||
}
|
||||
array = prop_array_internalize_from_zfile(plist);
|
||||
repod = prop_dictionary_internalize_from_zfile(plist);
|
||||
free(plist);
|
||||
assert(array);
|
||||
assert(repod);
|
||||
/*
|
||||
* Register repository into the array.
|
||||
*/
|
||||
if ((d = prop_dictionary_create()) == NULL) {
|
||||
rv = ENOMEM;
|
||||
prop_object_release(array);
|
||||
prop_object_release(repod);
|
||||
goto out;
|
||||
}
|
||||
if (!prop_dictionary_set_cstring_nocopy(d, "uri", repouri)) {
|
||||
rv = EINVAL;
|
||||
prop_object_release(array);
|
||||
prop_object_release(repod);
|
||||
prop_object_release(d);
|
||||
goto out;
|
||||
}
|
||||
if (!prop_dictionary_set(d, "index", array)) {
|
||||
if (!prop_dictionary_set(d, "index", repod)) {
|
||||
rv = EINVAL;
|
||||
prop_object_release(array);
|
||||
prop_object_release(repod);
|
||||
prop_object_release(d);
|
||||
goto out;
|
||||
}
|
||||
prop_object_release(array);
|
||||
prop_object_release(repod);
|
||||
if (!prop_array_add(xhp->repo_pool, d)) {
|
||||
rv = EINVAL;
|
||||
prop_object_release(d);
|
||||
@ -161,7 +160,7 @@ xbps_rpool_sync(struct xbps_handle *xhp, const char *file, const char *uri)
|
||||
if (uri && strcmp(repouri, uri))
|
||||
continue;
|
||||
|
||||
if (xbps_repository_sync_pkg_index(xhp, repouri, file) == -1) {
|
||||
if (xbps_rindex_sync(xhp, repouri, file) == -1) {
|
||||
xbps_dbg_printf(xhp,
|
||||
"[rpool] `%s' failed to fetch `%s': %s\n",
|
||||
repouri, file,
|
||||
@ -175,11 +174,11 @@ xbps_rpool_sync(struct xbps_handle *xhp, const char *file, const char *uri)
|
||||
|
||||
int
|
||||
xbps_rpool_foreach(struct xbps_handle *xhp,
|
||||
int (*fn)(struct xbps_handle *, struct xbps_rpool_index *, void *, bool *),
|
||||
int (*fn)(struct xbps_rindex *, void *, bool *),
|
||||
void *arg)
|
||||
{
|
||||
prop_dictionary_t d;
|
||||
struct xbps_rpool_index rpi;
|
||||
struct xbps_rindex rpi;
|
||||
size_t i;
|
||||
int rv = 0;
|
||||
bool done = false;
|
||||
@ -201,8 +200,9 @@ xbps_rpool_foreach(struct xbps_handle *xhp,
|
||||
for (i = 0; i < prop_array_count(xhp->repo_pool); i++) {
|
||||
d = prop_array_get(xhp->repo_pool, i);
|
||||
prop_dictionary_get_cstring_nocopy(d, "uri", &rpi.uri);
|
||||
rpi.repo = prop_dictionary_get(d, "index");
|
||||
rv = (*fn)(xhp, &rpi, arg, &done);
|
||||
rpi.repod = prop_dictionary_get(d, "index");
|
||||
rpi.xhp = xhp;
|
||||
rv = (*fn)(&rpi, arg, &done);
|
||||
if (rv != 0 || done)
|
||||
break;
|
||||
}
|
226
lib/rpool_get.c
Normal file
226
lib/rpool_get.c
Normal file
@ -0,0 +1,226 @@
|
||||
/*-
|
||||
* Copyright (c) 2009-2012 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 <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "xbps_api_impl.h"
|
||||
|
||||
/**
|
||||
* @file lib/rpool_get.c
|
||||
* @brief Repository pool functions
|
||||
* @defgroup repopool Repository pool functions
|
||||
*/
|
||||
struct rpool_fpkg {
|
||||
prop_dictionary_t pkgd;
|
||||
const char *pattern;
|
||||
const char *bestpkgver;
|
||||
bool best;
|
||||
};
|
||||
|
||||
static int
|
||||
find_virtualpkg_cb(struct xbps_rindex *rpi, void *arg, bool *done)
|
||||
{
|
||||
struct rpool_fpkg *rpf = arg;
|
||||
|
||||
rpf->pkgd = xbps_rindex_get_virtualpkg(rpi, rpf->pattern);
|
||||
if (rpf->pkgd) {
|
||||
/* found */
|
||||
*done = true;
|
||||
return 0;
|
||||
}
|
||||
/* not found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
find_pkg_cb(struct xbps_rindex *rpi, void *arg, bool *done)
|
||||
{
|
||||
struct rpool_fpkg *rpf = arg;
|
||||
|
||||
rpf->pkgd = xbps_rindex_get_pkg(rpi, rpf->pattern);
|
||||
if (rpf->pkgd) {
|
||||
/* found */
|
||||
*done = true;
|
||||
return 0;
|
||||
}
|
||||
/* Not found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
find_best_pkg_cb(struct xbps_rindex *rpi, void *arg, bool *done)
|
||||
{
|
||||
struct rpool_fpkg *rpf = arg;
|
||||
prop_dictionary_t pkgd;
|
||||
const char *repopkgver;
|
||||
|
||||
(void)done;
|
||||
|
||||
pkgd = xbps_rindex_get_pkg(rpi, rpf->pattern);
|
||||
if (pkgd == NULL) {
|
||||
if (errno && errno != ENOENT)
|
||||
return errno;
|
||||
|
||||
xbps_dbg_printf(rpi->xhp,
|
||||
"[rpool] Package '%s' not found in repository "
|
||||
"'%s'.\n", rpf->pattern, rpi->uri);
|
||||
return 0;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
"pkgver", &repopkgver);
|
||||
if (rpf->bestpkgver == NULL) {
|
||||
xbps_dbg_printf(rpi->xhp,
|
||||
"[rpool] Found best match '%s' (%s).\n",
|
||||
repopkgver, rpi->uri);
|
||||
rpf->pkgd = pkgd;
|
||||
prop_dictionary_set_cstring_nocopy(rpf->pkgd,
|
||||
"repository", rpi->uri);
|
||||
rpf->bestpkgver = repopkgver;
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Compare current stored version against new
|
||||
* version from current package in repository.
|
||||
*/
|
||||
if (xbps_cmpver(repopkgver, rpf->bestpkgver) == 1) {
|
||||
xbps_dbg_printf(rpi->xhp,
|
||||
"[rpool] Found best match '%s' (%s).\n",
|
||||
repopkgver, rpi->uri);
|
||||
rpf->pkgd = pkgd;
|
||||
prop_dictionary_set_cstring_nocopy(rpf->pkgd,
|
||||
"repository", rpi->uri);
|
||||
rpf->bestpkgver = repopkgver;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
BEST_PKG = 1,
|
||||
VIRTUAL_PKG,
|
||||
REAL_PKG
|
||||
} pkg_repo_type_t;
|
||||
|
||||
static prop_dictionary_t
|
||||
repo_find_pkg(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
pkg_repo_type_t type)
|
||||
{
|
||||
struct rpool_fpkg rpf;
|
||||
int rv = 0;
|
||||
|
||||
rpf.pattern = pkg;
|
||||
rpf.pkgd = NULL;
|
||||
rpf.bestpkgver = NULL;
|
||||
|
||||
switch (type) {
|
||||
case BEST_PKG:
|
||||
/*
|
||||
* Find best pkg version.
|
||||
*/
|
||||
rv = xbps_rpool_foreach(xhp, find_best_pkg_cb, &rpf);
|
||||
break;
|
||||
case VIRTUAL_PKG:
|
||||
/*
|
||||
* Find virtual pkg.
|
||||
*/
|
||||
rv = xbps_rpool_foreach(xhp, find_virtualpkg_cb, &rpf);
|
||||
break;
|
||||
case REAL_PKG:
|
||||
/*
|
||||
* Find real pkg.
|
||||
*/
|
||||
rv = xbps_rpool_foreach(xhp, find_pkg_cb, &rpf);
|
||||
break;
|
||||
}
|
||||
if (rv != 0) {
|
||||
errno = rv;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return rpf.pkgd;
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_rpool_get_virtualpkg(struct xbps_handle *xhp, const char *pkg)
|
||||
{
|
||||
assert(xhp);
|
||||
assert(pkg);
|
||||
|
||||
return repo_find_pkg(xhp, pkg, VIRTUAL_PKG);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_rpool_get_pkg(struct xbps_handle *xhp, const char *pkg)
|
||||
{
|
||||
assert(xhp);
|
||||
assert(pkg);
|
||||
|
||||
if (!xbps_pkgpattern_version(pkg) && !xbps_pkg_version(pkg))
|
||||
return repo_find_pkg(xhp, pkg, BEST_PKG);
|
||||
|
||||
return repo_find_pkg(xhp, pkg, REAL_PKG);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_rpool_get_pkg_plist(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
const char *plistf)
|
||||
{
|
||||
prop_dictionary_t pkgd = NULL, plistd = NULL;
|
||||
char *url;
|
||||
|
||||
assert(pkg != NULL);
|
||||
assert(plistf != NULL);
|
||||
/*
|
||||
* Iterate over the the repository pool and search for a plist file
|
||||
* in the binary package matching `pattern'. The plist file will be
|
||||
* internalized to a proplib dictionary.
|
||||
*
|
||||
* The first repository that has it wins and the loop is stopped.
|
||||
* This will work locally and remotely, thanks to libarchive and
|
||||
* libfetch!
|
||||
*/
|
||||
pkgd = xbps_rpool_get_pkg(xhp, pkg);
|
||||
if (pkgd == NULL)
|
||||
goto out;
|
||||
|
||||
url = xbps_repository_pkg_path(xhp, pkgd);
|
||||
if (url == NULL) {
|
||||
errno = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
plistd = xbps_get_pkg_plist_from_binpkg(url, plistf);
|
||||
free(url);
|
||||
|
||||
out:
|
||||
if (plistd == NULL)
|
||||
errno = ENOENT;
|
||||
|
||||
return plistd;
|
||||
}
|
@ -79,7 +79,7 @@ check_binpkgs_hash(struct xbps_handle *xhp, prop_object_iterator_t iter)
|
||||
prop_dictionary_get_cstring_nocopy(obj,
|
||||
"filename-sha256", &sha256);
|
||||
|
||||
binfile = xbps_path_from_repository_uri(xhp, obj, repoloc);
|
||||
binfile = xbps_repository_pkg_path(xhp, obj);
|
||||
if (binfile == NULL) {
|
||||
rv = EINVAL;
|
||||
break;
|
||||
@ -124,7 +124,7 @@ download_binpkgs(struct xbps_handle *xhp, prop_object_iterator_t iter)
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "filename", &filen);
|
||||
|
||||
binfile = xbps_path_from_repository_uri(xhp, obj, repoloc);
|
||||
binfile = xbps_repository_pkg_path(xhp, obj);
|
||||
if (binfile == NULL) {
|
||||
rv = EINVAL;
|
||||
break;
|
||||
@ -199,7 +199,6 @@ xbps_transaction_commit(struct xbps_handle *xhp)
|
||||
{
|
||||
prop_object_t obj;
|
||||
prop_object_iterator_t iter;
|
||||
size_t i;
|
||||
const char *pkgname, *version, *pkgver, *tract;
|
||||
int rv = 0;
|
||||
bool update, install, sr;
|
||||
@ -227,16 +226,7 @@ xbps_transaction_commit(struct xbps_handle *xhp)
|
||||
*/
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_TRANS_RUN, 0, NULL, NULL, NULL);
|
||||
|
||||
i = 0;
|
||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
||||
if ((xhp->transaction_frequency_flush > 0) &&
|
||||
(++i >= xhp->transaction_frequency_flush)) {
|
||||
rv = xbps_pkgdb_update(xhp, true);
|
||||
if (rv != 0 && rv != ENOENT)
|
||||
goto out;
|
||||
|
||||
i = 0;
|
||||
}
|
||||
update = false;
|
||||
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||
@ -252,7 +242,7 @@ xbps_transaction_commit(struct xbps_handle *xhp)
|
||||
prop_dictionary_get_bool(obj, "remove-and-update",
|
||||
&update);
|
||||
prop_dictionary_get_bool(obj, "softreplace", &sr);
|
||||
rv = xbps_remove_pkg(xhp, pkgname, version, update, sr);
|
||||
rv = xbps_remove_pkg(xhp, pkgver, update, sr);
|
||||
if (rv != 0) {
|
||||
xbps_dbg_printf(xhp, "[trans] failed to "
|
||||
"remove %s-%s\n", pkgname, version);
|
||||
@ -281,8 +271,7 @@ xbps_transaction_commit(struct xbps_handle *xhp)
|
||||
*/
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UPDATE, 0,
|
||||
pkgname, version, NULL);
|
||||
rv = xbps_remove_pkg(xhp, pkgname, version,
|
||||
true, false);
|
||||
rv = xbps_remove_pkg(xhp, pkgver, true, false);
|
||||
if (rv != 0) {
|
||||
xbps_set_cb_state(xhp,
|
||||
XBPS_STATE_UPDATE_FAIL,
|
||||
@ -305,34 +294,22 @@ xbps_transaction_commit(struct xbps_handle *xhp)
|
||||
/*
|
||||
* Register package.
|
||||
*/
|
||||
if ((rv = xbps_register_pkg(xhp, obj, false)) != 0)
|
||||
if ((rv = xbps_register_pkg(xhp, obj, true)) != 0)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
prop_object_iterator_reset(iter);
|
||||
|
||||
/* force a flush now packages were removed/unpacked */
|
||||
if ((rv = xbps_pkgdb_update(xhp, true)) != 0)
|
||||
goto out;
|
||||
|
||||
/* if there are no packages to install or update we are done */
|
||||
if (!update && !install)
|
||||
goto out;
|
||||
|
||||
/*
|
||||
* Configure all unpacked packages.
|
||||
*/
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_TRANS_CONFIGURE, 0, NULL, NULL, NULL);
|
||||
|
||||
i = 0;
|
||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
||||
if (xhp->transaction_frequency_flush > 0 &&
|
||||
++i >= xhp->transaction_frequency_flush) {
|
||||
if ((rv = xbps_pkgdb_update(xhp, true)) != 0)
|
||||
goto out;
|
||||
|
||||
i = 0;
|
||||
}
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
|
||||
if ((strcmp(tract, "remove") == 0) ||
|
||||
(strcmp(tract, "configure") == 0))
|
||||
@ -344,9 +321,12 @@ xbps_transaction_commit(struct xbps_handle *xhp)
|
||||
if (strcmp(tract, "update") == 0)
|
||||
update = true;
|
||||
|
||||
rv = xbps_configure_pkg(xhp, pkgname, false, update, false);
|
||||
if (rv != 0)
|
||||
rv = xbps_configure_pkg(xhp, pkgname, false, update, true);
|
||||
if (rv != 0) {
|
||||
xbps_dbg_printf(xhp, "%s: configure failed for "
|
||||
"%s-%s: %s\n", pkgname, version, strerror(rv));
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
* Notify client callback when a package has been
|
||||
* installed or updated.
|
||||
@ -360,8 +340,6 @@ xbps_transaction_commit(struct xbps_handle *xhp)
|
||||
}
|
||||
}
|
||||
|
||||
/* Force a flush now that packages are configured */
|
||||
rv = xbps_pkgdb_update(xhp, true);
|
||||
out:
|
||||
prop_object_iterator_release(iter);
|
||||
|
||||
|
@ -97,7 +97,7 @@ compute_transaction_stats(struct xbps_handle *xhp)
|
||||
*/
|
||||
if ((strcmp(tract, "remove") == 0) ||
|
||||
(strcmp(tract, "update") == 0)) {
|
||||
pkg_metad = xbps_metadir_get_pkgd(xhp, pkgname);
|
||||
pkg_metad = xbps_pkgdb_get_pkg_metadata(xhp, pkgname);
|
||||
if (pkg_metad == NULL)
|
||||
continue;
|
||||
prop_dictionary_get_uint64(pkg_metad,
|
||||
@ -109,7 +109,7 @@ compute_transaction_stats(struct xbps_handle *xhp)
|
||||
prop_dictionary_get_uint64(obj,
|
||||
"installed_size", &tsize);
|
||||
instsize += tsize;
|
||||
if (xbps_check_is_repository_uri_remote(repo)) {
|
||||
if (xbps_repository_is_remote(repo)) {
|
||||
prop_dictionary_get_uint64(obj,
|
||||
"filename-size", &tsize);
|
||||
dlsize += tsize;
|
||||
@ -263,7 +263,7 @@ xbps_transaction_prepare(struct xbps_handle *xhp)
|
||||
/*
|
||||
* Sort package dependencies if necessary.
|
||||
*/
|
||||
if ((rv = xbps_transaction_sort_pkg_deps(xhp)) != 0) {
|
||||
if ((rv = xbps_transaction_sort(xhp)) != 0) {
|
||||
prop_object_release(xhp->transd);
|
||||
xhp->transd = NULL;
|
||||
return rv;
|
||||
|
@ -58,8 +58,7 @@ enum {
|
||||
};
|
||||
|
||||
static int
|
||||
trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool bypattern,
|
||||
bool best, bool exact, int action)
|
||||
trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action)
|
||||
{
|
||||
prop_dictionary_t pkg_pkgdb, pkg_repod;
|
||||
prop_array_t unsorted;
|
||||
@ -74,27 +73,17 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool bypattern,
|
||||
*/
|
||||
if (action == TRANS_INSTALL) {
|
||||
reason = "install";
|
||||
if (exact) {
|
||||
pkg_repod = xbps_rpool_find_pkg_exact(xhp, pkg);
|
||||
if (pkg_repod == NULL) {
|
||||
if (((pkg_repod = xbps_rpool_get_pkg(xhp, pkg)) == NULL) &&
|
||||
((pkg_repod = xbps_rpool_get_virtualpkg(xhp, pkg)) == NULL)) {
|
||||
/* not found */
|
||||
return ENOENT;
|
||||
}
|
||||
} else {
|
||||
if (((pkg_repod = xbps_rpool_find_pkg(xhp, pkg, bypattern, best)) == NULL) &&
|
||||
((pkg_repod = xbps_rpool_find_virtualpkg_conf(xhp, pkg, bypattern)) == NULL) &&
|
||||
((pkg_repod = xbps_rpool_find_virtualpkg(xhp, pkg, bypattern)) == NULL)) {
|
||||
/* not found */
|
||||
return ENOENT;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((pkg_pkgdb = xbps_pkgdb_get_pkgd(xhp, pkg, false)) == NULL)
|
||||
if ((pkg_pkgdb = xbps_pkgdb_get_pkg(xhp, pkg)) == NULL)
|
||||
return ENODEV;
|
||||
|
||||
reason = "update";
|
||||
pkg_repod = xbps_rpool_find_pkg(xhp, pkg, false, true);
|
||||
if (pkg_repod == NULL) {
|
||||
if ((pkg_repod = xbps_rpool_get_pkg(xhp, pkg)) == NULL) {
|
||||
/* not found */
|
||||
return ENOENT;
|
||||
}
|
||||
@ -123,32 +112,25 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool bypattern,
|
||||
if ((rv = xbps_transaction_init(xhp)) != 0)
|
||||
return rv;
|
||||
|
||||
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
|
||||
/*
|
||||
* Find out if package has matched conflicts.
|
||||
*/
|
||||
xbps_pkg_find_conflicts(xhp, pkg_repod);
|
||||
xbps_pkg_find_conflicts(xhp, unsorted, pkg_repod);
|
||||
|
||||
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
|
||||
if (unsorted == NULL)
|
||||
return EINVAL;
|
||||
/*
|
||||
* Find out if package being updated matches the one already
|
||||
* in transaction, in that case ignore it.
|
||||
*/
|
||||
if (action == TRANS_UPDATE) {
|
||||
if (xbps_find_pkg_in_array_by_pkgver(xhp,
|
||||
unsorted, repopkgver, NULL)) {
|
||||
if (xbps_find_pkg_in_array(unsorted, repopkgver)) {
|
||||
xbps_dbg_printf(xhp, "[update] `%s' already queued in "
|
||||
"transaction.\n", repopkgver);
|
||||
return EEXIST;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Prepare required package dependencies and add them into the
|
||||
* "unsorted" array in transaction dictionary.
|
||||
*/
|
||||
if ((rv = xbps_repository_find_pkg_deps(xhp, pkg_repod)) != 0)
|
||||
if ((rv = xbps_repository_find_deps(xhp, unsorted, pkg_repod)) != 0)
|
||||
return rv;
|
||||
/*
|
||||
* Set package state in dictionary with same state than the
|
||||
@ -178,7 +160,7 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool bypattern,
|
||||
|
||||
/*
|
||||
* Add the pkg dictionary from repository's index dictionary into
|
||||
* the "unsorted" array in transaction dictionary.
|
||||
* the "unsorted" queue.
|
||||
*/
|
||||
if (!prop_array_add(unsorted, pkg_repod))
|
||||
return EINVAL;
|
||||
@ -219,8 +201,7 @@ xbps_transaction_update_packages(struct xbps_handle *xhp)
|
||||
foundhold = false;
|
||||
continue;
|
||||
}
|
||||
rv = trans_find_pkg(xhp, pkgname, false, true,
|
||||
false, TRANS_UPDATE);
|
||||
rv = trans_find_pkg(xhp, pkgname, TRANS_UPDATE);
|
||||
if (rv == 0)
|
||||
newpkg_found = true;
|
||||
else if (rv == ENOENT || rv == EEXIST || rv == ENODEV) {
|
||||
@ -236,42 +217,20 @@ xbps_transaction_update_packages(struct xbps_handle *xhp)
|
||||
}
|
||||
|
||||
int
|
||||
xbps_transaction_update_pkg(struct xbps_handle *xhp, const char *pkgname)
|
||||
xbps_transaction_update_pkg(struct xbps_handle *xhp, const char *pkg)
|
||||
{
|
||||
return trans_find_pkg(xhp, pkgname, false, true, false, TRANS_UPDATE);
|
||||
return trans_find_pkg(xhp, pkg, TRANS_UPDATE);
|
||||
}
|
||||
|
||||
int
|
||||
xbps_transaction_install_pkg(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
xbps_transaction_install_pkg(struct xbps_handle *xhp, const char *pkg,
|
||||
bool reinstall)
|
||||
{
|
||||
prop_dictionary_t pkgd = NULL;
|
||||
pkg_state_t state;
|
||||
char *pkgname;
|
||||
bool bypattern, best, exact;
|
||||
|
||||
if (xbps_pkgpattern_version(pkg)) {
|
||||
bypattern = true;
|
||||
best = false;
|
||||
exact = false;
|
||||
} else if ((pkgname = xbps_pkg_name(pkg)) != NULL) {
|
||||
exact = true;
|
||||
bypattern = false;
|
||||
best = false;
|
||||
} else {
|
||||
exact = false;
|
||||
bypattern = false;
|
||||
best = true;
|
||||
}
|
||||
|
||||
if (exact) {
|
||||
pkgd = xbps_pkgdb_get_pkgd(xhp, pkgname, false);
|
||||
free(pkgname);
|
||||
} else
|
||||
pkgd = xbps_pkgdb_get_pkgd(xhp, pkg, bypattern);
|
||||
|
||||
if (pkgd) {
|
||||
if ((pkgd = xbps_pkgdb_get_pkg(xhp, pkg)) ||
|
||||
(pkgd = xbps_pkgdb_get_virtualpkg(xhp, pkg))) {
|
||||
if (xbps_pkg_state_dictionary(pkgd, &state) != 0)
|
||||
return EINVAL;
|
||||
if ((state == XBPS_PKG_STATE_INSTALLED) && !reinstall) {
|
||||
@ -280,7 +239,7 @@ xbps_transaction_install_pkg(struct xbps_handle *xhp,
|
||||
}
|
||||
}
|
||||
|
||||
return trans_find_pkg(xhp, pkg, bypattern, best, exact, TRANS_INSTALL);
|
||||
return trans_find_pkg(xhp, pkg, TRANS_INSTALL);
|
||||
}
|
||||
|
||||
int
|
||||
@ -289,7 +248,7 @@ xbps_transaction_remove_pkg(struct xbps_handle *xhp,
|
||||
bool recursive)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
prop_array_t orphans, orphans_pkg, unsorted, reqby;
|
||||
prop_array_t unsorted, orphans, orphans_pkg, reqby;
|
||||
prop_object_t obj;
|
||||
const char *pkgver;
|
||||
size_t count;
|
||||
@ -297,7 +256,7 @@ xbps_transaction_remove_pkg(struct xbps_handle *xhp,
|
||||
|
||||
assert(pkgname != NULL);
|
||||
|
||||
if ((pkgd = xbps_pkgdb_get_pkgd(xhp, pkgname, false)) == NULL) {
|
||||
if ((pkgd = xbps_pkgdb_get_pkg(xhp, pkgname)) == NULL) {
|
||||
/* pkg not installed */
|
||||
return ENOENT;
|
||||
}
|
||||
@ -308,6 +267,7 @@ xbps_transaction_remove_pkg(struct xbps_handle *xhp,
|
||||
return rv;
|
||||
|
||||
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
|
||||
|
||||
if (!recursive)
|
||||
goto rmpkg;
|
||||
/*
|
||||
@ -334,7 +294,7 @@ xbps_transaction_remove_pkg(struct xbps_handle *xhp,
|
||||
prop_object_release(orphans);
|
||||
rmpkg:
|
||||
/*
|
||||
* Add pkg dictionary into the unsorted_deps array.
|
||||
* Add pkg dictionary into the transaction unsorted queue.
|
||||
*/
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
|
||||
prop_dictionary_set_cstring_nocopy(pkgd, "transaction", "remove");
|
||||
@ -376,21 +336,22 @@ xbps_transaction_autoremove_pkgs(struct xbps_handle *xhp)
|
||||
*/
|
||||
if ((rv = xbps_transaction_init(xhp)) != 0)
|
||||
goto out;
|
||||
/*
|
||||
* Add pkg orphan dictionary into the unsorted_deps array.
|
||||
*/
|
||||
|
||||
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
|
||||
/*
|
||||
* Add pkg orphan dictionary into the transaction unsorted queue.
|
||||
*/
|
||||
while (count--) {
|
||||
obj = prop_array_get(orphans, count);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
||||
prop_dictionary_set_cstring_nocopy(obj,
|
||||
"transaction", "remove");
|
||||
prop_array_add(unsorted, obj);
|
||||
xbps_dbg_printf(xhp, "%s: added into transaction (remove).\n",
|
||||
pkgver);
|
||||
xbps_dbg_printf(xhp, "%s: added (remove).\n", pkgver);
|
||||
}
|
||||
out:
|
||||
if (orphans != NULL)
|
||||
prop_object_release(orphans);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@
|
||||
int HIDDEN
|
||||
xbps_transaction_package_replace(struct xbps_handle *xhp)
|
||||
{
|
||||
prop_array_t replaces, instd_reqby, transd_unsorted;
|
||||
prop_array_t replaces, instd_reqby, unsorted;
|
||||
prop_dictionary_t instd, pkg_repod, reppkgd, filesd;
|
||||
prop_object_t obj;
|
||||
prop_object_iterator_t iter;
|
||||
@ -45,10 +45,10 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
||||
bool instd_auto, sr;
|
||||
size_t idx;
|
||||
|
||||
transd_unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
|
||||
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
|
||||
|
||||
for (idx = 0; idx < prop_array_count(transd_unsorted); idx++) {
|
||||
pkg_repod = prop_array_get(transd_unsorted, idx);
|
||||
for (idx = 0; idx < prop_array_count(unsorted); idx++) {
|
||||
pkg_repod = prop_array_get(unsorted, idx);
|
||||
replaces = prop_dictionary_get(pkg_repod, "replaces");
|
||||
if (replaces == NULL || prop_array_count(replaces) == 0)
|
||||
continue;
|
||||
@ -64,15 +64,13 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
||||
* Find the installed package that matches the pattern
|
||||
* to be replaced.
|
||||
*/
|
||||
instd =
|
||||
xbps_find_pkg_dict_installed(xhp, pattern, true);
|
||||
instd = xbps_pkgdb_get_pkg(xhp, pattern);
|
||||
if (instd == NULL) {
|
||||
/*
|
||||
* No package installed has been matched,
|
||||
* try looking for a virtual package.
|
||||
*/
|
||||
instd = xbps_find_virtualpkg_dict_installed(
|
||||
xhp, pattern, true);
|
||||
instd = xbps_pkgdb_get_virtualpkg(xhp, pattern);
|
||||
if (instd == NULL)
|
||||
continue;
|
||||
}
|
||||
@ -103,9 +101,8 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
||||
* package that should be replaced is also in the
|
||||
* transaction and it's going to be updated.
|
||||
*/
|
||||
reppkgd = xbps_find_pkg_in_array_by_name(
|
||||
xhp, transd_unsorted, curpkgname, NULL);
|
||||
if (reppkgd) {
|
||||
if ((reppkgd = xbps_find_pkg_in_array(unsorted, curpkgname)) ||
|
||||
(reppkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, curpkgname))) {
|
||||
xbps_dbg_printf(xhp,
|
||||
"found replaced pkg "
|
||||
"in transaction\n");
|
||||
@ -120,7 +117,7 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
||||
"automatic-install", instd_auto);
|
||||
prop_dictionary_set_bool(reppkgd,
|
||||
"skip-obsoletes", true);
|
||||
xbps_array_replace_dict_by_name(transd_unsorted,
|
||||
xbps_array_replace_dict_by_name(unsorted,
|
||||
reppkgd, curpkgname);
|
||||
}
|
||||
/*
|
||||
@ -182,10 +179,7 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
||||
*/
|
||||
prop_dictionary_set_cstring_nocopy(instd,
|
||||
"transaction", "remove");
|
||||
if (!xbps_add_obj_to_array(transd_unsorted, instd)) {
|
||||
prop_object_iterator_release(iter);
|
||||
return EINVAL;
|
||||
}
|
||||
prop_array_add(unsorted, instd);
|
||||
}
|
||||
prop_object_iterator_release(iter);
|
||||
}
|
||||
|
@ -50,31 +50,37 @@ struct pkgdep {
|
||||
TAILQ_ENTRY(pkgdep) pkgdep_entries;
|
||||
prop_dictionary_t d;
|
||||
char *name;
|
||||
const char *trans;
|
||||
};
|
||||
|
||||
static TAILQ_HEAD(pkgdep_head, pkgdep) pkgdep_list =
|
||||
TAILQ_HEAD_INITIALIZER(pkgdep_list);
|
||||
|
||||
static struct pkgdep *
|
||||
pkgdep_find(const char *name, const char *trans)
|
||||
pkgdep_find(const char *pkg)
|
||||
{
|
||||
struct pkgdep *pd = NULL, *pd_new = NULL;
|
||||
const char *pkgver, *tract;
|
||||
|
||||
TAILQ_FOREACH_SAFE(pd, &pkgdep_list, pkgdep_entries, pd_new) {
|
||||
if (strcmp(pd->name, name) == 0) {
|
||||
if (trans == NULL)
|
||||
return pd;
|
||||
if (strcmp(pd->trans, trans) == 0)
|
||||
return pd;
|
||||
}
|
||||
if (pd->d == NULL)
|
||||
if (pd->d == NULL) {
|
||||
/* ignore entries without dictionary */
|
||||
continue;
|
||||
if (xbps_match_virtual_pkg_in_dict(pd->d, name, false)) {
|
||||
if (trans && pd->trans &&
|
||||
(strcmp(trans, pd->trans) == 0))
|
||||
return pd;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(pd->d,
|
||||
"transaction", &tract);
|
||||
/* ignore pkgs to be removed */
|
||||
if (strcmp(tract, "remove") == 0)
|
||||
continue;
|
||||
/* simple match */
|
||||
prop_dictionary_get_cstring_nocopy(pd->d, "pkgver", &pkgver);
|
||||
if (strcmp(pkgver, pkg) == 0)
|
||||
return pd;
|
||||
/* pkg expression match */
|
||||
if (xbps_pkgpattern_match(pkgver, pkg))
|
||||
return pd;
|
||||
/* virtualpkg expression match */
|
||||
if (xbps_match_virtual_pkg_in_dict(pd->d, pkg, true))
|
||||
return pd;
|
||||
}
|
||||
|
||||
/* not found */
|
||||
@ -82,25 +88,35 @@ pkgdep_find(const char *name, const char *trans)
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
pkgdep_find_idx(const char *name, const char *trans)
|
||||
pkgdep_find_idx(const char *pkg)
|
||||
{
|
||||
struct pkgdep *pd, *pd_new;
|
||||
ssize_t idx = 0;
|
||||
const char *pkgver, *tract;
|
||||
|
||||
TAILQ_FOREACH_SAFE(pd, &pkgdep_list, pkgdep_entries, pd_new) {
|
||||
if (strcmp(pd->name, name) == 0) {
|
||||
if (trans == NULL)
|
||||
return idx;
|
||||
if (strcmp(pd->trans, trans) == 0)
|
||||
return idx;
|
||||
}
|
||||
if (pd->d == NULL)
|
||||
if (pd->d == NULL) {
|
||||
/* ignore entries without dictionary */
|
||||
idx++;
|
||||
continue;
|
||||
if (xbps_match_virtual_pkg_in_dict(pd->d, name, false)) {
|
||||
if (trans && pd->trans &&
|
||||
(strcmp(trans, pd->trans) == 0))
|
||||
return idx;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(pd->d,
|
||||
"transaction", &tract);
|
||||
/* ignore pkgs to be removed */
|
||||
if (strcmp(tract, "remove") == 0) {
|
||||
idx++;
|
||||
continue;
|
||||
}
|
||||
/* simple match */
|
||||
prop_dictionary_get_cstring_nocopy(pd->d, "pkgver", &pkgver);
|
||||
if (strcmp(pkgver, pkg) == 0)
|
||||
return idx;
|
||||
/* pkg expression match */
|
||||
if (xbps_pkgpattern_match(pkgver, pkg))
|
||||
return idx;
|
||||
/* virtualpkg expression match */
|
||||
if (xbps_match_virtual_pkg_in_dict(pd->d, pkg, true))
|
||||
return idx;
|
||||
|
||||
idx++;
|
||||
}
|
||||
@ -117,58 +133,28 @@ pkgdep_release(struct pkgdep *pd)
|
||||
}
|
||||
|
||||
static struct pkgdep *
|
||||
pkgdep_alloc(prop_dictionary_t d, const char *name, const char *trans)
|
||||
pkgdep_alloc(prop_dictionary_t d, const char *pkg)
|
||||
{
|
||||
struct pkgdep *pd;
|
||||
size_t len;
|
||||
|
||||
if ((pd = malloc(sizeof(*pd))) == NULL)
|
||||
return NULL;
|
||||
|
||||
len = strlen(name) + 1;
|
||||
if ((pd->name = malloc(len)) == NULL) {
|
||||
free(pd);
|
||||
return NULL;
|
||||
}
|
||||
pd = malloc(sizeof(*pd));
|
||||
assert(pd);
|
||||
pd->d = d;
|
||||
memcpy(pd->name, name, len-1);
|
||||
pd->name[len-1] = '\0';
|
||||
pd->trans = trans;
|
||||
pd->name = strdup(pkg);
|
||||
|
||||
return pd;
|
||||
}
|
||||
|
||||
static void
|
||||
pkgdep_end(struct xbps_handle *xhp, prop_array_t sorted)
|
||||
pkgdep_end(prop_array_t sorted)
|
||||
{
|
||||
prop_dictionary_t d;
|
||||
struct pkgdep *pd;
|
||||
const char *trans;
|
||||
|
||||
while ((pd = TAILQ_FIRST(&pkgdep_list)) != NULL) {
|
||||
TAILQ_REMOVE(&pkgdep_list, pd, pkgdep_entries);
|
||||
if (sorted != NULL && pd->d != NULL) {
|
||||
/* do not add duplicates due to vpkgs */
|
||||
d = xbps_find_pkg_in_array_by_name(xhp, sorted,
|
||||
pd->name, NULL);
|
||||
if (d == NULL) {
|
||||
/* find a virtual pkg otherwise */
|
||||
d = xbps_find_virtualpkg_in_array_by_name(
|
||||
xhp, sorted, pd->name);
|
||||
if (d == NULL) {
|
||||
if (sorted != NULL && pd->d != NULL)
|
||||
prop_array_add(sorted, pd->d);
|
||||
pkgdep_release(pd);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(d,
|
||||
"transaction", &trans);
|
||||
if (strcmp(trans, pd->trans) == 0) {
|
||||
pkgdep_release(pd);
|
||||
continue;
|
||||
}
|
||||
prop_array_add(sorted, pd->d);
|
||||
}
|
||||
|
||||
pkgdep_release(pd);
|
||||
}
|
||||
}
|
||||
@ -176,31 +162,26 @@ pkgdep_end(struct xbps_handle *xhp, prop_array_t sorted)
|
||||
static int
|
||||
sort_pkg_rundeps(struct xbps_handle *xhp,
|
||||
struct pkgdep *pd,
|
||||
prop_array_t pkg_rundeps)
|
||||
prop_array_t pkg_rundeps,
|
||||
prop_array_t unsorted)
|
||||
{
|
||||
prop_dictionary_t curpkgd;
|
||||
struct pkgdep *lpd, *pdn;
|
||||
const char *str, *tract;
|
||||
char *pkgnamedep;
|
||||
ssize_t pkgdepidx, curpkgidx;
|
||||
size_t i, idx = 0;
|
||||
int rv = 0;
|
||||
|
||||
xbps_dbg_printf_append(xhp, "\n");
|
||||
curpkgidx = pkgdep_find_idx(pd->name, pd->trans);
|
||||
curpkgidx = pkgdep_find_idx(pd->name);
|
||||
|
||||
again:
|
||||
for (i = idx; i < prop_array_count(pkg_rundeps); i++) {
|
||||
prop_array_get_cstring_nocopy(pkg_rundeps, i, &str);
|
||||
if (((pkgnamedep = xbps_pkgpattern_name(str)) == NULL) &&
|
||||
((pkgnamedep = xbps_pkg_name(str)) == NULL)) {
|
||||
rv = ENOMEM;
|
||||
break;
|
||||
}
|
||||
xbps_dbg_printf(xhp, " Required dependency '%s': ", str);
|
||||
pdn = pkgdep_find(pkgnamedep, NULL);
|
||||
if ((pdn == NULL) &&
|
||||
xbps_check_is_installed_pkg_by_pattern(xhp, str)) {
|
||||
|
||||
pdn = pkgdep_find(str);
|
||||
if ((pdn == NULL) && xbps_pkg_is_installed(xhp, str)) {
|
||||
/*
|
||||
* Package dependency is installed, just add to
|
||||
* the list but just mark it as "installed", to avoid
|
||||
@ -208,12 +189,7 @@ again:
|
||||
* which is expensive.
|
||||
*/
|
||||
xbps_dbg_printf_append(xhp, "installed.\n");
|
||||
lpd = pkgdep_alloc(NULL, pkgnamedep, "installed");
|
||||
if (lpd == NULL) {
|
||||
rv = ENOMEM;
|
||||
break;
|
||||
}
|
||||
free(pkgnamedep);
|
||||
lpd = pkgdep_alloc(NULL, str);
|
||||
TAILQ_INSERT_TAIL(&pkgdep_list, lpd, pkgdep_entries);
|
||||
continue;
|
||||
} else if (pdn != NULL && pdn->d == NULL) {
|
||||
@ -222,31 +198,18 @@ again:
|
||||
* and is installed, skip.
|
||||
*/
|
||||
xbps_dbg_printf_append(xhp, "installed.\n");
|
||||
free(pkgnamedep);
|
||||
continue;
|
||||
}
|
||||
/* Find pkg by name */
|
||||
curpkgd = xbps_find_pkg_in_dict_by_name(xhp, xhp->transd,
|
||||
"unsorted_deps", pkgnamedep);
|
||||
if (curpkgd == NULL) {
|
||||
/* find virtualpkg by name if no match */
|
||||
curpkgd =
|
||||
xbps_find_virtualpkg_in_dict_by_name(xhp,
|
||||
xhp->transd, "unsorted_deps", pkgnamedep);
|
||||
}
|
||||
if (curpkgd == NULL) {
|
||||
free(pkgnamedep);
|
||||
if (((curpkgd = xbps_find_pkg_in_array(unsorted, str)) == NULL) &&
|
||||
((curpkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, str)) == NULL)) {
|
||||
rv = EINVAL;
|
||||
break;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(curpkgd,
|
||||
"transaction", &tract);
|
||||
lpd = pkgdep_alloc(curpkgd, pkgnamedep, tract);
|
||||
if (lpd == NULL) {
|
||||
free(pkgnamedep);
|
||||
rv = ENOMEM;
|
||||
break;
|
||||
}
|
||||
|
||||
lpd = pkgdep_alloc(curpkgd, str);
|
||||
|
||||
if (pdn == NULL) {
|
||||
/*
|
||||
* If package is not in the list, add to the tail
|
||||
@ -256,18 +219,16 @@ again:
|
||||
idx = i;
|
||||
xbps_dbg_printf_append(xhp, "added into the tail, "
|
||||
"checking again...\n");
|
||||
free(pkgnamedep);
|
||||
goto again;
|
||||
}
|
||||
/*
|
||||
* Find package dependency index.
|
||||
*/
|
||||
pkgdepidx = pkgdep_find_idx(pkgnamedep, tract);
|
||||
pkgdepidx = pkgdep_find_idx(str);
|
||||
/*
|
||||
* If package dependency index is less than current
|
||||
* package index, it's already sorted.
|
||||
*/
|
||||
free(pkgnamedep);
|
||||
if (pkgdepidx < curpkgidx) {
|
||||
xbps_dbg_printf_append(xhp, "already sorted.\n");
|
||||
pkgdep_release(lpd);
|
||||
@ -288,13 +249,12 @@ again:
|
||||
}
|
||||
|
||||
int HIDDEN
|
||||
xbps_transaction_sort_pkg_deps(struct xbps_handle *xhp)
|
||||
xbps_transaction_sort(struct xbps_handle *xhp)
|
||||
{
|
||||
prop_array_t provides, sorted, unsorted, rundeps;
|
||||
prop_object_t obj;
|
||||
struct pkgdep *pd;
|
||||
size_t i, j, ndeps = 0, cnt = 0;
|
||||
char *vpkg, *vpkgname;
|
||||
const char *pkgname, *pkgver, *tract, *vpkgdep;
|
||||
int rv = 0;
|
||||
bool vpkg_found;
|
||||
@ -339,21 +299,12 @@ xbps_transaction_sort_pkg_deps(struct xbps_handle *xhp)
|
||||
/*
|
||||
* If current pkgdep provides any virtual pkg check
|
||||
* if any of them was previously added. If true, don't
|
||||
* add it into the list again just order its deps.
|
||||
* add it into the list again, just order its deps.
|
||||
*/
|
||||
for (j = 0; j < prop_array_count(provides); j++) {
|
||||
prop_array_get_cstring_nocopy(provides,
|
||||
j, &vpkgdep);
|
||||
if (strchr(vpkgdep, '_') == NULL) {
|
||||
vpkg = xbps_xasprintf("%s_1", vpkgdep);
|
||||
vpkgname = xbps_pkg_name(vpkg);
|
||||
free(vpkg);
|
||||
} else {
|
||||
vpkgname = xbps_pkg_name(vpkgdep);
|
||||
}
|
||||
assert(vpkgname);
|
||||
pd = pkgdep_find(vpkgname, tract);
|
||||
free(vpkgname);
|
||||
pd = pkgdep_find(vpkgdep);
|
||||
if (pd != NULL) {
|
||||
xbps_dbg_printf_append(xhp, "already "
|
||||
"sorted via `%s' vpkg.", vpkgdep);
|
||||
@ -362,17 +313,17 @@ xbps_transaction_sort_pkg_deps(struct xbps_handle *xhp)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!vpkg_found && (pd = pkgdep_find(pkgname, tract)) == NULL) {
|
||||
if (!vpkg_found && (pd = pkgdep_find(pkgver)) == NULL) {
|
||||
/*
|
||||
* If package not in list, just add to the tail.
|
||||
*/
|
||||
pd = pkgdep_alloc(obj, pkgname, tract);
|
||||
pd = pkgdep_alloc(obj, pkgver);
|
||||
if (pd == NULL) {
|
||||
pkgdep_end(xhp, NULL);
|
||||
pkgdep_end(NULL);
|
||||
rv = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
if (strcmp(pd->trans, "remove") == 0) {
|
||||
if (strcmp(tract, "remove") == 0) {
|
||||
xbps_dbg_printf_append(xhp, "added into head.");
|
||||
TAILQ_INSERT_HEAD(&pkgdep_list, pd,
|
||||
pkgdep_entries);
|
||||
@ -395,8 +346,8 @@ xbps_transaction_sort_pkg_deps(struct xbps_handle *xhp)
|
||||
/*
|
||||
* Sort package run-time dependencies for this package.
|
||||
*/
|
||||
if ((rv = sort_pkg_rundeps(xhp, pd, rundeps)) != 0) {
|
||||
pkgdep_end(xhp, NULL);
|
||||
if ((rv = sort_pkg_rundeps(xhp, pd, rundeps, unsorted)) != 0) {
|
||||
pkgdep_end(NULL);
|
||||
goto out;
|
||||
}
|
||||
cnt++;
|
||||
@ -406,7 +357,7 @@ xbps_transaction_sort_pkg_deps(struct xbps_handle *xhp)
|
||||
* from the sorted list into the "packages" array, and at
|
||||
* the same time freeing memory used for temporary sorting.
|
||||
*/
|
||||
pkgdep_end(xhp, sorted);
|
||||
pkgdep_end(sorted);
|
||||
/*
|
||||
* Sanity check that the array contains the same number of
|
||||
* objects than the total number of required dependencies.
|
||||
|
60
lib/util.c
60
lib/util.c
@ -47,7 +47,7 @@
|
||||
* @defgroup util Utility functions
|
||||
*/
|
||||
bool
|
||||
xbps_check_is_repository_uri_remote(const char *uri)
|
||||
xbps_repository_is_remote(const char *uri)
|
||||
{
|
||||
assert(uri != NULL);
|
||||
|
||||
@ -60,23 +60,17 @@ xbps_check_is_repository_uri_remote(const char *uri)
|
||||
}
|
||||
|
||||
int
|
||||
xbps_check_is_installed_pkg_by_pattern(struct xbps_handle *xhp,
|
||||
const char *pattern)
|
||||
xbps_pkg_is_installed(struct xbps_handle *xhp, const char *pkg)
|
||||
{
|
||||
prop_dictionary_t dict;
|
||||
pkg_state_t state;
|
||||
|
||||
assert(pattern != NULL);
|
||||
assert(xhp);
|
||||
assert(pkg);
|
||||
|
||||
dict = xbps_find_virtualpkg_dict_installed(xhp, pattern, true);
|
||||
if (dict == NULL) {
|
||||
dict = xbps_find_pkg_dict_installed(xhp, pattern, true);
|
||||
if (dict == NULL) {
|
||||
if (errno == ENOENT)
|
||||
if (((dict = xbps_pkgdb_get_virtualpkg(xhp, pkg)) == NULL) &&
|
||||
((dict = xbps_pkgdb_get_pkg(xhp, pkg)) == NULL))
|
||||
return 0; /* not installed */
|
||||
return -1; /* error */
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Check that package state is fully installed, not
|
||||
* unpacked or something else.
|
||||
@ -89,21 +83,6 @@ xbps_check_is_installed_pkg_by_pattern(struct xbps_handle *xhp,
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_check_is_installed_pkg_by_name(struct xbps_handle *xhp,
|
||||
const char *pkgname)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
|
||||
assert(pkgname != NULL);
|
||||
|
||||
if (((pkgd = xbps_find_pkg_dict_installed(xhp, pkgname, false)) == NULL) &&
|
||||
((pkgd = xbps_find_virtualpkg_dict_installed(xhp, pkgname, false)) == NULL))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const char *
|
||||
xbps_pkg_version(const char *pkg)
|
||||
{
|
||||
@ -208,39 +187,45 @@ get_pkg_index_remote_plist(struct xbps_handle *xhp,
|
||||
char *
|
||||
xbps_pkg_index_plist(struct xbps_handle *xhp, const char *uri)
|
||||
{
|
||||
assert(xhp);
|
||||
assert(uri != NULL);
|
||||
|
||||
if (xbps_check_is_repository_uri_remote(uri))
|
||||
if (xbps_repository_is_remote(uri))
|
||||
return get_pkg_index_remote_plist(xhp, uri, XBPS_PKGINDEX);
|
||||
|
||||
return xbps_xasprintf("%s/%s", uri, XBPS_PKGINDEX);
|
||||
return xbps_xasprintf("%s/%s-%s", uri, xhp->un_machine, XBPS_PKGINDEX);
|
||||
}
|
||||
|
||||
char *
|
||||
xbps_pkg_index_files_plist(struct xbps_handle *xhp, const char *uri)
|
||||
{
|
||||
assert(xhp);
|
||||
assert(uri != NULL);
|
||||
if (xbps_check_is_repository_uri_remote(uri))
|
||||
|
||||
if (xbps_repository_is_remote(uri))
|
||||
return get_pkg_index_remote_plist(xhp, uri, XBPS_PKGINDEX_FILES);
|
||||
|
||||
return xbps_xasprintf("%s/%s", uri, XBPS_PKGINDEX_FILES);
|
||||
return xbps_xasprintf("%s/%s-%s", uri,
|
||||
xhp->un_machine, XBPS_PKGINDEX_FILES);
|
||||
}
|
||||
|
||||
char *
|
||||
xbps_path_from_repository_uri(struct xbps_handle *xhp,
|
||||
prop_dictionary_t pkg_repod,
|
||||
const char *repoloc)
|
||||
char HIDDEN *
|
||||
xbps_repository_pkg_path(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
|
||||
{
|
||||
const char *filen;
|
||||
const char *filen, *repoloc;
|
||||
char *lbinpkg = NULL;
|
||||
|
||||
assert(xhp);
|
||||
assert(prop_object_type(pkg_repod) == PROP_TYPE_DICTIONARY);
|
||||
assert(repoloc != NULL);
|
||||
|
||||
if (!prop_dictionary_get_cstring_nocopy(pkg_repod,
|
||||
"filename", &filen))
|
||||
return NULL;
|
||||
if (!prop_dictionary_get_cstring_nocopy(pkg_repod,
|
||||
"repository", &repoloc))
|
||||
return NULL;
|
||||
|
||||
if (xbps_repository_is_remote(repoloc)) {
|
||||
/*
|
||||
* First check if binpkg is available in cachedir.
|
||||
*/
|
||||
@ -249,6 +234,7 @@ xbps_path_from_repository_uri(struct xbps_handle *xhp,
|
||||
return lbinpkg;
|
||||
|
||||
free(lbinpkg);
|
||||
}
|
||||
/*
|
||||
* Local and remote repositories use the same path.
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2008-2011 Juan Romero Pardines.
|
||||
* Copyright (c) 2008-2012 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -136,10 +136,8 @@ xbps_file_hash_check(const char *file, const char *sha256)
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *
|
||||
xbps_file_hash_dictionary(prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *file)
|
||||
static const char *
|
||||
file_hash_dictionary(prop_dictionary_t d, const char *key, const char *file)
|
||||
{
|
||||
prop_object_t obj;
|
||||
prop_object_iterator_t iter;
|
||||
@ -171,7 +169,7 @@ xbps_file_hash_dictionary(prop_dictionary_t d,
|
||||
return sha256;
|
||||
}
|
||||
|
||||
int
|
||||
int HIDDEN
|
||||
xbps_file_hash_check_dictionary(struct xbps_handle *xhp,
|
||||
prop_dictionary_t d,
|
||||
const char *key,
|
||||
@ -185,7 +183,7 @@ xbps_file_hash_check_dictionary(struct xbps_handle *xhp,
|
||||
assert(key != NULL);
|
||||
assert(file != NULL);
|
||||
|
||||
if ((sha256d = xbps_file_hash_dictionary(d, key, file)) == NULL) {
|
||||
if ((sha256d = file_hash_dictionary(d, key, file)) == NULL) {
|
||||
if (errno == ENOENT)
|
||||
return 1; /* no match, file not found */
|
||||
|
||||
|
Reference in New Issue
Block a user