transaction.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. * transaction.h
  9. *
  10. */
  11. #ifndef LIBSOLV_TRANSACTION_H
  12. #define LIBSOLV_TRANSACTION_H
  13. #include "pooltypes.h"
  14. #include "queue.h"
  15. #include "bitmap.h"
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. struct s_Pool;
  20. struct s_DUChanges;
  21. struct s_TransactionOrderdata;
  22. typedef struct s_Transaction {
  23. struct s_Pool *pool; /* back pointer to pool */
  24. Queue steps; /* the transaction steps */
  25. #ifdef LIBSOLV_INTERNAL
  26. Queue transaction_info;
  27. Id *transaction_installed;
  28. Map transactsmap;
  29. Map multiversionmap;
  30. struct s_TransactionOrderdata *orderdata;
  31. #endif
  32. } Transaction;
  33. /* step types */
  34. #define SOLVER_TRANSACTION_IGNORE 0x00
  35. #define SOLVER_TRANSACTION_ERASE 0x10
  36. #define SOLVER_TRANSACTION_REINSTALLED 0x11
  37. #define SOLVER_TRANSACTION_DOWNGRADED 0x12
  38. #define SOLVER_TRANSACTION_CHANGED 0x13
  39. #define SOLVER_TRANSACTION_UPGRADED 0x14
  40. #define SOLVER_TRANSACTION_OBSOLETED 0x15
  41. #define SOLVER_TRANSACTION_INSTALL 0x20
  42. #define SOLVER_TRANSACTION_REINSTALL 0x21
  43. #define SOLVER_TRANSACTION_DOWNGRADE 0x22
  44. #define SOLVER_TRANSACTION_CHANGE 0x23
  45. #define SOLVER_TRANSACTION_UPGRADE 0x24
  46. #define SOLVER_TRANSACTION_OBSOLETES 0x25
  47. #define SOLVER_TRANSACTION_MULTIINSTALL 0x30
  48. #define SOLVER_TRANSACTION_MULTIREINSTALL 0x31
  49. #define SOLVER_TRANSACTION_MAXTYPE 0x3f
  50. /* modes */
  51. #define SOLVER_TRANSACTION_SHOW_ACTIVE (1 << 0)
  52. #define SOLVER_TRANSACTION_SHOW_ALL (1 << 1)
  53. #define SOLVER_TRANSACTION_SHOW_OBSOLETES (1 << 2)
  54. #define SOLVER_TRANSACTION_SHOW_MULTIINSTALL (1 << 3)
  55. #define SOLVER_TRANSACTION_CHANGE_IS_REINSTALL (1 << 4)
  56. #define SOLVER_TRANSACTION_MERGE_VENDORCHANGES (1 << 5)
  57. #define SOLVER_TRANSACTION_MERGE_ARCHCHANGES (1 << 6)
  58. #define SOLVER_TRANSACTION_RPM_ONLY (1 << 7)
  59. #define SOLVER_TRANSACTION_KEEP_PSEUDO (1 << 8)
  60. #define SOLVER_TRANSACTION_OBSOLETE_IS_UPGRADE (1 << 9)
  61. /* extra classifications */
  62. #define SOLVER_TRANSACTION_ARCHCHANGE 0x100
  63. #define SOLVER_TRANSACTION_VENDORCHANGE 0x101
  64. /* order flags */
  65. #define SOLVER_TRANSACTION_KEEP_ORDERDATA (1 << 0)
  66. #define SOLVER_TRANSACTION_KEEP_ORDERCYCLES (1 << 1)
  67. #define SOLVER_TRANSACTION_KEEP_ORDEREDGES (1 << 2)
  68. /* cycle severities */
  69. #define SOLVER_ORDERCYCLE_HARMLESS 0
  70. #define SOLVER_ORDERCYCLE_NORMAL 1
  71. #define SOLVER_ORDERCYCLE_CRITICAL 2
  72. extern Transaction *transaction_create(struct s_Pool *pool);
  73. extern Transaction *transaction_create_decisionq(struct s_Pool *pool, Queue *decisionq, Map *multiversionmap);
  74. extern Transaction *transaction_create_clone(Transaction *srctrans);
  75. extern void transaction_free(Transaction *trans);
  76. /* if p is installed, returns with pkg(s) obsolete p */
  77. /* if p is not installed, returns with pkg(s) we obsolete */
  78. extern Id transaction_obs_pkg(Transaction *trans, Id p);
  79. extern void transaction_all_obs_pkgs(Transaction *trans, Id p, Queue *pkgs);
  80. /* return step type of a transaction element */
  81. extern Id transaction_type(Transaction *trans, Id p, int mode);
  82. /* return sorted collection of all step types */
  83. /* classify_pkgs can be used to return all packages of a type */
  84. extern void transaction_classify(Transaction *trans, int mode, Queue *classes);
  85. extern void transaction_classify_pkgs(Transaction *trans, int mode, Id type, Id from, Id to, Queue *pkgs);
  86. /* return all packages that will be installed after the transaction is run*/
  87. /* The new packages are put at the head of the queue, the number of new
  88. packages is returned */
  89. extern int transaction_installedresult(Transaction *trans, Queue *installedq);
  90. long long transaction_calc_installsizechange(Transaction *trans);
  91. void transaction_calc_duchanges(Transaction *trans, struct s_DUChanges *mps, int nmps);
  92. /* order a transaction */
  93. extern void transaction_order(Transaction *trans, int flags);
  94. /* roll your own order funcion:
  95. * add pkgs free for installation to queue choices after chosen was
  96. * installed. start with chosen = 0
  97. * needs an ordered transaction created with SOLVER_TRANSACTION_KEEP_ORDERDATA */
  98. extern int transaction_order_add_choices(Transaction *trans, Id chosen, Queue *choices);
  99. /* add obsoleted packages into transaction steps */
  100. extern void transaction_add_obsoleted(Transaction *trans);
  101. /* debug function, report problems found in the order */
  102. extern void transaction_check_order(Transaction *trans);
  103. /* order cycle introspection */
  104. extern void transaction_order_get_cycleids(Transaction *trans, Queue *q, int minseverity);
  105. extern int transaction_order_get_cycle(Transaction *trans, Id cid, Queue *q);
  106. extern void transaction_order_get_edges(Transaction *trans, Id p, Queue *q, int unbroken);
  107. extern void transaction_free_orderdata(Transaction *trans);
  108. extern void transaction_clone_orderdata(Transaction *trans, Transaction *srctrans);
  109. #ifdef __cplusplus
  110. }
  111. #endif
  112. #endif