4 /** \ingroup rpmts rpmte
6 * Structures used for an "rpmte" transaction element.
13 extern int _rpmte_debug;
17 * Transaction element ordering chain linkage.
19 typedef /*@abstract@*/ struct tsortInfo_s * tsortInfo;
22 * Transaction element iterator.
24 typedef /*@abstract@*/ struct rpmtsi_s * rpmtsi;
27 * Transaction element type.
29 typedef enum rpmElementType_e {
30 TR_ADDED = (1 << 0), /*!< Package will be installed. */
31 TR_REMOVED = (1 << 1) /*!< Package will be removed. */
34 #if defined(_RPMTE_INTERNAL)
36 * Dependncy ordering information.
38 /*@-fielduse@*/ /* LCL: confused by union? */
42 /*@exposed@*/ /*@dependent@*/ /*@null@*/
45 #define tsi_count tsi_u.count
46 #define tsi_suc tsi_u.suc
47 /*@owned@*/ /*@null@*/
48 struct tsortInfo_s * tsi_next;
49 /*@exposed@*/ /*@dependent@*/ /*@null@*/
57 * A single package instance to be installed/removed atomically.
60 rpmElementType type; /*!< Package disposition (installed/removed). */
62 /*@refcounted@*/ /*@relnull@*/
63 Header h; /*!< Package header. */
65 const char * NEVR; /*!< Package name-version-release. */
67 const char * NEVRA; /*!< Package name-version-release.arch. */
69 const char * name; /*!< Name: */
72 /*@dependent@*/ /*@null@*/
73 char * version; /*!< Version: */
74 /*@dependent@*/ /*@null@*/
75 char * release; /*!< Release: */
77 const char * arch; /*!< Architecture hint. */
79 const char * os; /*!< Operating system hint. */
80 int archScore; /*!< (TR_ADDED) Arch score. */
81 int osScore; /*!< (TR_ADDED) Os score. */
82 int isSource; /*!< (TR_ADDED) source rpm? */
84 rpmte parent; /*!< Parent transaction element. */
85 int degree; /*!< No. of immediate children. */
86 int depth; /*!< Max. depth in dependency tree. */
87 int npreds; /*!< No. of predecessors. */
88 int tree; /*!< Tree index. */
89 unsigned int db_instance; /*!< Database Instance after add */
91 tsortInfo tsi; /*!< Dependency ordering chains. */
93 /*@refcounted@*/ /*@null@*/
94 rpmds this; /*!< This package's provided NEVR. */
95 /*@refcounted@*/ /*@null@*/
96 rpmds provides; /*!< Provides: dependencies. */
97 /*@refcounted@*/ /*@null@*/
98 rpmds requires; /*!< Requires: dependencies. */
99 /*@refcounted@*/ /*@null@*/
100 rpmds conflicts; /*!< Conflicts: dependencies. */
101 /*@refcounted@*/ /*@null@*/
102 rpmds obsoletes; /*!< Obsoletes: dependencies. */
103 /*@refcounted@*/ /*@null@*/
104 rpmfi fi; /*!< File information. */
106 uint_32 color; /*!< Color bit(s) from package dependencies. */
107 uint_32 pkgFileSize; /*!< No. of bytes in package file (approx). */
109 /*@exposed@*/ /*@dependent@*/ /*@null@*/
110 fnpyKey key; /*!< (TR_ADDED) Retrieval key. */
111 /*@owned@*/ /*@null@*/
112 rpmRelocation * relocs; /*!< (TR_ADDED) Payload file relocations. */
113 int nrelocs; /*!< (TR_ADDED) No. of relocations. */
114 int autorelocatex; /*!< (TR_ADDED) Auto relocation entry index. */
115 /*@refcounted@*/ /*@null@*/
116 FD_t fd; /*!< (TR_ADDED) Payload file descriptor. */
118 /*@-fielduse@*/ /* LCL: confused by union? */
120 /*@exposed@*/ /*@dependent@*/ /*@null@*/
123 /*@exposed@*/ /*@dependent@*/ /*@null@*/
133 * Iterator across transaction elements, forward on install, backward on erase.
137 rpmts ts; /*!< transaction set. */
138 int reverse; /*!< reversed traversal? */
139 int ocsave; /*!< last returned iterator index. */
140 int oc; /*!< iterator index. */
143 #endif /* _RPMTE_INTERNAL */
150 * Destroy a transaction element.
151 * @param te transaction element
152 * @return NULL always
155 rpmte rpmteFree(/*@only@*/ /*@null@*/ rpmte te)
156 /*@globals fileSystem @*/
157 /*@modifies te, fileSystem @*/;
160 * Create a transaction element.
161 * @param ts transaction set
163 * @param type TR_ADDED/TR_REMOVED
164 * @param key (TR_ADDED) package retrieval key (e.g. file name)
165 * @param relocs (TR_ADDED) package file relocations
166 * @param dboffset (TR_REMOVED) rpmdb instance
167 * @param pkgKey associated added package (if any)
168 * @return new transaction element
170 /*@only@*/ /*@null@*/
171 rpmte rpmteNew(const rpmts ts, Header h, rpmElementType type,
172 /*@exposed@*/ /*@dependent@*/ /*@null@*/ fnpyKey key,
173 /*@null@*/ rpmRelocation * relocs,
175 /*@exposed@*/ /*@dependent@*/ /*@null@*/ alKey pkgKey)
176 /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
177 /*@modifies ts, h, rpmGlobalMacroContext, fileSystem, internalState @*/;
180 * Retrieve type of transaction element.
181 * @param te transaction element
184 rpmElementType rpmteType(rpmte te)
188 * Retrieve name string of transaction element.
189 * @param te transaction element
190 * @return name string
193 extern const char * rpmteN(rpmte te)
197 * Retrieve epoch string of transaction element.
198 * @param te transaction element
199 * @return epoch string
201 /*@observer@*/ /*@null@*/
202 extern const char * rpmteE(rpmte te)
206 * Retrieve version string of transaction element.
207 * @param te transaction element
208 * @return version string
210 /*@observer@*/ /*@null@*/
211 extern const char * rpmteV(rpmte te)
215 * Retrieve release string of transaction element.
216 * @param te transaction element
217 * @return release string
219 /*@observer@*/ /*@null@*/
220 extern const char * rpmteR(rpmte te)
224 * Retrieve arch string of transaction element.
225 * @param te transaction element
226 * @return arch string
228 /*@observer@*/ /*@null@*/
229 extern const char * rpmteA(rpmte te)
233 * Retrieve os string of transaction element.
234 * @param te transaction element
237 /*@observer@*/ /*@null@*/
238 extern const char * rpmteO(rpmte te)
242 * Retrieve color bits of transaction element.
243 * @param te transaction element
246 uint_32 rpmteColor(rpmte te)
250 * Set color bits of transaction element.
251 * @param te transaction element
252 * @param color new color bits
253 * @return previous color bits
255 uint_32 rpmteSetColor(rpmte te, uint_32 color)
259 * Retrieve last instance installed to the database.
260 * @param te transaction element
261 * @return last install instance.
263 unsigned int rpmteDBInstance(rpmte te)
267 * Set last instance installed to the database.
268 * @param te transaction element
269 * @param instance Database instance of last install element.
270 * @return last install instance.
272 void rpmteSetDBInstance(rpmte te, unsigned int instance)
276 * Retrieve size in bytes of package file.
277 * @todo Signature header is estimated at 256b.
278 * @param te transaction element
279 * @return size in bytes of package file.
281 uint_32 rpmtePkgFileSize(rpmte te)
285 * Retrieve tsort tree depth of transaction element.
286 * @param te transaction element
289 int rpmteDepth(rpmte te)
293 * Set tsort tree depth of transaction element.
294 * @param te transaction element
295 * @param ndepth new depth
296 * @return previous depth
298 int rpmteSetDepth(rpmte te, int ndepth)
302 * Retrieve tsort no. of predecessors of transaction element.
303 * @param te transaction element
304 * @return no. of predecessors
306 int rpmteNpreds(rpmte te)
310 * Set tsort no. of predecessors of transaction element.
311 * @param te transaction element
312 * @param npreds new no. of predecessors
313 * @return previous no. of predecessors
315 int rpmteSetNpreds(rpmte te, int npreds)
319 * Retrieve tree index of transaction element.
320 * @param te transaction element
323 int rpmteTree(rpmte te)
327 * Set tree index of transaction element.
328 * @param te transaction element
329 * @param ntree new tree index
330 * @return previous tree index
332 int rpmteSetTree(rpmte te, int ntree)
336 * Retrieve parent transaction element.
337 * @param te transaction element
338 * @return parent transaction element
340 /*@observer@*/ /*@unused@*/
341 rpmte rpmteParent(rpmte te)
345 * Set parent transaction element.
346 * @param te transaction element
347 * @param pte new parent transaction element
348 * @return previous parent transaction element
351 rpmte rpmteSetParent(rpmte te, rpmte pte)
355 * Retrieve number of children of transaction element.
356 * @param te transaction element
359 int rpmteDegree(rpmte te)
363 * Set number of children of transaction element.
364 * @param te transaction element
365 * @param ndegree new number of children
366 * @return previous number of children
368 int rpmteSetDegree(rpmte te, int ndegree)
372 * Retrieve tsort info for transaction element.
373 * @param te transaction element
376 tsortInfo rpmteTSI(rpmte te)
380 * Destroy tsort info of transaction element.
381 * @param te transaction element
383 void rpmteFreeTSI(rpmte te)
387 * Initialize tsort info of transaction element.
388 * @param te transaction element
390 void rpmteNewTSI(rpmte te)
394 * Destroy dependency set info of transaction element.
395 * @param te transaction element
398 void rpmteCleanDS(rpmte te)
402 * Retrieve pkgKey of TR_ADDED transaction element.
403 * @param te transaction element
406 /*@exposed@*/ /*@dependent@*/ /*@null@*/
407 alKey rpmteAddedKey(rpmte te)
411 * Set pkgKey of TR_ADDED transaction element.
412 * @param te transaction element
413 * @param npkgKey new pkgKey
414 * @return previous pkgKey
416 /*@exposed@*/ /*@dependent@*/ /*@null@*/
417 alKey rpmteSetAddedKey(rpmte te,
418 /*@exposed@*/ /*@dependent@*/ /*@null@*/ alKey npkgKey)
422 * Retrieve dependent pkgKey of TR_REMOVED transaction element.
423 * @param te transaction element
424 * @return dependent pkgKey
426 /*@exposed@*/ /*@dependent@*/ /*@null@*/
427 alKey rpmteDependsOnKey(rpmte te)
431 * Retrieve rpmdb instance of TR_REMOVED transaction element.
432 * @param te transaction element
433 * @return rpmdb instance
435 int rpmteDBOffset(rpmte te)
439 * Retrieve name-version-release string from transaction element.
440 * @param te transaction element
441 * @return name-version-release string
444 extern const char * rpmteNEVR(rpmte te)
448 * Retrieve name-version-release.arch string from transaction element.
449 * @param te transaction element
450 * @return name-version-release.arch string
454 extern const char * rpmteNEVRA(rpmte te)
459 * Retrieve file handle from transaction element.
460 * @param te transaction element
461 * @return file handle
463 FD_t rpmteFd(rpmte te)
467 * Retrieve key from transaction element.
468 * @param te transaction element
472 fnpyKey rpmteKey(rpmte te)
476 * Retrieve dependency tag set from transaction element.
477 * @param te transaction element
478 * @param tag dependency tag
479 * @return dependency tag set
481 rpmds rpmteDS(rpmte te, rpmTag tag)
485 * Retrieve file info tag set from transaction element.
486 * @param te transaction element
487 * @param tag file info tag (RPMTAG_BASENAMES)
488 * @return file info tag set
490 rpmfi rpmteFI(rpmte te, rpmTag tag)
494 * Calculate transaction element dependency colors/refs from file info.
495 * @param te transaction element
496 * @param tag dependency tag (RPMTAG_PROVIDENAME, RPMTAG_REQUIRENAME)
499 void rpmteColorDS(rpmte te, rpmTag tag)
504 * Return transaction element index.
505 * @param tsi transaction element iterator
506 * @return transaction element index
508 int rpmtsiOc(rpmtsi tsi)
512 * Destroy transaction element iterator.
513 * @param tsi transaction element iterator
514 * @return NULL always
516 /*@unused@*/ /*@null@*/
517 rpmtsi rpmtsiFree(/*@only@*//*@null@*/ rpmtsi tsi)
518 /*@globals fileSystem @*/
519 /*@modifies fileSystem @*/;
522 * Destroy transaction element iterator.
523 * @param tsi transaction element iterator
526 * @return NULL always
529 rpmtsi XrpmtsiFree(/*@only@*//*@null@*/ rpmtsi tsi,
530 const char * fn, unsigned int ln)
531 /*@globals fileSystem @*/
532 /*@modifies fileSystem @*/;
533 #define rpmtsiFree(_tsi) XrpmtsiFree(_tsi, __FILE__, __LINE__)
536 * Create transaction element iterator.
537 * @param ts transaction set
538 * @return transaction element iterator
540 /*@unused@*/ /*@only@*/
541 rpmtsi rpmtsiInit(rpmts ts)
545 * Create transaction element iterator.
546 * @param ts transaction set
549 * @return transaction element iterator
551 /*@unused@*/ /*@only@*/
552 rpmtsi XrpmtsiInit(rpmts ts,
553 const char * fn, unsigned int ln)
555 #define rpmtsiInit(_ts) XrpmtsiInit(_ts, __FILE__, __LINE__)
558 * Return next transaction element of type.
559 * @param tsi transaction element iterator
560 * @param type transaction element type selector (0 for any)
561 * @return next transaction element of type, NULL on termination
563 /*@dependent@*/ /*@null@*/
564 rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type)