Get rid of libfetch and proplib external dependencies.

The list of required external deps is now confuse, libarchive and openssl.

libxbps now includes a wrapper for proplib prefixed with xbps_ rather than prop_.
This commit is contained in:
Juan RP
2013-06-20 10:26:12 +02:00
parent 31efece727
commit 42c0766c00
67 changed files with 3004 additions and 1487 deletions

View File

@@ -16,10 +16,7 @@ LIBPROP_OBJS += portableproplib/prop_dictionary_util.o portableproplib/prop_zlib
LIBPROP_OBJS += portableproplib/prop_data.o
LIBPROP_CPPFLAGS = -D_GNU_SOURCE
LIBPROP_CFLAGS = -Wno-old-style-definition -Wno-cast-qual -Wno-unused-parameter
ifdef USE_EXTERNAL_PROPLIB
LIBPROP_OBJS =
endif
LIBPROP_CFLAGS += -fvisibility=hidden
# libfetch
LIBFETCH_OBJS = fetch/common.o fetch/fetch.o fetch/file.o
@@ -32,10 +29,6 @@ endif
LIBFETCH_INCS = fetch/common.h
LIBFETCH_GEN = fetch/ftperr.h fetch/httperr.h
ifdef USE_EXTERNAL_LIBFETCH
LIBFETCH_OBJS =
endif
# External code used by libxbps
EXTOBJS = external/dewey.o external/fexec.o external/mkpath.o
@@ -49,7 +42,7 @@ OBJS += download.o initend.o pkgdb.o package_conflicts.o
OBJS += plist.o plist_find.o plist_match.o archive.o
OBJS += plist_remove.o plist_fetch.o util.o util_hash.o
OBJS += repo.o repo_pkgdeps.o repo_sync.o
OBJS += rpool.o rpool_get.o cb_util.o
OBJS += rpool.o rpool_get.o cb_util.o proplib_wrapper.o
OBJS += $(EXTOBJS) $(COMPAT_SRCS)
.PHONY: all
@@ -77,13 +70,13 @@ $(OBJS): %.o: %.c
@printf " [CC]\t\t$@\n"
${SILENT}$(CC) $(CPPFLAGS) $(CFLAGS) $(SHAREDLIB_CFLAGS) -c $< -o $@
libxbps.so: $(OBJS) $(LIBFETCH_OBJS) $(LIBPROP_OBJS)
libxbps.so: $(LIBFETCH_OBJS) $(LIBPROP_OBJS) $(OBJS)
@printf " [CCLD]\t\t$@\n"
${SILENT}$(CC) $^ $(LDFLAGS) -o $(LIBXBPS_SHLIB)
@-ln -sf $(LIBXBPS_SHLIB) libxbps.so.$(LIBXBPS_MAJOR)
@-ln -sf $(LIBXBPS_SHLIB) libxbps.so
libxbps.a: $(OBJS) $(LIBFETCH_OBJS) $(LIBPROP_OBJS)
libxbps.a: $(LIBFETCH_OBJS) $(LIBPROP_OBJS) $(OBJS)
@printf " [AR]\t\t$@\n"
${SILENT}$(AR) rcs $@ $^
@printf " [RANLIB]\t$@\n"

View File

@@ -108,10 +108,10 @@ uncompress_plist_data(char *xml, size_t len)
}
#undef _READ_CHUNK
prop_dictionary_t HIDDEN
xbps_dictionary_t HIDDEN
xbps_archive_get_dictionary(struct archive *ar, struct archive_entry *entry)
{
prop_dictionary_t d = NULL;
xbps_dictionary_t d = NULL;
size_t buflen;
ssize_t nbytes = -1;
char *buf, *uncomp_buf;
@@ -131,8 +131,8 @@ xbps_archive_get_dictionary(struct archive *ar, struct archive_entry *entry)
}
/* If blob is already a dictionary we are done */
d = prop_dictionary_internalize(buf);
if (prop_object_type(d) == PROP_TYPE_DICTIONARY)
d = xbps_dictionary_internalize(buf);
if (xbps_object_type(d) == XBPS_TYPE_DICTIONARY)
goto out;
/* Try to uncompress blob */
@@ -143,7 +143,7 @@ xbps_archive_get_dictionary(struct archive *ar, struct archive_entry *entry)
return NULL;
} else {
/* We have the uncompressed data */
d = prop_dictionary_internalize(uncomp_buf);
d = xbps_dictionary_internalize(uncomp_buf);
free(uncomp_buf);
}

View File

@@ -257,7 +257,7 @@ xbps_end(struct xbps_handle *xhp)
xbps_rpool_release(xhp);
xbps_fetch_unset_cache_connection();
if (xhp->pkgdb_revdeps != NULL)
prop_object_release(xhp->pkgdb_revdeps);
xbps_object_release(xhp->pkgdb_revdeps);
cfg_free(xhp->cfg);
free(xhp->cachedir_priv);

View File

