- move policy-ruby.c into ruby dir
[platform/upstream/libsolv.git] / src / solver.h
1 /*
2  * solver.h
3  *
4  */
5
6 #ifndef SOLVER_H
7 #define SOLVER_H
8
9 #include "pooltypes.h"
10 #include "pool.h"
11 #include "repo.h"
12 #include "queue.h"
13 #include "bitmap.h"
14
15 /* ----------------------------------------------
16  * Rule
17  *
18  *   providerN(B) == Package Id of package providing tag B
19  *   N = 1, 2, 3, in case of multiple providers
20  *
21  * A requires B : !A | provider1(B) | provider2(B)
22  *
23  * A conflicts B : (!A | !provider1(B)) & (!A | !provider2(B)) ...
24  *
25  * 'not' is encoded as a negative Id
26  * 
27  * Binary rule: p = first literal, d = 0, w2 = second literal, w1 = p
28  */
29
30 typedef struct rule {
31   Id p;                 /* first literal in rule */
32   Id d;                 /* Id offset into 'list of providers terminated by 0' as used by whatprovides; pool->whatprovides + d */
33                         /* in case of binary rules, d == 0, w1 == p, w2 == other literal */
34   Id w1, w2;            /* watches, literals not-yet-decided */
35                                        /* if !w1, disabled */
36                                        /* if !w2, assertion, not rule */
37   Id n1, n2;            /* next rules in linked list, corresponding to w1,w2 */
38 } Rule;
39
40 typedef struct solver {
41   Pool *pool;
42   Repo *installed;
43
44   int fixsystem;                        /* repair errors in rpm dependency graph */
45   int allowdowngrade;                   /* allow to downgrade installed solvable */
46   int allowarchchange;                  /* allow to change architecture of installed solvables */
47   int allowvendorchange;                /* allow to change vendor of installed solvables */
48   int allowuninstall;                   /* allow removal of installed solvables */
49   int updatesystem;                     /* distupgrade */
50   int allowvirtualconflicts;            /* false: conflicts on package name, true: conflicts on package provides */
51   int noupdateprovide;                  /* true: update packages needs not to provide old package */
52   
53   Rule *rules;                          /* all rules */
54   Id nrules;                            /* rpm rules */
55
56   Id jobrules;                          /* user rules */
57   Id systemrules;                       /* policy rules, e.g. keep packages installed or update. All literals > 0 */
58   Id weakrules;                         /* rules that can be autodisabled */
59   Id learntrules;                       /* learnt rules */
60
61   Id *weaksystemrules;                  /* please try to install (r->d) */
62
63   Id *watches;                          /* Array of rule offsets
64                                          * watches has nsolvables*2 entries and is addressed from the middle
65                                          * middle-solvable : decision to conflict, offset point to linked-list of rules
66                                          * middle+solvable : decision to install: offset point to linked-list of rules
67                                          */
68
69   Queue ruletojob;
70
71   /* our decisions: */
72   Queue decisionq;
73   Queue decisionq_why;                  /* index of rule, Offset into rules */
74   Id *decisionmap;                      /* map for all available solvables, > 0: level of decision when installed, < 0 level of decision when conflict */
75
76   /* learnt rule history */
77   Queue learnt_why;
78   Queue learnt_pool;
79   Queue minimize;
80
81   int propagate_index;
82
83   Queue problems;
84   Queue suggestions;                    /* suggested packages */
85
86   Map recommendsmap;                    /* recommended packages from decisionmap */
87   Map suggestsmap;                      /* suggested packages from decisionmap */
88   int recommends_index;                 /* recommended level */
89
90   Id *obsoletes;                        /* obsoletes for each installed solvable */
91   Id *obsoletes_data;                   /* data area for obsoletes */
92
93   int rc_output;                        /* output result compatible to redcarpet/zypp testsuite, set == 2 for pure rc (will suppress architecture) */
94 } Solver;
95
96 /*
97  * queue commands
98  */
99
100 enum solvcmds {
101   SOLVCMD_NULL=0,
102   SOLVER_INSTALL_SOLVABLE,
103   SOLVER_ERASE_SOLVABLE,
104   SOLVER_INSTALL_SOLVABLE_NAME,
105   SOLVER_ERASE_SOLVABLE_NAME,
106   SOLVER_INSTALL_SOLVABLE_PROVIDES,
107   SOLVER_ERASE_SOLVABLE_PROVIDES,
108   SOLVER_INSTALL_SOLVABLE_UPDATE
109 } SolverCmd;
110
111 extern Solver *solver_create(Pool *pool, Repo *installed);
112 extern void solver_free(Solver *solv);
113 extern void solve(Solver *solv, Queue *job);
114
115 extern void prune_best_version_arch(Pool *pool, Queue *plist);
116
117 void printdecisions(Solver *solv);
118
119
120 #endif /* SOLVER_H */