Performance improvements while installing deps of a binpkg.
--HG-- extra : convert_revision : 2ad3b29cfd22489f76739287176f40dd9535dfee
This commit is contained in:
parent
57de10314a
commit
44926cd53c
8 changed files with 123 additions and 188 deletions
|
@ -176,7 +176,8 @@ repoidx_addpkg(const char *file, const char *filename, const char *pkgdir)
|
||||||
* registered actually, remove old package from
|
* registered actually, remove old package from
|
||||||
* the index.
|
* the index.
|
||||||
*/
|
*/
|
||||||
if (!xbps_remove_pkg_from_dict(idxdict, pkgname)) {
|
if (!xbps_remove_pkg_from_dict(idxdict,
|
||||||
|
"packages", pkgname)) {
|
||||||
prop_object_release(newpkgd);
|
prop_object_release(newpkgd);
|
||||||
rv = EINVAL;
|
rv = EINVAL;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -35,7 +35,7 @@ int xbps_register_pkg(prop_dictionary_t, bool, bool);
|
||||||
int xbps_unpack_binary_pkg(prop_dictionary_t, prop_dictionary_t);
|
int xbps_unpack_binary_pkg(prop_dictionary_t, prop_dictionary_t);
|
||||||
int xbps_requiredby_pkg_add(prop_array_t, prop_dictionary_t, bool);
|
int xbps_requiredby_pkg_add(prop_array_t, prop_dictionary_t, bool);
|
||||||
int xbps_requiredby_pkg_remove(const char *);
|
int xbps_requiredby_pkg_remove(const char *);
|
||||||
int xbps_find_deps_in_pkg(prop_dictionary_t);
|
int xbps_find_deps_in_pkg(prop_dictionary_t, prop_object_iterator_t);
|
||||||
|
|
||||||
prop_dictionary_t xbps_get_pkg_deps_dictionary(void);
|
prop_dictionary_t xbps_get_pkg_deps_dictionary(void);
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,6 @@ bool
|
||||||
xbps_remove_pkg_dict_from_file(const char *, const char *);
|
xbps_remove_pkg_dict_from_file(const char *, const char *);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
xbps_remove_pkg_from_dict(prop_dictionary_t, const char *);
|
xbps_remove_pkg_from_dict(prop_dictionary_t, const char *, const char *);
|
||||||
|
|
||||||
#endif /* !_XBPS_PLIST_H_ */
|
#endif /* !_XBPS_PLIST_H_ */
|
||||||
|
|
123
lib/depends.c
123
lib/depends.c
|
@ -33,7 +33,6 @@
|
||||||
#include <xbps_api.h>
|
#include <xbps_api.h>
|
||||||
|
|
||||||
static int add_missing_reqdep(const char *, const char *);
|
static int add_missing_reqdep(const char *, const char *);
|
||||||
static int remove_missing_reqdep(const char *);
|
|
||||||
static int find_pkg_deps_from_repo(prop_dictionary_t, prop_dictionary_t,
|
static int find_pkg_deps_from_repo(prop_dictionary_t, prop_dictionary_t,
|
||||||
prop_array_t);
|
prop_array_t);
|
||||||
static int find_pkg_missing_deps_from_repo(prop_dictionary_t,
|
static int find_pkg_missing_deps_from_repo(prop_dictionary_t,
|
||||||
|
@ -208,88 +207,22 @@ add_missing_reqdep(const char *pkgname, const char *version)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
remove_missing_reqdep(const char *pkgname)
|
|
||||||
{
|
|
||||||
prop_array_t array;
|
|
||||||
prop_object_t obj;
|
|
||||||
prop_object_iterator_t iter;
|
|
||||||
size_t idx = 0;
|
|
||||||
const char *curname;
|
|
||||||
bool found = false;
|
|
||||||
|
|
||||||
array = prop_dictionary_get(chaindeps, "missing_deps");
|
|
||||||
assert(pkgname != NULL);
|
|
||||||
assert(version != NULL);
|
|
||||||
assert(array != NULL);
|
|
||||||
iter = prop_array_iterator(array);
|
|
||||||
if (iter == NULL)
|
|
||||||
return ENOMEM;
|
|
||||||
/*
|
|
||||||
* Finds the index of a package in the missing deps array.
|
|
||||||
*/
|
|
||||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
|
||||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &curname);
|
|
||||||
if (strcmp(pkgname, curname) == 0) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
prop_object_iterator_release(iter);
|
|
||||||
if (found) {
|
|
||||||
prop_array_remove(array, idx);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ENOENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
xbps_find_deps_in_pkg(prop_dictionary_t pkg)
|
xbps_find_deps_in_pkg(prop_dictionary_t pkg, prop_object_iterator_t iter)
|
||||||
{
|
{
|
||||||
prop_array_t array, pkg_rdeps, missing_rdeps;
|
prop_array_t pkg_rdeps, missing_rdeps;
|
||||||
prop_dictionary_t repolistd, repod;
|
prop_dictionary_t repod;
|
||||||
prop_object_t obj;
|
prop_object_t obj;
|
||||||
prop_object_iterator_t iter;
|
|
||||||
char *plist;
|
char *plist;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
assert(pkg != NULL);
|
assert(pkg != NULL);
|
||||||
|
assert(iter != NULL);
|
||||||
|
|
||||||
pkg_rdeps = prop_dictionary_get(pkg, "run_depends");
|
pkg_rdeps = prop_dictionary_get(pkg, "run_depends");
|
||||||
if (pkg_rdeps == NULL)
|
if (pkg_rdeps == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the dictionary with the list of registered repositories.
|
|
||||||
*/
|
|
||||||
plist = xbps_append_full_path(true, NULL, XBPS_REPOLIST);
|
|
||||||
if (plist == NULL)
|
|
||||||
return EINVAL;
|
|
||||||
/*
|
|
||||||
* Get the dictionary with the list of registered repositories.
|
|
||||||
*/
|
|
||||||
repolistd = prop_dictionary_internalize_from_file(plist);
|
|
||||||
if (repolistd == NULL) {
|
|
||||||
free(plist);
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
free(plist);
|
|
||||||
plist = NULL;
|
|
||||||
|
|
||||||
array = prop_dictionary_get(repolistd, "repository-list");
|
|
||||||
if (array == NULL) {
|
|
||||||
prop_object_release(repolistd);
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
iter = prop_array_iterator(array);
|
|
||||||
if (iter == NULL) {
|
|
||||||
prop_object_release(repolistd);
|
|
||||||
return ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Iterate over the repository pool and find out if we have
|
* Iterate over the repository pool and find out if we have
|
||||||
* all available binary packages.
|
* all available binary packages.
|
||||||
|
@ -297,15 +230,13 @@ xbps_find_deps_in_pkg(prop_dictionary_t pkg)
|
||||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
||||||
plist =
|
plist =
|
||||||
xbps_get_pkg_index_plist(prop_string_cstring_nocopy(obj));
|
xbps_get_pkg_index_plist(prop_string_cstring_nocopy(obj));
|
||||||
if (plist == NULL) {
|
if (plist == NULL)
|
||||||
rv = EINVAL;
|
return EINVAL;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
repod = prop_dictionary_internalize_from_file(plist);
|
repod = prop_dictionary_internalize_from_file(plist);
|
||||||
if (repod == NULL) {
|
if (repod == NULL) {
|
||||||
free(plist);
|
free(plist);
|
||||||
rv = errno;
|
return errno;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
free(plist);
|
free(plist);
|
||||||
|
|
||||||
|
@ -329,7 +260,7 @@ xbps_find_deps_in_pkg(prop_dictionary_t pkg)
|
||||||
|
|
||||||
missing_rdeps = prop_dictionary_get(chaindeps, "missing_deps");
|
missing_rdeps = prop_dictionary_get(chaindeps, "missing_deps");
|
||||||
if (prop_array_count(missing_rdeps) == 0)
|
if (prop_array_count(missing_rdeps) == 0)
|
||||||
goto out;
|
return 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there are missing deps, iterate one more time
|
* If there are missing deps, iterate one more time
|
||||||
|
@ -339,32 +270,26 @@ xbps_find_deps_in_pkg(prop_dictionary_t pkg)
|
||||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
||||||
plist =
|
plist =
|
||||||
xbps_get_pkg_index_plist(prop_string_cstring_nocopy(obj));
|
xbps_get_pkg_index_plist(prop_string_cstring_nocopy(obj));
|
||||||
if (plist == NULL) {
|
if (plist == NULL)
|
||||||
rv = EINVAL;
|
return EINVAL;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
repod = prop_dictionary_internalize_from_file(plist);
|
repod = prop_dictionary_internalize_from_file(plist);
|
||||||
if (repod == NULL) {
|
if (repod == NULL) {
|
||||||
free(plist);
|
free(plist);
|
||||||
rv = errno;
|
return errno;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
free(plist);
|
free(plist);
|
||||||
|
|
||||||
rv = find_pkg_missing_deps_from_repo(repod, pkg);
|
rv = find_pkg_missing_deps_from_repo(repod, pkg);
|
||||||
if (rv != 0 && rv != ENOENT) {
|
if (rv != 0 && rv != ENOENT) {
|
||||||
prop_object_release(repod);
|
prop_object_release(repod);
|
||||||
break;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
prop_object_release(repod);
|
prop_object_release(repod);
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
return 0;
|
||||||
prop_object_iterator_release(iter);
|
|
||||||
prop_object_release(repolistd);
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
prop_dictionary_t
|
prop_dictionary_t
|
||||||
|
@ -422,9 +347,11 @@ find_pkg_missing_deps_from_repo(prop_dictionary_t repo, prop_dictionary_t pkg)
|
||||||
/*
|
/*
|
||||||
* Remove package from missing now.
|
* Remove package from missing now.
|
||||||
*/
|
*/
|
||||||
rv = remove_missing_reqdep(pkgname);
|
if (!xbps_remove_pkg_from_dict(chaindeps,
|
||||||
if (rv != 0 && rv != ENOENT)
|
"missing_deps", pkgname)) {
|
||||||
break;
|
if (errno != 0 && errno != ENOENT)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
prop_object_iterator_reset(iter);
|
prop_object_iterator_reset(iter);
|
||||||
}
|
}
|
||||||
|
@ -521,10 +448,12 @@ find_pkg_deps_from_repo(prop_dictionary_t repo, prop_dictionary_t pkg,
|
||||||
/*
|
/*
|
||||||
* Remove package from missing_deps now it's been found.
|
* Remove package from missing_deps now it's been found.
|
||||||
*/
|
*/
|
||||||
rv = remove_missing_reqdep(pkgname);
|
if (!xbps_remove_pkg_from_dict(chaindeps,
|
||||||
if (rv != 0 && rv != ENOENT) {
|
"missing_deps", pkgname)) {
|
||||||
free(pkgname);
|
if (errno != 0 && errno != ENOENT) {
|
||||||
break;
|
free(pkgname);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
free(pkgname);
|
free(pkgname);
|
||||||
|
|
||||||
|
|
167
lib/install.c
167
lib/install.c
|
@ -34,13 +34,6 @@
|
||||||
|
|
||||||
#include <xbps_api.h>
|
#include <xbps_api.h>
|
||||||
|
|
||||||
struct binpkg_instargs {
|
|
||||||
const char *pkgname;
|
|
||||||
bool update;
|
|
||||||
};
|
|
||||||
|
|
||||||
static int install_binpkg_repo_cb(prop_object_t, void *, bool *);
|
|
||||||
|
|
||||||
int
|
int
|
||||||
xbps_install_binary_pkg_fini(prop_dictionary_t repo, prop_dictionary_t pkgrd,
|
xbps_install_binary_pkg_fini(prop_dictionary_t repo, prop_dictionary_t pkgrd,
|
||||||
bool update)
|
bool update)
|
||||||
|
@ -96,69 +89,88 @@ xbps_install_binary_pkg_fini(prop_dictionary_t repo, prop_dictionary_t pkgrd,
|
||||||
int
|
int
|
||||||
xbps_install_binary_pkg(const char *pkgname, bool update)
|
xbps_install_binary_pkg(const char *pkgname, bool update)
|
||||||
{
|
{
|
||||||
struct binpkg_instargs bi;
|
prop_dictionary_t repod = NULL, repolistd, pkgrd = NULL;
|
||||||
int rv = 0;
|
prop_array_t array;
|
||||||
|
prop_object_t obj;
|
||||||
assert(pkgname != NULL);
|
prop_object_iterator_t repolist_iter;
|
||||||
|
|
||||||
bi.pkgname = pkgname;
|
|
||||||
bi.update = update;
|
|
||||||
/*
|
|
||||||
* Iterate over the repository pool and find out if we have
|
|
||||||
* all available binary packages.
|
|
||||||
*/
|
|
||||||
rv = xbps_callback_array_iter_in_repolist(install_binpkg_repo_cb,
|
|
||||||
(void *)&bi);
|
|
||||||
if (rv == 0 && errno != 0)
|
|
||||||
return errno;
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
install_binpkg_repo_cb(prop_object_t obj, void *arg, bool *cbloop_done)
|
|
||||||
{
|
|
||||||
prop_dictionary_t repod, pkgrd;
|
|
||||||
struct binpkg_instargs *bi = arg;
|
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
const char *repoloc, *instver;
|
const char *repoloc, *instver;
|
||||||
char *plist, *pkg;
|
char *plist, *pkg;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
plist = xbps_get_pkg_index_plist(prop_string_cstring_nocopy(obj));
|
assert(pkgname != NULL);
|
||||||
|
|
||||||
|
plist = xbps_append_full_path(true, NULL, XBPS_REPOLIST);
|
||||||
if (plist == NULL)
|
if (plist == NULL)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
repod = prop_dictionary_internalize_from_file(plist);
|
repolistd = prop_dictionary_internalize_from_file(plist);
|
||||||
if (repod == NULL) {
|
if (repolistd == NULL) {
|
||||||
free(plist);
|
free(plist);
|
||||||
return errno;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
free(plist);
|
free(plist);
|
||||||
|
plist = NULL;
|
||||||
|
|
||||||
|
array = prop_dictionary_get(repolistd, "repository-list");
|
||||||
|
if (array == NULL) {
|
||||||
|
prop_object_release(repolistd);
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
repolist_iter = prop_array_iterator(array);
|
||||||
|
if (repolist_iter == NULL) {
|
||||||
|
prop_object_release(repolistd);
|
||||||
|
return ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((obj = prop_object_iterator_next(repolist_iter)) != NULL) {
|
||||||
|
/*
|
||||||
|
* Iterate over the repository pool and find out if we have
|
||||||
|
* the binary package.
|
||||||
|
*/
|
||||||
|
plist =
|
||||||
|
xbps_get_pkg_index_plist(prop_string_cstring_nocopy(obj));
|
||||||
|
if (plist == NULL)
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
repod = prop_dictionary_internalize_from_file(plist);
|
||||||
|
if (repod == NULL) {
|
||||||
|
free(plist);
|
||||||
|
return errno;
|
||||||
|
}
|
||||||
|
free(plist);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the package dictionary from current repository.
|
||||||
|
* If it's not there, pass to the next repository.
|
||||||
|
*/
|
||||||
|
pkgrd = xbps_find_pkg_in_dict(repod, "packages", pkgname);
|
||||||
|
if (pkgrd == NULL) {
|
||||||
|
prop_object_release(repod);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
prop_object_iterator_reset(repolist_iter);
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the package dictionary from current repository.
|
|
||||||
* If it's not there, pass to the next repository.
|
|
||||||
*/
|
|
||||||
pkgrd = xbps_find_pkg_in_dict(repod, "packages", bi->pkgname);
|
|
||||||
if (pkgrd == NULL) {
|
if (pkgrd == NULL) {
|
||||||
prop_object_release(repod);
|
rv = EAGAIN;
|
||||||
errno = EAGAIN;
|
goto out2;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if available version in repository is already installed,
|
* Check if available version in repository is already
|
||||||
* and return immediately in that case.
|
* installed, and return immediately in that case.
|
||||||
*/
|
*/
|
||||||
prop_dictionary_get_cstring_nocopy(pkgrd, "version", &instver);
|
prop_dictionary_get_cstring_nocopy(pkgrd, "version", &instver);
|
||||||
len = strlen(bi->pkgname) + strlen(instver) + 2;
|
len = strlen(pkgname) + strlen(instver) + 2;
|
||||||
pkg = malloc(len);
|
pkg = malloc(len);
|
||||||
if (pkg == NULL) {
|
if (pkg == NULL) {
|
||||||
rv = EINVAL;
|
rv = errno;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
(void)snprintf(pkg, len, "%s-%s", bi->pkgname, instver);
|
(void)snprintf(pkg, len, "%s-%s", pkgname, instver);
|
||||||
if (xbps_check_is_installed_pkg(pkg) == 0) {
|
if (xbps_check_is_installed_pkg(pkg) == 0) {
|
||||||
free(pkg);
|
free(pkg);
|
||||||
rv = EEXIST;
|
rv = EEXIST;
|
||||||
|
@ -169,10 +181,10 @@ install_binpkg_repo_cb(prop_object_t obj, void *arg, bool *cbloop_done)
|
||||||
/*
|
/*
|
||||||
* Check SHA256 hash for binary package before anything else.
|
* Check SHA256 hash for binary package before anything else.
|
||||||
*/
|
*/
|
||||||
if (!prop_dictionary_get_cstring_nocopy(repod, "location-local",
|
if (!prop_dictionary_get_cstring_nocopy(repod,
|
||||||
&repoloc)) {
|
"location-local", &repoloc)) {
|
||||||
prop_object_release(repod);
|
rv = EINVAL;
|
||||||
return EINVAL;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rv = xbps_check_pkg_file_hash(pkgrd, repoloc)) != 0)
|
if ((rv = xbps_check_pkg_file_hash(pkgrd, repoloc)) != 0)
|
||||||
|
@ -181,41 +193,32 @@ install_binpkg_repo_cb(prop_object_t obj, void *arg, bool *cbloop_done)
|
||||||
/*
|
/*
|
||||||
* Check if this package needs dependencies.
|
* Check if this package needs dependencies.
|
||||||
*/
|
*/
|
||||||
if (!xbps_pkg_has_rundeps(pkgrd)) {
|
if (xbps_pkg_has_rundeps(pkgrd)) {
|
||||||
/* pkg has no deps, just install it. */
|
/*
|
||||||
goto install;
|
* Construct the dependency chain for this package.
|
||||||
|
*/
|
||||||
|
printf("Finding required dependencies...\n");
|
||||||
|
if ((rv = xbps_find_deps_in_pkg(pkgrd, repolist_iter)) != 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Install all required dependencies and the package itself.
|
||||||
|
*/
|
||||||
|
rv = xbps_install_pkg_deps(pkgname, update);
|
||||||
|
if (rv != 0)
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Construct the dependency chain for this package.
|
* Finally install the binary package that was requested by
|
||||||
|
* the client.
|
||||||
*/
|
*/
|
||||||
printf("Finding required dependencies...\n");
|
rv = xbps_install_binary_pkg_fini(repod, pkgrd, update);
|
||||||
if ((rv = xbps_find_deps_in_pkg(pkgrd)) != 0) {
|
|
||||||
prop_object_release(repod);
|
|
||||||
if (rv == ENOENT) {
|
|
||||||
errno = ENOENT;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Install all required dependencies and the package itself.
|
|
||||||
*/
|
|
||||||
rv = xbps_install_pkg_deps(bi->pkgname, bi->update);
|
|
||||||
if (rv != 0)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
install:
|
|
||||||
rv = xbps_install_binary_pkg_fini(repod, pkgrd, bi->update);
|
|
||||||
if (rv == 0) {
|
|
||||||
*cbloop_done = true;
|
|
||||||
/* Cleanup errno, just in case */
|
|
||||||
errno = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
prop_object_release(repod);
|
prop_object_release(repod);
|
||||||
|
out2:
|
||||||
|
prop_object_iterator_release(repolist_iter);
|
||||||
|
prop_object_release(repolistd);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,7 +238,8 @@ xbps_get_array_iter_from_dict(prop_dictionary_t dict, const char *key)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
xbps_remove_pkg_from_dict(prop_dictionary_t dict, const char *pkgname)
|
xbps_remove_pkg_from_dict(prop_dictionary_t dict, const char *key,
|
||||||
|
const char *pkgname)
|
||||||
{
|
{
|
||||||
prop_array_t array;
|
prop_array_t array;
|
||||||
prop_object_t obj;
|
prop_object_t obj;
|
||||||
|
@ -251,7 +252,7 @@ xbps_remove_pkg_from_dict(prop_dictionary_t dict, const char *pkgname)
|
||||||
assert(key != NULL);
|
assert(key != NULL);
|
||||||
assert(pkgname != NULL);
|
assert(pkgname != NULL);
|
||||||
|
|
||||||
array = prop_dictionary_get(dict, "packages");
|
array = prop_dictionary_get(dict, key);
|
||||||
if (array == NULL || prop_object_type(array) != PROP_TYPE_ARRAY)
|
if (array == NULL || prop_object_type(array) != PROP_TYPE_ARRAY)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -272,6 +273,8 @@ xbps_remove_pkg_from_dict(prop_dictionary_t dict, const char *pkgname)
|
||||||
prop_object_iterator_release(iter);
|
prop_object_iterator_release(iter);
|
||||||
if (found == true)
|
if (found == true)
|
||||||
prop_array_remove(array, i);
|
prop_array_remove(array, i);
|
||||||
|
else
|
||||||
|
errno = ENOENT;
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
@ -288,7 +291,7 @@ xbps_remove_pkg_dict_from_file(const char *pkg, const char *plist)
|
||||||
if (pdict == NULL)
|
if (pdict == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!xbps_remove_pkg_from_dict(pdict, pkg)) {
|
if (!xbps_remove_pkg_from_dict(pdict, "packages", pkg)) {
|
||||||
prop_object_release(pdict);
|
prop_object_release(pdict);
|
||||||
errno = ENODEV;
|
errno = ENODEV;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -103,7 +103,7 @@ again:
|
||||||
if (find_sorteddep_by_name(pkgname) != NULL)
|
if (find_sorteddep_by_name(pkgname) != NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
sdep = calloc(1, sizeof(*sdep));
|
sdep = malloc(sizeof(*sdep));
|
||||||
if (sdep == NULL) {
|
if (sdep == NULL) {
|
||||||
rv = ENOMEM;
|
rv = ENOMEM;
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
@ -212,8 +212,7 @@ unpack_archive_fini(struct archive *ar, prop_dictionary_t pkg)
|
||||||
if (archive_read_extract(ar, entry, lflags) != 0) {
|
if (archive_read_extract(ar, entry, lflags) != 0) {
|
||||||
rv = archive_errno(ar);
|
rv = archive_errno(ar);
|
||||||
if (rv != EEXIST) {
|
if (rv != EEXIST) {
|
||||||
printf("ERROR: couldn't unpack %s (%s), "
|
printf("ERROR: %s...exiting!\n",
|
||||||
"exiting!\n", archive_entry_pathname(entry),
|
|
||||||
archive_error_string(ar));
|
archive_error_string(ar));
|
||||||
(void)fflush(stdout);
|
(void)fflush(stdout);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue