Install packages in order from highest to lowest priority.
--HG-- extra : convert_revision : 33be12f1d249bfd8f76d4f1cb8374dfc3f71df21
This commit is contained in:
parent
456c6a2763
commit
86cdb7dae6
1 changed files with 27 additions and 4 deletions
|
@ -35,6 +35,7 @@
|
||||||
struct pkg_dependency {
|
struct pkg_dependency {
|
||||||
SIMPLEQ_ENTRY(pkg_dependency) deps;
|
SIMPLEQ_ENTRY(pkg_dependency) deps;
|
||||||
prop_dictionary_t repo;
|
prop_dictionary_t repo;
|
||||||
|
uint64_t priority;
|
||||||
const char *namever;
|
const char *namever;
|
||||||
char *name;
|
char *name;
|
||||||
};
|
};
|
||||||
|
@ -104,14 +105,15 @@ xbps_clean_pkg_depslist(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xbps_add_pkg_dependency(const char *pkg, prop_dictionary_t repo)
|
xbps_add_pkg_dependency(const char *pkg, uint64_t prio, prop_dictionary_t repo)
|
||||||
{
|
{
|
||||||
struct pkg_dependency *dep;
|
struct pkg_dependency *dep, *dep_prev;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
char *pkgname;
|
char *pkgname;
|
||||||
|
|
||||||
assert(repo != NULL);
|
assert(repo != NULL);
|
||||||
assert(pkg != NULL);
|
assert(pkg != NULL);
|
||||||
|
assert(pkgd != NULL);
|
||||||
|
|
||||||
pkgname = xbps_get_pkg_name(pkg);
|
pkgname = xbps_get_pkg_name(pkg);
|
||||||
|
|
||||||
|
@ -136,7 +138,20 @@ xbps_add_pkg_dependency(const char *pkg, prop_dictionary_t repo)
|
||||||
dep->repo = prop_dictionary_copy(repo);
|
dep->repo = prop_dictionary_copy(repo);
|
||||||
dep->namever = pkg;
|
dep->namever = pkg;
|
||||||
|
|
||||||
SIMPLEQ_INSERT_TAIL(&pkg_deps_queue, dep, deps);
|
if (SIMPLEQ_EMPTY(&pkg_deps_queue)) {
|
||||||
|
SIMPLEQ_INSERT_HEAD(&pkg_deps_queue, dep, deps);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If package has a higher priority, it must be installed
|
||||||
|
* before other ones with lower priority.
|
||||||
|
*/
|
||||||
|
dep_prev = SIMPLEQ_FIRST(&pkg_deps_queue);
|
||||||
|
if (prio > dep_prev->priority)
|
||||||
|
SIMPLEQ_INSERT_TAIL(&pkg_deps_queue, dep, deps);
|
||||||
|
else
|
||||||
|
SIMPLEQ_INSERT_HEAD(&pkg_deps_queue, dep, deps);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -144,8 +159,10 @@ find_deps_in_pkg(prop_dictionary_t repo, prop_dictionary_t pkg)
|
||||||
{
|
{
|
||||||
prop_dictionary_t pkgdict;
|
prop_dictionary_t pkgdict;
|
||||||
prop_array_t array;
|
prop_array_t array;
|
||||||
|
prop_number_t prio_num;
|
||||||
prop_object_t obj;
|
prop_object_t obj;
|
||||||
prop_object_iterator_t iter = NULL;
|
prop_object_iterator_t iter = NULL;
|
||||||
|
uint64_t prio;
|
||||||
const char *reqpkg;
|
const char *reqpkg;
|
||||||
char *pkgname;
|
char *pkgname;
|
||||||
|
|
||||||
|
@ -177,7 +194,13 @@ find_deps_in_pkg(prop_dictionary_t repo, prop_dictionary_t pkg)
|
||||||
/*
|
/*
|
||||||
* Package is on repo, add it into the list.
|
* Package is on repo, add it into the list.
|
||||||
*/
|
*/
|
||||||
xbps_add_pkg_dependency(reqpkg, repo);
|
prio_num = prop_dictionary_get(pkgdict, "priority");
|
||||||
|
if (prio_num == NULL)
|
||||||
|
prio = 0;
|
||||||
|
else
|
||||||
|
prio = prop_number_unsigned_integer_value(prio_num);
|
||||||
|
|
||||||
|
xbps_add_pkg_dependency(reqpkg, prio, repo);
|
||||||
free(pkgname);
|
free(pkgname);
|
||||||
|
|
||||||
/* Iterate on required pkg to find more deps */
|
/* Iterate on required pkg to find more deps */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue