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 header from transaction element.
181 * @param te transaction element
184 extern Header rpmteHeader(rpmte te)
188 * Save header into transaction element.
189 * @param te transaction element
191 * @return NULL always
193 extern Header rpmteSetHeader(rpmte te, Header h)
194 /*@modifies te, h @*/;
197 * Retrieve type of transaction element.
198 * @param te transaction element
201 rpmElementType rpmteType(rpmte te)
205 * Retrieve name string of transaction element.
206 * @param te transaction element
207 * @return name string
210 extern const char * rpmteN(rpmte te)
214 * Retrieve epoch string of transaction element.
215 * @param te transaction element
216 * @return epoch string
218 /*@observer@*/ /*@null@*/
219 extern const char * rpmteE(rpmte te)
223 * Retrieve version string of transaction element.
224 * @param te transaction element
225 * @return version string
227 /*@observer@*/ /*@null@*/
228 extern const char * rpmteV(rpmte te)
232 * Retrieve release string of transaction element.
233 * @param te transaction element
234 * @return release string
236 /*@observer@*/ /*@null@*/
237 extern const char * rpmteR(rpmte te)
241 * Retrieve arch string of transaction element.
242 * @param te transaction element
243 * @return arch string
245 /*@observer@*/ /*@null@*/
246 extern const char * rpmteA(rpmte te)
250 * Retrieve os string of transaction element.
251 * @param te transaction element
254 /*@observer@*/ /*@null@*/
255 extern const char * rpmteO(rpmte te)
259 * Retrieve isSource attribute of transaction element.
260 * @param te transaction element
261 * @return isSource attribute
263 extern int rpmteIsSource(rpmte te)
267 * Retrieve color bits of transaction element.
268 * @param te transaction element
271 uint_32 rpmteColor(rpmte te)
275 * Set color bits of transaction element.
276 * @param te transaction element
277 * @param color new color bits
278 * @return previous color bits
280 uint_32 rpmteSetColor(rpmte te, uint_32 color)
284 * Retrieve last instance installed to the database.
285 * @param te transaction element
286 * @return last install instance.
288 unsigned int rpmteDBInstance(rpmte te)
292 * Set last instance installed to the database.
293 * @param te transaction element
294 * @param instance Database instance of last install element.
295 * @return last install instance.
297 void rpmteSetDBInstance(rpmte te, unsigned int instance)
301 * Retrieve size in bytes of package file.
302 * @todo Signature header is estimated at 256b.
303 * @param te transaction element
304 * @return size in bytes of package file.
306 uint_32 rpmtePkgFileSize(rpmte te)
310 * Retrieve tsort tree depth of transaction element.
311 * @param te transaction element
314 int rpmteDepth(rpmte te)
318 * Set tsort tree depth of transaction element.
319 * @param te transaction element
320 * @param ndepth new depth
321 * @return previous depth
323 int rpmteSetDepth(rpmte te, int ndepth)
327 * Retrieve tsort no. of predecessors of transaction element.
328 * @param te transaction element
329 * @return no. of predecessors
331 int rpmteNpreds(rpmte te)
335 * Set tsort no. of predecessors of transaction element.
336 * @param te transaction element
337 * @param npreds new no. of predecessors
338 * @return previous no. of predecessors
340 int rpmteSetNpreds(rpmte te, int npreds)
344 * Retrieve tree index of transaction element.
345 * @param te transaction element
348 int rpmteTree(rpmte te)
352 * Set tree index of transaction element.
353 * @param te transaction element
354 * @param ntree new tree index
355 * @return previous tree index
357 int rpmteSetTree(rpmte te, int ntree)
361 * Retrieve parent transaction element.
362 * @param te transaction element
363 * @return parent transaction element
365 /*@observer@*/ /*@unused@*/
366 rpmte rpmteParent(rpmte te)
370 * Set parent transaction element.
371 * @param te transaction element
372 * @param pte new parent transaction element
373 * @return previous parent transaction element
376 rpmte rpmteSetParent(rpmte te, rpmte pte)
380 * Retrieve number of children of transaction element.
381 * @param te transaction element
384 int rpmteDegree(rpmte te)
388 * Set number of children of transaction element.
389 * @param te transaction element
390 * @param ndegree new number of children
391 * @return previous number of children
393 int rpmteSetDegree(rpmte te, int ndegree)
397 * Retrieve tsort info for transaction element.
398 * @param te transaction element
401 tsortInfo rpmteTSI(rpmte te)
405 * Destroy tsort info of transaction element.
406 * @param te transaction element
408 void rpmteFreeTSI(rpmte te)
412 * Initialize tsort info of transaction element.
413 * @param te transaction element
415 void rpmteNewTSI(rpmte te)
419 * Destroy dependency set info of transaction element.
420 * @param te transaction element
423 void rpmteCleanDS(rpmte te)
427 * Retrieve pkgKey of TR_ADDED transaction element.
428 * @param te transaction element
431 /*@exposed@*/ /*@dependent@*/ /*@null@*/
432 alKey rpmteAddedKey(rpmte te)
436 * Set pkgKey of TR_ADDED transaction element.
437 * @param te transaction element
438 * @param npkgKey new pkgKey
439 * @return previous pkgKey
441 /*@exposed@*/ /*@dependent@*/ /*@null@*/
442 alKey rpmteSetAddedKey(rpmte te,
443 /*@exposed@*/ /*@dependent@*/ /*@null@*/ alKey npkgKey)
447 * Retrieve dependent pkgKey of TR_REMOVED transaction element.
448 * @param te transaction element
449 * @return dependent pkgKey
451 /*@exposed@*/ /*@dependent@*/ /*@null@*/
452 alKey rpmteDependsOnKey(rpmte te)
456 * Retrieve rpmdb instance of TR_REMOVED transaction element.
457 * @param te transaction element
458 * @return rpmdb instance
460 int rpmteDBOffset(rpmte te)
464 * Retrieve name-version-release string from transaction element.
465 * @param te transaction element
466 * @return name-version-release string
469 extern const char * rpmteNEVR(rpmte te)
473 * Retrieve name-version-release.arch string from transaction element.
474 * @param te transaction element
475 * @return name-version-release.arch string
479 extern const char * rpmteNEVRA(rpmte te)
484 * Retrieve file handle from transaction element.
485 * @param te transaction element
486 * @return file handle
488 FD_t rpmteFd(rpmte te)
492 * Retrieve key from transaction element.
493 * @param te transaction element
497 fnpyKey rpmteKey(rpmte te)
501 * Retrieve dependency tag set from transaction element.
502 * @param te transaction element
503 * @param tag dependency tag
504 * @return dependency tag set
506 rpmds rpmteDS(rpmte te, rpmTag tag)
510 * Retrieve file info tag set from transaction element.
511 * @param te transaction element
512 * @param tag file info tag (RPMTAG_BASENAMES)
513 * @return file info tag set
515 rpmfi rpmteFI(rpmte te, rpmTag tag)
519 * Calculate transaction element dependency colors/refs from file info.
520 * @param te transaction element
521 * @param tag dependency tag (RPMTAG_PROVIDENAME, RPMTAG_REQUIRENAME)
524 void rpmteColorDS(rpmte te, rpmTag tag)
529 * Return transaction element index.
530 * @param tsi transaction element iterator
531 * @return transaction element index
533 int rpmtsiOc(rpmtsi tsi)
537 * Destroy transaction element iterator.
538 * @param tsi transaction element iterator
539 * @return NULL always
541 /*@unused@*/ /*@null@*/
542 rpmtsi rpmtsiFree(/*@only@*//*@null@*/ rpmtsi tsi)
543 /*@globals fileSystem @*/
544 /*@modifies fileSystem @*/;
547 * Destroy transaction element iterator.
548 * @param tsi transaction element iterator
551 * @return NULL always
554 rpmtsi XrpmtsiFree(/*@only@*//*@null@*/ rpmtsi tsi,
555 const char * fn, unsigned int ln)
556 /*@globals fileSystem @*/
557 /*@modifies fileSystem @*/;
558 #define rpmtsiFree(_tsi) XrpmtsiFree(_tsi, __FILE__, __LINE__)
561 * Create transaction element iterator.
562 * @param ts transaction set
563 * @return transaction element iterator
565 /*@unused@*/ /*@only@*/
566 rpmtsi rpmtsiInit(rpmts ts)
570 * Create transaction element iterator.
571 * @param ts transaction set
574 * @return transaction element iterator
576 /*@unused@*/ /*@only@*/
577 rpmtsi XrpmtsiInit(rpmts ts,
578 const char * fn, unsigned int ln)
580 #define rpmtsiInit(_ts) XrpmtsiInit(_ts, __FILE__, __LINE__)
583 * Return next transaction element of type.
584 * @param tsi transaction element iterator
585 * @param type transaction element type selector (0 for any)
586 * @return next transaction element of type, NULL on termination
588 /*@dependent@*/ /*@null@*/
589 rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type)