4 /** \ingroup rpmtrans payload
6 * Package state machine to handle a package from a transaction set.
19 struct sharedFileInfo {
28 struct transactionFileInfo_s {
29 /*@null@*/ Header h; /*!< Package header */
31 /*@owned@*/ const char * name; /*!< Name: tag (malloc'd). */
32 /*@owned@*/ const char * version; /*!< Version: tag (malloc'd). */
33 /*@owned@*/ const char * release; /*!< Release: tag (malloc'd). */
36 /*@owned@*/ const char ** provides; /*!< Provides: name strings. */
37 /*@owned@*/ const char ** providesEVR; /*!< Provides: [epoch:]version[-release] strings. */
38 /*@dependent@*/ int * provideFlags; /*!< Provides: logical range qualifiers. */
39 /*@owned@*//*@null@*/ const char ** requires; /*!< Requires: name strings. */
40 /*@owned@*//*@null@*/ const char ** requiresEVR;/*!< Requires: [epoch:]version[-release] strings. */
41 /*@dependent@*//*@null@*/ int * requireFlags; /*!< Requires: logical range qualifiers. */
42 /*@owned@*//*@null@*/ const char ** baseNames; /*!< Header file basenames. */
43 /*@dependent@*//*@null@*/ int_32 * epoch; /*!< Header epoch (if any). */
44 int providesCount; /*!< No. of Provide:'s in header. */
45 int requiresCount; /*!< No. of Require:'s in header. */
46 int filesCount; /*!< No. of files in header. */
47 int npreds; /*!< No. of predecessors. */
48 int depth; /*!< Max. depth in dependency tree. */
49 struct tsortInfo_s tsi; /*!< Dependency tsort data. */
52 uint_32 multiLib; /* MULTILIB */
54 const void * key; /*!< Package notify key. */
55 /*@null@*/ /*@dependent@*/
56 rpmRelocation * relocs; /*!< Package file relocations. */
58 FD_t fd; /*!< Package file handle */
60 /*=============================*/
62 /* for all packages */
63 enum rpmTransactionType type;
64 fileAction action; /*!< File disposition default. */
65 /*@owned@*/ fileAction * actions; /*!< File disposition(s) */
66 /*@owned@*/ struct fingerPrint_s * fps; /*!< File fingerprint(s) */
67 HGE_t hge; /*!< Vector to headerGetEntry() */
68 HAE_t hae; /*!< Vector to headerAddEntry() */
69 HME_t hme; /*!< Vector to headerModifyEntry() */
70 HRE_t hre; /*!< Vector to headerRemoveEntry() */
71 HFD_t hfd; /*!< Vector to headerFreeData() */
73 uint_32 flags; /*!< File flag default. */
74 const uint_32 * fflags; /*!< File flag(s) (from header) */
75 const uint_32 * fsizes; /*!< File size(s) (from header) */
76 const uint_32 * fmtimes; /*!< File modification time(s) (from header) */
77 /*@owned@*/ const char ** bnl; /*!< Base name(s) (from header) */
78 /*@owned@*/ const char ** dnl; /*!< Directory name(s) (from header) */
79 int_32 * dil; /*!< Directory indice(s) (from header) */
80 /*@owned@*/ const char ** obnl; /*!< Original base name(s) (from header) */
81 /*@owned@*/ const char ** odnl; /*!< Original directory name(s) (from header) */
82 /*@unused@*/ int_32 * odil; /*!< Original directory indice(s) (from header) */
83 /*@owned@*/ const char ** fmd5s;/*!< File MD5 sum(s) (from header) */
84 /*@owned@*/ const char ** flinks; /*!< File link(s) (from header) */
85 /* XXX setuid/setgid bits are turned off if fuser/fgroup doesn't map. */
86 uint_16 * fmodes; /*!< File mode(s) (from header) */
87 uint_16 * frdevs; /*!< File rdev(s) (from header) */
88 /*@only@*/ /*@null@*/ char * fstates; /*!< File state(s) (from header) */
89 /*@owned@*/ const char ** fuser; /*!< File owner(s) */
90 /*@owned@*/ const char ** fgroup; /*!< File group(s) */
91 /*@owned@*/ const char ** flangs; /*!< File lang(s) */
92 int fc; /*!< No. of files. */
93 int dc; /*!< No. of directories. */
94 int bnlmax; /*!< Length (in bytes) of longest base name. */
95 int dnlmax; /*!< Length (in bytes) of longest dir name. */
98 unsigned int archiveSize;
99 mode_t dperms; /*!< Directory perms (0755) if not mapped. */
100 mode_t fperms; /*!< File perms (0644) if not mapped. */
101 /*@only@*/ /*@null@*/ const char ** apath;
103 /*@owned@*/ /*@null@*/ int * fmapflags;
105 /*@owned@*/ /*@null@*/ uid_t * fuids; /*!< File uid(s) */
107 /*@owned@*/ /*@null@*/ gid_t * fgids; /*!< File gid(s) */
110 #define TFIMAGIC 0x09697923
111 /*@owned@*/ FSM_t fsm; /*!< File state machine data. */
113 int keep_header; /*!< Keep header? */
114 /*@refs@*/ int nrefs; /*!< Reference count. */
116 /*@owned@*/ struct sharedFileInfo * replaced; /*!< (TR_ADDED) */
117 /*@owned@*/ uint_32 * replacedSizes; /*!< (TR_ADDED) */
119 unsigned int record; /*!< (TR_REMOVED) */
124 #define PSM_VERBOSE 0x8000
125 #define PSM_INTERNAL 0x4000
126 #define PSM_SYSCALL 0x2000
127 #define PSM_DEAD 0x1000
128 #define _fv(_a) ((_a) | PSM_VERBOSE)
129 #define _fi(_a) ((_a) | PSM_INTERNAL)
130 #define _fs(_a) ((_a) | (PSM_INTERNAL | PSM_SYSCALL))
131 #define _fd(_a) ((_a) | (PSM_INTERNAL | PSM_DEAD))
132 typedef enum pkgStage_e {
155 PSM_IMMED_TRIGGERS = 55,
156 PSM_RPMIO_FLAGS = 56,
160 PSM_RPMDB_REMOVE = 99,
172 rpmTransactionSet ts; /*!< transaction set */
174 TFI_t fi; /*!< transaction element file info */
175 FD_t cfd; /*!< Payload file handle. */
176 FD_t fd; /*!< Repackage file handle. */
177 Header oh; /*!< Repackage/multilib header. */
178 /*@null@*/ rpmdbMatchIterator mi;
179 /*@observer@*/ const char * stepName;
180 /*@only@*/ /*@null@*/ const char * rpmio_flags;
181 /*@only@*/ /*@null@*/ const char * failedFile;
182 /*@only@*/ /*@null@*/ const char * pkgURL; /*!< Repackage URL. */
183 /*@dependent@*/ const char * pkgfn; /*!< Repackage file name. */
184 int scriptTag; /*!< Scriptlet data tag. */
185 int progTag; /*!< Scriptlet interpreter tag. */
186 int npkgs_installed; /*!< No. of installed instances. */
187 int scriptArg; /*!< Scriptlet package arg. */
188 int sense; /*!< One of RPMSENSE_TRIGGER{IN,UN,POSTUN}. */
189 int countCorrection; /*!< 0 if installing, -1 if removing. */
190 int chrootDone; /*!< Was chroot(2) done by pkgStage? */
191 rpmCallbackType what; /*!< Callback type. */
192 unsigned long amount; /*!< Callback amount. */
193 unsigned long total; /*!< Callback total. */
196 /*@unused@*/ pkgStage stage;
204 * Return (malloc'd) transaction element name-version-release string.
205 * @param fi transaction element file info
206 * @return name-version-release string
208 /*@only@*/ /*@null@*/
209 char * fiGetNVR(/*@null@*/const TFI_t fi)
213 * Return file type from mode_t.
214 * @param mode file mode bits (from header)
217 fileTypes whatis(uint_16 mode)
221 * Relocate files in header.
222 * @todo multilib file dispositions need to be checked.
223 * @param ts transaction set
224 * @param fi transaction element file info
225 * @param origH package header
226 * @param actions file dispositions
227 * @return header with relocated files
229 Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
230 Header origH, fileAction * actions)
231 /*@modifies ts, fi, origH, actions @*/;
234 * Load data from header into transaction file element info.
235 * @param ts transaction set
236 * @param fi transaction element file info
238 * @param keep_header use header memory?
240 void loadFi(/*@null@*/ const rpmTransactionSet ts, TFI_t fi,
241 Header h, int keep_header)
242 /*@modifies ts, fi, h @*/;
245 * Destroy transaction element file info.
246 * @param fi transaction element file info
248 void freeFi(TFI_t fi)
252 * Retrieve key from transaction element file info
253 * @param fi transaction element file info
254 * @return transaction element file info key
256 /*@null@*/ const void * rpmfiGetKey(TFI_t fi)
260 * Return formatted string representation of package disposition.
261 * @param a package dispostion
262 * @return formatted string
264 /*@observer@*/ const char *const fiTypeString(/*@partial@*/TFI_t fi)
268 * Package state machine driver.
269 * @param psm package state machine data
270 * @param stage next stage
271 * @return 0 on success
273 int psmStage(PSM_t psm, pkgStage stage)
274 /*@globals rpmGlobalMacroContext,
275 fileSystem, internalState @*/
276 /*@modifies psm, rpmGlobalMacroContext, fileSystem, internalState @*/;
282 #endif /* H_ROLLBACK */