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. */
56 rpmRelocation * relocs; /*!< Package file relocations. */
57 /*@null@*/ FD_t fd; /*!< Package file handle */
59 /*=============================*/
61 /* for all packages */
62 enum rpmTransactionType type;
63 fileAction action; /*!< File disposition default. */
64 /*@owned@*/ fileAction * actions; /*!< File disposition(s) */
65 /*@owned@*/ struct fingerPrint_s * fps; /*!< File fingerprint(s) */
66 HGE_t hge; /*!< Vector to headerGetEntry() */
67 HAE_t hae; /*!< Vector to headerAddEntry() */
68 HME_t hme; /*!< Vector to headerModifyEntry() */
69 HRE_t hre; /*!< Vector to headerRemoveEntry() */
70 HFD_t hfd; /*!< Vector to headerFreeData() */
72 uint_32 flags; /*!< File flag default. */
73 const uint_32 * fflags; /*!< File flag(s) (from header) */
74 const uint_32 * fsizes; /*!< File size(s) (from header) */
75 const uint_32 * fmtimes; /*!< File modification time(s) (from header) */
76 /*@owned@*/ const char ** bnl; /*!< Base name(s) (from header) */
77 /*@owned@*/ const char ** dnl; /*!< Directory name(s) (from header) */
78 int_32 * dil; /*!< Directory indice(s) (from header) */
79 /*@owned@*/ const char ** obnl; /*!< Original base name(s) (from header) */
80 /*@owned@*/ const char ** odnl; /*!< Original directory name(s) (from header) */
81 /*@unused@*/ int_32 * odil; /*!< Original directory indice(s) (from header) */
82 /*@owned@*/ const char ** fmd5s;/*!< File MD5 sum(s) (from header) */
83 /*@owned@*/ const char ** flinks; /*!< File link(s) (from header) */
84 /* XXX setuid/setgid bits are turned off if fuser/fgroup doesn't map. */
85 uint_16 * fmodes; /*!< File mode(s) (from header) */
86 uint_16 * frdevs; /*!< File rdev(s) (from header) */
87 /*@only@*/ /*@null@*/ char * fstates; /*!< File state(s) (from header) */
88 /*@owned@*/ const char ** fuser; /*!< File owner(s) */
89 /*@owned@*/ const char ** fgroup; /*!< File group(s) */
90 /*@owned@*/ const char ** flangs; /*!< File lang(s) */
91 int fc; /*!< No. of files. */
92 int dc; /*!< No. of directories. */
93 int bnlmax; /*!< Length (in bytes) of longest base name. */
94 int dnlmax; /*!< Length (in bytes) of longest dir name. */
97 unsigned int archiveSize;
98 mode_t dperms; /*!< Directory perms (0755) if not mapped. */
99 mode_t fperms; /*!< File perms (0644) if not mapped. */
100 /*@only@*/ /*@null@*/ const char ** apath;
102 /*@owned@*/ /*@null@*/ int * fmapflags;
104 /*@owned@*/ /*@null@*/ uid_t * fuids; /*!< File uid(s) */
106 /*@owned@*/ /*@null@*/ gid_t * fgids; /*!< File gid(s) */
109 #define TFIMAGIC 0x09697923
110 /*@owned@*/ FSM_t fsm; /*!< File state machine data. */
112 int keep_header; /*!< Keep header? */
113 /*@refs@*/ int nrefs; /*!< Reference count. */
115 /*@owned@*/ struct sharedFileInfo * replaced; /*!< (TR_ADDED) */
116 /*@owned@*/ uint_32 * replacedSizes; /*!< (TR_ADDED) */
118 unsigned int record; /*!< (TR_REMOVED) */
123 #define PSM_VERBOSE 0x8000
124 #define PSM_INTERNAL 0x4000
125 #define PSM_SYSCALL 0x2000
126 #define PSM_DEAD 0x1000
127 #define _fv(_a) ((_a) | PSM_VERBOSE)
128 #define _fi(_a) ((_a) | PSM_INTERNAL)
129 #define _fs(_a) ((_a) | (PSM_INTERNAL | PSM_SYSCALL))
130 #define _fd(_a) ((_a) | (PSM_INTERNAL | PSM_DEAD))
131 typedef enum pkgStage_e {
154 PSM_IMMED_TRIGGERS = 55,
155 PSM_RPMIO_FLAGS = 56,
159 PSM_RPMDB_REMOVE = 99,
171 rpmTransactionSet ts; /*!< transaction set */
173 TFI_t fi; /*!< transaction element file info */
174 FD_t cfd; /*!< Payload file handle. */
175 FD_t fd; /*!< Repackage file handle. */
176 Header oh; /*!< Repackage/multilib header. */
177 /*@null@*/ rpmdbMatchIterator mi;
178 /*@observer@*/ const char * stepName;
179 /*@only@*/ /*@null@*/ const char * rpmio_flags;
180 /*@only@*/ /*@null@*/ const char * failedFile;
181 /*@only@*/ /*@null@*/ const char * pkgURL; /*!< Repackage URL. */
182 /*@dependent@*/ const char * pkgfn; /*!< Repackage file name. */
183 int scriptTag; /*!< Scriptlet data tag. */
184 int progTag; /*!< Scriptlet interpreter tag. */
185 int npkgs_installed; /*!< No. of installed instances. */
186 int scriptArg; /*!< Scriptlet package arg. */
187 int sense; /*!< One of RPMSENSE_TRIGGER{IN,UN,POSTUN}. */
188 int countCorrection; /*!< 0 if installing, -1 if removing. */
189 int chrootDone; /*!< Was chroot(2) done by pkgStage? */
190 rpmCallbackType what; /*!< Callback type. */
191 unsigned long amount; /*!< Callback amount. */
192 unsigned long total; /*!< Callback total. */
195 /*@unused@*/ pkgStage stage;
203 * Return (malloc'd) transaction element name-version-release string.
204 * @param fi transaction element file info
205 * @return name-version-release string
207 /*@only@*/ /*@null@*/
208 char * fiGetNVR(/*@null@*/const TFI_t fi)
212 * Return file type from mode_t.
213 * @param mode file mode bits (from header)
216 fileTypes whatis(uint_16 mode)
220 * Relocate files in header.
221 * @todo multilib file dispositions need to be checked.
222 * @param ts transaction set
223 * @param fi transaction element file info
224 * @param origH package header
225 * @param actions file dispositions
226 * @return header with relocated files
228 Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
229 Header origH, fileAction * actions)
230 /*@modifies ts, fi, origH, actions @*/;
233 * Load data from header into transaction file element info.
234 * @param ts transaction set
235 * @param fi transaction element file info
237 * @param keep_header use header memory?
239 void loadFi(/*@null@*/ const rpmTransactionSet ts, TFI_t fi,
240 Header h, int keep_header)
241 /*@modifies ts, fi, h @*/;
244 * Destroy transaction element file info.
245 * @param fi transaction element file info
247 void freeFi(TFI_t fi)
251 * Retrieve key from transaction element file info
252 * @param fi transaction element file info
253 * @return transaction element file info key
255 /*@null@*/ const void * rpmfiGetKey(TFI_t fi)
259 * Return formatted string representation of package disposition.
260 * @param a package dispostion
261 * @return formatted string
263 /*@observer@*/ const char *const fiTypeString(/*@partial@*/TFI_t fi)
267 * Package state machine driver.
268 * @param psm package state machine data
269 * @param stage next stage
270 * @return 0 on success
272 int psmStage(PSM_t psm, pkgStage stage)
273 /*@globals rpmGlobalMacroContext,
274 fileSystem, internalState @*/
275 /*@modifies psm, rpmGlobalMacroContext, fileSystem, internalState @*/;
281 #endif /* H_ROLLBACK */