rules.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. * Copyright (c) 2007-2009, Novell Inc.
  3. *
  4. * This program is licensed under the BSD license, read LICENSE.BSD
  5. * for further information
  6. */
  7. /*
  8. * rules.h
  9. *
  10. */
  11. #ifndef LIBSOLV_RULES_H
  12. #define LIBSOLV_RULES_H
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. /* ----------------------------------------------
  17. * Rule
  18. *
  19. * providerN(B) == Package Id of package providing tag B
  20. * N = 1, 2, 3, in case of multiple providers
  21. *
  22. * A requires B : !A | provider1(B) | provider2(B)
  23. *
  24. * A conflicts B : (!A | !provider1(B)) & (!A | !provider2(B)) ...
  25. *
  26. * 'not' is encoded as a negative Id
  27. *
  28. * Binary rule: p = first literal, d = 0, w2 = second literal, w1 = p
  29. *
  30. * There are a lot of rules, so the struct is kept as small as
  31. * possible. Do not add new members unless there is no other way.
  32. */
  33. typedef struct s_Rule {
  34. Id p; /* first literal in rule */
  35. Id d; /* Id offset into 'list of providers terminated by 0' as used by whatprovides; pool->whatprovides + d */
  36. /* in case of binary rules, d == 0, w1 == p, w2 == other literal */
  37. /* in case of disabled rules: ~d, aka -d - 1 */
  38. Id w1, w2; /* watches, literals not-yet-decided */
  39. /* if !w2, assertion, not rule */
  40. Id n1, n2; /* next rules in linked list, corresponding to w1, w2 */
  41. } Rule;
  42. typedef enum {
  43. SOLVER_RULE_UNKNOWN = 0,
  44. SOLVER_RULE_PKG = 0x100,
  45. SOLVER_RULE_PKG_NOT_INSTALLABLE,
  46. SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP,
  47. SOLVER_RULE_PKG_REQUIRES,
  48. SOLVER_RULE_PKG_SELF_CONFLICT,
  49. SOLVER_RULE_PKG_CONFLICTS,
  50. SOLVER_RULE_PKG_SAME_NAME,
  51. SOLVER_RULE_PKG_OBSOLETES,
  52. SOLVER_RULE_PKG_IMPLICIT_OBSOLETES,
  53. SOLVER_RULE_PKG_INSTALLED_OBSOLETES,
  54. SOLVER_RULE_PKG_RECOMMENDS,
  55. SOLVER_RULE_PKG_CONSTRAINS,
  56. SOLVER_RULE_UPDATE = 0x200,
  57. SOLVER_RULE_FEATURE = 0x300,
  58. SOLVER_RULE_JOB = 0x400,
  59. SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP,
  60. SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM,
  61. SOLVER_RULE_JOB_UNKNOWN_PACKAGE,
  62. SOLVER_RULE_JOB_UNSUPPORTED,
  63. SOLVER_RULE_DISTUPGRADE = 0x500,
  64. SOLVER_RULE_INFARCH = 0x600,
  65. SOLVER_RULE_CHOICE = 0x700,
  66. SOLVER_RULE_LEARNT = 0x800,
  67. SOLVER_RULE_BEST = 0x900,
  68. SOLVER_RULE_YUMOBS = 0xa00,
  69. SOLVER_RULE_RECOMMENDS = 0xb00,
  70. SOLVER_RULE_BLACK = 0xc00,
  71. SOLVER_RULE_STRICT_REPO_PRIORITY = 0xd00
  72. } SolverRuleinfo;
  73. #define SOLVER_RULE_TYPEMASK 0xff00
  74. struct s_Solver;
  75. /*-------------------------------------------------------------------
  76. * disable rule
  77. */
  78. static inline void
  79. solver_disablerule(struct s_Solver *solv, Rule *r)
  80. {
  81. if (r->d >= 0)
  82. r->d = -r->d - 1;
  83. }
  84. /*-------------------------------------------------------------------
  85. * enable rule
  86. */
  87. static inline void
  88. solver_enablerule(struct s_Solver *solv, Rule *r)
  89. {
  90. if (r->d < 0)
  91. r->d = -r->d - 1;
  92. }
  93. extern Rule *solver_addrule(struct s_Solver *solv, Id p, Id p2, Id d);
  94. extern void solver_unifyrules(struct s_Solver *solv);
  95. extern int solver_rulecmp(struct s_Solver *solv, Rule *r1, Rule *r2);
  96. extern void solver_shrinkrules(struct s_Solver *solv, int nrules);
  97. /* pkg rules */
  98. extern void solver_addpkgrulesforsolvable(struct s_Solver *solv, Solvable *s, Map *m);
  99. extern void solver_addpkgrulesforweak(struct s_Solver *solv, Map *m);
  100. extern void solver_addpkgrulesforlinked(struct s_Solver *solv, Map *m);
  101. extern void solver_addpkgrulesforupdaters(struct s_Solver *solv, Solvable *s, Map *m, int allow_all);
  102. /* update/feature rules */
  103. extern void solver_addfeaturerule(struct s_Solver *solv, Solvable *s);
  104. extern void solver_addupdaterule(struct s_Solver *solv, Solvable *s);
  105. /* infarch rules */
  106. extern void solver_addinfarchrules(struct s_Solver *solv, Map *addedmap);
  107. /* dup rules */
  108. extern void solver_createdupmaps(struct s_Solver *solv);
  109. extern void solver_freedupmaps(struct s_Solver *solv);
  110. extern void solver_addduprules(struct s_Solver *solv, Map *addedmap);
  111. /* choice rules */
  112. extern void solver_addchoicerules(struct s_Solver *solv);
  113. extern void solver_disablechoicerules(struct s_Solver *solv, Rule *r);
  114. /* best rules */
  115. extern void solver_addbestrules(struct s_Solver *solv, int havebestinstalljobs, int haslockjob);
  116. /* yumobs rules */
  117. extern void solver_addyumobsrules(struct s_Solver *solv);
  118. /* black rules */
  119. extern void solver_addblackrules(struct s_Solver *solv);
  120. /* recommends rules */
  121. extern void solver_addrecommendsrules(struct s_Solver *solv);
  122. /* channel priority rules */
  123. extern void solver_addstrictrepopriorules(struct s_Solver *solv, Map *addedmap);
  124. /* policy rule disabling/reenabling */
  125. extern void solver_disablepolicyrules(struct s_Solver *solv);
  126. extern void solver_reenablepolicyrules(struct s_Solver *solv, int jobidx);
  127. extern void solver_reenablepolicyrules_cleandeps(struct s_Solver *solv, Id pkg);
  128. /* rule info */
  129. extern int solver_allruleinfos(struct s_Solver *solv, Id rid, Queue *rq);
  130. extern SolverRuleinfo solver_ruleinfo(struct s_Solver *solv, Id rid, Id *fromp, Id *top, Id *depp);
  131. extern SolverRuleinfo solver_ruleclass(struct s_Solver *solv, Id rid);
  132. extern void solver_ruleliterals(struct s_Solver *solv, Id rid, Queue *q);
  133. extern int solver_rule2jobidx(struct s_Solver *solv, Id rid);
  134. extern Id solver_rule2job(struct s_Solver *solv, Id rid, Id *whatp);
  135. extern Id solver_rule2solvable(struct s_Solver *solv, Id rid);
  136. extern void solver_rule2rules(struct s_Solver *solv, Id rid, Queue *q, int recursive);
  137. extern Id solver_rule2pkgrule(struct s_Solver *solv, Id rid);
  138. /* orphan handling */
  139. extern void solver_breakorphans(struct s_Solver *solv);
  140. extern void solver_check_brokenorphanrules(struct s_Solver *solv, Queue *dq);
  141. /* legacy */
  142. #define SOLVER_RULE_RPM SOLVER_RULE_PKG
  143. #define SOLVER_RULE_RPM_NOT_INSTALLABLE SOLVER_RULE_PKG_NOT_INSTALLABLE
  144. #define SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP
  145. #define SOLVER_RULE_RPM_PACKAGE_REQUIRES SOLVER_RULE_PKG_REQUIRES
  146. #define SOLVER_RULE_RPM_SELF_CONFLICT SOLVER_RULE_PKG_SELF_CONFLICT
  147. #define SOLVER_RULE_RPM_PACKAGE_CONFLICT SOLVER_RULE_PKG_CONFLICTS
  148. #define SOLVER_RULE_RPM_SAME_NAME SOLVER_RULE_PKG_SAME_NAME
  149. #define SOLVER_RULE_RPM_PACKAGE_OBSOLETES SOLVER_RULE_PKG_OBSOLETES
  150. #define SOLVER_RULE_RPM_IMPLICIT_OBSOLETES SOLVER_RULE_PKG_IMPLICIT_OBSOLETES
  151. #define SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES SOLVER_RULE_PKG_INSTALLED_OBSOLETES
  152. #ifdef __cplusplus
  153. }
  154. #endif
  155. #endif