opkg: re-arrange source code into sub-directories
[oweals/opkg-lede.git] / libopkg / pkg_depends.h
1 /* pkg_depends.h - the itsy 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     PREDEPEND,
26     DEPEND,
27     CONFLICTS,
28     GREEDY_DEPEND,
29     RECOMMEND,
30     SUGGEST
31 };
32 typedef enum depend_type depend_type_t;
33
34 enum version_constraint {
35     NONE,
36     EARLIER,
37     EARLIER_EQUAL,
38     EQUAL,
39     LATER_EQUAL,
40     LATER
41 };
42 typedef enum version_constraint version_constraint_t;
43
44 struct depend{
45     version_constraint_t constraint;
46     char * version;
47     abstract_pkg_t * pkg;
48 };
49 typedef struct depend depend_t;
50     
51 struct compound_depend{
52     depend_type_t type;
53     int possibility_count;
54     struct depend ** possibilities;
55 };
56 typedef struct compound_depend compound_depend_t;
57
58 #include "hash_table.h"
59
60 int buildProvides(hash_table_t * hash, abstract_pkg_t * ab_pkg, pkg_t * pkg);
61 int buildConflicts(hash_table_t * hash, abstract_pkg_t * ab_pkg, pkg_t * pkg);
62 int buildReplaces(hash_table_t * hash, abstract_pkg_t * ab_pkg, pkg_t * pkg);
63 int buildDepends(hash_table_t * hash, pkg_t * pkg);
64
65 /**
66  * pkg_has_common_provides returns 1 if pkg and replacee both provide
67  * the same abstract package and 0 otherwise.
68  */
69 int pkg_has_common_provides(pkg_t *pkg, pkg_t *replacee);
70
71 /**
72  * pkg_provides returns 1 if pkg->provides contains providee and 0
73  * otherwise.
74  */
75 int pkg_provides_abstract(pkg_t *pkg, abstract_pkg_t *providee);
76
77 /**
78  * pkg_replaces returns 1 if pkg->replaces contains one of replacee's provides and 0
79  * otherwise.
80  */
81 int pkg_replaces(pkg_t *pkg, pkg_t *replacee);
82
83 /**
84  * pkg_conflicts_abstract returns 1 if pkg->conflicts contains conflictee provides and 0
85  * otherwise.
86  */
87 int pkg_conflicts_abstract(pkg_t *pkg, abstract_pkg_t *conflicts);
88
89 /**
90  * pkg_conflicts returns 1 if pkg->conflicts contains one of conflictee's provides and 0
91  * otherwise.
92  */
93 int pkg_conflicts(pkg_t *pkg, pkg_t *conflicts);
94
95 char *pkg_depend_str(pkg_t *pkg, int index);
96 void buildDependedUponBy(pkg_t * pkg, abstract_pkg_t * ab_pkg);
97 void freeDepends(pkg_t *pkg);
98 void printDepends(pkg_t * pkg);
99 int version_constraints_satisfied(depend_t * depends, pkg_t * pkg);
100 int pkg_hash_fetch_unsatisfied_dependencies(opkg_conf_t *conf, pkg_t * pkg, pkg_vec_t *depends, char *** unresolved);
101 pkg_vec_t * pkg_hash_fetch_conflicts(hash_table_t * hash, pkg_t * pkg);
102 int pkg_dependence_satisfiable(opkg_conf_t *conf, depend_t *depend);
103 int pkg_dependence_satisfied(opkg_conf_t *conf, depend_t *depend);
104
105 #endif