Doxygen annotations for config files.
[tools/librpm-tizen.git] / lib / psm.h
1 #ifndef H_PSM
2 #define H_PSM
3
4 /** \ingroup rpmtrans payload
5  * \file lib/psm.h
6  * Package state machine to handle a package from a transaction set.
7  */
8
9 #include <rpmlib.h>
10 #include "depends.h"
11 #include "fsm.h"
12
13 /**
14  */
15 struct sharedFile {
16     int mainFileNumber;
17     int secRecOffset;
18     int secFileNumber;
19 } ;
20
21 /**
22  */
23 struct sharedFileInfo {
24     int pkgFileNum;
25     int otherFileNum;
26     int otherPkg;
27     int isRemoved;
28 };
29
30 /**
31  */
32 struct transactionFileInfo_s {
33   /* for all packages */
34     enum rpmTransactionType type;
35     fileAction action;          /*!< File disposition default. */
36 /*@owned@*/ fileAction * actions;       /*!< File disposition(s) */
37 /*@owned@*/ struct fingerPrint_s * fps; /*!< File fingerprint(s) */
38     HGE_t hge;                  /*!< Vector to headerGetEntry() */
39     HFD_t hfd;                  /*!< Vector to headerFreeData() */
40     Header h;                   /*!< Package header */
41 /*@owned@*/ const char * name;
42 /*@owned@*/ const char * version;
43 /*@owned@*/ const char * release;
44     int_32 epoch;
45     uint_32 flags;              /*!< File flag default. */
46     const uint_32 * fflags;     /*!< File flag(s) (from header) */
47     const uint_32 * fsizes;     /*!< File size(s) (from header) */
48     const uint_32 * fmtimes;    /*!< File modification time(s) (from header) */
49 /*@owned@*/ const char ** bnl;  /*!< Base name(s) (from header) */
50 /*@owned@*/ const char ** dnl;  /*!< Directory name(s) (from header) */
51     int_32 * dil;               /*!< Directory indice(s) (from header) */
52 /*@owned@*/ const char ** obnl; /*!< Original base name(s) (from header) */
53 /*@owned@*/ const char ** odnl; /*!< Original directory name(s) (from header) */
54     int_32 * odil;      /*!< Original directory indice(s) (from header) */
55 /*@owned@*/ const char ** fmd5s;/*!< File MD5 sum(s) (from header) */
56 /*@owned@*/ const char ** flinks;       /*!< File link(s) (from header) */
57 /* XXX setuid/setgid bits are turned off if fuser/fgroup doesn't map. */
58     uint_16 * fmodes;           /*!< File mode(s) (from header) */
59 /*@owned@*/ char * fstates;     /*!< File state(s) (from header) */
60 /*@owned@*/ const char ** fuser;        /*!< File owner(s) */
61 /*@owned@*/ const char ** fgroup;       /*!< File group(s) */
62 /*@owned@*/ const char ** flangs;       /*!< File lang(s) */
63     int fc;                     /*!< No. of files. */
64     int dc;                     /*!< No. of directories. */
65     int bnlmax;                 /*!< Length (in bytes) of longest base name. */
66     int dnlmax;                 /*!< Length (in bytes) of longest dir name. */
67     int astriplen;
68     int striplen;
69     unsigned int archiveSize;
70     mode_t dperms;              /*!< Directory perms (0755) if not mapped. */
71     mode_t fperms;              /*!< File perms (0644) if not mapped. */
72 /*@owned@*/ const char ** apath;
73     int mapflags;
74 /*@owned@*/ int * fmapflags;
75     uid_t uid;
76 /*@owned@*/ /*@null@*/ uid_t * fuids;   /*!< File uid(s) */
77     gid_t gid;
78 /*@owned@*/ /*@null@*/ gid_t * fgids;   /*!< File gid(s) */
79     int magic;
80 #define TFIMAGIC        0x09697923
81 /*@owned@*/ FSM_t fsm;          /*!< File state machine data. */
82
83   /* these are for TR_ADDED packages */
84 /*@dependent@*/ struct availablePackage * ap;
85 /*@owned@*/ struct sharedFileInfo * replaced;
86 /*@owned@*/ uint_32 * replacedSizes;
87   /* for TR_REMOVED packages */
88     unsigned int record;
89 };
90
91 /**
92  */
93 #define PSM_VERBOSE     0x8000
94 #define PSM_INTERNAL    0x4000
95 #define PSM_SYSCALL     0x2000
96 #define PSM_DEAD        0x1000
97 #define _fv(_a)         ((_a) | PSM_VERBOSE)
98 #define _fi(_a)         ((_a) | PSM_INTERNAL)
99 #define _fs(_a)         ((_a) | (PSM_INTERNAL | PSM_SYSCALL))
100 #define _fd(_a)         ((_a) | (PSM_INTERNAL | PSM_DEAD))
101 typedef enum pkgStage_e {
102     PSM_UNKNOWN         =  0,
103     PSM_INIT            =  1,
104     PSM_PRE             =  2,
105     PSM_PROCESS         =  3,
106     PSM_POST            =  4,
107     PSM_UNDO            =  5,
108     PSM_FINI            =  6,
109
110     PSM_PKGINSTALL      =  7,
111     PSM_PKGERASE        =  8,
112     PSM_PKGCOMMIT       = 10,
113     PSM_PKGSAVE         = 12,
114
115     PSM_CREATE          = 17,
116     PSM_NOTIFY          = 22,
117     PSM_DESTROY         = 23,
118     PSM_COMMIT          = 25,
119
120     PSM_CHROOT_IN       = 51,
121     PSM_CHROOT_OUT      = 52,
122     PSM_SCRIPT          = 53,
123     PSM_TRIGGERS        = 54,
124     PSM_IMMED_TRIGGERS  = 55,
125     PSM_RPMIO_FLAGS     = 56,
126
127     PSM_RPMDB_LOAD      = 97,
128     PSM_RPMDB_ADD       = 98,
129     PSM_RPMDB_REMOVE    = 99,
130
131 } pkgStage;
132 #undef  _fv
133 #undef  _fi
134 #undef  _fs
135 #undef  _fd
136
137 /**
138  */
139 struct psm_s {
140 /*@kept@*/ rpmTransactionSet ts;/*!< transaction set */
141 /*@kept@*/ TFI_t fi;            /*!< transaction element file info */
142     FD_t cfd;                   /*!< Payload file handle. */
143     FD_t fd;                    /*!< Repackage file handle. */
144     Header oh;                  /*!< Repackage/multilib header. */
145     rpmdbMatchIterator mi;
146 /*@observer@*/ const char * stepName;
147 /*@owned@*/ const char * rpmio_flags;
148 /*@owned@*/ const char * failedFile;
149 /*@owned@*/ const char * pkgURL;        /*!< Repackage URL. */
150 /*@dependent@*/ const char * pkgfn;     /*!< Repackage file name. */
151     int scriptTag;              /*!< Scriptlet data tag. */
152     int progTag;                /*!< Scriptlet interpreter tag. */
153     int npkgs_installed;        /*!< No. of installed instances. */
154     int scriptArg;              /*!< Scriptlet package arg. */
155     int sense;                  /*!< One of RPMSENSE_TRIGGER{IN,UN,POSTUN}. */
156     int countCorrection;        /*!< 0 if installing, -1 if removing. */
157     int chrootDone;             /*!< Was chroot(2) done by pkgStage? */
158     rpmCallbackType what;       /*!< Callback type. */
159     unsigned long amount;       /*!< Callback amount. */
160     unsigned long total;        /*!< Callback total. */
161     rpmRC rc;
162     pkgStage goal;
163     pkgStage stage;
164 };
165
166 #ifdef __cplusplus
167 extern "C" {
168 #endif
169
170 /**
171  * Load data from header into transaction file element info.
172  * @param h             header
173  * @param fi            transaction element file info
174  */
175 void loadFi(Header h, TFI_t fi)
176         /*@modifies h, fi @*/;
177
178 /**
179  * Destroy transaction element file info.
180  * @param fi            transaction element file info
181  */
182 void freeFi(TFI_t fi)
183         /*@modifies fi @*/;
184
185 /**
186  * Return formatted string representation of package disposition.
187  * @param a             package dispostion
188  * @return              formatted string
189  */
190 /*@observer@*/ const char *const fiTypeString(TFI_t fi);
191
192 /**
193  * Package state machine driver.
194  * @param psm           package state machine data
195  * @param stage         next stage
196  * @return              0 on success
197  */
198 int psmStage(PSM_t psm, pkgStage stage)
199         /*@modifies psm @*/;
200
201 #ifdef __cplusplus
202 }
203 #endif
204
205 #endif  /* H_ROLLBACK */