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