2009-08-17 22:37:20 +05:30
|
|
|
/*-
|
2012-01-22 14:30:46 +05:30
|
|
|
* Copyright (c) 2009-2012 Juan Romero Pardines.
|
2009-08-17 22:37:20 +05:30
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2010-11-13 07:48:58 +05:30
|
|
|
#include "xbps_api_impl.h"
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2011-01-17 21:47:02 +05:30
|
|
|
/*
|
|
|
|
* Sorting algorithm for packages in the transaction dictionary.
|
|
|
|
* The transaction dictionary contains all package dictionaries found from
|
|
|
|
* the repository plist index file in the "unsorted_deps" array.
|
|
|
|
*
|
2011-01-29 00:17:05 +05:30
|
|
|
* Any package in the unsorted_deps array is added into the tail and
|
|
|
|
* later if a package dependency has an index greater than current
|
|
|
|
* package, the package dependency is moved just before it.
|
2011-01-17 21:47:02 +05:30
|
|
|
*
|
2011-01-29 00:17:05 +05:30
|
|
|
* Once that all package dependencies for a package are in the correct
|
|
|
|
* index, the counter is increased. When all packages in the "unsorted_deps"
|
|
|
|
* array are processed the loop is stopped and the counter should have
|
|
|
|
* the same number than the "unsorted_deps" array... otherwise something
|
|
|
|
* went wrong.
|
2011-01-17 21:47:02 +05:30
|
|
|
*/
|
2011-01-29 00:17:05 +05:30
|
|
|
|
|
|
|
struct pkgdep {
|
|
|
|
TAILQ_ENTRY(pkgdep) pkgdep_entries;
|
|
|
|
prop_dictionary_t d;
|
|
|
|
char *name;
|
2011-02-18 21:09:42 +05:30
|
|
|
const char *trans;
|
2011-01-29 00:17:05 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
static TAILQ_HEAD(pkgdep_head, pkgdep) pkgdep_list =
|
|
|
|
TAILQ_HEAD_INITIALIZER(pkgdep_list);
|
|
|
|
|
|
|
|
static struct pkgdep *
|
2011-02-18 21:09:42 +05:30
|
|
|
pkgdep_find(const char *name, const char *trans)
|
2011-01-29 00:17:05 +05:30
|
|
|
{
|
2011-01-30 19:12:17 +05:30
|
|
|
struct pkgdep *pd = NULL, *pd_new = NULL;
|
2011-01-29 00:17:05 +05:30
|
|
|
|
2011-01-30 19:12:17 +05:30
|
|
|
TAILQ_FOREACH_SAFE(pd, &pkgdep_list, pkgdep_entries, pd_new) {
|
2011-02-18 21:09:42 +05:30
|
|
|
if (strcmp(pd->name, name) == 0) {
|
|
|
|
if (trans == NULL)
|
|
|
|
return pd;
|
|
|
|
if (strcmp(pd->trans, trans) == 0)
|
|
|
|
return pd;
|
|
|
|
}
|
2011-01-29 01:26:28 +05:30
|
|
|
if (pd->d == NULL)
|
|
|
|
continue;
|
2011-10-15 23:30:41 +05:30
|
|
|
if (xbps_match_virtual_pkg_in_dict(pd->d, name, false)) {
|
2011-10-16 15:52:46 +05:30
|
|
|
if (trans && pd->trans &&
|
|
|
|
(strcmp(trans, pd->trans) == 0))
|
2011-10-15 23:30:41 +05:30
|
|
|
return pd;
|
|
|
|
}
|
2011-01-29 01:26:28 +05:30
|
|
|
}
|
2011-01-29 00:17:05 +05:30
|
|
|
|
|
|
|
/* not found */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
2011-02-18 21:09:42 +05:30
|
|
|
pkgdep_find_idx(const char *name, const char *trans)
|
2011-01-29 00:17:05 +05:30
|
|
|
{
|
2011-01-30 19:12:17 +05:30
|
|
|
struct pkgdep *pd, *pd_new;
|
2011-01-29 00:17:05 +05:30
|
|
|
ssize_t idx = 0;
|
|
|
|
|
2011-01-30 19:12:17 +05:30
|
|
|
TAILQ_FOREACH_SAFE(pd, &pkgdep_list, pkgdep_entries, pd_new) {
|
2011-02-18 21:09:42 +05:30
|
|
|
if (strcmp(pd->name, name) == 0) {
|
|
|
|
if (trans == NULL)
|
|
|
|
return idx;
|
|
|
|
if (strcmp(pd->trans, trans) == 0)
|
|
|
|
return idx;
|
|
|
|
}
|
2011-01-29 01:26:28 +05:30
|
|
|
if (pd->d == NULL)
|
|
|
|
continue;
|
2011-10-15 23:30:41 +05:30
|
|
|
if (xbps_match_virtual_pkg_in_dict(pd->d, name, false)) {
|
2011-10-16 15:52:46 +05:30
|
|
|
if (trans && pd->trans &&
|
|
|
|
(strcmp(trans, pd->trans) == 0))
|
2011-10-15 23:30:41 +05:30
|
|
|
return idx;
|
|
|
|
}
|
2011-01-29 00:17:05 +05:30
|
|
|
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
/* not found */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pkgdep_release(struct pkgdep *pd)
|
|
|
|
{
|
|
|
|
if (pd->d != NULL)
|
|
|
|
prop_object_release(pd->d);
|
|
|
|
|
|
|
|
free(pd->name);
|
|
|
|
free(pd);
|
|
|
|
pd = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct pkgdep *
|
2011-02-18 21:09:42 +05:30
|
|
|
pkgdep_alloc(prop_dictionary_t d, const char *name, const char *trans)
|
2011-01-29 00:17:05 +05:30
|
|
|
{
|
|
|
|
struct pkgdep *pd;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
if ((pd = malloc(sizeof(*pd))) == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
len = strlen(name) + 1;
|
|
|
|
if ((pd->name = malloc(len)) == NULL) {
|
|
|
|
free(pd);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (d != NULL)
|
|
|
|
pd->d = prop_dictionary_copy(d);
|
|
|
|
else
|
|
|
|
pd->d = NULL;
|
|
|
|
|
|
|
|
(void)strlcpy(pd->name, name, len);
|
2011-02-18 21:09:42 +05:30
|
|
|
pd->trans = trans;
|
2011-01-29 00:17:05 +05:30
|
|
|
|
|
|
|
return pd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-15 19:03:11 +05:30
|
|
|
pkgdep_end(struct xbps_handle *xhp, prop_array_t sorted)
|
2011-01-29 00:17:05 +05:30
|
|
|
{
|
2012-06-14 15:23:27 +05:30
|
|
|
prop_dictionary_t d;
|
2011-01-29 00:17:05 +05:30
|
|
|
struct pkgdep *pd;
|
2012-06-14 15:23:27 +05:30
|
|
|
const char *trans;
|
2011-01-29 00:17:05 +05:30
|
|
|
|
|
|
|
while ((pd = TAILQ_FIRST(&pkgdep_list)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&pkgdep_list, pd, pkgdep_entries);
|
2012-06-14 15:23:27 +05:30
|
|
|
if (sorted != NULL && pd->d != NULL) {
|
|
|
|
/* do not add duplicates due to vpkgs */
|
2012-06-15 19:03:11 +05:30
|
|
|
d = xbps_find_pkg_in_array_by_name(xhp, sorted,
|
2012-06-14 15:23:27 +05:30
|
|
|
pd->name, NULL);
|
|
|
|
if (d == NULL) {
|
2012-06-14 15:42:05 +05:30
|
|
|
/* find a virtual pkg otherwise */
|
|
|
|
d = xbps_find_virtualpkg_in_array_by_name(
|
2012-06-15 19:03:11 +05:30
|
|
|
xhp, sorted, pd->name);
|
2012-06-14 15:42:05 +05:30
|
|
|
if (d == NULL) {
|
|
|
|
prop_array_add(sorted, pd->d);
|
|
|
|
pkgdep_release(pd);
|
|
|
|
continue;
|
|
|
|
}
|
2012-06-14 15:23:27 +05:30
|
|
|
}
|
|
|
|
prop_dictionary_get_cstring_nocopy(d,
|
|
|
|
"transaction", &trans);
|
|
|
|
if (strcmp(trans, pd->trans) == 0) {
|
|
|
|
pkgdep_release(pd);
|
|
|
|
continue;
|
|
|
|
}
|
2011-06-26 02:23:16 +05:30
|
|
|
prop_array_add(sorted, pd->d);
|
2012-06-14 15:23:27 +05:30
|
|
|
}
|
2011-01-29 00:17:05 +05:30
|
|
|
pkgdep_release(pd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-14 11:52:11 +05:30
|
|
|
sort_pkg_rundeps(struct xbps_handle *xhp,
|
2011-01-29 00:17:05 +05:30
|
|
|
struct pkgdep *pd,
|
|
|
|
prop_array_t pkg_rundeps)
|
|
|
|
{
|
|
|
|
prop_dictionary_t curpkgd;
|
|
|
|
struct pkgdep *lpd, *pdn;
|
2011-02-18 21:09:42 +05:30
|
|
|
const char *str, *tract;
|
2011-01-29 00:17:05 +05:30
|
|
|
char *pkgnamedep;
|
2011-02-18 21:09:42 +05:30
|
|
|
ssize_t pkgdepidx, curpkgidx;
|
2011-01-29 00:17:05 +05:30
|
|
|
size_t i, idx = 0;
|
|
|
|
int rv = 0;
|
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf_append(xhp, "\n");
|
2011-02-18 21:09:42 +05:30
|
|
|
curpkgidx = pkgdep_find_idx(pd->name, pd->trans);
|
2011-01-29 00:17:05 +05:30
|
|
|
|
|
|
|
again:
|
|
|
|
for (i = idx; i < prop_array_count(pkg_rundeps); i++) {
|
2012-06-13 12:53:48 +05:30
|
|
|
prop_array_get_cstring_nocopy(pkg_rundeps, i, &str);
|
2011-06-01 13:07:32 +05:30
|
|
|
pkgnamedep = xbps_pkgpattern_name(str);
|
2011-01-29 00:17:05 +05:30
|
|
|
if (pkgnamedep == NULL) {
|
|
|
|
rv = ENOMEM;
|
|
|
|
break;
|
|
|
|
}
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf(xhp, " Required dependency '%s': ", str);
|
2011-02-18 21:09:42 +05:30
|
|
|
pdn = pkgdep_find(pkgnamedep, NULL);
|
2011-01-29 00:17:05 +05:30
|
|
|
if ((pdn == NULL) &&
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_check_is_installed_pkg_by_name(xhp, pkgnamedep)) {
|
2011-01-29 00:17:05 +05:30
|
|
|
/*
|
|
|
|
* Package dependency is installed, just add to
|
|
|
|
* the list but just mark it as "installed", to avoid
|
|
|
|
* calling xbps_check_is_installed_pkg_by_name(),
|
|
|
|
* which is expensive.
|
|
|
|
*/
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf_append(xhp, "installed.\n");
|
2011-02-18 21:09:42 +05:30
|
|
|
lpd = pkgdep_alloc(NULL, pkgnamedep, "installed");
|
2011-01-29 00:17:05 +05:30
|
|
|
if (lpd == NULL) {
|
|
|
|
rv = ENOMEM;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
free(pkgnamedep);
|
|
|
|
TAILQ_INSERT_TAIL(&pkgdep_list, lpd, pkgdep_entries);
|
|
|
|
continue;
|
|
|
|
} else if (pdn != NULL && pdn->d == NULL) {
|
|
|
|
/*
|
|
|
|
* Package was added previously into the list
|
|
|
|
* and is installed, skip.
|
|
|
|
*/
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf_append(xhp, "installed.\n");
|
2011-01-29 00:17:05 +05:30
|
|
|
free(pkgnamedep);
|
|
|
|
continue;
|
|
|
|
}
|
2011-10-16 15:52:46 +05:30
|
|
|
/* Find pkg by name */
|
2012-06-15 19:03:11 +05:30
|
|
|
curpkgd = xbps_find_pkg_in_dict_by_name(xhp, xhp->transd,
|
2011-01-29 00:17:05 +05:30
|
|
|
"unsorted_deps", pkgnamedep);
|
2011-07-15 21:52:58 +05:30
|
|
|
if (curpkgd == NULL) {
|
2011-10-16 15:52:46 +05:30
|
|
|
/* find virtualpkg by name if no match */
|
|
|
|
curpkgd =
|
2012-06-15 19:03:11 +05:30
|
|
|
xbps_find_virtualpkg_in_dict_by_name(xhp,
|
|
|
|
xhp->transd, "unsorted_deps", pkgnamedep);
|
2011-07-15 21:52:58 +05:30
|
|
|
}
|
2011-02-04 20:47:47 +05:30
|
|
|
if (curpkgd == NULL) {
|
|
|
|
free(pkgnamedep);
|
|
|
|
rv = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
2011-02-18 21:09:42 +05:30
|
|
|
prop_dictionary_get_cstring_nocopy(curpkgd,
|
|
|
|
"transaction", &tract);
|
|
|
|
lpd = pkgdep_alloc(curpkgd, pkgnamedep, tract);
|
2011-01-29 00:17:05 +05:30
|
|
|
if (lpd == NULL) {
|
|
|
|
free(pkgnamedep);
|
|
|
|
rv = ENOMEM;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (pdn == NULL) {
|
|
|
|
/*
|
|
|
|
* If package is not in the list, add to the tail
|
|
|
|
* and iterate at the same position.
|
|
|
|
*/
|
|
|
|
TAILQ_INSERT_TAIL(&pkgdep_list, lpd, pkgdep_entries);
|
|
|
|
idx = i;
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf_append(xhp, "added into the tail, "
|
2011-01-29 00:17:05 +05:30
|
|
|
"checking again...\n");
|
|
|
|
free(pkgnamedep);
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Find package dependency index.
|
|
|
|
*/
|
2011-02-18 21:09:42 +05:30
|
|
|
pkgdepidx = pkgdep_find_idx(pkgnamedep, tract);
|
2011-01-29 00:17:05 +05:30
|
|
|
/*
|
|
|
|
* If package dependency index is less than current
|
|
|
|
* package index, it's already sorted.
|
|
|
|
*/
|
|
|
|
free(pkgnamedep);
|
|
|
|
if (pkgdepidx < curpkgidx) {
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf_append(xhp, "already sorted.\n");
|
2011-01-29 00:17:05 +05:30
|
|
|
pkgdep_release(lpd);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Remove package dependency from list and move
|
|
|
|
* it before current package.
|
|
|
|
*/
|
|
|
|
TAILQ_REMOVE(&pkgdep_list, pdn, pkgdep_entries);
|
|
|
|
pkgdep_release(pdn);
|
|
|
|
TAILQ_INSERT_BEFORE(pd, lpd, pkgdep_entries);
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf_append(xhp,
|
|
|
|
"added before `%s'.\n", pd->name);
|
2011-01-29 00:17:05 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2010-01-21 07:40:19 +05:30
|
|
|
int HIDDEN
|
2012-01-22 14:30:46 +05:30
|
|
|
xbps_transaction_sort_pkg_deps(struct xbps_handle *xhp)
|
2009-08-17 22:37:20 +05:30
|
|
|
{
|
2011-01-24 21:25:58 +05:30
|
|
|
prop_array_t sorted, unsorted, rundeps;
|
2011-01-29 00:17:05 +05:30
|
|
|
prop_object_t obj;
|
|
|
|
struct pkgdep *pd;
|
2012-06-14 11:52:11 +05:30
|
|
|
size_t i, ndeps = 0, cnt = 0;
|
2011-02-18 21:09:42 +05:30
|
|
|
const char *pkgname, *pkgver, *tract;
|
2009-08-17 22:37:20 +05:30
|
|
|
int rv = 0;
|
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
if ((sorted = prop_array_create()) == NULL)
|
2009-08-17 22:37:20 +05:30
|
|
|
return ENOMEM;
|
2011-01-17 21:47:02 +05:30
|
|
|
/*
|
|
|
|
* Add sorted packages array into transaction dictionary (empty).
|
|
|
|
*/
|
2012-01-22 14:30:46 +05:30
|
|
|
if (!prop_dictionary_set(xhp->transd, "packages", sorted)) {
|
2011-01-17 21:47:02 +05:30
|
|
|
rv = EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
2009-08-17 22:37:20 +05:30
|
|
|
/*
|
|
|
|
* All required deps are satisfied (already installed).
|
|
|
|
*/
|
2012-01-22 14:30:46 +05:30
|
|
|
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
|
2009-08-17 22:37:20 +05:30
|
|
|
if (prop_array_count(unsorted) == 0) {
|
2012-01-22 14:30:46 +05:30
|
|
|
prop_dictionary_set(xhp->transd, "packages", sorted);
|
2009-08-17 22:37:20 +05:30
|
|
|
return 0;
|
|
|
|
}
|
2011-01-25 19:26:37 +05:30
|
|
|
/*
|
|
|
|
* The sorted array should have the same capacity than
|
|
|
|
* all objects in the unsorted array.
|
|
|
|
*/
|
2009-08-17 22:37:20 +05:30
|
|
|
ndeps = prop_array_count(unsorted);
|
|
|
|
/*
|
2011-01-29 00:17:05 +05:30
|
|
|
* Iterate over the unsorted package dictionaries and sort all
|
|
|
|
* its package dependencies.
|
2009-08-17 22:37:20 +05:30
|
|
|
*/
|
2012-06-14 11:52:11 +05:30
|
|
|
for (i = 0; i < ndeps; i++) {
|
|
|
|
obj = prop_array_get(unsorted, i);
|
2010-11-06 11:14:00 +05:30
|
|
|
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
|
|
|
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
2011-02-18 21:09:42 +05:30
|
|
|
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf(xhp, "Sorting package '%s' (%s): ", pkgver, tract);
|
2011-01-29 00:17:05 +05:30
|
|
|
|
2011-02-18 21:09:42 +05:30
|
|
|
pd = pkgdep_find(pkgname, tract);
|
2011-01-29 00:17:05 +05:30
|
|
|
if (pd == NULL) {
|
|
|
|
/*
|
|
|
|
* If package not in list, just add to the tail.
|
|
|
|
*/
|
2011-02-18 21:09:42 +05:30
|
|
|
pd = pkgdep_alloc(obj, pkgname, tract);
|
2011-01-29 00:17:05 +05:30
|
|
|
if (pd == NULL) {
|
2012-06-15 19:03:11 +05:30
|
|
|
pkgdep_end(xhp, NULL);
|
2011-01-29 00:17:05 +05:30
|
|
|
rv = ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
2011-10-20 16:40:39 +05:30
|
|
|
if (strcmp(pd->trans, "remove") == 0) {
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf_append(xhp, "added into head.");
|
2011-10-20 16:40:39 +05:30
|
|
|
TAILQ_INSERT_HEAD(&pkgdep_list, pd,
|
|
|
|
pkgdep_entries);
|
|
|
|
} else {
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf_append(xhp, "added into tail.");
|
2011-10-20 16:40:39 +05:30
|
|
|
TAILQ_INSERT_TAIL(&pkgdep_list, pd,
|
|
|
|
pkgdep_entries);
|
|
|
|
}
|
2009-11-29 10:23:27 +05:30
|
|
|
}
|
2009-08-17 22:37:20 +05:30
|
|
|
/*
|
2011-10-20 16:40:39 +05:30
|
|
|
* Packages that don't have deps go at head, because
|
2009-08-17 22:37:20 +05:30
|
|
|
* it doesn't matter.
|
|
|
|
*/
|
|
|
|
rundeps = prop_dictionary_get(obj, "run_depends");
|
|
|
|
if (rundeps == NULL || prop_array_count(rundeps) == 0) {
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf_append(xhp, "\n");
|
2009-08-17 22:37:20 +05:30
|
|
|
cnt++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/*
|
2011-01-29 00:17:05 +05:30
|
|
|
* Sort package run-time dependencies for this package.
|
2009-08-17 22:37:20 +05:30
|
|
|
*/
|
2012-06-14 11:52:11 +05:30
|
|
|
if ((rv = sort_pkg_rundeps(xhp, pd, rundeps)) != 0) {
|
2012-06-15 19:03:11 +05:30
|
|
|
pkgdep_end(xhp, NULL);
|
2011-01-29 00:17:05 +05:30
|
|
|
goto out;
|
2009-08-17 22:37:20 +05:30
|
|
|
}
|
2011-01-29 00:17:05 +05:30
|
|
|
cnt++;
|
2009-08-17 22:37:20 +05:30
|
|
|
}
|
2011-01-29 00:17:05 +05:30
|
|
|
/*
|
|
|
|
* We are done, now we have to copy all pkg dictionaries
|
|
|
|
* from the sorted list into the "packages" array, and at
|
|
|
|
* the same time freeing memory used for temporary sorting.
|
|
|
|
*/
|
2012-06-15 19:03:11 +05:30
|
|
|
pkgdep_end(xhp, sorted);
|
2009-08-17 22:37:20 +05:30
|
|
|
/*
|
|
|
|
* Sanity check that the array contains the same number of
|
|
|
|
* objects than the total number of required dependencies.
|
|
|
|
*/
|
2011-01-29 00:17:05 +05:30
|
|
|
assert(cnt == prop_array_count(unsorted));
|
2009-08-17 22:37:20 +05:30
|
|
|
/*
|
2011-01-17 21:47:02 +05:30
|
|
|
* We are done, all packages were sorted... remove the
|
|
|
|
* temporary array with unsorted packages.
|
2009-08-17 22:37:20 +05:30
|
|
|
*/
|
2012-01-22 14:30:46 +05:30
|
|
|
prop_dictionary_remove(xhp->transd, "unsorted_deps");
|
2011-01-17 21:47:02 +05:30
|
|
|
out:
|
2011-01-18 19:14:39 +05:30
|
|
|
if (rv != 0)
|
2012-01-22 14:30:46 +05:30
|
|
|
prop_dictionary_remove(xhp->transd, "packages");
|
2011-01-18 19:14:39 +05:30
|
|
|
|
|
|
|
prop_object_release(sorted);
|
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
return rv;
|
|
|
|
}
|