@@ -34,22 +34,22 @@
* Returns true if entry is a configuration file, false otherwise.
*/
int HIDDEN
xbps_entry_is_a_conf_file(prop_dictionary_t propsd,
xbps_entry_is_a_conf_file(xbps_dictionary_t propsd,
const char *entry_pname)
{
prop_array_t array;
xbps_array_t array;
const char *cffile;
unsigned int i;
assert(prop_object_type(propsd) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(propsd) == XBPS_TYPE_DICTIONARY);
assert(entry_pname != NULL);
array = prop_dictionary_get(propsd, "conf_files");
if (prop_array_count(array) == 0)
array = xbps_dictionary_get(propsd, "conf_files");
if (xbps_array_count(array) == 0)
return false;
for (i = 0; i < prop_array_count(array); i++) {
prop_array_get_cstring_nocopy(array, i, &cffile);
for (i = 0; i < xbps_array_count(array); i++) {
xbps_array_get_cstring_nocopy(array, i, &cffile);
if (strcmp(cffile, entry_pname) == 0)
return true;
}
@@ -61,20 +61,20 @@ xbps_entry_is_a_conf_file(prop_dictionary_t propsd,
*/
int HIDDEN
xbps_entry_install_conf_file(struct xbps_handle *xhp,
prop_dictionary_t filesd,
xbps_dictionary_t filesd,
struct archive_entry *entry,
const char *entry_pname,
const char *pkgver,
const char *pkgname)
{
prop_dictionary_t forigd;
prop_object_t obj, obj2;
prop_object_iterator_t iter, iter2;
xbps_dictionary_t forigd;
xbps_object_t obj, obj2;
xbps_object_iterator_t iter, iter2;
const char *cffile, *sha256_new = NULL;
char *buf, *sha256_cur = NULL, *sha256_orig = NULL;
int rv = 0;
assert(prop_object_type(filesd) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(filesd) == XBPS_TYPE_DICTIONARY);
assert(entry != NULL);
assert(entry_pname != NULL);
assert(pkgver != NULL);
@@ -100,12 +100,12 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
iter2 = xbps_array_iter_from_dict(forigd, "conf_files");
if (iter2 != NULL) {
while ((obj2 = prop_object_iterator_next(iter2))) {
prop_dictionary_get_cstring_nocopy(obj2,
while ((obj2 = xbps_object_iterator_next(iter2))) {
xbps_dictionary_get_cstring_nocopy(obj2,
"file", &cffile);
buf = xbps_xasprintf(".%s", cffile);
if (strcmp(entry_pname, buf) == 0) {
prop_dictionary_get_cstring(obj2, "sha256",
xbps_dictionary_get_cstring(obj2, "sha256",
&sha256_orig);
free(buf);
break;
@@ -113,7 +113,7 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
free(buf);
buf = NULL;
}
prop_object_iterator_release(iter2);
xbps_object_iterator_release(iter2);
}
/*
* First case: original hash not found, install new file.
@@ -128,8 +128,8 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
/*
* Compare original, installed and new hash for current file.
*/
while ((obj = prop_object_iterator_next(iter))) {
prop_dictionary_get_cstring_nocopy(obj, "file", &cffile);
while ((obj = xbps_object_iterator_next(iter))) {
xbps_dictionary_get_cstring_nocopy(obj, "file", &cffile);
buf = xbps_xasprintf(".%s", cffile);
if (strcmp(entry_pname, buf)) {
free(buf);
@@ -138,7 +138,7 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
}
sha256_cur = xbps_file_hash(buf);
free(buf);
prop_dictionary_get_cstring_nocopy(obj, "sha256", &sha256_new);
xbps_dictionary_get_cstring_nocopy(obj, "sha256", &sha256_new);
if (sha256_cur == NULL) {
if (errno == ENOENT) {
/*
@@ -239,7 +239,7 @@ out:
if (sha256_cur)
free(sha256_cur);
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
xbps_dbg_printf(xhp, "%s: conf_file %s returned %d\n",
pkgver, entry_pname, rv);

View File

@@ -49,20 +49,20 @@
int
xbps_configure_packages(struct xbps_handle *xhp, bool flush)
{
prop_dictionary_t pkgd;
prop_object_t obj;
prop_object_iterator_t iter;
xbps_dictionary_t pkgd;
xbps_object_t obj;
xbps_object_iterator_t iter;
const char *pkgver;
int rv;
if ((rv = xbps_pkgdb_init(xhp)) != 0)
return rv;
iter = prop_dictionary_iterator(xhp->pkgdb);
iter = xbps_dictionary_iterator(xhp->pkgdb);
assert(iter);
while ((obj = prop_object_iterator_next(iter))) {
pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
while ((obj = xbps_object_iterator_next(iter))) {
pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
rv = xbps_configure_pkg(xhp, pkgver, true, false, false);
if (rv != 0) {
xbps_dbg_printf(xhp, "%s: failed to configure %s: %s\n",
@@ -70,7 +70,7 @@ xbps_configure_packages(struct xbps_handle *xhp, bool flush)
break;
}
}
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
if ((rv == 0) && flush)
rv = xbps_pkgdb_update(xhp, true);
@@ -85,7 +85,7 @@ xbps_configure_pkg(struct xbps_handle *xhp,
bool update,
bool flush)
{
prop_dictionary_t pkgd, pkgmetad;
xbps_dictionary_t pkgd, pkgmetad;
char *pkgname, *plist;
int rv = 0;
pkg_state_t state = 0;
@@ -122,7 +122,7 @@ xbps_configure_pkg(struct xbps_handle *xhp,
plist = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname);
free(pkgname);
pkgmetad = prop_dictionary_internalize_from_file(plist);
pkgmetad = xbps_dictionary_internalize_from_file(plist);
if (pkgmetad == NULL) {
xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE_FAIL,
errno, pkgver,
@@ -143,7 +143,7 @@ xbps_configure_pkg(struct xbps_handle *xhp,
return rv;
}
if (state == XBPS_PKG_STATE_INSTALLED) {
prop_object_release(pkgmetad);
xbps_object_release(pkgmetad);
return rv;
}
@@ -161,7 +161,7 @@ xbps_configure_pkg(struct xbps_handle *xhp,
pkgver, strerror(rv));
}
}
prop_object_release(pkgmetad);
xbps_object_release(pkgmetad);
if (rv == 0)
xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE_DONE, 0, pkgver, NULL);

View File

@@ -33,37 +33,37 @@
void HIDDEN
xbps_pkg_find_conflicts(struct xbps_handle *xhp,
prop_array_t unsorted,
prop_dictionary_t pkg_repod)
xbps_array_t unsorted,
xbps_dictionary_t pkg_repod)
{
prop_array_t pkg_cflicts, trans_cflicts;
prop_dictionary_t pkgd;
prop_object_t obj;
prop_object_iterator_t iter;
xbps_array_t pkg_cflicts, trans_cflicts;
xbps_dictionary_t pkgd;
xbps_object_t obj;
xbps_object_iterator_t iter;
const char *cfpkg, *repopkgver, *pkgver;
char *pkgname, *repopkgname, *buf;
pkg_cflicts = prop_dictionary_get(pkg_repod, "conflicts");
if (prop_array_count(pkg_cflicts) == 0)
pkg_cflicts = xbps_dictionary_get(pkg_repod, "conflicts");
if (xbps_array_count(pkg_cflicts) == 0)
return;
trans_cflicts = prop_dictionary_get(xhp->transd, "conflicts");
prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &repopkgver);
trans_cflicts = xbps_dictionary_get(xhp->transd, "conflicts");
xbps_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &repopkgver);
repopkgname = xbps_pkg_name(repopkgver);
assert(repopkgname);
iter = prop_array_iterator(pkg_cflicts);
iter = xbps_array_iterator(pkg_cflicts);
assert(iter);
while ((obj = prop_object_iterator_next(iter))) {
cfpkg = prop_string_cstring_nocopy(obj);
while ((obj = xbps_object_iterator_next(iter))) {
cfpkg = xbps_string_cstring_nocopy(obj);
/*
* Check if current pkg conflicts with an installed package.
*/
if ((pkgd = xbps_pkgdb_get_pkg(xhp, cfpkg)) ||
(pkgd = xbps_pkgdb_get_virtualpkg(xhp, cfpkg))) {
prop_dictionary_get_cstring_nocopy(pkgd,
xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &pkgver);
pkgname = xbps_pkg_name(pkgver);
assert(pkgname);
@@ -77,7 +77,7 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp,
repopkgver);
buf = xbps_xasprintf("%s conflicts with "
"installed pkg %s", repopkgver, pkgver);
prop_array_add_cstring(trans_cflicts, buf);
xbps_array_add_cstring(trans_cflicts, buf);
free(buf);
continue;
}
@@ -86,7 +86,7 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp,
*/
if ((pkgd = xbps_find_pkg_in_array(unsorted, cfpkg)) ||
(pkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, cfpkg))) {
prop_dictionary_get_cstring_nocopy(pkgd,
xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &pkgver);
pkgname = xbps_pkg_name(pkgver);
assert(pkgname);
@@ -99,11 +99,11 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp,
"transaction %s <-> %s\n", pkgver, repopkgver);
buf = xbps_xasprintf("%s conflicts with "
"%s in transaction", repopkgver, pkgver);
prop_array_add_cstring(trans_cflicts, buf);
xbps_array_add_cstring(trans_cflicts, buf);
free(buf);
continue;
}
}
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
free(repopkgname);
}

View File

@@ -32,68 +32,68 @@
#include "xbps_api_impl.h"
static prop_array_t
merge_filelist(prop_dictionary_t d)
static xbps_array_t
merge_filelist(xbps_dictionary_t d)
{
prop_array_t a, result;
prop_dictionary_t filed;
xbps_array_t a, result;
xbps_dictionary_t filed;
unsigned int i;
result = prop_array_create();
result = xbps_array_create();
assert(result);
if ((a = prop_dictionary_get(d, "files"))) {
for (i = 0; i < prop_array_count(a); i++) {
filed = prop_array_get(a, i);
prop_array_add(result, filed);
if ((a = xbps_dictionary_get(d, "files"))) {
for (i = 0; i < xbps_array_count(a); i++) {
filed = xbps_array_get(a, i);
xbps_array_add(result, filed);
}
}
if ((a = prop_dictionary_get(d, "links"))) {
for (i = 0; i < prop_array_count(a); i++) {
filed = prop_array_get(a, i);
prop_array_add(result, filed);
if ((a = xbps_dictionary_get(d, "links"))) {
for (i = 0; i < xbps_array_count(a); i++) {
filed = xbps_array_get(a, i);
xbps_array_add(result, filed);
}
}
if ((a = prop_dictionary_get(d, "conf_files"))) {
for (i = 0; i < prop_array_count(a); i++) {
filed = prop_array_get(a, i);
prop_array_add(result, filed);
if ((a = xbps_dictionary_get(d, "conf_files"))) {
for (i = 0; i < xbps_array_count(a); i++) {
filed = xbps_array_get(a, i);
xbps_array_add(result, filed);
}
}
if ((a = prop_dictionary_get(d, "dirs"))) {
for (i = 0; i < prop_array_count(a); i++) {
filed = prop_array_get(a, i);
prop_array_add(result, filed);
if ((a = xbps_dictionary_get(d, "dirs"))) {
for (i = 0; i < xbps_array_count(a); i++) {
filed = xbps_array_get(a, i);
xbps_array_add(result, filed);
}
}
return result;
}
prop_array_t
xbps_array_t
xbps_find_pkg_obsoletes(struct xbps_handle *xhp,
prop_dictionary_t instd,
prop_dictionary_t newd)
xbps_dictionary_t instd,
xbps_dictionary_t newd)
{
prop_array_t instfiles, newfiles, obsoletes;
prop_object_t obj, obj2;
prop_string_t oldstr, newstr;
xbps_array_t instfiles, newfiles, obsoletes;
xbps_object_t obj, obj2;
xbps_string_t oldstr, newstr;
unsigned int i, x;
const char *oldhash;
char *file;
int rv = 0;
bool found;
assert(prop_object_type(instd) == PROP_TYPE_DICTIONARY);
assert(prop_object_type(newd) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(instd) == XBPS_TYPE_DICTIONARY);
assert(xbps_object_type(newd) == XBPS_TYPE_DICTIONARY);
obsoletes = prop_array_create();
obsoletes = xbps_array_create();
assert(obsoletes);
instfiles = merge_filelist(instd);
if (prop_array_count(instfiles) == 0) {
if (xbps_array_count(instfiles) == 0) {
/* nothing to check if current pkg does not own any file */
prop_object_release(instfiles);
xbps_object_release(instfiles);
return obsoletes;
}
newfiles = merge_filelist(newd);
@@ -101,22 +101,22 @@ xbps_find_pkg_obsoletes(struct xbps_handle *xhp,
/*
* Iterate over files list from installed package.
*/
for (i = 0; i < prop_array_count(instfiles); i++) {
for (i = 0; i < xbps_array_count(instfiles); i++) {
found = false;
obj = prop_array_get(instfiles, i);
if (prop_object_type(obj) != PROP_TYPE_DICTIONARY) {
obj = xbps_array_get(instfiles, i);
if (xbps_object_type(obj) != XBPS_TYPE_DICTIONARY) {
/* ignore unexistent files */
continue;
}
oldstr = prop_dictionary_get(obj, "file");
oldstr = xbps_dictionary_get(obj, "file");
if (oldstr == NULL)
continue;
file = xbps_xasprintf(".%s",
prop_string_cstring_nocopy(oldstr));
xbps_string_cstring_nocopy(oldstr));
oldhash = NULL;
prop_dictionary_get_cstring_nocopy(obj,
xbps_dictionary_get_cstring_nocopy(obj,
"sha256", &oldhash);
if (oldhash) {
rv = xbps_file_hash_check(file, oldhash);
@@ -132,14 +132,14 @@ xbps_find_pkg_obsoletes(struct xbps_handle *xhp,
/*
* Check if current file is available in new pkg filelist.
*/
for (x = 0; x < prop_array_count(newfiles); x++) {
obj2 = prop_array_get(newfiles, x);
newstr = prop_dictionary_get(obj2, "file");
for (x = 0; x < xbps_array_count(newfiles); x++) {
obj2 = xbps_array_get(newfiles, x);
newstr = xbps_dictionary_get(obj2, "file");
assert(newstr);
/*
* Skip files with same path.
*/
if (prop_string_equals(oldstr, newstr)) {
if (xbps_string_equals(oldstr, newstr)) {
found = true;
break;
}
@@ -167,11 +167,11 @@ xbps_find_pkg_obsoletes(struct xbps_handle *xhp,
* Obsolete found, add onto the array.
*/
xbps_dbg_printf(xhp, "found obsolete: %s\n", file);
prop_array_add_cstring(obsoletes, file);
xbps_array_add_cstring(obsoletes, file);
free(file);
}
prop_object_release(instfiles);
prop_object_release(newfiles);
xbps_object_release(instfiles);
xbps_object_release(newfiles);
return obsoletes;
}

View File

@@ -59,13 +59,13 @@
* dictionary.
*/
prop_array_t
xbps_find_pkg_orphans(struct xbps_handle *xhp, prop_array_t orphans_user)
xbps_array_t
xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans_user)
{
prop_array_t rdeps, reqby, array = NULL;
prop_dictionary_t pkgd, deppkgd;
prop_object_t obj;
prop_object_iterator_t iter;
xbps_array_t rdeps, reqby, array = NULL;
xbps_dictionary_t pkgd, deppkgd;
xbps_object_t obj;
xbps_object_iterator_t iter;
const char *curpkgver, *deppkgver, *reqbydep;
bool automatic = false;
unsigned int i, x, j, cnt, reqbycnt;
@@ -74,64 +74,64 @@ xbps_find_pkg_orphans(struct xbps_handle *xhp, prop_array_t orphans_user)
if (xbps_pkgdb_init(xhp) != 0)
return NULL;
if ((array = prop_array_create()) == NULL)
if ((array = xbps_array_create()) == NULL)
return NULL;
/*
* Add all packages specified by the client.
*/
for (i = 0; i < prop_array_count(orphans_user); i++) {
prop_array_get_cstring_nocopy(orphans_user, i, &curpkgver);
for (i = 0; i < xbps_array_count(orphans_user); i++) {
xbps_array_get_cstring_nocopy(orphans_user, i, &curpkgver);
pkgd = xbps_pkgdb_get_pkg(xhp, curpkgver);
if (pkgd == NULL)
continue;
prop_array_add(array, pkgd);
xbps_array_add(array, pkgd);
}
if (prop_array_count(array))
if (xbps_array_count(array))
goto find_orphans;
iter = prop_dictionary_iterator(xhp->pkgdb);
iter = xbps_dictionary_iterator(xhp->pkgdb);
assert(iter);
/*
* First pass: track pkgs that were installed manually and
* without reverse dependencies.
*/
while ((obj = prop_object_iterator_next(iter))) {
pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj);
while ((obj = xbps_object_iterator_next(iter))) {
pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj);
/*
* Skip packages that were not installed automatically.
*/
prop_dictionary_get_bool(pkgd, "automatic-install", &automatic);
xbps_dictionary_get_bool(pkgd, "automatic-install", &automatic);
if (!automatic)
continue;
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &curpkgver);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &curpkgver);
reqby = xbps_pkgdb_get_pkg_revdeps(xhp, curpkgver);
if (prop_array_count(reqby) == 0) {
if (xbps_array_count(reqby) == 0) {
/*
* Add packages with empty revdeps.
*/
prop_array_add(array, pkgd);
xbps_array_add(array, pkgd);
continue;
}
}
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
find_orphans:
for (i = 0; i < prop_array_count(array); i++) {
pkgd = prop_array_get(array, i);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &curpkgver);
for (i = 0; i < xbps_array_count(array); i++) {
pkgd = xbps_array_get(array, i);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &curpkgver);
rdeps = prop_dictionary_get(pkgd, "run_depends");
for (x = 0; x < prop_array_count(rdeps); x++) {
rdeps = xbps_dictionary_get(pkgd, "run_depends");
for (x = 0; x < xbps_array_count(rdeps); x++) {
cnt = 0;
prop_array_get_cstring_nocopy(rdeps, x, &deppkgver);
xbps_array_get_cstring_nocopy(rdeps, x, &deppkgver);
reqby = xbps_pkgdb_get_pkg_revdeps(xhp, deppkgver);
if (reqby == NULL)
continue;
reqbycnt = prop_array_count(reqby);
reqbycnt = xbps_array_count(reqby);
for (j = 0; j < reqbycnt; j++) {
prop_array_get_cstring_nocopy(reqby, j, &reqbydep);
xbps_array_get_cstring_nocopy(reqby, j, &reqbydep);
if (xbps_find_pkg_in_array(array, reqbydep)) {
cnt++;
continue;
@@ -140,7 +140,7 @@ find_orphans:
if (cnt == reqbycnt) {
deppkgd = xbps_pkgdb_get_pkg(xhp, deppkgver);
if (!xbps_find_pkg_in_array(array, deppkgver))
prop_array_add(array, deppkgd);
xbps_array_add(array, deppkgd);
}
}
}

View File

@@ -32,10 +32,10 @@
#include "xbps_api_impl.h"
int HIDDEN
xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd)
xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd)
{
prop_dictionary_t pkgd;
prop_array_t provides, rundeps;
xbps_dictionary_t pkgd;
xbps_array_t provides, rundeps;
char outstr[64];
time_t t;
struct tm *tmp;
@@ -44,13 +44,13 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd)
int rv = 0;
bool autoinst = false;
assert(prop_object_type(pkgrd) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(pkgrd) == XBPS_TYPE_DICTIONARY);
prop_dictionary_get_cstring_nocopy(pkgrd, "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(pkgrd, "short_desc", &desc);
prop_dictionary_get_bool(pkgrd, "automatic-install", &autoinst);
provides = prop_dictionary_get(pkgrd, "provides");
rundeps = prop_dictionary_get(pkgrd, "run_depends");
xbps_dictionary_get_cstring_nocopy(pkgrd, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(pkgrd, "short_desc", &desc);
xbps_dictionary_get_bool(pkgrd, "automatic-install", &autoinst);
provides = xbps_dictionary_get(pkgrd, "provides");
rundeps = xbps_dictionary_get(pkgrd, "run_depends");
assert(pkgver != NULL);
assert(desc != NULL);
@@ -60,14 +60,14 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd)
rv = ENOENT;
goto out;
}
if (!prop_dictionary_set_cstring_nocopy(pkgd,
if (!xbps_dictionary_set_cstring_nocopy(pkgd,
"pkgver", pkgver)) {
xbps_dbg_printf(xhp, "%s: invalid pkgver for %s\n",
__func__, pkgver);
rv = EINVAL;
goto out;
}
if (!prop_dictionary_set_cstring_nocopy(pkgd,
if (!xbps_dictionary_set_cstring_nocopy(pkgd,
"short_desc", desc)) {
xbps_dbg_printf(xhp, "%s: invalid short_desc for %s\n",
__func__, pkgver);
@@ -77,7 +77,7 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd)
if (xhp->flags & XBPS_FLAG_INSTALL_AUTO)
autoinst = true;
if (!prop_dictionary_set_bool(pkgd,
if (!xbps_dictionary_set_bool(pkgd,
"automatic-install", autoinst)) {
xbps_dbg_printf(xhp, "%s: invalid autoinst for %s\n",
__func__, pkgver);
@@ -100,19 +100,19 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd)
rv = EINVAL;
goto out;
}
if (!prop_dictionary_set_cstring(pkgd, "install-date", outstr)) {
if (!xbps_dictionary_set_cstring(pkgd, "install-date", outstr)) {
xbps_dbg_printf(xhp, "%s: install-date set failed!\n", pkgver);
rv = EINVAL;
goto out;
}
if (provides && !prop_dictionary_set(pkgd, "provides", provides)) {
if (provides && !xbps_dictionary_set(pkgd, "provides", provides)) {
xbps_dbg_printf(xhp, "%s: failed to set provides for %s\n",
__func__, pkgver);
rv = EINVAL;
goto out;
}
if (rundeps && !prop_dictionary_set(pkgd, "run_depends", rundeps)) {
if (rundeps && !xbps_dictionary_set(pkgd, "run_depends", rundeps)) {
xbps_dbg_printf(xhp, "%s: failed to set rundeps for %s\n",
__func__, pkgver);
rv = EINVAL;
@@ -127,17 +127,17 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd)
buf = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname);
sha256 = xbps_file_hash(buf);
assert(sha256);
prop_dictionary_set_cstring(pkgd, "metafile-sha256", sha256);
xbps_dictionary_set_cstring(pkgd, "metafile-sha256", sha256);
free(sha256);
free(buf);
/*
* Remove unneeded objs from pkg dictionary.
*/
prop_dictionary_remove(pkgd, "remove-and-update");
prop_dictionary_remove(pkgd, "transaction");
prop_dictionary_remove(pkgd, "skip-obsoletes");
xbps_dictionary_remove(pkgd, "remove-and-update");
xbps_dictionary_remove(pkgd, "transaction");
xbps_dictionary_remove(pkgd, "skip-obsoletes");
if (!prop_dictionary_set(xhp->pkgdb, pkgname, pkgd)) {
if (!xbps_dictionary_set(xhp->pkgdb, pkgname, pkgd)) {
xbps_dbg_printf(xhp,
"%s: failed to set pkgd for %s\n", __func__, pkgver);
goto out;

View File

@@ -35,24 +35,24 @@
int HIDDEN
xbps_remove_pkg_files(struct xbps_handle *xhp,
prop_dictionary_t dict,
xbps_dictionary_t dict,
const char *key,
const char *pkgver)
{
struct stat st;
prop_array_t array;
prop_object_iterator_t iter;
prop_object_t obj;
xbps_array_t array;
xbps_object_iterator_t iter;
xbps_object_t obj;
const char *file, *sha256, *curobj = NULL;
char *path = NULL, *pkgname = NULL;
char buf[PATH_MAX];
int rv = 0;
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
assert(key != NULL);
array = prop_dictionary_get(dict, key);
if (prop_array_count(array) == 0)
array = xbps_dictionary_get(dict, key);
if (xbps_array_count(array) == 0)
return 0;
iter = xbps_array_iter_from_dict(dict, key);
@@ -71,8 +71,8 @@ xbps_remove_pkg_files(struct xbps_handle *xhp,
pkgname = xbps_pkg_name(pkgver);
assert(pkgname);
while ((obj = prop_object_iterator_next(iter))) {
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
while ((obj = xbps_object_iterator_next(iter))) {
xbps_dictionary_get_cstring_nocopy(obj, "file", &file);
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
if ((strcmp(key, "files") == 0) ||
@@ -81,7 +81,7 @@ xbps_remove_pkg_files(struct xbps_handle *xhp,
* Check SHA256 hash in regular files and
* configuration files.
*/
prop_dictionary_get_cstring_nocopy(obj,
xbps_dictionary_get_cstring_nocopy(obj,
"sha256", &sha256);
rv = xbps_file_hash_check(path, sha256);
if (rv == ENOENT) {
@@ -157,7 +157,7 @@ xbps_remove_pkg_files(struct xbps_handle *xhp,
}
free(path);
}
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
free(pkgname);
return rv;
@@ -169,7 +169,7 @@ xbps_remove_pkg(struct xbps_handle *xhp,
bool update,
bool soft_replace)
{
prop_dictionary_t pkgd = NULL;
xbps_dictionary_t pkgd = NULL;
char *pkgname, *buf = NULL;
int rv = 0;
pkg_state_t state = 0;
@@ -200,7 +200,7 @@ xbps_remove_pkg(struct xbps_handle *xhp,
/* internalize pkg dictionary from metadir */
buf = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname);
pkgd = prop_dictionary_internalize_from_file(buf);
pkgd = xbps_dictionary_internalize_from_file(buf);
free(buf);
if (pkgd == NULL)
xbps_dbg_printf(xhp, "WARNING: metaplist for %s "
@@ -231,7 +231,7 @@ xbps_remove_pkg(struct xbps_handle *xhp,
*/
if (update) {
if (pkgd)
prop_object_release(pkgd);
xbps_object_release(pkgd);
free(pkgname);
return 0;
} else if (soft_replace) {
@@ -297,7 +297,7 @@ purge:
"purge ACTION: %s", pkgver, strerror(rv));
goto out;
}
prop_object_release(pkgd);
xbps_object_release(pkgd);
}
/*
* Remove package metadata plist.
@@ -315,7 +315,7 @@ purge:
/*
* Unregister package from pkgdb.
*/
prop_dictionary_remove(xhp->pkgdb, pkgname);
xbps_dictionary_remove(xhp->pkgdb, pkgname);
if ((rv = xbps_pkgdb_update(xhp, true)) != 0)
goto out;

View File

@@ -109,12 +109,12 @@ out:
int
xbps_pkg_exec_script(struct xbps_handle *xhp,
prop_dictionary_t d,
xbps_dictionary_t d,
const char *script,
const char *action,
bool update)
{
prop_data_t data;
xbps_data_t data;
void *buf;
size_t buflen;
const char *pkgver;
@@ -125,14 +125,14 @@ xbps_pkg_exec_script(struct xbps_handle *xhp,
assert(script);
assert(action);
data = prop_dictionary_get(d, script);
data = xbps_dictionary_get(d, script);
if (data == NULL)
return 0;
prop_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver);
buf = prop_data_data(data);
buflen = prop_data_size(data);
buf = xbps_data_data(data);
buflen = xbps_data_size(data);
rv = xbps_pkg_exec_buffer(xhp, buf, buflen, pkgver, action, update);
free(buf);

View File

@@ -53,11 +53,11 @@ static const struct state states[] = {
*/
static int
set_new_state(prop_dictionary_t dict, pkg_state_t state)
set_new_state(xbps_dictionary_t dict, pkg_state_t state)
{
const struct state *stp;
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
for (stp = states; stp->string != NULL; stp++)
if (state == stp->number)
@@ -66,21 +66,21 @@ set_new_state(prop_dictionary_t dict, pkg_state_t state)
if (stp->string == NULL)
return EINVAL;
if (!prop_dictionary_set_cstring_nocopy(dict, "state", stp->string))
if (!xbps_dictionary_set_cstring_nocopy(dict, "state", stp->string))
return EINVAL;
return 0;
}
static pkg_state_t
get_state(prop_dictionary_t dict)
get_state(xbps_dictionary_t dict)
{
const struct state *stp;
const char *state_str;
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
if (!prop_dictionary_get_cstring_nocopy(dict,
if (!xbps_dictionary_get_cstring_nocopy(dict,
"state", &state_str))
return 0;
@@ -96,7 +96,7 @@ xbps_pkg_state_installed(struct xbps_handle *xhp,
const char *pkgver,
pkg_state_t *state)
{
prop_dictionary_t pkgd;
xbps_dictionary_t pkgd;
assert(pkgver != NULL);
assert(state != NULL);
@@ -113,9 +113,9 @@ xbps_pkg_state_installed(struct xbps_handle *xhp,
}
int
xbps_pkg_state_dictionary(prop_dictionary_t dict, pkg_state_t *state)
xbps_pkg_state_dictionary(xbps_dictionary_t dict, pkg_state_t *state)
{
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
assert(state != NULL);
if ((*state = get_state(dict)) == 0)
@@ -125,9 +125,9 @@ xbps_pkg_state_dictionary(prop_dictionary_t dict, pkg_state_t *state)
}
int
xbps_set_pkg_state_dictionary(prop_dictionary_t dict, pkg_state_t state)
xbps_set_pkg_state_dictionary(xbps_dictionary_t dict, pkg_state_t state)
{
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
return set_new_state(dict, state);
}
@@ -137,7 +137,7 @@ xbps_set_pkg_state_installed(struct xbps_handle *xhp,
const char *pkgver,
pkg_state_t state)
{
prop_dictionary_t pkgd;
xbps_dictionary_t pkgd;
char *pkgname;
int rv = 0;
@@ -145,35 +145,35 @@ xbps_set_pkg_state_installed(struct xbps_handle *xhp,
pkgd = xbps_pkgdb_get_pkg(xhp, pkgver);
if (pkgd == NULL) {
pkgd = prop_dictionary_create();
pkgd = xbps_dictionary_create();
if (pkgd == NULL)
return ENOMEM;
if (!prop_dictionary_set_cstring_nocopy(pkgd,
if (!xbps_dictionary_set_cstring_nocopy(pkgd,
"pkgver", pkgver)) {
prop_object_release(pkgd);
xbps_object_release(pkgd);
return EINVAL;
}
if ((rv = set_new_state(pkgd, state)) != 0) {
prop_object_release(pkgd);
xbps_object_release(pkgd);
return rv;
}
pkgname = xbps_pkg_name(pkgver);
assert(pkgname);
if (!prop_dictionary_set(xhp->pkgdb, pkgname, pkgd)) {
prop_object_release(pkgd);
if (!xbps_dictionary_set(xhp->pkgdb, pkgname, pkgd)) {
xbps_object_release(pkgd);
free(pkgname);
return EINVAL;
}
free(pkgname);
prop_object_release(pkgd);
xbps_object_release(pkgd);
} else {
if ((rv = set_new_state(pkgd, state)) != 0)
return rv;
pkgname = xbps_pkg_name(pkgver);
assert(pkgname);
if (!prop_dictionary_set(xhp->pkgdb, pkgname, pkgd)) {
if (!xbps_dictionary_set(xhp->pkgdb, pkgname, pkgd)) {
free(pkgname);
return EINVAL;
}

View File

@@ -53,23 +53,23 @@ set_extract_flags(uid_t euid)
}
static const char *
find_pkg_symlink_target(prop_dictionary_t d, const char *file)
find_pkg_symlink_target(xbps_dictionary_t d, const char *file)
{
prop_array_t links;
prop_object_t obj;
xbps_array_t links;
xbps_object_t obj;
unsigned int i;
const char *pkgfile, *tgt = NULL;
char *rfile;
assert(d);
links = prop_dictionary_get(d, "links");
for (i = 0; i < prop_array_count(links); i++) {
links = xbps_dictionary_get(d, "links");
for (i = 0; i < xbps_array_count(links); i++) {
rfile = strchr(file, '.') + 1;
obj = prop_array_get(links, i);
prop_dictionary_get_cstring_nocopy(obj, "file", &pkgfile);
obj = xbps_array_get(links, i);
xbps_dictionary_get_cstring_nocopy(obj, "file", &pkgfile);
if (strcmp(rfile, pkgfile) == 0) {
prop_dictionary_get_cstring_nocopy(obj, "target", &tgt);
xbps_dictionary_get_cstring_nocopy(obj, "target", &tgt);
break;
}
}
@@ -79,52 +79,52 @@ find_pkg_symlink_target(prop_dictionary_t d, const char *file)
static int
create_pkg_metaplist(struct xbps_handle *xhp, const char *pkgname, const char *pkgver,
prop_dictionary_t propsd, prop_dictionary_t filesd,
xbps_dictionary_t propsd, xbps_dictionary_t filesd,
const void *instbuf, const size_t instbufsiz,
const void *rembuf, const size_t rembufsiz)
{
prop_array_t array;
prop_dictionary_t pkg_metad;
prop_data_t data;
xbps_array_t array;
xbps_dictionary_t pkg_metad;
xbps_data_t data;
char *buf;
int rv = 0;
prop_dictionary_make_immutable(propsd);
pkg_metad = prop_dictionary_copy_mutable(propsd);
xbps_dictionary_make_immutable(propsd);
pkg_metad = xbps_dictionary_copy_mutable(propsd);
/* Add objects from XBPS_PKGFILES */
array = prop_dictionary_get(filesd, "files");
if (prop_array_count(array))
prop_dictionary_set(pkg_metad, "files", array);
array = prop_dictionary_get(filesd, "conf_files");
if (prop_array_count(array))
prop_dictionary_set(pkg_metad, "conf_files", array);
array = prop_dictionary_get(filesd, "links");
if (prop_array_count(array))
prop_dictionary_set(pkg_metad, "links", array);
array = prop_dictionary_get(filesd, "dirs");
if (prop_array_count(array))
prop_dictionary_set(pkg_metad, "dirs", array);
array = xbps_dictionary_get(filesd, "files");
if (xbps_array_count(array))
xbps_dictionary_set(pkg_metad, "files", array);
array = xbps_dictionary_get(filesd, "conf_files");
if (xbps_array_count(array))
xbps_dictionary_set(pkg_metad, "conf_files", array);
array = xbps_dictionary_get(filesd, "links");
if (xbps_array_count(array))
xbps_dictionary_set(pkg_metad, "links", array);
array = xbps_dictionary_get(filesd, "dirs");
if (xbps_array_count(array))
xbps_dictionary_set(pkg_metad, "dirs", array);
/* Add install/remove scripts data objects */
if (instbuf != NULL) {
data = prop_data_create_data(instbuf, instbufsiz);
data = xbps_data_create_data(instbuf, instbufsiz);
assert(data);
prop_dictionary_set(pkg_metad, "install-script", data);
prop_object_release(data);
xbps_dictionary_set(pkg_metad, "install-script", data);
xbps_object_release(data);
}
if (rembuf != NULL) {
data = prop_data_create_data(rembuf, rembufsiz);
data = xbps_data_create_data(rembuf, rembufsiz);
assert(data);
prop_dictionary_set(pkg_metad, "remove-script", data);
prop_object_release(data);
xbps_dictionary_set(pkg_metad, "remove-script", data);
xbps_object_release(data);
}
/* Remove unneeded objs from transaction */
prop_dictionary_remove(pkg_metad, "remove-and-update");
prop_dictionary_remove(pkg_metad, "transaction");
prop_dictionary_remove(pkg_metad, "state");
prop_dictionary_remove(pkg_metad, "pkgname");
prop_dictionary_remove(pkg_metad, "version");
xbps_dictionary_remove(pkg_metad, "remove-and-update");
xbps_dictionary_remove(pkg_metad, "transaction");
xbps_dictionary_remove(pkg_metad, "state");
xbps_dictionary_remove(pkg_metad, "pkgname");
xbps_dictionary_remove(pkg_metad, "version");
/*
* Externalize pkg dictionary to metadir.
@@ -137,7 +137,7 @@ create_pkg_metaplist(struct xbps_handle *xhp, const char *pkgname, const char *p
}
}
buf = xbps_xasprintf("%s/.%s.plist", XBPS_META_PATH, pkgname);
if (!prop_dictionary_externalize_to_file(pkg_metad, buf)) {
if (!xbps_dictionary_externalize_to_file(pkg_metad, buf)) {
rv = errno;
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
errno, pkgver,
@@ -145,21 +145,21 @@ create_pkg_metaplist(struct xbps_handle *xhp, const char *pkgname, const char *p
pkgver, buf, strerror(errno));
}
free(buf);
prop_object_release(pkg_metad);
xbps_object_release(pkg_metad);
return rv;
}
static int
unpack_archive(struct xbps_handle *xhp,
prop_dictionary_t pkg_repod,
xbps_dictionary_t pkg_repod,
const char *pkgver,
const char *fname,
struct archive *ar)
{
prop_dictionary_t propsd, filesd, old_filesd;
prop_array_t array, obsoletes;
prop_object_t obj;
xbps_dictionary_t propsd, filesd, old_filesd;
xbps_array_t array, obsoletes;
xbps_object_t obj;
void *instbuf = NULL, *rembuf = NULL;
struct stat st;
struct xbps_unpack_cb_data xucd;
@@ -173,17 +173,17 @@ unpack_archive(struct xbps_handle *xhp,
bool softreplace, skip_extract, force, metafile;
uid_t euid;
assert(prop_object_type(pkg_repod) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(pkg_repod) == XBPS_TYPE_DICTIONARY);
assert(ar != NULL);
propsd = filesd = old_filesd = NULL;
force = preserve = update = conf_file = file_exists = false;
skip_obsoletes = softreplace = metafile = false;
prop_dictionary_get_bool(pkg_repod, "preserve", &preserve);
prop_dictionary_get_bool(pkg_repod, "skip-obsoletes", &skip_obsoletes);
prop_dictionary_get_bool(pkg_repod, "softreplace", &softreplace);
prop_dictionary_get_cstring_nocopy(pkg_repod,
xbps_dictionary_get_bool(pkg_repod, "preserve", &preserve);
xbps_dictionary_get_bool(pkg_repod, "skip-obsoletes", &skip_obsoletes);
xbps_dictionary_get_bool(pkg_repod, "softreplace", &softreplace);
xbps_dictionary_get_cstring_nocopy(pkg_repod,
"transaction", &transact);
euid = geteuid();
@@ -350,15 +350,15 @@ unpack_archive(struct xbps_handle *xhp,
*/
if (xhp->unpack_cb != NULL) {
xucd.entry_total_count = 0;
array = prop_dictionary_get(filesd, "files");
array = xbps_dictionary_get(filesd, "files");
xucd.entry_total_count +=
(ssize_t)prop_array_count(array);
array = prop_dictionary_get(filesd, "conf_files");
(ssize_t)xbps_array_count(array);
array = xbps_dictionary_get(filesd, "conf_files");
xucd.entry_total_count +=
(ssize_t)prop_array_count(array);
array = prop_dictionary_get(filesd, "links");
(ssize_t)xbps_array_count(array);
array = xbps_dictionary_get(filesd, "links");
xucd.entry_total_count +=
(ssize_t)prop_array_count(array);
(ssize_t)xbps_array_count(array);
}
/*
* Always check that extracted file exists and hash
@@ -589,9 +589,9 @@ unpack_archive(struct xbps_handle *xhp,
goto out;
obsoletes = xbps_find_pkg_obsoletes(xhp, old_filesd, filesd);
for (i = 0; i < prop_array_count(obsoletes); i++) {
obj = prop_array_get(obsoletes, i);
file = prop_string_cstring_nocopy(obj);
for (i = 0; i < xbps_array_count(obsoletes); i++) {
obj = xbps_array_get(obsoletes, i);
file = xbps_string_cstring_nocopy(obj);
if (remove(file) == -1) {
xbps_set_cb_state(xhp,
XBPS_STATE_REMOVE_FILE_OBSOLETE_FAIL,
@@ -603,14 +603,14 @@ unpack_archive(struct xbps_handle *xhp,
xbps_set_cb_state(xhp,
XBPS_STATE_REMOVE_FILE_OBSOLETE,
0, pkgver, "%s: removed obsolete entry: %s", pkgver, file);
prop_object_release(obj);
xbps_object_release(obj);
}
out:
if (prop_object_type(filesd) == PROP_TYPE_DICTIONARY)
prop_object_release(filesd);
if (prop_object_type(propsd) == PROP_TYPE_DICTIONARY)
prop_object_release(propsd);
if (xbps_object_type(filesd) == XBPS_TYPE_DICTIONARY)
xbps_object_release(filesd);
if (xbps_object_type(propsd) == XBPS_TYPE_DICTIONARY)
xbps_object_release(propsd);
if (pkgname != NULL)
free(pkgname);
if (instbuf != NULL)
@@ -622,16 +622,16 @@ out:
}
int HIDDEN
xbps_unpack_binary_pkg(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
xbps_unpack_binary_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkg_repod)
{
struct archive *ar = NULL;
const char *pkgver;
char *bpkg;
int pkg_fd, rv = 0;
assert(prop_object_type(pkg_repod) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(pkg_repod) == XBPS_TYPE_DICTIONARY);
prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &pkgver);
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK, 0, pkgver, NULL);
bpkg = xbps_repository_pkg_path(xhp, pkg_repod);

View File

@@ -79,7 +79,7 @@ xbps_pkgdb_init(struct xbps_handle *xhp)
int
xbps_pkgdb_update(struct xbps_handle *xhp, bool flush)
{
prop_dictionary_t pkgdb_storage;
xbps_dictionary_t pkgdb_storage;
char *plist;
static int cached_rv;
int rv = 0;
@@ -89,26 +89,26 @@ xbps_pkgdb_update(struct xbps_handle *xhp, bool flush)
plist = xbps_xasprintf("%s/%s", xhp->metadir, XBPS_PKGDB);
if (xhp->pkgdb && flush) {
pkgdb_storage = prop_dictionary_internalize_from_file(plist);
pkgdb_storage = xbps_dictionary_internalize_from_file(plist);
if (pkgdb_storage == NULL ||
!prop_dictionary_equals(xhp->pkgdb, pkgdb_storage)) {
!xbps_dictionary_equals(xhp->pkgdb, pkgdb_storage)) {
/* flush dictionary to storage */
if (!prop_dictionary_externalize_to_file(xhp->pkgdb, plist)) {
if (!xbps_dictionary_externalize_to_file(xhp->pkgdb, plist)) {
free(plist);
return errno;
}
}
if (pkgdb_storage)
prop_object_release(pkgdb_storage);
xbps_object_release(pkgdb_storage);
prop_object_release(xhp->pkgdb);
xbps_object_release(xhp->pkgdb);
xhp->pkgdb = NULL;
cached_rv = 0;
}
/* update copy in memory */
if ((xhp->pkgdb = prop_dictionary_internalize_from_file(plist)) == NULL) {
if ((xhp->pkgdb = xbps_dictionary_internalize_from_file(plist)) == NULL) {
if (errno == ENOENT)
xhp->pkgdb = prop_dictionary_create();
xhp->pkgdb = xbps_dictionary_create();
else
xbps_error_printf("cannot access to pkgdb: %s\n", strerror(errno));
@@ -127,22 +127,22 @@ 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);
if (xbps_object_type(xhp->pkg_metad) == XBPS_TYPE_DICTIONARY)
xbps_object_release(xhp->pkg_metad);
prop_object_release(xhp->pkgdb);
xbps_object_release(xhp->pkgdb);
xhp->pkgdb = NULL;
xbps_dbg_printf(xhp, "[pkgdb] released ok.\n");
}
int
xbps_pkgdb_foreach_reverse_cb(struct xbps_handle *xhp,
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *),
int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *),
void *arg)
{
prop_array_t allkeys;
prop_object_t obj;
prop_dictionary_t pkgd;
xbps_array_t allkeys;
xbps_object_t obj;
xbps_dictionary_t pkgd;
unsigned int i;
int rv;
bool done = false;
@@ -150,45 +150,45 @@ xbps_pkgdb_foreach_reverse_cb(struct xbps_handle *xhp,
if ((rv = xbps_pkgdb_init(xhp)) != 0)
return rv;
allkeys = prop_dictionary_all_keys(xhp->pkgdb);
for (i = prop_array_count(allkeys); i > 0; i--) {
obj = prop_array_get(allkeys, i);
pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj);
allkeys = xbps_dictionary_all_keys(xhp->pkgdb);
for (i = xbps_array_count(allkeys); i > 0; i--) {
obj = xbps_array_get(allkeys, i);
pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj);
rv = (*fn)(xhp, pkgd, arg, &done);
if (rv != 0 || done)
break;
}
prop_object_release(allkeys);
xbps_object_release(allkeys);
return rv;
}
int
xbps_pkgdb_foreach_cb(struct xbps_handle *xhp,
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *),
int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *),
void *arg)
{
prop_object_t obj;
prop_object_iterator_t iter;
prop_dictionary_t pkgd;
xbps_object_t obj;
xbps_object_iterator_t iter;
xbps_dictionary_t pkgd;
int rv;
bool done = false;
if ((rv = xbps_pkgdb_init(xhp)) != 0)
return rv;
iter = prop_dictionary_iterator(xhp->pkgdb);
iter = xbps_dictionary_iterator(xhp->pkgdb);
assert(iter);
while ((obj = prop_object_iterator_next(iter))) {
pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj);
while ((obj = xbps_object_iterator_next(iter))) {
pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj);
rv = (*fn)(xhp, pkgd, arg, &done);
if (rv != 0 || done)
break;
}
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
return rv;
}
prop_dictionary_t
xbps_dictionary_t
xbps_pkgdb_get_pkg(struct xbps_handle *xhp, const char *pkg)
{
if (xbps_pkgdb_init(xhp) != 0)
@@ -197,7 +197,7 @@ xbps_pkgdb_get_pkg(struct xbps_handle *xhp, const char *pkg)
return xbps_find_pkg_in_dict(xhp->pkgdb, pkg);
}
prop_dictionary_t
xbps_dictionary_t
xbps_pkgdb_get_virtualpkg(struct xbps_handle *xhp, const char *vpkg)
{
if (xbps_pkgdb_init(xhp) != 0)
@@ -206,23 +206,23 @@ xbps_pkgdb_get_virtualpkg(struct xbps_handle *xhp, const char *vpkg)
return xbps_find_virtualpkg_in_dict(xhp, xhp->pkgdb, vpkg);
}
static prop_dictionary_t
get_pkg_metadata(struct xbps_handle *xhp, prop_dictionary_t pkgd)
static xbps_dictionary_t
get_pkg_metadata(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
{
prop_dictionary_t pkg_metad;
xbps_dictionary_t pkg_metad;
const char *pkgver;
char *pkgname, *plist;
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
pkgname = xbps_pkg_name(pkgver);
assert(pkgname);
if ((pkg_metad = prop_dictionary_get(xhp->pkg_metad, pkgname)) != NULL) {
if ((pkg_metad = xbps_dictionary_get(xhp->pkg_metad, pkgname)) != NULL) {
free(pkgname);
return pkg_metad;
}
plist = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname);
pkg_metad = prop_dictionary_internalize_from_file(plist);
pkg_metad = xbps_dictionary_internalize_from_file(plist);
free(plist);
if (pkg_metad == NULL) {
@@ -233,10 +233,10 @@ get_pkg_metadata(struct xbps_handle *xhp, prop_dictionary_t pkgd)
}
if (xhp->pkg_metad == NULL)
xhp->pkg_metad = prop_dictionary_create();
xhp->pkg_metad = xbps_dictionary_create();
prop_dictionary_set(xhp->pkg_metad, pkgname, pkg_metad);
prop_object_release(pkg_metad);
xbps_dictionary_set(xhp->pkg_metad, pkgname, pkg_metad);
xbps_object_release(pkg_metad);
free(pkgname);
return pkg_metad;
@@ -245,10 +245,10 @@ get_pkg_metadata(struct xbps_handle *xhp, prop_dictionary_t pkgd)
static void
generate_full_revdeps_tree(struct xbps_handle *xhp)
{
prop_array_t rundeps, pkg;
prop_dictionary_t pkgd;
prop_object_t obj;
prop_object_iterator_t iter;
xbps_array_t rundeps, pkg;
xbps_dictionary_t pkgd;
xbps_object_t obj;
xbps_object_iterator_t iter;
const char *pkgver, *pkgdep, *vpkgname;
char *curpkgname;
unsigned int i;
@@ -257,20 +257,20 @@ generate_full_revdeps_tree(struct xbps_handle *xhp)
if (xhp->pkgdb_revdeps)
return;
xhp->pkgdb_revdeps = prop_dictionary_create();
xhp->pkgdb_revdeps = xbps_dictionary_create();
iter = prop_dictionary_iterator(xhp->pkgdb);
iter = xbps_dictionary_iterator(xhp->pkgdb);
assert(iter);
while ((obj = prop_object_iterator_next(iter))) {
pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj);
rundeps = prop_dictionary_get(pkgd, "run_depends");
if (!prop_array_count(rundeps))
while ((obj = xbps_object_iterator_next(iter))) {
pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj);
rundeps = xbps_dictionary_get(pkgd, "run_depends");
if (!xbps_array_count(rundeps))
continue;
for (i = 0; i < prop_array_count(rundeps); i++) {
for (i = 0; i < xbps_array_count(rundeps); i++) {
alloc = false;
prop_array_get_cstring_nocopy(rundeps, i, &pkgdep);
xbps_array_get_cstring_nocopy(rundeps, i, &pkgdep);
curpkgname = xbps_pkgpattern_name(pkgdep);
if (curpkgname == NULL)
curpkgname = xbps_pkg_name(pkgdep);
@@ -279,29 +279,29 @@ generate_full_revdeps_tree(struct xbps_handle *xhp)
if (vpkgname == NULL)
vpkgname = curpkgname;
pkg = prop_dictionary_get(xhp->pkgdb_revdeps, vpkgname);
pkg = xbps_dictionary_get(xhp->pkgdb_revdeps, vpkgname);
if (pkg == NULL) {
alloc = true;
pkg = prop_array_create();
pkg = xbps_array_create();
}
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
if (!xbps_match_string_in_array(pkg, pkgver)) {
prop_array_add_cstring_nocopy(pkg, pkgver);
prop_dictionary_set(xhp->pkgdb_revdeps, vpkgname, pkg);
xbps_array_add_cstring_nocopy(pkg, pkgver);
xbps_dictionary_set(xhp->pkgdb_revdeps, vpkgname, pkg);
}
free(curpkgname);
if (alloc)
prop_object_release(pkg);
xbps_object_release(pkg);
}
}
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
}
prop_array_t
xbps_array_t
xbps_pkgdb_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
{
prop_array_t res;
prop_dictionary_t pkgd;
xbps_array_t res;
xbps_dictionary_t pkgd;
const char *pkgver;
char *pkgname;
@@ -309,18 +309,18 @@ xbps_pkgdb_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
return NULL;
generate_full_revdeps_tree(xhp);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
pkgname = xbps_pkg_name(pkgver);
res = prop_dictionary_get(xhp->pkgdb_revdeps, pkgname);
res = xbps_dictionary_get(xhp->pkgdb_revdeps, pkgname);
free(pkgname);
return res;
}
prop_dictionary_t
xbps_dictionary_t
xbps_pkgdb_get_pkg_metadata(struct xbps_handle *xhp, const char *pkg)
{
prop_dictionary_t pkgd;
xbps_dictionary_t pkgd;
pkgd = xbps_pkgdb_get_pkg(xhp, pkg);
if (pkgd == NULL)

View File

@@ -40,88 +40,88 @@
* all library functions.
*/
bool HIDDEN
xbps_add_obj_to_dict(prop_dictionary_t dict, prop_object_t obj,
xbps_add_obj_to_dict(xbps_dictionary_t dict, xbps_object_t obj,
const char *key)
{
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
assert(obj != NULL);
assert(key != NULL);
if (!prop_dictionary_set(dict, key, obj)) {
prop_object_release(dict);
if (!xbps_dictionary_set(dict, key, obj)) {
xbps_object_release(dict);
errno = EINVAL;
return false;
}
prop_object_release(obj);
xbps_object_release(obj);
return true;
}
bool HIDDEN
xbps_add_obj_to_array(prop_array_t array, prop_object_t obj)
xbps_add_obj_to_array(xbps_array_t array, xbps_object_t obj)
{
assert(prop_object_type(array) == PROP_TYPE_ARRAY);
assert(xbps_object_type(array) == XBPS_TYPE_ARRAY);
assert(obj != NULL);
if (!prop_array_add(array, obj)) {
prop_object_release(array);
if (!xbps_array_add(array, obj)) {
xbps_object_release(array);
errno = EINVAL;
return false;
}
prop_object_release(obj);
xbps_object_release(obj);
return true;
}
int
xbps_callback_array_iter(struct xbps_handle *xhp,
prop_array_t array,
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *),
xbps_array_t array,
int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *),
void *arg)
{
prop_object_t obj;
prop_object_iterator_t iter;
xbps_object_t obj;
xbps_object_iterator_t iter;
int rv = 0;
bool loop_done = false;
assert(prop_object_type(array) == PROP_TYPE_ARRAY);
assert(xbps_object_type(array) == XBPS_TYPE_ARRAY);
assert(fn != NULL);
iter = prop_array_iterator(array);
iter = xbps_array_iterator(array);
if (iter == NULL)
return ENOMEM;
while ((obj = prop_object_iterator_next(iter)) != NULL) {
while ((obj = xbps_object_iterator_next(iter)) != NULL) {
rv = (*fn)(xhp, obj, arg, &loop_done);
if (rv != 0 || loop_done)
break;
}
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
return rv;
}
int
xbps_callback_array_iter_in_dict(struct xbps_handle *xhp,
prop_dictionary_t dict,
xbps_dictionary_t dict,
const char *key,
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *),
int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *),
void *arg)
{
prop_object_t obj;
prop_array_t array;
xbps_object_t obj;
xbps_array_t array;
unsigned int i;
int rv = 0;
bool cbloop_done = false;
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
assert(xhp != NULL);
assert(key != NULL);
assert(fn != NULL);
array = prop_dictionary_get(dict, key);
for (i = 0; i < prop_array_count(array); i++) {
obj = prop_array_get(array, i);
array = xbps_dictionary_get(dict, key);
for (i = 0; i < xbps_array_count(array); i++) {
obj = xbps_array_get(array, i);
if (obj == NULL)
continue;
rv = (*fn)(xhp, obj, arg, &cbloop_done);
@@ -134,24 +134,24 @@ xbps_callback_array_iter_in_dict(struct xbps_handle *xhp,
int
xbps_callback_array_iter_reverse(struct xbps_handle *xhp,
prop_array_t array,
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *),
xbps_array_t array,
int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *),
void *arg)
{
prop_object_t obj;
xbps_object_t obj;
unsigned int cnt;
int rv = 0;
bool loop_done = false;
assert(prop_object_type(array) == PROP_TYPE_ARRAY);
assert(xbps_object_type(array) == XBPS_TYPE_ARRAY);
assert(fn != NULL);
assert(xhp != NULL);
if ((cnt = prop_array_count(array)) == 0)
if ((cnt = xbps_array_count(array)) == 0)
return 0;
while (cnt--) {
obj = prop_array_get(array, cnt);
obj = xbps_array_get(array, cnt);
if (obj == NULL)
continue;
rv = (*fn)(xhp, obj, arg, &loop_done);
@@ -164,20 +164,20 @@ xbps_callback_array_iter_reverse(struct xbps_handle *xhp,
int
xbps_callback_array_iter_reverse_in_dict(struct xbps_handle *xhp,
prop_dictionary_t dict,
xbps_dictionary_t dict,
const char *key,
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *),
int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *),
void *arg)
{
prop_array_t array;
xbps_array_t array;
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
assert(key != NULL);
assert(fn != NULL);
assert(xhp != NULL);
array = prop_dictionary_get(dict, key);
if (prop_object_type(array) != PROP_TYPE_ARRAY) {
array = xbps_dictionary_get(dict, key);
if (xbps_object_type(array) != XBPS_TYPE_ARRAY) {
xbps_dbg_printf(xhp, "invalid key '%s' for dictionary", key);
return EINVAL;
}
@@ -185,60 +185,60 @@ xbps_callback_array_iter_reverse_in_dict(struct xbps_handle *xhp,
return xbps_callback_array_iter_reverse(xhp, array, fn, arg);
}
prop_object_iterator_t
xbps_array_iter_from_dict(prop_dictionary_t dict, const char *key)
xbps_object_iterator_t
xbps_array_iter_from_dict(xbps_dictionary_t dict, const char *key)
{
prop_array_t array;
xbps_array_t array;
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
assert(key != NULL);
array = prop_dictionary_get(dict, key);
if (prop_object_type(array) != PROP_TYPE_ARRAY) {
array = xbps_dictionary_get(dict, key);
if (xbps_object_type(array) != XBPS_TYPE_ARRAY) {
errno = EINVAL;
return NULL;
}
return prop_array_iterator(array);
return xbps_array_iterator(array);
}
static int
array_replace_dict(prop_array_t array,
prop_dictionary_t dict,
array_replace_dict(xbps_array_t array,
xbps_dictionary_t dict,
const char *str,
bool bypattern)
{
prop_object_t obj;
xbps_object_t obj;
unsigned int i;
const char *curpkgver;
char *curpkgname;
assert(prop_object_type(array) == PROP_TYPE_ARRAY);
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(array) == XBPS_TYPE_ARRAY);
assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
assert(str != NULL);
for (i = 0; i < prop_array_count(array); i++) {
obj = prop_array_get(array, i);
for (i = 0; i < xbps_array_count(array); i++) {
obj = xbps_array_get(array, i);
if (obj == NULL)
continue;
if (bypattern) {
/* pkgpattern match */
prop_dictionary_get_cstring_nocopy(obj,
xbps_dictionary_get_cstring_nocopy(obj,
"pkgver", &curpkgver);
if (xbps_pkgpattern_match(curpkgver, str)) {
if (!prop_array_set(array, i, dict))
if (!xbps_array_set(array, i, dict))
return EINVAL;
return 0;
}
} else {
/* pkgname match */
prop_dictionary_get_cstring_nocopy(obj,
xbps_dictionary_get_cstring_nocopy(obj,
"pkgver", &curpkgver);
curpkgname = xbps_pkg_name(curpkgver);
assert(curpkgname);
if (strcmp(curpkgname, str) == 0) {
if (!prop_array_set(array, i, dict)) {
if (!xbps_array_set(array, i, dict)) {
free(curpkgname);
return EINVAL;
}
@@ -253,16 +253,16 @@ array_replace_dict(prop_array_t array,
}
int HIDDEN
xbps_array_replace_dict_by_name(prop_array_t array,
prop_dictionary_t dict,
xbps_array_replace_dict_by_name(xbps_array_t array,
xbps_dictionary_t dict,
const char *pkgver)
{
return array_replace_dict(array, dict, pkgver, false);
}
int HIDDEN
xbps_array_replace_dict_by_pattern(prop_array_t array,
prop_dictionary_t dict,
xbps_array_replace_dict_by_pattern(xbps_array_t array,
xbps_dictionary_t dict,
const char *pattern)
{
return array_replace_dict(array, dict, pattern, true);

View File

@@ -145,10 +145,10 @@ open_archive(const char *url)
return a;
}
prop_dictionary_t
xbps_dictionary_t
xbps_get_pkg_plist_from_binpkg(const char *fname, const char *plistf)
{
prop_dictionary_t plistd = NULL;
xbps_dictionary_t plistd = NULL;
struct archive *a;
struct archive_entry *entry;
const char *curpath, *comptype;
@@ -185,7 +185,7 @@ xbps_get_pkg_plist_from_binpkg(const char *fname, const char *plistf)
errno = EINVAL;
break;
}
prop_dictionary_set_cstring_nocopy(plistd,
xbps_dictionary_set_cstring_nocopy(plistd,
"archive-compression-type", comptype);
break;

View File

@@ -37,19 +37,19 @@
static pthread_mutex_t cfg_mtx = PTHREAD_MUTEX_INITIALIZER;
static bool cfg_vpkgs_init;
static prop_dictionary_t
get_pkg_in_array(prop_array_t array, const char *str, bool virtual)
static xbps_dictionary_t
get_pkg_in_array(xbps_array_t array, const char *str, bool virtual)
{
prop_object_t obj = NULL;
prop_object_iterator_t iter;
xbps_object_t obj = NULL;
xbps_object_iterator_t iter;
const char *pkgver;
char *dpkgn;
bool found = false;
iter = prop_array_iterator(array);
iter = xbps_array_iterator(array);
assert(iter);
while ((obj = prop_object_iterator_next(iter))) {
while ((obj = xbps_object_iterator_next(iter))) {
if (virtual) {
/*
* Check if package pattern matches
@@ -64,7 +64,7 @@ get_pkg_in_array(prop_array_t array, const char *str, bool virtual)
break;
} else if (xbps_pkgpattern_version(str)) {
/* ,atch by pattern against pkgver */
if (!prop_dictionary_get_cstring_nocopy(obj,
if (!xbps_dictionary_get_cstring_nocopy(obj,
"pkgver", &pkgver))
continue;
if (xbps_pkgpattern_match(pkgver, str)) {
@@ -73,7 +73,7 @@ get_pkg_in_array(prop_array_t array, const char *str, bool virtual)
}
} else if (xbps_pkg_version(str)) {
/* match by exact pkgver */
if (!prop_dictionary_get_cstring_nocopy(obj,
if (!xbps_dictionary_get_cstring_nocopy(obj,
"pkgver", &pkgver))
continue;
if (strcmp(str, pkgver) == 0) {
@@ -82,7 +82,7 @@ get_pkg_in_array(prop_array_t array, const char *str, bool virtual)
}
} else {
/* match by pkgname */
if (!prop_dictionary_get_cstring_nocopy(obj,
if (!xbps_dictionary_get_cstring_nocopy(obj,
"pkgver", &pkgver))
continue;
dpkgn = xbps_pkg_name(pkgver);
@@ -95,31 +95,31 @@ get_pkg_in_array(prop_array_t array, const char *str, bool virtual)
free(dpkgn);
}
}
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
return found ? obj : NULL;
}
prop_dictionary_t HIDDEN
xbps_find_pkg_in_array(prop_array_t a, const char *s)
xbps_dictionary_t HIDDEN
xbps_find_pkg_in_array(xbps_array_t a, const char *s)
{
assert(prop_object_type(a) == PROP_TYPE_ARRAY);
assert(xbps_object_type(a) == XBPS_TYPE_ARRAY);
assert(s);
return get_pkg_in_array(a, s, false);
}
prop_dictionary_t HIDDEN
xbps_dictionary_t HIDDEN
xbps_find_virtualpkg_in_array(struct xbps_handle *x,
prop_array_t a,
xbps_array_t a,
const char *s)
{
prop_dictionary_t pkgd;
xbps_dictionary_t pkgd;
const char *vpkg;
bool bypattern = false;
assert(x);
assert(prop_object_type(a) == PROP_TYPE_ARRAY);
assert(xbps_object_type(a) == XBPS_TYPE_ARRAY);
assert(s);
if (xbps_pkgpattern_version(s))
@@ -133,10 +133,10 @@ xbps_find_virtualpkg_in_array(struct xbps_handle *x,
return get_pkg_in_array(a, s, true);
}
static prop_dictionary_t
match_pkg_by_pkgver(prop_dictionary_t repod, const char *p)
static xbps_dictionary_t
match_pkg_by_pkgver(xbps_dictionary_t repod, const char *p)
{
prop_dictionary_t d = NULL;
xbps_dictionary_t d = NULL;
const char *pkgver;
char *pkgname;
@@ -144,9 +144,9 @@ match_pkg_by_pkgver(prop_dictionary_t repod, const char *p)
if ((pkgname = xbps_pkg_name(p)) == NULL)
return NULL;
d = prop_dictionary_get(repod, pkgname);
d = xbps_dictionary_get(repod, pkgname);
if (d) {
prop_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver);
if (strcmp(pkgver, p))
d = NULL;
}
@@ -155,10 +155,10 @@ match_pkg_by_pkgver(prop_dictionary_t repod, const char *p)
return d;
}
static prop_dictionary_t
match_pkg_by_pattern(prop_dictionary_t repod, const char *p)
static xbps_dictionary_t
match_pkg_by_pattern(xbps_dictionary_t repod, const char *p)
{
prop_dictionary_t d = NULL;
xbps_dictionary_t d = NULL;
const char *pkgver;
char *pkgname;
@@ -170,9 +170,9 @@ match_pkg_by_pattern(prop_dictionary_t repod, const char *p)
return NULL;
}
d = prop_dictionary_get(repod, pkgname);
d = xbps_dictionary_get(repod, pkgname);
if (d) {
prop_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver);
assert(pkgver);
if (!xbps_pkgpattern_match(pkgver, p))
d = NULL;
@@ -289,14 +289,14 @@ vpkg_user_conf(struct xbps_handle *xhp,
return pkg;
}
prop_dictionary_t
xbps_dictionary_t
xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp,
prop_dictionary_t d,
xbps_dictionary_t d,
const char *pkg)
{
prop_object_t obj;
prop_object_iterator_t iter;
prop_dictionary_t pkgd = NULL;
xbps_object_t obj;
xbps_object_iterator_t iter;
xbps_dictionary_t pkgd = NULL;
const char *vpkg;
bool found = false, bypattern = false;
@@ -311,7 +311,7 @@ xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp,
else if (xbps_pkg_version(vpkg))
pkgd = match_pkg_by_pkgver(d, vpkg);
else
pkgd = prop_dictionary_get(d, vpkg);
pkgd = xbps_dictionary_get(d, vpkg);
if (pkgd) {
found = true;
@@ -320,17 +320,17 @@ xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp,
}
/* ... otherwise match the first one in dictionary */
iter = prop_dictionary_iterator(d);
iter = xbps_dictionary_iterator(d);
assert(iter);
while ((obj = prop_object_iterator_next(iter))) {
pkgd = prop_dictionary_get_keysym(d, obj);
while ((obj = xbps_object_iterator_next(iter))) {
pkgd = xbps_dictionary_get_keysym(d, obj);
if (xbps_match_virtual_pkg_in_dict(pkgd, pkg, bypattern)) {
found = true;
break;
}
}
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
out:
if (found)
@@ -339,17 +339,17 @@ out:
return NULL;
}
prop_dictionary_t
xbps_find_pkg_in_dict(prop_dictionary_t d, const char *pkg)
xbps_dictionary_t
xbps_find_pkg_in_dict(xbps_dictionary_t d, const char *pkg)
{
prop_dictionary_t pkgd = NULL;
xbps_dictionary_t pkgd = NULL;
if (xbps_pkgpattern_version(pkg))
pkgd = match_pkg_by_pattern(d, pkg);
else if (xbps_pkg_version(pkg))
pkgd = match_pkg_by_pkgver(d, pkg);
else
pkgd = prop_dictionary_get(d, pkg);
pkgd = xbps_dictionary_get(d, pkg);
return pkgd;
}

View File

@@ -40,16 +40,16 @@
* all library functions.
*/
bool
xbps_match_virtual_pkg_in_dict(prop_dictionary_t d,
xbps_match_virtual_pkg_in_dict(xbps_dictionary_t d,
const char *str,
bool bypattern)
{
prop_array_t provides;
xbps_array_t provides;
bool found = false;
assert(prop_object_type(d) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(d) == XBPS_TYPE_DICTIONARY);
if ((provides = prop_dictionary_get(d, "provides"))) {
if ((provides = xbps_dictionary_get(d, "provides"))) {
if (bypattern)
found = xbps_match_pkgpattern_in_array(provides, str);
else {
@@ -62,72 +62,72 @@ xbps_match_virtual_pkg_in_dict(prop_dictionary_t d,
}
bool
xbps_match_any_virtualpkg_in_rundeps(prop_array_t rundeps,
prop_array_t provides)
xbps_match_any_virtualpkg_in_rundeps(xbps_array_t rundeps,
xbps_array_t provides)
{
prop_object_t obj, obj2;
prop_object_iterator_t iter, iter2;
xbps_object_t obj, obj2;
xbps_object_iterator_t iter, iter2;
const char *vpkgver, *pkgpattern;
char *tmp;
iter = prop_array_iterator(provides);
iter = xbps_array_iterator(provides);
assert(iter);
while ((obj = prop_object_iterator_next(iter))) {
while ((obj = xbps_object_iterator_next(iter))) {
tmp = NULL;
vpkgver = prop_string_cstring_nocopy(obj);
vpkgver = xbps_string_cstring_nocopy(obj);
if (strchr(vpkgver, '_') == NULL) {
tmp = xbps_xasprintf("%s_1", vpkgver);
vpkgver = tmp;
}
iter2 = prop_array_iterator(rundeps);
iter2 = xbps_array_iterator(rundeps);
assert(iter2);
while ((obj2 = prop_object_iterator_next(iter2))) {
pkgpattern = prop_string_cstring_nocopy(obj2);
while ((obj2 = xbps_object_iterator_next(iter2))) {
pkgpattern = xbps_string_cstring_nocopy(obj2);
if (xbps_pkgpattern_match(vpkgver, pkgpattern)) {
if (tmp != NULL)
free(tmp);
prop_object_iterator_release(iter2);
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter2);
xbps_object_iterator_release(iter);
return true;
}
}
prop_object_iterator_release(iter2);
xbps_object_iterator_release(iter2);
if (tmp != NULL)
free(tmp);
}
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
return false;
}
static bool
match_string_in_array(prop_array_t array, const char *str, int mode)
match_string_in_array(xbps_array_t array, const char *str, int mode)
{
prop_object_iterator_t iter;
prop_object_t obj;
xbps_object_iterator_t iter;
xbps_object_t obj;
const char *pkgdep;
char *curpkgname, *tmp;
bool found = false;
assert(prop_object_type(array) == PROP_TYPE_ARRAY);
assert(xbps_object_type(array) == XBPS_TYPE_ARRAY);
assert(str != NULL);
iter = prop_array_iterator(array);
iter = xbps_array_iterator(array);
assert(iter);
while ((obj = prop_object_iterator_next(iter))) {
while ((obj = xbps_object_iterator_next(iter))) {
tmp = NULL;
if (mode == 0) {
/* match by string */
if (prop_string_equals_cstring(obj, str)) {
if (xbps_string_equals_cstring(obj, str)) {
found = true;
break;
}
} else if (mode == 1) {
/* match by pkgname */
pkgdep = prop_string_cstring_nocopy(obj);
pkgdep = xbps_string_cstring_nocopy(obj);
if (strchr(pkgdep, '_') == NULL) {
tmp = xbps_xasprintf("%s_1", pkgdep);
curpkgname = xbps_pkg_name(tmp);
@@ -145,7 +145,7 @@ match_string_in_array(prop_array_t array, const char *str, int mode)
free(curpkgname);
} else if (mode == 2) {
/* match pkgpattern against pkgdep */
pkgdep = prop_string_cstring_nocopy(obj);
pkgdep = xbps_string_cstring_nocopy(obj);
if (strchr(pkgdep, '_') == NULL) {
tmp = xbps_xasprintf("%s_1", pkgdep);
pkgdep = tmp;
@@ -161,7 +161,7 @@ match_string_in_array(prop_array_t array, const char *str, int mode)
} else if (mode == 3) {
/* match pkgdep against pkgpattern */
pkgdep = prop_string_cstring_nocopy(obj);
pkgdep = xbps_string_cstring_nocopy(obj);
if (strchr(pkgdep, '_') == NULL) {
tmp = xbps_xasprintf("%s_1", pkgdep);
pkgdep = tmp;
@@ -176,31 +176,31 @@ match_string_in_array(prop_array_t array, const char *str, int mode)
free(tmp);
}
}
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
return found;
}
bool
xbps_match_string_in_array(prop_array_t array, const char *str)
xbps_match_string_in_array(xbps_array_t array, const char *str)
{
return match_string_in_array(array, str, 0);
}
bool
xbps_match_pkgname_in_array(prop_array_t array, const char *pkgname)
xbps_match_pkgname_in_array(xbps_array_t array, const char *pkgname)
{
return match_string_in_array(array, pkgname, 1);
}
bool
xbps_match_pkgpattern_in_array(prop_array_t array, const char *pattern)
xbps_match_pkgpattern_in_array(xbps_array_t array, const char *pattern)
{
return match_string_in_array(array, pattern, 2);
}
bool
xbps_match_pkgdep_in_array(prop_array_t array, const char *pkgver)
xbps_match_pkgdep_in_array(xbps_array_t array, const char *pkgver)
{
return match_string_in_array(array, pkgver, 3);
}

View File

@@ -32,31 +32,31 @@
#include "xbps_api_impl.h"
static bool
remove_obj_from_array(prop_array_t array, const char *str, int mode)
remove_obj_from_array(xbps_array_t array, const char *str, int mode)
{
prop_object_iterator_t iter;
prop_object_t obj;
xbps_object_iterator_t iter;
xbps_object_t obj;
const char *curname, *pkgdep;
char *curpkgname;
unsigned int idx = 0;
bool found = false;
assert(prop_object_type(array) == PROP_TYPE_ARRAY);
assert(xbps_object_type(array) == XBPS_TYPE_ARRAY);
iter = prop_array_iterator(array);
iter = xbps_array_iterator(array);
if (iter == NULL)
return false;
while ((obj = prop_object_iterator_next(iter))) {
while ((obj = xbps_object_iterator_next(iter))) {
if (mode == 0) {
/* exact match, obj is a string */
if (prop_string_equals_cstring(obj, str)) {
if (xbps_string_equals_cstring(obj, str)) {
found = true;
break;
}
} else if (mode == 1) {
/* match by pkgname, obj is a string */
pkgdep = prop_string_cstring_nocopy(obj);
pkgdep = xbps_string_cstring_nocopy(obj);
curpkgname = xbps_pkg_name(pkgdep);
if (curpkgname == NULL)
break;
@@ -68,7 +68,7 @@ remove_obj_from_array(prop_array_t array, const char *str, int mode)
free(curpkgname);
} else if (mode == 2) {
/* match by pkgname, obj is a dictionary */
prop_dictionary_get_cstring_nocopy(obj,
xbps_dictionary_get_cstring_nocopy(obj,
"pkgname", &curname);
if (strcmp(curname, str) == 0) {
found = true;
@@ -76,7 +76,7 @@ remove_obj_from_array(prop_array_t array, const char *str, int mode)
}
} else if (mode == 3) {
/* match by pkgver, obj is a dictionary */
prop_dictionary_get_cstring_nocopy(obj,
xbps_dictionary_get_cstring_nocopy(obj,
"pkgver", &curname);
if (strcmp(curname, str) == 0) {
found = true;
@@ -84,7 +84,7 @@ remove_obj_from_array(prop_array_t array, const char *str, int mode)
}
} else if (mode == 4) {
/* match by pattern, obj is a dictionary */
prop_dictionary_get_cstring_nocopy(obj,
xbps_dictionary_get_cstring_nocopy(obj,
"pkgver", &curname);
if (xbps_pkgpattern_match(curname, str)) {
found = true;
@@ -93,43 +93,43 @@ remove_obj_from_array(prop_array_t array, const char *str, int mode)
}
idx++;
}
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
if (!found) {
errno = ENOENT;
return false;
}
prop_array_remove(array, idx);
xbps_array_remove(array, idx);
return true;
}
bool HIDDEN
xbps_remove_string_from_array(prop_array_t array, const char *str)
xbps_remove_string_from_array(xbps_array_t array, const char *str)
{
return remove_obj_from_array(array, str, 0);
}
bool HIDDEN
xbps_remove_pkgname_from_array(prop_array_t array, const char *str)
xbps_remove_pkgname_from_array(xbps_array_t array, const char *str)
{
return remove_obj_from_array(array, str, 1);
}
bool HIDDEN
xbps_remove_pkg_from_array_by_name(prop_array_t array, const char *str)
xbps_remove_pkg_from_array_by_name(xbps_array_t array, const char *str)
{
return remove_obj_from_array(array, str, 2);
}
bool HIDDEN
xbps_remove_pkg_from_array_by_pkgver(prop_array_t array, const char *str)
xbps_remove_pkg_from_array_by_pkgver(xbps_array_t array, const char *str)
{
return remove_obj_from_array(array, str, 3);
}
bool HIDDEN
xbps_remove_pkg_from_array_by_pattern(prop_array_t array, const char *str)
xbps_remove_pkg_from_array_by_pattern(xbps_array_t array, const char *str)
{
return remove_obj_from_array(array, str, 4);
}

View File

@@ -29,6 +29,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <prop/prop_object.h>
#include "prop_object_impl.h"
@@ -834,7 +838,7 @@ _prop_object_externalize_write_file(const char *fname, const char *xml,
return (false);
}
#else
otname = strncat(tname, "/.plistXXXXXX", sizeof(tname));
otname = strncat(tname, "/.plistXXXXXX", sizeof(tname) - strlen(tname) - 1);
if (sizeof(*otname) >= sizeof(tname)) {
errno = ENAMETOOLONG;

927
lib/proplib_wrapper.c Normal file
View File

@@ -0,0 +1,927 @@
/*-
* Copyright (c) 2013 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"
#include <prop/proplib.h>
/* prop_array */
xbps_array_t
xbps_array_create(void)
{
return prop_array_create();
}
xbps_array_t
xbps_array_create_with_capacity(unsigned int capacity)
{
return prop_array_create_with_capacity(capacity);
}
xbps_array_t
xbps_array_copy(xbps_array_t a)
{
return prop_array_copy(a);
}
xbps_array_t
xbps_array_copy_mutable(xbps_array_t a)
{
return prop_array_copy_mutable(a);
}
unsigned int
xbps_array_capacity(xbps_array_t a)
{
return prop_array_capacity(a);
}
unsigned int
xbps_array_count(xbps_array_t a)
{
return prop_array_count(a);
}
bool
xbps_array_ensure_capacity(xbps_array_t a, unsigned int i)
{
return prop_array_ensure_capacity(a, i);
}
void
xbps_array_make_immutable(xbps_array_t a)
{
return prop_array_make_immutable(a);
}
bool
xbps_array_mutable(xbps_array_t a)
{
return prop_array_mutable(a);
}
xbps_object_iterator_t
xbps_array_iterator(xbps_array_t a)
{
return prop_array_iterator(a);
}
xbps_object_t
xbps_array_get(xbps_array_t a, unsigned int i)
{
return prop_array_get(a, i);
}
bool
xbps_array_set(xbps_array_t a, unsigned int i, xbps_object_t obj)
{
return prop_array_set(a, i, obj);
}
bool
xbps_array_add(xbps_array_t a, xbps_object_t obj)
{
return prop_array_add(a, obj);
}
void
xbps_array_remove(xbps_array_t a, unsigned int i)
{
return prop_array_remove(a, i);
}
bool
xbps_array_equals(xbps_array_t a, xbps_array_t b)
{
return prop_array_equals(a, b);
}
char *
xbps_array_externalize(xbps_array_t a)
{
return prop_array_externalize(a);
}
xbps_array_t
xbps_array_internalize(const char *s)
{
return prop_array_internalize(s);
}
bool
xbps_array_externalize_to_file(xbps_array_t a, const char *s)
{
return prop_array_externalize_to_file(a, s);
}
bool
xbps_array_externalize_to_zfile(xbps_array_t a, const char *s)
{
return prop_array_externalize_to_zfile(a, s);
}
xbps_array_t
xbps_array_internalize_from_file(const char *s)
{
return prop_array_internalize_from_file(s);
}
xbps_array_t
xbps_array_internalize_from_zfile(const char *s)
{
return prop_array_internalize_from_zfile(s);
}
/*
* Utility routines to make it more convenient to work with values
* stored in dictionaries.
*/
bool
xbps_array_get_bool(xbps_array_t a, unsigned int i, bool *b)
{
return prop_array_get_bool(a, i, b);
}
bool
xbps_array_set_bool(xbps_array_t a, unsigned int i, bool b)
{
return prop_array_set_bool(a, i, b);
}
bool
xbps_array_get_int8(xbps_array_t a, unsigned int i, int8_t *v)
{
return prop_array_get_int8(a, i, v);
}
bool
xbps_array_get_uint8(xbps_array_t a, unsigned int i, uint8_t *v)
{
return prop_array_get_uint8(a, i, v);
}
bool
xbps_array_set_int8(xbps_array_t a, unsigned int i, int8_t v)
{
return prop_array_set_int8(a, i, v);
}
bool
xbps_array_set_uint8(xbps_array_t a, unsigned int i, uint8_t v)
{
return prop_array_set_uint8(a, i, v);
}
bool
xbps_array_get_int16(xbps_array_t a, unsigned int i, int16_t *v)
{
return prop_array_get_int16(a, i, v);
}
bool
xbps_array_get_uint16(xbps_array_t a, unsigned int i, uint16_t *v)
{
return prop_array_get_uint16(a, i, v);
}
bool
xbps_array_set_int16(xbps_array_t a, unsigned int i, int16_t v)
{
return prop_array_set_int16(a, i, v);
}
bool
xbps_array_set_uint16(xbps_array_t a, unsigned int i, uint16_t v)
{
return prop_array_set_uint16(a, i, v);
}
bool
xbps_array_get_int32(xbps_array_t a, unsigned int i, int32_t *v)
{
return prop_array_get_int32(a, i, v);
}
bool
xbps_array_get_uint32(xbps_array_t a, unsigned int i, uint32_t *v)
{
return prop_array_get_uint32(a, i, v);
}
bool
xbps_array_set_int32(xbps_array_t a, unsigned int i, int32_t v)
{
return prop_array_set_int32(a, i, v);
}
bool
xbps_array_set_uint32(xbps_array_t a, unsigned int i, uint32_t v)
{
return prop_array_set_uint32(a, i, v);
}
bool
xbps_array_get_int64(xbps_array_t a, unsigned int i, int64_t *v)
{
return prop_array_get_int64(a, i, v);
}
bool
xbps_array_get_uint64(xbps_array_t a, unsigned int i, uint64_t *v)
{
return prop_array_get_uint64(a, i, v);
}
bool
xbps_array_set_int64(xbps_array_t a, unsigned int i, int64_t v)
{
return prop_array_set_int64(a, i, v);
}
bool
xbps_array_set_uint64(xbps_array_t a, unsigned int i, uint64_t v)
{
return prop_array_set_uint64(a, i, v);
}
bool
xbps_array_add_int8(xbps_array_t a, int8_t v)
{
return prop_array_add_int8(a, v);
}
bool
xbps_array_add_uint8(xbps_array_t a, uint8_t v)
{
return prop_array_add_uint8(a, v);
}
bool
xbps_array_add_int16(xbps_array_t a, int16_t v)
{
return prop_array_add_int16(a, v);
}
bool
xbps_array_add_uint16(xbps_array_t a, uint16_t v)
{
return prop_array_add_uint16(a, v);
}
bool
xbps_array_add_int32(xbps_array_t a, int32_t v)
{
return prop_array_add_int32(a, v);
}
bool
xbps_array_add_uint32(xbps_array_t a, uint32_t v)
{
return prop_array_add_uint32(a, v);
}
bool
xbps_array_add_int64(xbps_array_t a, int64_t v)
{
return prop_array_add_int64(a, v);
}
bool
xbps_array_add_uint64(xbps_array_t a, uint64_t v)
{
return prop_array_add_uint64(a, v);
}
bool
xbps_array_get_cstring(xbps_array_t a, unsigned int i, char **s)
{
return prop_array_get_cstring(a, i, s);
}
bool
xbps_array_set_cstring(xbps_array_t a, unsigned int i, const char *s)
{
return prop_array_set_cstring(a, i, s);
}
bool
xbps_array_add_cstring(xbps_array_t a, const char *s)
{
return prop_array_add_cstring(a, s);
}
bool
xbps_array_add_cstring_nocopy(xbps_array_t a, const char *s)
{
return prop_array_add_cstring_nocopy(a, s);
}
bool
xbps_array_get_cstring_nocopy(xbps_array_t a, unsigned int i, const char **s)
{
return prop_array_get_cstring_nocopy(a, i, s);
}
bool
xbps_array_set_cstring_nocopy(xbps_array_t a, unsigned int i, const char *s)
{
return prop_array_set_cstring_nocopy(a, i, s);
}
bool
xbps_array_add_and_rel(xbps_array_t a, xbps_object_t o)
{
return prop_array_add_and_rel(a, o);
}
/* prop_bool */
xbps_bool_t
xbps_bool_create(bool v)
{
return prop_bool_create(v);
}
xbps_bool_t
xbps_bool_copy(xbps_bool_t b)
{
return prop_bool_copy(b);
}
bool
xbps_bool_true(xbps_bool_t b)
{
return prop_bool_true(b);
}
bool
xbps_bool_equals(xbps_bool_t a, xbps_bool_t b)
{
return prop_bool_equals(a, b);
}
/* prop_data */
xbps_data_t
xbps_data_create_data(const void *v, size_t s)
{
return prop_data_create_data(v, s);
}
xbps_data_t
xbps_data_create_data_nocopy(const void *v, size_t s)
{
return prop_data_create_data_nocopy(v, s);
}
xbps_data_t
xbps_data_copy(xbps_data_t d)
{
return prop_data_copy(d);
}
size_t
xbps_data_size(xbps_data_t d)
{
return prop_data_size(d);
}
void *
xbps_data_data(xbps_data_t d)
{
return prop_data_data(d);
}
const void *
xbps_data_data_nocopy(xbps_data_t d)
{
return prop_data_data_nocopy(d);
}
bool
xbps_data_equals(xbps_data_t a, xbps_data_t b)
{
return prop_data_equals(a, b);
}
bool
xbps_data_equals_data(xbps_data_t d, const void *v, size_t s)
{
return prop_data_equals_data(d, v, s);
}
/* prop_dictionary */
xbps_dictionary_t
xbps_dictionary_create(void)
{
return prop_dictionary_create();
}
xbps_dictionary_t
xbps_dictionary_create_with_capacity(unsigned int i)
{
return prop_dictionary_create_with_capacity(i);
}
xbps_dictionary_t
xbps_dictionary_copy(xbps_dictionary_t d)
{
return prop_dictionary_copy(d);
}
xbps_dictionary_t
xbps_dictionary_copy_mutable(xbps_dictionary_t d)
{
return prop_dictionary_copy_mutable(d);
}
unsigned int
xbps_dictionary_count(xbps_dictionary_t d)
{
return prop_dictionary_count(d);
}
bool
xbps_dictionary_ensure_capacity(xbps_dictionary_t d, unsigned int i)
{
return prop_dictionary_ensure_capacity(d, i);
}
void
xbps_dictionary_make_immutable(xbps_dictionary_t d)
{
return prop_dictionary_make_immutable(d);
}
xbps_object_iterator_t
xbps_dictionary_iterator(xbps_dictionary_t d)
{
return prop_dictionary_iterator(d);
}
xbps_array_t
xbps_dictionary_all_keys(xbps_dictionary_t d)
{
return prop_dictionary_all_keys(d);
}
xbps_object_t
xbps_dictionary_get(xbps_dictionary_t d, const char *s)
{
return prop_dictionary_get(d, s);
}
bool
xbps_dictionary_set(xbps_dictionary_t d, const char *s, xbps_object_t o)
{
return prop_dictionary_set(d, s, o);
}
void
xbps_dictionary_remove(xbps_dictionary_t d, const char *s)
{
return prop_dictionary_remove(d, s);
}
xbps_object_t
xbps_dictionary_get_keysym(xbps_dictionary_t d, xbps_dictionary_keysym_t k)
{
return prop_dictionary_get_keysym(d, k);
}
bool
xbps_dictionary_set_keysym(xbps_dictionary_t d, xbps_dictionary_keysym_t k,
xbps_object_t o)
{
return prop_dictionary_set_keysym(d, k, o);
}
void
xbps_dictionary_remove_keysym(xbps_dictionary_t d, xbps_dictionary_keysym_t k)
{
return prop_dictionary_remove_keysym(d, k);
}
bool
xbps_dictionary_equals(xbps_dictionary_t a, xbps_dictionary_t b)
{
return prop_dictionary_equals(a, b);
}
char *
xbps_dictionary_externalize(xbps_dictionary_t d)
{
return prop_dictionary_externalize(d);
}
xbps_dictionary_t
xbps_dictionary_internalize(const char *s)
{
return prop_dictionary_internalize(s);
}
bool
xbps_dictionary_externalize_to_file(xbps_dictionary_t d, const char *s)
{
return prop_dictionary_externalize_to_file(d, s);
}
bool
xbps_dictionary_externalize_to_zfile(xbps_dictionary_t d, const char *s)
{
return prop_dictionary_externalize_to_zfile(d, s);
}
xbps_dictionary_t
xbps_dictionary_internalize_from_file(const char *s)
{
return prop_dictionary_internalize_from_file(s);
}
xbps_dictionary_t
xbps_dictionary_internalize_from_zfile(const char *s)
{
return prop_dictionary_internalize_from_zfile(s);
}
const char *
xbps_dictionary_keysym_cstring_nocopy(xbps_dictionary_keysym_t k)
{
return prop_dictionary_keysym_cstring_nocopy(k);
}
bool
xbps_dictionary_keysym_equals(xbps_dictionary_keysym_t a, xbps_dictionary_keysym_t b)
{
return prop_dictionary_keysym_equals(a, b);
}
/*
* Utility routines to make it more convenient to work with values
* stored in dictionaries.
*/
bool
xbps_dictionary_get_dict(xbps_dictionary_t d, const char *s,
xbps_dictionary_t *rd)
{
return prop_dictionary_get_dict(d, s, rd);
}
bool
xbps_dictionary_get_bool(xbps_dictionary_t d, const char *s, bool *b)
{
return prop_dictionary_get_bool(d, s, b);
}
bool
xbps_dictionary_set_bool(xbps_dictionary_t d, const char *s, bool b)
{
return prop_dictionary_set_bool(d, s, b);
}
bool
xbps_dictionary_get_int8(xbps_dictionary_t d, const char *s, int8_t *v)
{
return prop_dictionary_get_int8(d, s, v);
}
bool
xbps_dictionary_get_uint8(xbps_dictionary_t d, const char *s, uint8_t *v)
{
return prop_dictionary_get_uint8(d, s, v);
}
bool
xbps_dictionary_set_int8(xbps_dictionary_t d, const char *s, int8_t v)
{
return prop_dictionary_set_int8(d, s, v);
}
bool
xbps_dictionary_set_uint8(xbps_dictionary_t d, const char *s, uint8_t v)
{
return prop_dictionary_set_uint8(d, s, v);
}
bool
xbps_dictionary_get_int16(xbps_dictionary_t d, const char *s, int16_t *v)
{
return prop_dictionary_get_int16(d, s, v);
}
bool
xbps_dictionary_get_uint16(xbps_dictionary_t d, const char *s, uint16_t *v)
{
return prop_dictionary_get_uint16(d, s, v);
}
bool
xbps_dictionary_set_int16(xbps_dictionary_t d, const char *s, int16_t v)
{
return prop_dictionary_set_int16(d, s, v);
}
bool
xbps_dictionary_set_uint16(xbps_dictionary_t d, const char *s, uint16_t v)
{
return prop_dictionary_set_uint16(d, s, v);
}
bool
xbps_dictionary_get_int32(xbps_dictionary_t d, const char *s, int32_t *v)
{
return prop_dictionary_get_int32(d, s, v);
}
bool
xbps_dictionary_get_uint32(xbps_dictionary_t d, const char *s, uint32_t *v)
{
return prop_dictionary_get_uint32(d, s, v);
}
bool
xbps_dictionary_set_int32(xbps_dictionary_t d, const char *s, int32_t v)
{
return prop_dictionary_set_int32(d, s, v);
}
bool
xbps_dictionary_set_uint32(xbps_dictionary_t d, const char *s, uint32_t v)
{
return prop_dictionary_set_uint32(d, s, v);
}
bool
xbps_dictionary_get_int64(xbps_dictionary_t d, const char *s, int64_t *v)
{
return prop_dictionary_get_int64(d, s, v);
}
bool
xbps_dictionary_get_uint64(xbps_dictionary_t d, const char *s, uint64_t *v)
{
return prop_dictionary_get_uint64(d, s, v);
}
bool
xbps_dictionary_set_int64(xbps_dictionary_t d, const char *s, int64_t v)
{
return prop_dictionary_set_int64(d, s, v);
}
bool
xbps_dictionary_set_uint64(xbps_dictionary_t d, const char *s, uint64_t v)
{
return prop_dictionary_set_uint64(d, s, v);
}
bool
xbps_dictionary_get_cstring(xbps_dictionary_t d, const char *s, char **ss)
{
return prop_dictionary_get_cstring(d, s, ss);
}
bool
xbps_dictionary_set_cstring(xbps_dictionary_t d, const char *s, const char *ss)
{
return prop_dictionary_set_cstring(d, s, ss);
}
bool
xbps_dictionary_get_cstring_nocopy(xbps_dictionary_t d, const char *s, const char **ss)
{
return prop_dictionary_get_cstring_nocopy(d, s, ss);
}
bool
xbps_dictionary_set_cstring_nocopy(xbps_dictionary_t d, const char *s, const char *ss)
{
return prop_dictionary_set_cstring_nocopy(d, s, ss);
}
bool
xbps_dictionary_set_and_rel(xbps_dictionary_t d, const char *s, xbps_object_t o)
{
return prop_dictionary_set_and_rel(d, s, o);
}
/* prop_number */
xbps_number_t
xbps_number_create_integer(int64_t v)
{
return prop_number_create_integer(v);
}
xbps_number_t
xbps_number_create_unsigned_integer(uint64_t v)
{
return prop_number_create_unsigned_integer(v);
}
xbps_number_t
xbps_number_copy(xbps_number_t n)
{
return prop_number_copy(n);
}
int
xbps_number_size(xbps_number_t n)
{
return prop_number_size(n);
}
bool
xbps_number_unsigned(xbps_number_t n)
{
return prop_number_unsigned(n);
}
int64_t
xbps_number_integer_value(xbps_number_t n)
{
return prop_number_integer_value(n);
}
uint64_t
xbps_number_unsigned_integer_value(xbps_number_t n)
{
return prop_number_unsigned_integer_value(n);
}
bool
xbps_number_equals(xbps_number_t n, xbps_number_t nn)
{
return prop_number_equals(n, nn);
}
bool
xbps_number_equals_integer(xbps_number_t n, int64_t v)
{
return prop_number_equals_integer(n, v);
}
bool
xbps_number_equals_unsigned_integer(xbps_number_t n, uint64_t v)
{
return prop_number_equals_unsigned_integer(n, v);
}
/* prop_object */
void
xbps_object_retain(xbps_object_t o)
{
return prop_object_retain(o);
}
void
xbps_object_release(xbps_object_t o)
{
return prop_object_release(o);
}
xbps_type_t
xbps_object_type(xbps_object_t o)
{
return (xbps_type_t)prop_object_type(o);
}
bool
xbps_object_equals(xbps_object_t o, xbps_object_t oo)
{
return prop_object_equals(o, oo);
}
bool
xbps_object_equals_with_error(xbps_object_t o, xbps_object_t oo, bool *b)
{
return prop_object_equals_with_error(o, oo, b);
}
xbps_object_t
xbps_object_iterator_next(xbps_object_iterator_t o)
{
return prop_object_iterator_next(o);
}
void
xbps_object_iterator_reset(xbps_object_iterator_t o)
{
return prop_object_iterator_reset(o);
}
void
xbps_object_iterator_release(xbps_object_iterator_t o)
{
return prop_object_iterator_release(o);
}
/* prop_string */
xbps_string_t
xbps_string_create(void)
{
return prop_string_create();
}
xbps_string_t
xbps_string_create_cstring(const char *s)
{
return prop_string_create_cstring(s);
}
xbps_string_t
xbps_string_create_cstring_nocopy(const char *s)
{
return prop_string_create_cstring_nocopy(s);
}
xbps_string_t
xbps_string_copy(xbps_string_t s)
{
return prop_string_copy(s);
}
xbps_string_t
xbps_string_copy_mutable(xbps_string_t s)
{
return prop_string_copy_mutable(s);
}
size_t
xbps_string_size(xbps_string_t s)
{
return prop_string_size(s);
}
bool
xbps_string_mutable(xbps_string_t s)
{
return prop_string_mutable(s);
}
char *
xbps_string_cstring(xbps_string_t s)
{
return prop_string_cstring(s);
}
const char *
xbps_string_cstring_nocopy(xbps_string_t s)
{
return prop_string_cstring_nocopy(s);
}
bool
xbps_string_append(xbps_string_t s, xbps_string_t ss)
{
return prop_string_append(s, ss);
}
bool
xbps_string_append_cstring(xbps_string_t s, const char *ss)
{
return prop_string_append_cstring(s, ss);
}
bool
xbps_string_equals(xbps_string_t s, xbps_string_t ss)
{
return prop_string_equals(s, ss);
}
bool
xbps_string_equals_cstring(xbps_string_t s, const char *ss)
{
return prop_string_equals_cstring(s, ss);
}

View File

@@ -94,10 +94,10 @@ xbps_repo_open(struct xbps_handle *xhp, const char *url)
return repo;
}
prop_dictionary_t
xbps_dictionary_t
xbps_repo_get_plist(struct xbps_repo *repo, const char *file)
{
prop_dictionary_t d;
xbps_dictionary_t d;
struct archive_entry *entry;
void *buf;
size_t buflen;
@@ -123,7 +123,7 @@ xbps_repo_get_plist(struct xbps_repo *repo, const char *file)
free(buf);
return NULL;
}
d = prop_dictionary_internalize(buf);
d = xbps_dictionary_internalize(buf);
free(buf);
return d;
}
@@ -138,51 +138,51 @@ xbps_repo_close(struct xbps_repo *repo)
assert(repo);
archive_read_free(repo->ar);
if (prop_object_type(repo->idx) == PROP_TYPE_DICTIONARY)
prop_object_release(repo->idx);
if (prop_object_type(repo->idxfiles) == PROP_TYPE_DICTIONARY)
prop_object_release(repo->idxfiles);
if (xbps_object_type(repo->idx) == XBPS_TYPE_DICTIONARY)
xbps_object_release(repo->idx);
if (xbps_object_type(repo->idxfiles) == XBPS_TYPE_DICTIONARY)
xbps_object_release(repo->idxfiles);
free(repo);
}
prop_dictionary_t
xbps_dictionary_t
xbps_repo_get_virtualpkg(struct xbps_repo *repo, const char *pkg)
{
prop_dictionary_t pkgd;
xbps_dictionary_t pkgd;
assert(repo);
assert(repo->ar);
assert(pkg);
if (prop_object_type(repo->idx) != PROP_TYPE_DICTIONARY) {
if (xbps_object_type(repo->idx) != XBPS_TYPE_DICTIONARY) {
repo->idx = xbps_repo_get_plist(repo, XBPS_PKGINDEX);
assert(repo->idx);
}
pkgd = xbps_find_virtualpkg_in_dict(repo->xhp, repo->idx, pkg);
if (pkgd) {
prop_dictionary_set_cstring_nocopy(pkgd,
xbps_dictionary_set_cstring_nocopy(pkgd,
"repository", repo->uri);
return pkgd;
}
return NULL;
}
prop_dictionary_t
xbps_dictionary_t
xbps_repo_get_pkg(struct xbps_repo *repo, const char *pkg)
{
prop_dictionary_t pkgd;
xbps_dictionary_t pkgd;
assert(repo);
assert(repo->ar);
assert(pkg);
if (prop_object_type(repo->idx) != PROP_TYPE_DICTIONARY) {
if (xbps_object_type(repo->idx) != XBPS_TYPE_DICTIONARY) {
repo->idx = xbps_repo_get_plist(repo, XBPS_PKGINDEX);
assert(repo->idx);
}
pkgd = xbps_find_pkg_in_dict(repo->idx, pkg);
if (pkgd) {
prop_dictionary_set_cstring_nocopy(pkgd,
xbps_dictionary_set_cstring_nocopy(pkgd,
"repository", repo->uri);
return pkgd;
}
@@ -190,11 +190,11 @@ xbps_repo_get_pkg(struct xbps_repo *repo, const char *pkg)
return NULL;
}
prop_dictionary_t
xbps_repo_get_pkg_plist(struct xbps_handle *xhp, prop_dictionary_t pkgd,
xbps_dictionary_t
xbps_repo_get_pkg_plist(struct xbps_handle *xhp, xbps_dictionary_t pkgd,
const char *plist)
{
prop_dictionary_t bpkgd;
xbps_dictionary_t bpkgd;
char *url;
url = xbps_repository_pkg_path(xhp, pkgd);
@@ -206,27 +206,27 @@ xbps_repo_get_pkg_plist(struct xbps_handle *xhp, prop_dictionary_t pkgd,
return bpkgd;
}
static prop_array_t
revdeps_match(struct xbps_repo *repo, prop_dictionary_t tpkgd, const char *str)
static xbps_array_t
revdeps_match(struct xbps_repo *repo, xbps_dictionary_t tpkgd, const char *str)
{
prop_dictionary_t pkgd;
prop_array_t revdeps = NULL, pkgdeps, provides;
prop_object_iterator_t iter;
prop_object_t obj;
xbps_dictionary_t pkgd;
xbps_array_t revdeps = NULL, pkgdeps, provides;
xbps_object_iterator_t iter;
xbps_object_t obj;
const char *pkgver, *tpkgver, *arch, *vpkg;
char *buf;
unsigned int i;
iter = prop_dictionary_iterator(repo->idx);
iter = xbps_dictionary_iterator(repo->idx);
assert(iter);
while ((obj = prop_object_iterator_next(iter))) {
pkgd = prop_dictionary_get_keysym(repo->idx, obj);
if (prop_dictionary_equals(pkgd, tpkgd))
while ((obj = xbps_object_iterator_next(iter))) {
pkgd = xbps_dictionary_get_keysym(repo->idx, obj);
if (xbps_dictionary_equals(pkgd, tpkgd))
continue;
pkgdeps = prop_dictionary_get(pkgd, "run_depends");
if (!prop_array_count(pkgdeps))
pkgdeps = xbps_dictionary_get(pkgd, "run_depends");
if (!xbps_array_count(pkgdeps))
continue;
/*
* Try to match passed in string.
@@ -234,28 +234,28 @@ revdeps_match(struct xbps_repo *repo, prop_dictionary_t tpkgd, const char *str)
if (str) {
if (!xbps_match_pkgdep_in_array(pkgdeps, str))
continue;
prop_dictionary_get_cstring_nocopy(pkgd,
xbps_dictionary_get_cstring_nocopy(pkgd,
"architecture", &arch);
if (!xbps_pkg_arch_match(repo->xhp, arch, NULL))
continue;
prop_dictionary_get_cstring_nocopy(pkgd,
xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &tpkgver);
/* match */
if (revdeps == NULL)
revdeps = prop_array_create();
revdeps = xbps_array_create();
if (!xbps_match_string_in_array(revdeps, tpkgver))
prop_array_add_cstring_nocopy(revdeps, tpkgver);
xbps_array_add_cstring_nocopy(revdeps, tpkgver);
continue;
}
/*
* Try to match any virtual package.
*/
provides = prop_dictionary_get(tpkgd, "provides");
for (i = 0; i < prop_array_count(provides); i++) {
prop_array_get_cstring_nocopy(provides, i, &vpkg);
provides = xbps_dictionary_get(tpkgd, "provides");
for (i = 0; i < xbps_array_count(provides); i++) {
xbps_array_get_cstring_nocopy(provides, i, &vpkg);
if (strchr(vpkg, '_') == NULL)
buf = xbps_xasprintf("%s_1", vpkg);
else
@@ -266,49 +266,49 @@ revdeps_match(struct xbps_repo *repo, prop_dictionary_t tpkgd, const char *str)
continue;
}
free(buf);
prop_dictionary_get_cstring_nocopy(pkgd,
xbps_dictionary_get_cstring_nocopy(pkgd,
"architecture", &arch);
if (!xbps_pkg_arch_match(repo->xhp, arch, NULL))
continue;
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver",
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver",
&tpkgver);
/* match */
if (revdeps == NULL)
revdeps = prop_array_create();
revdeps = xbps_array_create();
if (!xbps_match_string_in_array(revdeps, tpkgver))
prop_array_add_cstring_nocopy(revdeps, tpkgver);
xbps_array_add_cstring_nocopy(revdeps, tpkgver);
}
/*
* Try to match by pkgver.
*/
prop_dictionary_get_cstring_nocopy(tpkgd, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(tpkgd, "pkgver", &pkgver);
if (!xbps_match_pkgdep_in_array(pkgdeps, pkgver))
continue;
prop_dictionary_get_cstring_nocopy(pkgd,
xbps_dictionary_get_cstring_nocopy(pkgd,
"architecture", &arch);
if (!xbps_pkg_arch_match(repo->xhp, arch, NULL))
continue;
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &tpkgver);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &tpkgver);
/* match */
if (revdeps == NULL)
revdeps = prop_array_create();
revdeps = xbps_array_create();
if (!xbps_match_string_in_array(revdeps, tpkgver))
prop_array_add_cstring_nocopy(revdeps, tpkgver);
xbps_array_add_cstring_nocopy(revdeps, tpkgver);
}
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
return revdeps;
}
prop_array_t
xbps_array_t
xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg)
{
prop_array_t revdeps = NULL, vdeps = NULL;
prop_dictionary_t pkgd;
xbps_array_t revdeps = NULL, vdeps = NULL;
xbps_dictionary_t pkgd;
const char *vpkg;
char *buf = NULL;
unsigned int i;
@@ -321,11 +321,11 @@ xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg)
/*
* If pkg is a virtual pkg let's match it instead of the real pkgver.
*/
if ((vdeps = prop_dictionary_get(pkgd, "provides"))) {
for (i = 0; i < prop_array_count(vdeps); i++) {
if ((vdeps = xbps_dictionary_get(pkgd, "provides"))) {
for (i = 0; i < xbps_array_count(vdeps); i++) {
char *vpkgn;
prop_array_get_cstring_nocopy(vdeps, i, &vpkg);
xbps_array_get_cstring_nocopy(vdeps, i, &vpkg);
if (strchr(vpkg, '_') == NULL)
buf = xbps_xasprintf("%s_1", vpkg);
else
@@ -346,7 +346,7 @@ xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg)
free(buf);
}
}
if (!prop_array_count(revdeps))
if (!xbps_array_count(revdeps))
revdeps = revdeps_match(repo, pkgd, NULL);
return revdeps;

View File

@@ -32,8 +32,8 @@
static int
store_dependency(struct xbps_handle *xhp,
prop_array_t unsorted,
prop_dictionary_t repo_pkgd,
xbps_array_t unsorted,
xbps_dictionary_t repo_pkgd,
pkg_state_t repo_pkg_state)
{
int rv;
@@ -46,12 +46,12 @@ store_dependency(struct xbps_handle *xhp,
/*
* Add required objects into package dep's dictionary.
*/
if (!prop_dictionary_set_bool(repo_pkgd, "automatic-install", true))
if (!xbps_dictionary_set_bool(repo_pkgd, "automatic-install", true))
return EINVAL;
/*
* Add the dictionary into the unsorted queue.
*/
prop_array_add(unsorted, repo_pkgd);
xbps_array_add(unsorted, repo_pkgd);
xbps_dbg_printf_append(xhp, "(added)\n");
return 0;
@@ -60,10 +60,10 @@ store_dependency(struct xbps_handle *xhp,
static int
add_missing_reqdep(struct xbps_handle *xhp, const char *reqpkg)
{
prop_array_t mdeps;
prop_string_t reqpkg_str;
prop_object_iterator_t iter = NULL;
prop_object_t obj;
xbps_array_t mdeps;
xbps_string_t reqpkg_str;
xbps_object_iterator_t iter = NULL;
xbps_object_t obj;
unsigned int idx = 0;
bool add_pkgdep, pkgfound, update_pkgdep;
int rv = 0;
@@ -71,22 +71,22 @@ add_missing_reqdep(struct xbps_handle *xhp, const char *reqpkg)
assert(reqpkg != NULL);
add_pkgdep = update_pkgdep = pkgfound = false;
mdeps = prop_dictionary_get(xhp->transd, "missing_deps");
mdeps = xbps_dictionary_get(xhp->transd, "missing_deps");
reqpkg_str = prop_string_create_cstring_nocopy(reqpkg);
reqpkg_str = xbps_string_create_cstring_nocopy(reqpkg);
if (reqpkg_str == NULL)
return errno;
iter = prop_array_iterator(mdeps);
iter = xbps_array_iterator(mdeps);
if (iter == NULL)
goto out;
while ((obj = prop_object_iterator_next(iter)) != NULL) {
while ((obj = xbps_object_iterator_next(iter)) != NULL) {
const char *curdep, *curver, *pkgver;
char *curpkgnamedep = NULL, *pkgnamedep = NULL;
assert(prop_object_type(obj) == PROP_TYPE_STRING);
curdep = prop_string_cstring_nocopy(obj);
assert(xbps_object_type(obj) == XBPS_TYPE_STRING);
curdep = xbps_string_cstring_nocopy(obj);
curver = xbps_pkgpattern_version(curdep);
pkgver = xbps_pkgpattern_version(reqpkg);
if (curver == NULL || pkgver == NULL)
@@ -132,11 +132,11 @@ add_missing_reqdep(struct xbps_handle *xhp, const char *reqpkg)
add_pkgdep = true;
out:
if (iter)
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
if (update_pkgdep)
prop_array_remove(mdeps, idx);
xbps_array_remove(mdeps, idx);
if (add_pkgdep && !xbps_add_obj_to_array(mdeps, reqpkg_str)) {
prop_object_release(reqpkg_str);
xbps_object_release(reqpkg_str);
return errno;
}
@@ -147,15 +147,15 @@ 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 */
xbps_array_t unsorted, /* array of unsorted deps */
xbps_array_t pkg_rdeps_array, /* current pkg rundeps array */
const char *curpkg, /* current pkgver */
unsigned short *depth) /* max recursion depth */
{
prop_dictionary_t curpkgd, tmpd;
prop_object_t obj;
prop_object_iterator_t iter;
prop_array_t curpkgrdeps;
xbps_dictionary_t curpkgd, tmpd;
xbps_object_t obj;
xbps_object_iterator_t iter;
xbps_array_t curpkgrdeps;
pkg_state_t state;
unsigned int x;
const char *reqpkg, *pkgver_q, *reason = NULL;
@@ -169,11 +169,11 @@ find_repo_deps(struct xbps_handle *xhp,
* Iterate over the list of required run dependencies for
* current package.
*/
iter = prop_array_iterator(pkg_rdeps_array);
iter = xbps_array_iterator(pkg_rdeps_array);
assert(iter);
while ((obj = prop_object_iterator_next(iter))) {
reqpkg = prop_string_cstring_nocopy(obj);
while ((obj = xbps_object_iterator_next(iter))) {
reqpkg = xbps_string_cstring_nocopy(obj);
if (xhp->flags & XBPS_FLAG_DEBUG) {
xbps_dbg_printf(xhp, "");
for (x = 0; x < *depth; x++)
@@ -213,7 +213,7 @@ find_repo_deps(struct xbps_handle *xhp,
* Check if installed version matches the
* required pkgdep version.
*/
prop_dictionary_get_cstring_nocopy(tmpd,
xbps_dictionary_get_cstring_nocopy(tmpd,
"pkgver", &pkgver_q);
/* Check its state */
@@ -277,7 +277,7 @@ find_repo_deps(struct xbps_handle *xhp,
*/
if ((curpkgd = xbps_find_pkg_in_array(unsorted, reqpkg)) ||
(curpkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, reqpkg))) {
prop_dictionary_get_cstring_nocopy(curpkgd,
xbps_dictionary_get_cstring_nocopy(curpkgd,
"pkgver", &pkgver_q);
xbps_dbg_printf_append(xhp, " (%s queued)\n", pkgver_q);
continue;
@@ -315,7 +315,7 @@ find_repo_deps(struct xbps_handle *xhp,
continue;
}
}
prop_dictionary_get_cstring_nocopy(curpkgd,
xbps_dictionary_get_cstring_nocopy(curpkgd,
"pkgver", &pkgver_q);
reqpkgname = xbps_pkg_name(pkgver_q);
assert(reqpkgname);
@@ -342,7 +342,7 @@ find_repo_deps(struct xbps_handle *xhp,
/*
* Package is on repo, add it into the transaction dictionary.
*/
prop_dictionary_set_cstring_nocopy(curpkgd, "transaction", reason);
xbps_dictionary_set_cstring_nocopy(curpkgd, "transaction", reason);
rv = store_dependency(xhp, unsorted, curpkgd, state);
if (rv != 0) {
xbps_dbg_printf(xhp, "store_dependency failed for "
@@ -352,7 +352,7 @@ find_repo_deps(struct xbps_handle *xhp,
/*
* If package doesn't have rundeps, pass to the next one.
*/
curpkgrdeps = prop_dictionary_get(curpkgd, "run_depends");
curpkgrdeps = xbps_dictionary_get(curpkgd, "run_depends");
if (curpkgrdeps == NULL)
continue;
@@ -376,7 +376,7 @@ find_repo_deps(struct xbps_handle *xhp,
break;
}
}
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
(*depth)--;
return rv;
@@ -384,18 +384,18 @@ find_repo_deps(struct xbps_handle *xhp,
int HIDDEN
xbps_repository_find_deps(struct xbps_handle *xhp,
prop_array_t unsorted,
prop_dictionary_t repo_pkgd)
xbps_array_t unsorted,
xbps_dictionary_t repo_pkgd)
{
prop_array_t pkg_rdeps;
xbps_array_t pkg_rdeps;
const char *pkgver;
unsigned short depth = 0;
pkg_rdeps = prop_dictionary_get(repo_pkgd, "run_depends");
if (prop_array_count(pkg_rdeps) == 0)
pkg_rdeps = xbps_dictionary_get(repo_pkgd, "run_depends");
if (xbps_array_count(pkg_rdeps) == 0)
return 0;
prop_dictionary_get_cstring_nocopy(repo_pkgd, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(repo_pkgd, "pkgver", &pkgver);
xbps_dbg_printf(xhp, "Finding required dependencies for '%s':\n", pkgver);
/*
* This will find direct and indirect deps, if any of them is not

View File

@@ -37,8 +37,8 @@
* @defgroup repopool Repository pool functions
*/
struct rpool_fpkg {
prop_array_t revdeps;
prop_dictionary_t pkgd;
xbps_array_t revdeps;
xbps_dictionary_t pkgd;
const char *pattern;
const char *bestpkgver;
bool best;
@@ -78,22 +78,22 @@ static int
find_pkg_revdeps_cb(struct xbps_repo *repo, void *arg, bool *done)
{
struct rpool_fpkg *rpf = arg;
prop_array_t revdeps = NULL;
xbps_array_t revdeps = NULL;
const char *pkgver;
unsigned int i;
(void)done;
revdeps = xbps_repo_get_pkg_revdeps(repo, rpf->pattern);
if (prop_array_count(revdeps)) {
if (xbps_array_count(revdeps)) {
/* found */
if (rpf->revdeps == NULL)
rpf->revdeps = prop_array_create();
for (i = 0; i < prop_array_count(revdeps); i++) {
prop_array_get_cstring_nocopy(revdeps, i, &pkgver);
prop_array_add_cstring_nocopy(rpf->revdeps, pkgver);
rpf->revdeps = xbps_array_create();
for (i = 0; i < xbps_array_count(revdeps); i++) {
xbps_array_get_cstring_nocopy(revdeps, i, &pkgver);
xbps_array_add_cstring_nocopy(rpf->revdeps, pkgver);
}
prop_object_release(revdeps);
xbps_object_release(revdeps);
}
return 0;
}
@@ -102,7 +102,7 @@ static int
find_best_pkg_cb(struct xbps_repo *repo, void *arg, bool *done)
{
struct rpool_fpkg *rpf = arg;
prop_dictionary_t pkgd;
xbps_dictionary_t pkgd;
const char *repopkgver;
(void)done;
@@ -117,14 +117,14 @@ find_best_pkg_cb(struct xbps_repo *repo, void *arg, bool *done)
"'%s'.\n", rpf->pattern, repo->uri);
return 0;
}
prop_dictionary_get_cstring_nocopy(pkgd,
xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &repopkgver);
if (rpf->bestpkgver == NULL) {
xbps_dbg_printf(repo->xhp,
"[rpool] Found best match '%s' (%s).\n",
repopkgver, repo->uri);
rpf->pkgd = pkgd;
prop_dictionary_set_cstring_nocopy(rpf->pkgd,
xbps_dictionary_set_cstring_nocopy(rpf->pkgd,
"repository", repo->uri);
rpf->bestpkgver = repopkgver;
return 0;
@@ -138,7 +138,7 @@ find_best_pkg_cb(struct xbps_repo *repo, void *arg, bool *done)
"[rpool] Found best match '%s' (%s).\n",
repopkgver, repo->uri);
rpf->pkgd = pkgd;
prop_dictionary_set_cstring_nocopy(rpf->pkgd,
xbps_dictionary_set_cstring_nocopy(rpf->pkgd,
"repository", repo->uri);
rpf->bestpkgver = repopkgver;
}
@@ -152,7 +152,7 @@ typedef enum {
REVDEPS_PKG
} pkg_repo_type_t;
static prop_object_t
static xbps_object_t
repo_find_pkg(struct xbps_handle *xhp,
const char *pkg,
pkg_repo_type_t type)
@@ -200,7 +200,7 @@ repo_find_pkg(struct xbps_handle *xhp,
return rpf.pkgd;
}
prop_dictionary_t
xbps_dictionary_t
xbps_rpool_get_virtualpkg(struct xbps_handle *xhp, const char *pkg)
{
assert(xhp);
@@ -209,7 +209,7 @@ xbps_rpool_get_virtualpkg(struct xbps_handle *xhp, const char *pkg)
return repo_find_pkg(xhp, pkg, VIRTUAL_PKG);
}
prop_dictionary_t
xbps_dictionary_t
xbps_rpool_get_pkg(struct xbps_handle *xhp, const char *pkg)
{
assert(xhp);
@@ -221,7 +221,7 @@ xbps_rpool_get_pkg(struct xbps_handle *xhp, const char *pkg)
return repo_find_pkg(xhp, pkg, REAL_PKG);
}
prop_array_t
xbps_array_t
xbps_rpool_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
{
assert(xhp);
@@ -230,12 +230,12 @@ xbps_rpool_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
return repo_find_pkg(xhp, pkg, REVDEPS_PKG);
}
prop_dictionary_t
xbps_dictionary_t
xbps_rpool_get_pkg_plist(struct xbps_handle *xhp,
const char *pkg,
const char *plistf)
{
prop_dictionary_t pkgd = NULL, plistd = NULL;
xbps_dictionary_t pkgd = NULL, plistd = NULL;
const char *repo;
char *url;
@@ -261,8 +261,8 @@ xbps_rpool_get_pkg_plist(struct xbps_handle *xhp,
}
plistd = xbps_get_pkg_plist_from_binpkg(url, plistf);
if (plistd) {
prop_dictionary_get_cstring_nocopy(pkgd, "repository", &repo);
prop_dictionary_set_cstring_nocopy(plistd, "repository", repo);
xbps_dictionary_get_cstring_nocopy(pkgd, "repository", &repo);
xbps_dictionary_set_cstring_nocopy(plistd, "repository", repo);
}
free(url);

View File

@@ -56,23 +56,23 @@
*/
static int
check_binpkgs_hash(struct xbps_handle *xhp, prop_object_iterator_t iter)
check_binpkgs_hash(struct xbps_handle *xhp, xbps_object_iterator_t iter)
{
prop_object_t obj;
xbps_object_t obj;
const char *pkgver, *arch, *repoloc, *sha256, *trans;
char *binfile, *filen;
int rv = 0;
while ((obj = prop_object_iterator_next(iter)) != NULL) {
prop_dictionary_get_cstring_nocopy(obj, "transaction", &trans);
while ((obj = xbps_object_iterator_next(iter)) != NULL) {
xbps_dictionary_get_cstring_nocopy(obj, "transaction", &trans);
if ((strcmp(trans, "remove") == 0) ||
(strcmp(trans, "configure") == 0))
continue;
prop_dictionary_get_cstring_nocopy(obj, "architecture", &arch);
prop_dictionary_get_cstring_nocopy(obj, "repository", &repoloc);
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(obj,
xbps_dictionary_get_cstring_nocopy(obj, "architecture", &arch);
xbps_dictionary_get_cstring_nocopy(obj, "repository", &repoloc);
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(obj,
"filename-sha256", &sha256);
binfile = xbps_repository_pkg_path(xhp, obj);
@@ -97,29 +97,29 @@ check_binpkgs_hash(struct xbps_handle *xhp, prop_object_iterator_t iter)
free(binfile);
free(filen);
}
prop_object_iterator_reset(iter);
xbps_object_iterator_reset(iter);
return rv;
}
static int
download_binpkgs(struct xbps_handle *xhp, prop_object_iterator_t iter)
download_binpkgs(struct xbps_handle *xhp, xbps_object_iterator_t iter)
{
prop_object_t obj;
xbps_object_t obj;
const char *pkgver, *arch, *fetchstr, *repoloc, *trans;
char *binfile, *filen;
int rv = 0;
bool state_dload = false;
while ((obj = prop_object_iterator_next(iter)) != NULL) {
prop_dictionary_get_cstring_nocopy(obj, "transaction", &trans);
while ((obj = xbps_object_iterator_next(iter)) != NULL) {
xbps_dictionary_get_cstring_nocopy(obj, "transaction", &trans);
if ((strcmp(trans, "remove") == 0) ||
(strcmp(trans, "configure") == 0))
continue;
prop_dictionary_get_cstring_nocopy(obj, "architecture", &arch);
prop_dictionary_get_cstring_nocopy(obj, "repository", &repoloc);
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(obj, "architecture", &arch);
xbps_dictionary_get_cstring_nocopy(obj, "repository", &repoloc);
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
binfile = xbps_repository_pkg_path(xhp, obj);
if (binfile == NULL) {
@@ -188,7 +188,7 @@ download_binpkgs(struct xbps_handle *xhp, prop_object_iterator_t iter)
free(binfile);
free(filen);
}
prop_object_iterator_reset(iter);
xbps_object_iterator_reset(iter);
return rv;
}
@@ -196,13 +196,13 @@ download_binpkgs(struct xbps_handle *xhp, prop_object_iterator_t iter)
int
xbps_transaction_commit(struct xbps_handle *xhp)
{
prop_object_t obj;
prop_object_iterator_t iter;
xbps_object_t obj;
xbps_object_iterator_t iter;
const char *pkgver, *tract;
int rv = 0;
bool update, install, sr;
assert(prop_object_type(xhp->transd) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(xhp->transd) == XBPS_TYPE_DICTIONARY);
update = install = false;
iter = xbps_array_iter_from_dict(xhp->transd, "packages");
@@ -225,10 +225,10 @@ xbps_transaction_commit(struct xbps_handle *xhp)
*/
xbps_set_cb_state(xhp, XBPS_STATE_TRANS_RUN, 0, NULL, NULL);
while ((obj = prop_object_iterator_next(iter)) != NULL) {
while ((obj = xbps_object_iterator_next(iter)) != NULL) {
update = false;
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
if (strcmp(tract, "remove") == 0) {
update = false;
@@ -236,9 +236,9 @@ xbps_transaction_commit(struct xbps_handle *xhp)
/*
* Remove package.
*/
prop_dictionary_get_bool(obj, "remove-and-update",
xbps_dictionary_get_bool(obj, "remove-and-update",
&update);
prop_dictionary_get_bool(obj, "softreplace", &sr);
xbps_dictionary_get_bool(obj, "softreplace", &sr);
rv = xbps_remove_pkg(xhp, pkgver, update, sr);
if (rv != 0) {
xbps_dbg_printf(xhp, "[trans] failed to "
@@ -303,20 +303,20 @@ xbps_transaction_commit(struct xbps_handle *xhp)
if (xhp->target_arch && strcmp(xhp->native_arch, xhp->target_arch))
goto out;
prop_object_iterator_reset(iter);
xbps_object_iterator_reset(iter);
/*
* Configure all unpacked packages.
*/
xbps_set_cb_state(xhp, XBPS_STATE_TRANS_CONFIGURE, 0, NULL, NULL);
while ((obj = prop_object_iterator_next(iter)) != NULL) {
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
while ((obj = xbps_object_iterator_next(iter)) != NULL) {
xbps_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
if ((strcmp(tract, "remove") == 0) ||
(strcmp(tract, "configure") == 0))
continue;
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
update = false;
if (strcmp(tract, "update") == 0)
update = true;
@@ -341,7 +341,7 @@ xbps_transaction_commit(struct xbps_handle *xhp)
}
out:
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
return rv;
}

View File

@@ -55,9 +55,9 @@
static int
compute_transaction_stats(struct xbps_handle *xhp)
{
prop_dictionary_t pkg_metad;
prop_object_iterator_t iter;
prop_object_t obj;
xbps_dictionary_t pkg_metad;
xbps_object_iterator_t iter;
xbps_object_t obj;
uint64_t tsize, dlsize, instsize, rmsize;
uint32_t inst_pkgcnt, up_pkgcnt, cf_pkgcnt, rm_pkgcnt;
int rv = 0;
@@ -70,14 +70,14 @@ compute_transaction_stats(struct xbps_handle *xhp)
if (iter == NULL)
return EINVAL;
while ((obj = prop_object_iterator_next(iter)) != NULL) {
while ((obj = xbps_object_iterator_next(iter)) != NULL) {
/*
* Count number of pkgs to be removed, configured,
* installed and updated.
*/
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
prop_dictionary_get_cstring_nocopy(obj, "repository", &repo);
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
xbps_dictionary_get_cstring_nocopy(obj, "repository", &repo);
if (strcmp(tract, "configure") == 0) {
cf_pkgcnt++;
@@ -105,17 +105,17 @@ compute_transaction_stats(struct xbps_handle *xhp)
free(pkgname);
if (pkg_metad == NULL)
continue;
prop_dictionary_get_uint64(pkg_metad,
xbps_dictionary_get_uint64(pkg_metad,
"installed_size", &tsize);
rmsize += tsize;
}
if ((strcmp(tract, "install") == 0) ||
(strcmp(tract, "update") == 0)) {
prop_dictionary_get_uint64(obj,
xbps_dictionary_get_uint64(obj,
"installed_size", &tsize);
instsize += tsize;
if (xbps_repository_is_remote(repo)) {
prop_dictionary_get_uint64(obj,
xbps_dictionary_get_uint64(obj,
"filename-size", &tsize);
dlsize += tsize;
}
@@ -123,25 +123,25 @@ compute_transaction_stats(struct xbps_handle *xhp)
}
if (inst_pkgcnt &&
!prop_dictionary_set_uint32(xhp->transd, "total-install-pkgs",
!xbps_dictionary_set_uint32(xhp->transd, "total-install-pkgs",
inst_pkgcnt)) {
rv = EINVAL;
goto out;
}
if (up_pkgcnt &&
!prop_dictionary_set_uint32(xhp->transd, "total-update-pkgs",
!xbps_dictionary_set_uint32(xhp->transd, "total-update-pkgs",
up_pkgcnt)) {
rv = EINVAL;
goto out;
}
if (cf_pkgcnt &&
!prop_dictionary_set_uint32(xhp->transd, "total-configure-pkgs",
!xbps_dictionary_set_uint32(xhp->transd, "total-configure-pkgs",
cf_pkgcnt)) {
rv = EINVAL;
goto out;
}
if (rm_pkgcnt &&
!prop_dictionary_set_uint32(xhp->transd, "total-remove-pkgs",
!xbps_dictionary_set_uint32(xhp->transd, "total-remove-pkgs",
rm_pkgcnt)) {
rv = EINVAL;
goto out;
@@ -160,7 +160,7 @@ compute_transaction_stats(struct xbps_handle *xhp)
* Add object in transaction dictionary with total installed
* size that it will take.
*/
if (!prop_dictionary_set_uint64(xhp->transd,
if (!xbps_dictionary_set_uint64(xhp->transd,
"total-installed-size", instsize)) {
rv = EINVAL;
goto out;
@@ -169,7 +169,7 @@ compute_transaction_stats(struct xbps_handle *xhp)
* Add object in transaction dictionary with total download
* size that needs to be sucked in.
*/
if (!prop_dictionary_set_uint64(xhp->transd,
if (!xbps_dictionary_set_uint64(xhp->transd,
"total-download-size", dlsize)) {
rv = EINVAL;
goto out;
@@ -178,13 +178,13 @@ compute_transaction_stats(struct xbps_handle *xhp)
* Add object in transaction dictionary with total size to be
* freed from packages to be removed.
*/
if (!prop_dictionary_set_uint64(xhp->transd,
if (!xbps_dictionary_set_uint64(xhp->transd,
"total-removed-size", rmsize)) {
rv = EINVAL;
goto out;
}
out:
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
return rv;
}
@@ -192,41 +192,41 @@ out:
int HIDDEN
xbps_transaction_init(struct xbps_handle *xhp)
{
prop_array_t unsorted, mdeps, conflicts;
xbps_array_t unsorted, mdeps, conflicts;
if (xhp->transd != NULL)
return 0;
if ((xhp->transd = prop_dictionary_create()) == NULL)
if ((xhp->transd = xbps_dictionary_create()) == NULL)
return ENOMEM;
if ((unsorted = prop_array_create()) == NULL) {
prop_object_release(xhp->transd);
if ((unsorted = xbps_array_create()) == NULL) {
xbps_object_release(xhp->transd);
xhp->transd = NULL;
return ENOMEM;
}
if (!xbps_add_obj_to_dict(xhp->transd, unsorted, "unsorted_deps")) {
prop_object_release(xhp->transd);
xbps_object_release(xhp->transd);
xhp->transd = NULL;
return EINVAL;
}
if ((mdeps = prop_array_create()) == NULL) {
prop_object_release(xhp->transd);
if ((mdeps = xbps_array_create()) == NULL) {
xbps_object_release(xhp->transd);
xhp->transd = NULL;
return ENOMEM;
}
if (!xbps_add_obj_to_dict(xhp->transd, mdeps, "missing_deps")) {
prop_object_release(xhp->transd);
xbps_object_release(xhp->transd);
xhp->transd = NULL;
return EINVAL;
}
if ((conflicts = prop_array_create()) == NULL) {
prop_object_release(xhp->transd);
if ((conflicts = xbps_array_create()) == NULL) {
xbps_object_release(xhp->transd);
xhp->transd = NULL;
return ENOMEM;
}
if (!xbps_add_obj_to_dict(xhp->transd, conflicts, "conflicts")) {
prop_object_release(xhp->transd);
xbps_object_release(xhp->transd);
xhp->transd = NULL;
return EINVAL;
}
@@ -237,7 +237,7 @@ xbps_transaction_init(struct xbps_handle *xhp)
int
xbps_transaction_prepare(struct xbps_handle *xhp)
{
prop_array_t mdeps, conflicts;
xbps_array_t mdeps, conflicts;
int rv = 0;
if (xhp->transd == NULL)
@@ -246,22 +246,22 @@ xbps_transaction_prepare(struct xbps_handle *xhp)
/*
* If there are missing deps bail out.
*/
mdeps = prop_dictionary_get(xhp->transd, "missing_deps");
if (prop_array_count(mdeps) > 0)
mdeps = xbps_dictionary_get(xhp->transd, "missing_deps");
if (xbps_array_count(mdeps) > 0)
return ENODEV;
/*
* If there are package conflicts bail out.
*/
conflicts = prop_dictionary_get(xhp->transd, "conflicts");
if (prop_array_count(conflicts) > 0)
conflicts = xbps_dictionary_get(xhp->transd, "conflicts");
if (xbps_array_count(conflicts) > 0)
return EAGAIN;
/*
* Check for packages to be replaced.
*/
if ((rv = xbps_transaction_package_replace(xhp)) != 0) {
prop_object_release(xhp->transd);
xbps_object_release(xhp->transd);
xhp->transd = NULL;
return rv;
}
@@ -269,7 +269,7 @@ xbps_transaction_prepare(struct xbps_handle *xhp)
* Sort package dependencies if necessary.
*/
if ((rv = xbps_transaction_sort(xhp)) != 0) {
prop_object_release(xhp->transd);
xbps_object_release(xhp->transd);
xhp->transd = NULL;
return rv;
}
@@ -279,16 +279,16 @@ xbps_transaction_prepare(struct xbps_handle *xhp)
* and removed to the transaction dictionary.
*/
if ((rv = compute_transaction_stats(xhp)) != 0) {
prop_object_release(xhp->transd);
xbps_object_release(xhp->transd);
xhp->transd = NULL;
return rv;
}
/*
* The missing deps and conflicts arrays are not necessary anymore.
*/
prop_dictionary_remove(xhp->transd, "missing_deps");
prop_dictionary_remove(xhp->transd, "conflicts");
prop_dictionary_make_immutable(xhp->transd);
xbps_dictionary_remove(xhp->transd, "missing_deps");
xbps_dictionary_remove(xhp->transd, "conflicts");
xbps_dictionary_make_immutable(xhp->transd);
return 0;
}

View File

@@ -60,8 +60,8 @@ enum {
static int
trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action)
{
prop_dictionary_t pkg_pkgdb = NULL, pkg_repod;
prop_array_t unsorted;
xbps_dictionary_t pkg_pkgdb = NULL, pkg_repod;
xbps_array_t unsorted;
const char *repoloc, *repopkgver, *instpkgver, *reason;
char *pkgname;
int rv = 0;
@@ -90,14 +90,14 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action)
return ENOENT;
}
}
prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &repopkgver);
prop_dictionary_get_cstring_nocopy(pkg_repod, "repository", &repoloc);
xbps_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &repopkgver);
xbps_dictionary_get_cstring_nocopy(pkg_repod, "repository", &repoloc);
if (action == TRANS_UPDATE) {
/*
* Compare installed version vs best pkg available in repos.
*/
prop_dictionary_get_cstring_nocopy(pkg_pkgdb,
xbps_dictionary_get_cstring_nocopy(pkg_pkgdb,
"pkgver", &instpkgver);
if (xbps_cmpver(repopkgver, instpkgver) <= 0) {
xbps_dbg_printf(xhp, "[rpool] Skipping `%s' "
@@ -106,9 +106,9 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action)
return EEXIST;
}
/* respect current install mode from pkgdb */
prop_dictionary_get_bool(pkg_pkgdb, "automatic-install",
xbps_dictionary_get_bool(pkg_pkgdb, "automatic-install",
&autoinst);
prop_dictionary_set_bool(pkg_repod, "automatic-install",
xbps_dictionary_set_bool(pkg_repod, "automatic-install",
autoinst);
}
/*
@@ -117,7 +117,7 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action)
if ((rv = xbps_transaction_init(xhp)) != 0)
return rv;
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps");
/*
* Find out if package has matched conflicts.
*/
@@ -166,7 +166,7 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action)
* Set transaction obj in pkg dictionary to "install", "configure"
* or "update".
*/
if (!prop_dictionary_set_cstring_nocopy(pkg_repod,
if (!xbps_dictionary_set_cstring_nocopy(pkg_repod,
"transaction", reason))
return EINVAL;
@@ -174,7 +174,7 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action)
* Add the pkg dictionary from repository's index dictionary into
* the "unsorted" queue.
*/
if (!prop_array_add(unsorted, pkg_repod))
if (!xbps_array_add(unsorted, pkg_repod))
return EINVAL;
xbps_dbg_printf(xhp, "%s: added into the transaction (%s).\n",
@@ -186,9 +186,9 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action)
int
xbps_transaction_update_packages(struct xbps_handle *xhp)
{
prop_dictionary_t pkgd;
prop_object_t obj;
prop_object_iterator_t iter;
xbps_dictionary_t pkgd;
xbps_object_t obj;
xbps_object_iterator_t iter;
const char *pkgver, *holdpkg;
char *pkgname;
bool foundhold = false, newpkg_found = false;
@@ -198,12 +198,12 @@ xbps_transaction_update_packages(struct xbps_handle *xhp)
if ((rv = xbps_pkgdb_init(xhp)) != 0)
return rv;
iter = prop_dictionary_iterator(xhp->pkgdb);
iter = xbps_dictionary_iterator(xhp->pkgdb);
assert(iter);
while ((obj = prop_object_iterator_next(iter))) {
pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
while ((obj = xbps_object_iterator_next(iter))) {
pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
pkgname = xbps_pkg_name(pkgver);
assert(pkgname);
@@ -233,7 +233,7 @@ xbps_transaction_update_packages(struct xbps_handle *xhp)
}
free(pkgname);
}
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
return newpkg_found ? rv : EEXIST;
}
@@ -248,7 +248,7 @@ int
xbps_transaction_install_pkg(struct xbps_handle *xhp, const char *pkg,
bool reinstall)
{
prop_dictionary_t pkgd = NULL;
xbps_dictionary_t pkgd = NULL;
pkg_state_t state;
if ((pkgd = xbps_pkgdb_get_pkg(xhp, pkg)) ||
@@ -269,9 +269,9 @@ xbps_transaction_remove_pkg(struct xbps_handle *xhp,
const char *pkgname,
bool recursive)
{
prop_dictionary_t pkgd;
prop_array_t unsorted, orphans, orphans_pkg, reqby;
prop_object_t obj;
xbps_dictionary_t pkgd;
xbps_array_t unsorted, orphans, orphans_pkg, reqby;
xbps_object_t obj;
const char *pkgver;
unsigned int count;
int rv = 0;
@@ -288,7 +288,7 @@ xbps_transaction_remove_pkg(struct xbps_handle *xhp,
if ((rv = xbps_transaction_init(xhp)) != 0)
return rv;
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps");
if (!recursive)
goto rmpkg;
@@ -296,21 +296,21 @@ xbps_transaction_remove_pkg(struct xbps_handle *xhp,
* If recursive is set, find out which packages would be orphans
* if the supplied package were already removed.
*/
if ((orphans_pkg = prop_array_create()) == NULL)
if ((orphans_pkg = xbps_array_create()) == NULL)
return ENOMEM;
prop_array_set_cstring_nocopy(orphans_pkg, 0, pkgname);
xbps_array_set_cstring_nocopy(orphans_pkg, 0, pkgname);
orphans = xbps_find_pkg_orphans(xhp, orphans_pkg);
prop_object_release(orphans_pkg);
if (prop_object_type(orphans) != PROP_TYPE_ARRAY)
xbps_object_release(orphans_pkg);
if (xbps_object_type(orphans) != XBPS_TYPE_ARRAY)
return EINVAL;
count = prop_array_count(orphans);
count = xbps_array_count(orphans);
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);
obj = xbps_array_get(orphans, count);
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
xbps_dictionary_set_cstring_nocopy(obj, "transaction", "remove");
xbps_array_add(unsorted, obj);
xbps_dbg_printf(xhp, "%s: added into transaction (remove).\n", pkgver);
}
reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkgname);
@@ -318,28 +318,28 @@ xbps_transaction_remove_pkg(struct xbps_handle *xhp,
* If target pkg is required by any installed pkg, the client must be aware
* of this to take appropiate action.
*/
if ((prop_object_type(reqby) == PROP_TYPE_ARRAY) &&
(prop_array_count(reqby) > 0))
if ((xbps_object_type(reqby) == XBPS_TYPE_ARRAY) &&
(xbps_array_count(reqby) > 0))
rv = EEXIST;
prop_object_release(orphans);
xbps_object_release(orphans);
return rv;
rmpkg:
/*
* Add pkg dictionary into the transaction unsorted queue.
*/
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
prop_dictionary_set_cstring_nocopy(pkgd, "transaction", "remove");
prop_array_add(unsorted, pkgd);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
xbps_dictionary_set_cstring_nocopy(pkgd, "transaction", "remove");
xbps_array_add(unsorted, pkgd);
xbps_dbg_printf(xhp, "%s: added into transaction (remove).\n", pkgver);
reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkgver);
/*
* If target pkg is required by any installed pkg, the client must be aware
* of this to take appropiate action.
*/
if ((prop_object_type(reqby) == PROP_TYPE_ARRAY) &&
(prop_array_count(reqby) > 0))
if ((xbps_object_type(reqby) == XBPS_TYPE_ARRAY) &&
(xbps_array_count(reqby) > 0))
rv = EEXIST;
return rv;
@@ -348,14 +348,14 @@ rmpkg:
int
xbps_transaction_autoremove_pkgs(struct xbps_handle *xhp)
{
prop_array_t orphans, unsorted;
prop_object_t obj;
xbps_array_t orphans, unsorted;
xbps_object_t obj;
const char *pkgver;
unsigned int count;
int rv = 0;
orphans = xbps_find_pkg_orphans(xhp, NULL);
if ((count = prop_array_count(orphans)) == 0) {
if ((count = xbps_array_count(orphans)) == 0) {
/* no orphans? we are done */
rv = ENOENT;
goto out;
@@ -366,21 +366,21 @@ xbps_transaction_autoremove_pkgs(struct xbps_handle *xhp)
if ((rv = xbps_transaction_init(xhp)) != 0)
goto out;
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
unsorted = xbps_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,
obj = xbps_array_get(orphans, count);
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
xbps_dictionary_set_cstring_nocopy(obj,
"transaction", "remove");
prop_array_add(unsorted, obj);
xbps_array_add(unsorted, obj);
xbps_dbg_printf(xhp, "%s: added (remove).\n", pkgver);
}
out:
if (orphans != NULL)
prop_object_release(orphans);
xbps_object_release(orphans);
return rv;
}

View File

@@ -36,28 +36,28 @@
int HIDDEN
xbps_transaction_package_replace(struct xbps_handle *xhp)
{
prop_array_t replaces, unsorted;
prop_dictionary_t instd, reppkgd, filesd;
prop_object_t obj, obj2;
prop_object_iterator_t iter;
xbps_array_t replaces, unsorted;
xbps_dictionary_t instd, reppkgd, filesd;
xbps_object_t obj, obj2;
xbps_object_iterator_t iter;
const char *pattern, *pkgver, *curpkgver;
char *buf, *pkgname, *curpkgname;
bool instd_auto, sr;
unsigned int i;
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps");
for (i = 0; i < prop_array_count(unsorted); i++) {
obj = prop_array_get(unsorted, i);
replaces = prop_dictionary_get(obj, "replaces");
if (replaces == NULL || prop_array_count(replaces) == 0)
for (i = 0; i < xbps_array_count(unsorted); i++) {
obj = xbps_array_get(unsorted, i);
replaces = xbps_dictionary_get(obj, "replaces");
if (replaces == NULL || xbps_array_count(replaces) == 0)
continue;
iter = prop_array_iterator(replaces);
iter = xbps_array_iterator(replaces);
assert(iter);
while ((obj2 = prop_object_iterator_next(iter)) != NULL) {
pattern = prop_string_cstring_nocopy(obj2);
while ((obj2 = xbps_object_iterator_next(iter)) != NULL) {
pattern = xbps_string_cstring_nocopy(obj2);
/*
* Find the installed package that matches the pattern
* to be replaced.
@@ -66,9 +66,9 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
((instd = xbps_pkgdb_get_virtualpkg(xhp, pattern)) == NULL))
continue;
prop_dictionary_get_cstring_nocopy(obj,
xbps_dictionary_get_cstring_nocopy(obj,
"pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(instd,
xbps_dictionary_get_cstring_nocopy(instd,
"pkgver", &curpkgver);
pkgname = xbps_pkg_name(pkgver);
assert(pkgname);
@@ -88,7 +88,7 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
"Package `%s' will be replaced by `%s', "
"matched with `%s'\n", curpkgver, pkgver, pattern);
instd_auto = false;
prop_dictionary_get_bool(instd,
xbps_dictionary_get_bool(instd,
"automatic-install", &instd_auto);
/*
* Package contains replaces="pkgpattern", but the
@@ -99,11 +99,11 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
xbps_dbg_printf(xhp,
"found replaced pkg "
"in transaction\n");
prop_dictionary_set_bool(instd,
xbps_dictionary_set_bool(instd,
"remove-and-update", true);
prop_dictionary_set_bool(reppkgd,
xbps_dictionary_set_bool(reppkgd,
"automatic-install", instd_auto);
prop_dictionary_set_bool(reppkgd,
xbps_dictionary_set_bool(reppkgd,
"skip-obsoletes", true);
xbps_array_replace_dict_by_name(unsorted,
reppkgd, curpkgname);
@@ -117,45 +117,45 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
pattern, true) ||
xbps_match_virtual_pkg_in_dict(instd,
pkgname, false)) {
prop_dictionary_set_bool(obj,
xbps_dictionary_set_bool(obj,
"automatic-install", instd_auto);
}
sr = false;
prop_dictionary_get_bool(obj, "softreplace", &sr);
xbps_dictionary_get_bool(obj, "softreplace", &sr);
if (sr) {
prop_dictionary_set_bool(obj,
xbps_dictionary_set_bool(obj,
"automatic-install", instd_auto);
prop_dictionary_set_bool(instd,
xbps_dictionary_set_bool(instd,
"softreplace", true);
buf = xbps_xasprintf("%s/.%s.plist",
xhp->metadir, curpkgname);
filesd = prop_dictionary_internalize_from_file(buf);
filesd = xbps_dictionary_internalize_from_file(buf);
free(buf);
assert(filesd != NULL);
buf = xbps_xasprintf("%s/.%s.plist",
xhp->metadir, pkgname);
if (!prop_dictionary_externalize_to_file(filesd, buf)) {
if (!xbps_dictionary_externalize_to_file(filesd, buf)) {
free(buf);
prop_object_release(filesd);
prop_object_iterator_release(iter);
xbps_object_release(filesd);
xbps_object_iterator_release(iter);
free(pkgname);
free(curpkgname);
return errno;
}
prop_object_release(filesd);
xbps_object_release(filesd);
free(buf);
}
/*
* Add package dictionary into the transaction and mark
* it as to be "removed".
*/
prop_dictionary_set_cstring_nocopy(instd,
xbps_dictionary_set_cstring_nocopy(instd,
"transaction", "remove");
prop_array_add(unsorted, instd);
xbps_array_add(unsorted, instd);
free(pkgname);
free(curpkgname);
}
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
}
return 0;

View File

@@ -48,7 +48,7 @@
struct pkgdep {
TAILQ_ENTRY(pkgdep) pkgdep_entries;
prop_dictionary_t d;
xbps_dictionary_t d;
char *name;
};
@@ -66,13 +66,13 @@ pkgdep_find(const char *pkg)
/* ignore entries without dictionary */
continue;
}
prop_dictionary_get_cstring_nocopy(pd->d,
xbps_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);
xbps_dictionary_get_cstring_nocopy(pd->d, "pkgver", &pkgver);
if (strcmp(pkgver, pkg) == 0)
return pd;
/* pkg expression match */
@@ -100,7 +100,7 @@ pkgdep_find_idx(const char *pkg)
idx++;
continue;
}
prop_dictionary_get_cstring_nocopy(pd->d,
xbps_dictionary_get_cstring_nocopy(pd->d,
"transaction", &tract);
/* ignore pkgs to be removed */
if (strcmp(tract, "remove") == 0) {
@@ -108,7 +108,7 @@ pkgdep_find_idx(const char *pkg)
continue;
}
/* simple match */
prop_dictionary_get_cstring_nocopy(pd->d, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(pd->d, "pkgver", &pkgver);
if (strcmp(pkgver, pkg) == 0)
return idx;
/* pkg expression match */
@@ -132,7 +132,7 @@ pkgdep_release(struct pkgdep *pd)
}
static struct pkgdep *
pkgdep_alloc(prop_dictionary_t d, const char *pkg)
pkgdep_alloc(xbps_dictionary_t d, const char *pkg)
{
struct pkgdep *pd;
@@ -145,14 +145,14 @@ pkgdep_alloc(prop_dictionary_t d, const char *pkg)
}
static void
pkgdep_end(prop_array_t sorted)
pkgdep_end(xbps_array_t sorted)
{
struct pkgdep *pd;
while ((pd = TAILQ_FIRST(&pkgdep_list)) != NULL) {
TAILQ_REMOVE(&pkgdep_list, pd, pkgdep_entries);
if (sorted != NULL && pd->d != NULL)
prop_array_add(sorted, pd->d);
xbps_array_add(sorted, pd->d);
pkgdep_release(pd);
}
@@ -161,10 +161,10 @@ pkgdep_end(prop_array_t sorted)
static int
sort_pkg_rundeps(struct xbps_handle *xhp,
struct pkgdep *pd,
prop_array_t pkg_rundeps,
prop_array_t unsorted)
xbps_array_t pkg_rundeps,
xbps_array_t unsorted)
{
prop_dictionary_t curpkgd;
xbps_dictionary_t curpkgd;
struct pkgdep *lpd, *pdn;
const char *str, *tract;
int32_t pkgdepidx, curpkgidx;
@@ -175,8 +175,8 @@ sort_pkg_rundeps(struct xbps_handle *xhp,
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);
for (i = idx; i < xbps_array_count(pkg_rundeps); i++) {
xbps_array_get_cstring_nocopy(pkg_rundeps, i, &str);
xbps_dbg_printf(xhp, " Required dependency '%s': ", str);
pdn = pkgdep_find(str);
@@ -210,7 +210,7 @@ again:
"dependency %s (depends on itself)\n", str);
continue;
}
prop_dictionary_get_cstring_nocopy(curpkgd,
xbps_dictionary_get_cstring_nocopy(curpkgd,
"transaction", &tract);
lpd = pkgdep_alloc(curpkgd, str);
@@ -255,48 +255,48 @@ again:
int HIDDEN
xbps_transaction_sort(struct xbps_handle *xhp)
{
prop_array_t provides, sorted, unsorted, rundeps;
prop_object_t obj;
xbps_array_t provides, sorted, unsorted, rundeps;
xbps_object_t obj;
struct pkgdep *pd;
unsigned int i, j, ndeps = 0, cnt = 0;
const char *pkgname, *pkgver, *tract, *vpkgdep;
int rv = 0;
bool vpkg_found;
if ((sorted = prop_array_create()) == NULL)
if ((sorted = xbps_array_create()) == NULL)
return ENOMEM;
/*
* Add sorted packages array into transaction dictionary (empty).
*/
if (!prop_dictionary_set(xhp->transd, "packages", sorted)) {
if (!xbps_dictionary_set(xhp->transd, "packages", sorted)) {
rv = EINVAL;
goto out;
}
/*
* All required deps are satisfied (already installed).
*/
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
if (prop_array_count(unsorted) == 0) {
prop_dictionary_set(xhp->transd, "packages", sorted);
prop_object_release(sorted);
unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps");
if (xbps_array_count(unsorted) == 0) {
xbps_dictionary_set(xhp->transd, "packages", sorted);
xbps_object_release(sorted);
return 0;
}
/*
* The sorted array should have the same capacity than
* all objects in the unsorted array.
*/
ndeps = prop_array_count(unsorted);
ndeps = xbps_array_count(unsorted);
/*
* Iterate over the unsorted package dictionaries and sort all
* its package dependencies.
*/
for (i = 0; i < ndeps; i++) {
vpkg_found = false;
obj = prop_array_get(unsorted, i);
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
provides = prop_dictionary_get(obj, "provides");
obj = xbps_array_get(unsorted, i);
xbps_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
provides = xbps_dictionary_get(obj, "provides");
xbps_dbg_printf(xhp, "Sorting package '%s' (%s): ", pkgver, tract);
if (provides) {
@@ -305,8 +305,8 @@ xbps_transaction_sort(struct xbps_handle *xhp)
* if any of them was previously added. If true, don't
* 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,
for (j = 0; j < xbps_array_count(provides); j++) {
xbps_array_get_cstring_nocopy(provides,
j, &vpkgdep);
pd = pkgdep_find(vpkgdep);
if (pd != NULL) {
@@ -343,8 +343,8 @@ xbps_transaction_sort(struct xbps_handle *xhp)
* Packages that don't have deps go at head, because
* it doesn't matter.
*/
rundeps = prop_dictionary_get(obj, "run_depends");
if (prop_array_count(rundeps) == 0) {
rundeps = xbps_dictionary_get(obj, "run_depends");
if (xbps_array_count(rundeps) == 0) {
xbps_dbg_printf_append(xhp, "\n");
cnt++;
continue;
@@ -368,17 +368,17 @@ xbps_transaction_sort(struct xbps_handle *xhp)
* Sanity check that the array contains the same number of
* objects than the total number of required dependencies.
*/
assert(cnt == prop_array_count(unsorted));
assert(cnt == xbps_array_count(unsorted));
/*
* We are done, all packages were sorted... remove the
* temporary array with unsorted packages.
*/
prop_dictionary_remove(xhp->transd, "unsorted_deps");
xbps_dictionary_remove(xhp->transd, "unsorted_deps");
out:
if (rv != 0)
prop_dictionary_remove(xhp->transd, "packages");
xbps_dictionary_remove(xhp->transd, "packages");
prop_object_release(sorted);
xbps_object_release(sorted);
return rv;
}

View File

@@ -67,7 +67,7 @@ xbps_repository_is_remote(const char *uri)
int
xbps_pkg_is_installed(struct xbps_handle *xhp, const char *pkg)
{
prop_dictionary_t dict;
xbps_dictionary_t dict;
pkg_state_t state;
assert(xhp);
@@ -172,21 +172,21 @@ xbps_pkgpattern_version(const char *pkg)
}
char HIDDEN *
xbps_repository_pkg_path(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
xbps_repository_pkg_path(struct xbps_handle *xhp, xbps_dictionary_t pkg_repod)
{
const char *pkgver, *arch, *repoloc;
char *lbinpkg = NULL;
assert(xhp);
assert(prop_object_type(pkg_repod) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(pkg_repod) == XBPS_TYPE_DICTIONARY);
if (!prop_dictionary_get_cstring_nocopy(pkg_repod,
if (!xbps_dictionary_get_cstring_nocopy(pkg_repod,
"pkgver", &pkgver))
return NULL;
if (!prop_dictionary_get_cstring_nocopy(pkg_repod,
if (!xbps_dictionary_get_cstring_nocopy(pkg_repod,
"architecture", &arch))
return NULL;
if (!prop_dictionary_get_cstring_nocopy(pkg_repod,
if (!xbps_dictionary_get_cstring_nocopy(pkg_repod,
"repository", &repoloc))
return NULL;
@@ -208,14 +208,14 @@ xbps_repository_pkg_path(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
}
bool
xbps_pkg_has_rundeps(prop_dictionary_t pkgd)
xbps_pkg_has_rundeps(xbps_dictionary_t pkgd)
{
prop_array_t array;
xbps_array_t array;
assert(prop_object_type(pkgd) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(pkgd) == XBPS_TYPE_DICTIONARY);
array = prop_dictionary_get(pkgd, "run_depends");
if (prop_array_count(array))
array = xbps_dictionary_get(pkgd, "run_depends");
if (xbps_array_count(array))
return true;
return false;

View File

@@ -140,13 +140,13 @@ xbps_file_hash_check(const char *file, const char *sha256)
}
static const char *
file_hash_dictionary(prop_dictionary_t d, const char *key, const char *file)
file_hash_dictionary(xbps_dictionary_t d, const char *key, const char *file)
{
prop_object_t obj;
prop_object_iterator_t iter;
xbps_object_t obj;
xbps_object_iterator_t iter;
const char *curfile = NULL, *sha256 = NULL;
assert(prop_object_type(d) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(d) == XBPS_TYPE_DICTIONARY);
assert(key != NULL);
assert(file != NULL);
@@ -155,17 +155,17 @@ file_hash_dictionary(prop_dictionary_t d, const char *key, const char *file)
errno = ENOENT;
return NULL;
}
while ((obj = prop_object_iterator_next(iter)) != NULL) {
prop_dictionary_get_cstring_nocopy(obj,
while ((obj = xbps_object_iterator_next(iter)) != NULL) {
xbps_dictionary_get_cstring_nocopy(obj,
"file", &curfile);
if (strcmp(file, curfile) == 0) {
/* file matched */
prop_dictionary_get_cstring_nocopy(obj,
xbps_dictionary_get_cstring_nocopy(obj,
"sha256", &sha256);
break;
}
}
prop_object_iterator_release(iter);
xbps_object_iterator_release(iter);
if (sha256 == NULL)
errno = ENOENT;
@@ -174,7 +174,7 @@ file_hash_dictionary(prop_dictionary_t d, const char *key, const char *file)
int HIDDEN
xbps_file_hash_check_dictionary(struct xbps_handle *xhp,
prop_dictionary_t d,
xbps_dictionary_t d,
const char *key,
const char *file)
{
@@ -182,7 +182,7 @@ xbps_file_hash_check_dictionary(struct xbps_handle *xhp,
char *buf;
int rv;
assert(prop_object_type(d) == PROP_TYPE_DICTIONARY);
assert(xbps_object_type(d) == XBPS_TYPE_DICTIONARY);
assert(key != NULL);
assert(file != NULL);