4 /** \ingroup rpmtrans payload
6 * Package state machine to handle a package from a transaction set.
21 struct sharedFileInfo {
30 struct transactionFileInfo_s {
31 /*@null@*/ Header h; /*!< Package header */
33 /*@owned@*/ const char * name; /*!< Name: tag (malloc'd). */
34 /*@owned@*/ const char * version; /*!< Version: tag (malloc'd). */
35 /*@owned@*/ const char * release; /*!< Release: tag (malloc'd). */
37 uint_32 multiLib; /* MULTILIB */
39 fnpyKey key; /*!< Package notify key. */
40 /*@null@*/ /*@dependent@*/
41 rpmRelocation * relocs; /*!< Package file relocations. */
43 FD_t fd; /*!< Package file handle */
45 /*=============================*/
47 /* for all packages */
48 enum rpmTransactionType type;
49 fileAction action; /*!< File disposition default. */
50 /*@owned@*/ fileAction * actions; /*!< File disposition(s) */
51 /*@owned@*/ struct fingerPrint_s * fps; /*!< File fingerprint(s) */
52 HGE_t hge; /*!< Vector to headerGetEntry() */
53 HAE_t hae; /*!< Vector to headerAddEntry() */
54 HME_t hme; /*!< Vector to headerModifyEntry() */
55 HRE_t hre; /*!< Vector to headerRemoveEntry() */
56 HFD_t hfd; /*!< Vector to headerFreeData() */
58 uint_32 flags; /*!< File flag default. */
60 /*@owned@*/ const char ** bnl; /*!< Base name(s) (from header) */
61 /*@owned@*/ const char ** dnl; /*!< Directory name(s) (from header) */
62 /*@owned@*/ const char ** fmd5s;/*!< File MD5 sum(s) (from header) */
63 /*@owned@*/ const char ** flinks; /*!< File link(s) (from header) */
64 /*@owned@*/ const char ** flangs; /*!< File lang(s) */
65 int_32 * dil; /*!< Directory indice(s) (from header) */
66 const uint_32 * fflags; /*!< File flag(s) (from header) */
67 const uint_32 * fsizes; /*!< File size(s) (from header) */
68 const uint_32 * fmtimes; /*!< File modification time(s) (from header) */
69 /* XXX setuid/setgid bits are turned off if fuser/fgroup doesn't map. */
70 uint_16 * fmodes; /*!< File mode(s) (from header) */
71 uint_16 * frdevs; /*!< File rdev(s) (from header) */
73 /*@owned@*/ const char ** fuser; /*!< File owner(s) */
74 /*@owned@*/ const char ** fgroup; /*!< File group(s) */
75 /*@owned@*/ /*@null@*/ uid_t * fuids; /*!< File uid(s) */
76 /*@owned@*/ /*@null@*/ gid_t * fgids; /*!< File gid(s) */
78 /*@only@*/ /*@null@*/ char * fstates; /*!< File state(s) (from header) */
80 int fc; /*!< No. of files. */
81 int dc; /*!< No. of directories. */
83 /*@owned@*/ const char ** obnl; /*!< Original base name(s) (from header) */
84 /*@owned@*/ const char ** odnl; /*!< Original directory name(s) (from header) */
85 /*@unused@*/ int_32 * odil; /*!< Original directory indice(s) (from header) */
86 int bnlmax; /*!< Length (in bytes) of longest base name. */
87 int dnlmax; /*!< Length (in bytes) of longest dir name. */
90 unsigned int archiveSize;
91 mode_t dperms; /*!< Directory perms (0755) if not mapped. */
92 mode_t fperms; /*!< File perms (0644) if not mapped. */
93 /*@only@*/ /*@null@*/ const char ** apath;
95 /*@owned@*/ /*@null@*/ int * fmapflags;
100 #define TFIMAGIC 0x09697923
101 /*@owned@*/ FSM_t fsm; /*!< File state machine data. */
103 int keep_header; /*!< Keep header? */
105 /*@owned@*/ struct sharedFileInfo * replaced; /*!< (TR_ADDED) */
106 /*@owned@*/ uint_32 * replacedSizes; /*!< (TR_ADDED) */
108 unsigned int record; /*!< (TR_REMOVED) */
110 /*@refs@*/ int nrefs; /*!< Reference count. */
116 #define PSM_VERBOSE 0x8000
117 #define PSM_INTERNAL 0x4000
118 #define PSM_SYSCALL 0x2000
119 #define PSM_DEAD 0x1000
120 #define _fv(_a) ((_a) | PSM_VERBOSE)
121 #define _fi(_a) ((_a) | PSM_INTERNAL)
122 #define _fs(_a) ((_a) | (PSM_INTERNAL | PSM_SYSCALL))
123 #define _fd(_a) ((_a) | (PSM_INTERNAL | PSM_DEAD))
124 typedef enum pkgStage_e {
147 PSM_IMMED_TRIGGERS = 55,
148 PSM_RPMIO_FLAGS = 56,
152 PSM_RPMDB_REMOVE = 99,
164 rpmTransactionSet ts; /*!< transaction set */
166 TFI_t fi; /*!< transaction element file info */
167 FD_t cfd; /*!< Payload file handle. */
168 FD_t fd; /*!< Repackage file handle. */
169 Header oh; /*!< Repackage/multilib header. */
170 /*@null@*/ rpmdbMatchIterator mi;
171 /*@observer@*/ const char * stepName;
172 /*@only@*/ /*@null@*/ const char * rpmio_flags;
173 /*@only@*/ /*@null@*/ const char * failedFile;
174 /*@only@*/ /*@null@*/ const char * pkgURL; /*!< Repackage URL. */
175 /*@dependent@*/ const char * pkgfn; /*!< Repackage file name. */
176 int scriptTag; /*!< Scriptlet data tag. */
177 int progTag; /*!< Scriptlet interpreter tag. */
178 int npkgs_installed; /*!< No. of installed instances. */
179 int scriptArg; /*!< Scriptlet package arg. */
180 int sense; /*!< One of RPMSENSE_TRIGGER{IN,UN,POSTUN}. */
181 int countCorrection; /*!< 0 if installing, -1 if removing. */
182 int chrootDone; /*!< Was chroot(2) done by pkgStage? */
183 rpmCallbackType what; /*!< Callback type. */
184 unsigned long amount; /*!< Callback amount. */
185 unsigned long total; /*!< Callback total. */
188 /*@unused@*/ pkgStage stage;
196 * Return (malloc'd) transaction element name-version-release string.
197 * @param fi transaction element file info
198 * @return name-version-release string
200 /*@only@*/ /*@null@*/
201 char * fiGetNEVR(/*@null@*/const TFI_t fi)
205 * Return file type from mode_t.
206 * @param mode file mode bits (from header)
209 fileTypes whatis(uint_16 mode)
213 * Relocate files in header.
214 * @todo multilib file dispositions need to be checked.
215 * @param ts transaction set
216 * @param fi transaction element file info
217 * @param origH package header
218 * @param actions file dispositions
219 * @return header with relocated files
221 Header relocateFileList(const rpmTransactionSet ts, TFI_t fi,
222 Header origH, fileAction * actions)
223 /*@modifies ts, fi, origH, actions @*/;
226 * Load data from header into transaction file element info.
227 * @param ts transaction set
228 * @param fi transaction element file info
230 * @param keep_header use header memory?
232 void loadFi(/*@null@*/ const rpmTransactionSet ts, TFI_t fi,
233 Header h, int keep_header)
234 /*@modifies ts, fi, h @*/;
237 * Destroy transaction element file info.
238 * @param fi transaction element file info
240 void freeFi(TFI_t fi)
244 * Retrieve key from transaction element file info
245 * @param fi transaction element file info
246 * @return transaction element file info key
248 /*@null@*/ const void * rpmfiGetKey(TFI_t fi)
252 * Return formatted string representation of package disposition.
253 * @param a package dispostion
254 * @return formatted string
256 /*@observer@*/ const char *const fiTypeString(/*@partial@*/TFI_t fi)
260 * Package state machine driver.
261 * @param psm package state machine data
262 * @param stage next stage
263 * @return 0 on success
265 int psmStage(PSM_t psm, pkgStage stage)
266 /*@globals rpmGlobalMacroContext,
267 fileSystem, internalState @*/
268 /*@modifies psm, rpmGlobalMacroContext, fileSystem, internalState @*/;