summaryrefslogtreecommitdiff
path: root/lib/rpmtsscore.h
blob: 871fa7766d52175427394549727ccdf2abf3e23a (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
#ifndef H_RPMTSSCORE
#define H_RPMTSSCORE

#include <rpmlib.h>
#include <rpmte.h>

/**********************
 * Transaction Scores *
 **********************
 *
 * In order to allow instance counts to be adjusted properly when an
 * autorollback transaction is ran, we keep a list that is indexed
 * by rpm name of whether the rpm has been installed or erased.  This listed
 * is only updated:
 *
 *	iif autorollbacks are enabled.
 *	iif this is not a rollback or autorollback transaction.
 *
 * When creating an autorollback transaction, its rpmts points to the same
 * rpmtsScore object as the running transaction.  So when the autorollback
 * transaction runs it can see where each package was in the running transaction
 * at the point the running transaction failed, and thus on a per package
 * basis make adjustments to the instance counts.
 *
 */

struct rpmtsScoreEntry_s {
    char *         N;                   /*!<Name of package                */
    rpmElementType te_types;            /*!<te types this entry represents */
    int            installed;           /*!<Was the new header installed   */
    int            erased;              /*!<Was the old header removed     */
};

typedef struct rpmtsScoreEntry_s * rpmtsScoreEntry;

struct rpmtsScore_s {
        int entries;                    /*!< Number of scores       */
        rpmtsScoreEntry * scores;       /*!< Array of score entries */
        int nrefs;                      /*!< Reference count.       */
};

typedef struct rpmtsScore_s * rpmtsScore;

/** \ingroup rpmts
 * initialize rpmtsScore for running transaction and autorollback
 * transaction.
 * @param runningTS	Running Transaction.
 * @param rollbackTS	Rollback Transaction.
 * @return		RPMRC_OK
 */
rpmRC rpmtsScoreInit(rpmts runningTS, rpmts rollbackTS);

/** \ingroup rpmts
 * Free rpmtsScore provided no more references exist against it.
 * @param score		rpmtsScore to free
 * @return		NULL always
 */
rpmtsScore rpmtsScoreFree(rpmtsScore score);

/** \ingroup rpmts
 * Get rpmtsScore from transaction.
 * @param ts	RPM Transaction.
 * @return	rpmtsScore or NULL.
 */
rpmtsScore rpmtsGetScore(rpmts ts);

/** \ingroup rpmts
 * Get rpmtsScoreEntry from rpmtsScore.
 * @param score   RPM Transaction Score.
 * @param N   	  Score entry name.
 * @return	  rpmtsScoreEntry or NULL.
 */
rpmtsScoreEntry rpmtsScoreGetEntry(rpmtsScore score, const char *N);

#endif /* H_RPMTSSCORE */