eeaa5ffe569be420154ef2222a624d8f6d402d8c
[project/opkg-lede.git] / libopkg / pkg_depends.h
1 /* pkg_depends.h - the opkg package management system
2
3 Steven M. Ayer
4
5 Copyright (C) 2002 Compaq Computer Corporation
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2, or (at
10 your option) any later version.
11
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
16 */
17
18 #ifndef PKG_DEPENDS_H
19 #define PKG_DEPENDS_H
20
21 #include "pkg.h"
22 #include "pkg_hash.h"
23
24 enum depend_type {
25 UNSPEC,
26 PREDEPEND,
27 DEPEND,
28 CONFLICTS,
29 GREEDY_DEPEND,
30 RECOMMEND,
31 SUGGEST
32 };
33 typedef enum depend_type depend_type_t;
34
35 enum version_constraint {
36 NONE,
37 EARLIER,
38 EARLIER_EQUAL,
39 EQUAL,
40 LATER_EQUAL,
41 LATER
42 };
43 typedef enum version_constraint version_constraint_t;
44
45 struct depend {
46 version_constraint_t constraint;
47 char *version;
48 abstract_pkg_t *pkg;
49 };
50 typedef struct depend depend_t;
51
52 struct compound_depend {
53 depend_type_t type;
54 int possibility_count;
55 struct depend **possibilities;
56 };
57 typedef struct compound_depend compound_depend_t;
58
59 void buildProvides(abstract_pkg_t * ab_pkg, pkg_t * pkg);
60 void buildConflicts(pkg_t * pkg);
61 void buildReplaces(abstract_pkg_t * ab_pkg, pkg_t * pkg);
62 void buildDepends(pkg_t * pkg);
63
64 void parse_deplist(pkg_t *pkg, enum depend_type type, char *list);
65
66 abstract_pkg_t **init_providelist(pkg_t *pkg, int *count);
67 void parse_providelist(pkg_t *pkg, char *list);
68
69 /**
70 * pkg_replaces returns 1 if pkg->replaces contains one of replacee's provides and 0
71 * otherwise.
72 */
73 int pkg_replaces(pkg_t * pkg, pkg_t * replacee);
74
75 /**
76 * pkg_conflicts_abstract returns 1 if pkg->conflicts contains conflictee provides and 0
77 * otherwise.
78 */
79 int pkg_conflicts_abstract(pkg_t * pkg, abstract_pkg_t * conflicts);
80
81 /**
82 * pkg_conflicts returns 1 if pkg->conflicts contains one of conflictee's provides and 0
83 * otherwise.
84 */
85 int pkg_conflicts(pkg_t * pkg, pkg_t * conflicts);
86
87 char *pkg_depend_str(pkg_t * pkg, int index);
88 void buildDependedUponBy(pkg_t * pkg, abstract_pkg_t * ab_pkg);
89 int version_constraints_satisfied(depend_t * depends, pkg_t * pkg);
90 int pkg_hash_fetch_unsatisfied_dependencies(pkg_t * pkg, pkg_vec_t * depends,
91 char ***unresolved);
92 pkg_vec_t *pkg_hash_fetch_conflicts(pkg_t * pkg);
93 int pkg_dependence_satisfiable(depend_t * depend);
94 int pkg_dependence_satisfied(depend_t * depend);
95 const char *constraint_to_str(enum version_constraint c);
96
97 compound_depend_t *pkg_get_depends(pkg_t *pkg, enum depend_type type);
98
99 #endif