summaryrefslogtreecommitdiff
path: root/src/transaction.h
blob: a5d301579e71994e71f60eaaabc24db3cebe8a76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
 * Copyright (c) 2007-2009, Novell Inc.
 *
 * This program is licensed under the BSD license, read LICENSE.BSD
 * for further information
 */

/*
 * transaction.h
 *
 */

#ifndef LIBSOLV_TRANSACTION_H
#define LIBSOLV_TRANSACTION_H

#ifdef __cplusplus
extern "C" {
#endif

#include "pooltypes.h"
#include "queue.h"
#include "bitmap.h"

struct _Pool;
struct _DUChanges;
struct _TransactionOrderdata;

typedef struct _Transaction {
  struct _Pool *pool;		/* back pointer to pool */

  Queue steps;			/* the transaction steps */

  Queue transaction_info;
  Id *transaction_installed;
  Map transactsmap;
  Map noobsmap;

  struct _TransactionOrderdata *orderdata;

} Transaction;


/* step types */
#define SOLVER_TRANSACTION_IGNORE		0x00

#define SOLVER_TRANSACTION_ERASE		0x10
#define SOLVER_TRANSACTION_REINSTALLED		0x11
#define SOLVER_TRANSACTION_DOWNGRADED		0x12
#define SOLVER_TRANSACTION_CHANGED		0x13
#define SOLVER_TRANSACTION_UPGRADED		0x14
#define SOLVER_TRANSACTION_OBSOLETED		0x15

#define SOLVER_TRANSACTION_INSTALL		0x20
#define SOLVER_TRANSACTION_REINSTALL		0x21
#define SOLVER_TRANSACTION_DOWNGRADE		0x22
#define SOLVER_TRANSACTION_CHANGE		0x23
#define SOLVER_TRANSACTION_UPGRADE		0x24
#define SOLVER_TRANSACTION_OBSOLETES		0x25

#define SOLVER_TRANSACTION_MULTIINSTALL		0x30
#define SOLVER_TRANSACTION_MULTIREINSTALL	0x31

#define SOLVER_TRANSACTION_MAXTYPE		0x3f

/* modes */
#define SOLVER_TRANSACTION_SHOW_ACTIVE		(1 << 0)
#define SOLVER_TRANSACTION_SHOW_ALL		(1 << 1)
#define SOLVER_TRANSACTION_SHOW_OBSOLETES	(1 << 2)
#define SOLVER_TRANSACTION_SHOW_MULTIINSTALL	(1 << 3)
#define SOLVER_TRANSACTION_CHANGE_IS_REINSTALL	(1 << 4)
#define SOLVER_TRANSACTION_MERGE_VENDORCHANGES	(1 << 5)
#define SOLVER_TRANSACTION_MERGE_ARCHCHANGES	(1 << 6)

#define SOLVER_TRANSACTION_RPM_ONLY		(1 << 7)

/* extra classifications */
#define SOLVER_TRANSACTION_ARCHCHANGE		0x100
#define SOLVER_TRANSACTION_VENDORCHANGE		0x101

/* order flags */
#define SOLVER_TRANSACTION_KEEP_ORDERDATA	(1 << 0)

extern Transaction *transaction_create(struct _Pool *pool);
extern Transaction *transaction_create_decisionq(struct _Pool *pool, Queue *decisionq, Map *noobsmap);
extern Transaction *transaction_create_clone(Transaction *srctrans);
extern void transaction_free(Transaction *trans);
extern void transaction_free_orderdata(Transaction *trans);

/* if p is installed, returns with pkg(s) obsolete p */
/* if p is not installed, returns with pkg(s) we obsolete */
extern Id   transaction_obs_pkg(Transaction *trans, Id p);
extern void transaction_all_obs_pkgs(Transaction *trans, Id p, Queue *pkgs);

/* return step type of a transaction element */
extern Id   transaction_type(Transaction *trans, Id p, int mode);

/* return sorted collection of all step types */
/* classify_pkgs can be used to return all packages of a type */
extern void transaction_classify(Transaction *trans, int mode, Queue *classes);
extern void transaction_classify_pkgs(Transaction *trans, int mode, Id type, Id from, Id to, Queue *pkgs);

/* return all packages that will be installed after the transaction is run*/
/* The new packages are put at the head of the queue, the number of new
   packages is returned */
extern int transaction_installedresult(Transaction *trans, Queue *installedq);

int transaction_calc_installsizechange(Transaction *trans);
void transaction_calc_duchanges(Transaction *trans, struct _DUChanges *mps, int nmps);

/* order a transaction */
extern void transaction_order(Transaction *trans, int flags);

/* roll your own order funcion: 
 * add pkgs free for installation to queue choices after chosen was
 * installed. start with chosen = 0
 * needs an ordered transaction created with SOLVER_TRANSACTION_KEEP_ORDERDATA */
extern int  transaction_order_add_choices(Transaction *trans, Id chosen, Queue *choices);
/* add obsoleted packages into transaction steps */
extern void transaction_add_obsoleted(Transaction *trans);

/* debug function, report problems found in the order */
extern void transaction_check_order(Transaction *trans);


#ifdef __cplusplus
}
#endif

#endif