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