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 npreds; /*!< No. of predecessors. */
87 int tree; /*!< Tree index. */
88 int depth; /*!< Depth in dependency tree. */
89 int breadth; /*!< Breadth in dependency tree. */
90 unsigned int db_instance; /*!< Database Instance after add */
92 tsortInfo tsi; /*!< Dependency ordering chains. */
94 /*@refcounted@*/ /*@null@*/
95 rpmds this; /*!< This package's provided NEVR. */
96 /*@refcounted@*/ /*@null@*/
97 rpmds provides; /*!< Provides: dependencies. */
98 /*@refcounted@*/ /*@null@*/
99 rpmds requires; /*!< Requires: dependencies. */
100 /*@refcounted@*/ /*@null@*/
101 rpmds conflicts; /*!< Conflicts: dependencies. */
102 /*@refcounted@*/ /*@null@*/
103 rpmds obsoletes; /*!< Obsoletes: dependencies. */
104 /*@refcounted@*/ /*@null@*/
105 rpmfi fi; /*!< File information. */
107 uint_32 color; /*!< Color bit(s) from package dependencies. */
108 uint_32 pkgFileSize; /*!< No. of bytes in package file (approx). */
110 /*@exposed@*/ /*@dependent@*/ /*@null@*/
111 fnpyKey key; /*!< (TR_ADDED) Retrieval key. */
112 /*@owned@*/ /*@null@*/
113 rpmRelocation * relocs; /*!< (TR_ADDED) Payload file relocations. */
114 int nrelocs; /*!< (TR_ADDED) No. of relocations. */
115 int autorelocatex; /*!< (TR_ADDED) Auto relocation entry index. */
116 /*@refcounted@*/ /*@null@*/
117 FD_t fd; /*!< (TR_ADDED) Payload file descriptor. */
119 /*@-fielduse@*/ /* LCL: confused by union? */
121 /*@exposed@*/ /*@dependent@*/ /*@null@*/
124 /*@exposed@*/ /*@dependent@*/ /*@null@*/
134 * Iterator across transaction elements, forward on install, backward on erase.
138 rpmts ts; /*!< transaction set. */
139 int reverse; /*!< reversed traversal? */
140 int ocsave; /*!< last returned iterator index. */
141 int oc; /*!< iterator index. */
144 #endif /* _RPMTE_INTERNAL */
151 * Destroy a transaction element.
152 * @param te transaction element
153 * @return NULL always
156 rpmte rpmteFree(/*@only@*/ /*@null@*/ rpmte te)
157 /*@globals fileSystem @*/
158 /*@modifies te, fileSystem @*/;
161 * Create a transaction element.
162 * @param ts transaction set
164 * @param type TR_ADDED/TR_REMOVED
165 * @param key (TR_ADDED) package retrieval key (e.g. file name)
166 * @param relocs (TR_ADDED) package file relocations
167 * @param dboffset (TR_REMOVED) rpmdb instance
168 * @param pkgKey associated added package (if any)
169 * @return new transaction element
171 /*@only@*/ /*@null@*/
172 rpmte rpmteNew(const rpmts ts, Header h, rpmElementType type,
173 /*@exposed@*/ /*@dependent@*/ /*@null@*/ fnpyKey key,
174 /*@null@*/ rpmRelocation * relocs,
176 /*@exposed@*/ /*@dependent@*/ /*@null@*/ alKey pkgKey)
177 /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
178 /*@modifies ts, h, rpmGlobalMacroContext, fileSystem, internalState @*/;
181 * Retrieve header from transaction element.
182 * @param te transaction element
185 extern Header rpmteHeader(rpmte te)
189 * Save header into transaction element.
190 * @param te transaction element
192 * @return NULL always
194 extern Header rpmteSetHeader(rpmte te, Header h)
195 /*@modifies te, h @*/;
198 * Retrieve type of transaction element.
199 * @param te transaction element
202 rpmElementType rpmteType(rpmte te)
206 * Retrieve name string of transaction element.
207 * @param te transaction element
208 * @return name string
211 extern const char * rpmteN(rpmte te)
215 * Retrieve epoch string of transaction element.
216 * @param te transaction element
217 * @return epoch string
219 /*@observer@*/ /*@null@*/
220 extern const char * rpmteE(rpmte te)
224 * Retrieve version string of transaction element.
225 * @param te transaction element
226 * @return version string
228 /*@observer@*/ /*@null@*/
229 extern const char * rpmteV(rpmte te)
233 * Retrieve release string of transaction element.
234 * @param te transaction element
235 * @return release string
237 /*@observer@*/ /*@null@*/
238 extern const char * rpmteR(rpmte te)
242 * Retrieve arch string of transaction element.
243 * @param te transaction element
244 * @return arch string
246 /*@observer@*/ /*@null@*/
247 extern const char * rpmteA(rpmte te)
251 * Retrieve os string of transaction element.
252 * @param te transaction element
255 /*@observer@*/ /*@null@*/
256 extern const char * rpmteO(rpmte te)
260 * Retrieve isSource attribute of transaction element.
261 * @param te transaction element
262 * @return isSource attribute
264 extern int rpmteIsSource(rpmte te)
268 * Retrieve color bits of transaction element.
269 * @param te transaction element
272 uint_32 rpmteColor(rpmte te)
276 * Set color bits of transaction element.
277 * @param te transaction element
278 * @param color new color bits
279 * @return previous color bits
281 uint_32 rpmteSetColor(rpmte te, uint_32 color)
285 * Retrieve last instance installed to the database.
286 * @param te transaction element
287 * @return last install instance.
289 unsigned int rpmteDBInstance(rpmte te)
293 * Set last instance installed to the database.
294 * @param te transaction element
295 * @param instance Database instance of last install element.
296 * @return last install instance.
298 void rpmteSetDBInstance(rpmte te, unsigned int instance)
302 * Retrieve size in bytes of package file.
303 * @todo Signature header is estimated at 256b.
304 * @param te transaction element
305 * @return size in bytes of package file.
307 uint_32 rpmtePkgFileSize(rpmte te)
311 * Retrieve dependency tree depth of transaction element.
312 * @param te transaction element
315 int rpmteDepth(rpmte te)
319 * Set dependency tree depth of transaction element.
320 * @param te transaction element
321 * @param ndepth new depth
322 * @return previous depth
324 int rpmteSetDepth(rpmte te, int ndepth)
328 * Retrieve dependency tree breadth of transaction element.
329 * @param te transaction element
332 int rpmteBreadth(rpmte te)
336 * Set dependency tree breadth of transaction element.
337 * @param te transaction element
338 * @param nbreadth new breadth
339 * @return previous breadth
341 int rpmteSetBreadth(rpmte te, int nbreadth)
345 * Retrieve tsort no. of predecessors of transaction element.
346 * @param te transaction element
347 * @return no. of predecessors
349 int rpmteNpreds(rpmte te)
353 * Set tsort no. of predecessors of transaction element.
354 * @param te transaction element
355 * @param npreds new no. of predecessors
356 * @return previous no. of predecessors
358 int rpmteSetNpreds(rpmte te, int npreds)
362 * Retrieve tree index of transaction element.
363 * @param te transaction element
366 int rpmteTree(rpmte te)
370 * Set tree index of transaction element.
371 * @param te transaction element
372 * @param ntree new tree index
373 * @return previous tree index
375 int rpmteSetTree(rpmte te, int ntree)
379 * Retrieve parent transaction element.
380 * @param te transaction element
381 * @return parent transaction element
383 /*@observer@*/ /*@unused@*/
384 rpmte rpmteParent(rpmte te)
388 * Set parent transaction element.
389 * @param te transaction element
390 * @param pte new parent transaction element
391 * @return previous parent transaction element
394 rpmte rpmteSetParent(rpmte te, rpmte pte)
398 * Retrieve number of children of transaction element.
399 * @param te transaction element
402 int rpmteDegree(rpmte te)
406 * Set number of children of transaction element.
407 * @param te transaction element
408 * @param ndegree new number of children
409 * @return previous number of children
411 int rpmteSetDegree(rpmte te, int ndegree)
415 * Retrieve tsort info for transaction element.
416 * @param te transaction element
419 tsortInfo rpmteTSI(rpmte te)
423 * Destroy tsort info of transaction element.
424 * @param te transaction element
426 void rpmteFreeTSI(rpmte te)
430 * Initialize tsort info of transaction element.
431 * @param te transaction element
433 void rpmteNewTSI(rpmte te)
437 * Destroy dependency set info of transaction element.
438 * @param te transaction element
441 void rpmteCleanDS(rpmte te)
445 * Retrieve pkgKey of TR_ADDED transaction element.
446 * @param te transaction element
449 /*@exposed@*/ /*@dependent@*/ /*@null@*/
450 alKey rpmteAddedKey(rpmte te)
454 * Set pkgKey of TR_ADDED transaction element.
455 * @param te transaction element
456 * @param npkgKey new pkgKey
457 * @return previous pkgKey
459 /*@exposed@*/ /*@dependent@*/ /*@null@*/
460 alKey rpmteSetAddedKey(rpmte te,
461 /*@exposed@*/ /*@dependent@*/ /*@null@*/ alKey npkgKey)
465 * Retrieve dependent pkgKey of TR_REMOVED transaction element.
466 * @param te transaction element
467 * @return dependent pkgKey
469 /*@exposed@*/ /*@dependent@*/ /*@null@*/
470 alKey rpmteDependsOnKey(rpmte te)
474 * Retrieve rpmdb instance of TR_REMOVED transaction element.
475 * @param te transaction element
476 * @return rpmdb instance
478 int rpmteDBOffset(rpmte te)
482 * Retrieve name-version-release string from transaction element.
483 * @param te transaction element
484 * @return name-version-release string
487 extern const char * rpmteNEVR(rpmte te)
491 * Retrieve name-version-release.arch string from transaction element.
492 * @param te transaction element
493 * @return name-version-release.arch string
497 extern const char * rpmteNEVRA(rpmte te)
502 * Retrieve file handle from transaction element.
503 * @param te transaction element
504 * @return file handle
506 FD_t rpmteFd(rpmte te)
510 * Retrieve key from transaction element.
511 * @param te transaction element
515 fnpyKey rpmteKey(rpmte te)
519 * Retrieve dependency tag set from transaction element.
520 * @param te transaction element
521 * @param tag dependency tag
522 * @return dependency tag set
524 rpmds rpmteDS(rpmte te, rpmTag tag)
528 * Retrieve file info tag set from transaction element.
529 * @param te transaction element
530 * @param tag file info tag (RPMTAG_BASENAMES)
531 * @return file info tag set
533 rpmfi rpmteFI(rpmte te, rpmTag tag)
537 * Calculate transaction element dependency colors/refs from file info.
538 * @param te transaction element
539 * @param tag dependency tag (RPMTAG_PROVIDENAME, RPMTAG_REQUIRENAME)
542 void rpmteColorDS(rpmte te, rpmTag tag)
547 * Return transaction element index.
548 * @param tsi transaction element iterator
549 * @return transaction element index
551 int rpmtsiOc(rpmtsi tsi)
555 * Destroy transaction element iterator.
556 * @param tsi transaction element iterator
557 * @return NULL always
559 /*@unused@*/ /*@null@*/
560 rpmtsi rpmtsiFree(/*@only@*//*@null@*/ rpmtsi tsi)
561 /*@globals fileSystem @*/
562 /*@modifies fileSystem @*/;
565 * Destroy transaction element iterator.
566 * @param tsi transaction element iterator
569 * @return NULL always
572 rpmtsi XrpmtsiFree(/*@only@*//*@null@*/ rpmtsi tsi,
573 const char * fn, unsigned int ln)
574 /*@globals fileSystem @*/
575 /*@modifies fileSystem @*/;
576 #define rpmtsiFree(_tsi) XrpmtsiFree(_tsi, __FILE__, __LINE__)
579 * Create transaction element iterator.
580 * @param ts transaction set
581 * @return transaction element iterator
583 /*@unused@*/ /*@only@*/
584 rpmtsi rpmtsiInit(rpmts ts)
588 * Create transaction element iterator.
589 * @param ts transaction set
592 * @return transaction element iterator
594 /*@unused@*/ /*@only@*/
595 rpmtsi XrpmtsiInit(rpmts ts,
596 const char * fn, unsigned int ln)
598 #define rpmtsiInit(_ts) XrpmtsiInit(_ts, __FILE__, __LINE__)
601 * Return next transaction element of type.
602 * @param tsi transaction element iterator
603 * @param type transaction element type selector (0 for any)
604 * @return next transaction element of type, NULL on termination
606 /*@dependent@*/ /*@null@*/
607 rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type)