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. */
83 rpmte parent; /*!< Parent transaction element. */
84 int degree; /*!< No. of immediate children. */
85 int depth; /*!< Max. depth in dependency tree. */
86 int npreds; /*!< No. of predecessors. */
87 int tree; /*!< Tree index. */
88 unsigned int db_instance; /*!< Database Instance after add */
90 tsortInfo tsi; /*!< Dependency ordering chains. */
92 /*@refcounted@*/ /*@null@*/
93 rpmds this; /*!< This package's provided NEVR. */
94 /*@refcounted@*/ /*@null@*/
95 rpmds provides; /*!< Provides: dependencies. */
96 /*@refcounted@*/ /*@null@*/
97 rpmds requires; /*!< Requires: dependencies. */
98 /*@refcounted@*/ /*@null@*/
99 rpmds conflicts; /*!< Conflicts: dependencies. */
100 /*@refcounted@*/ /*@null@*/
101 rpmds obsoletes; /*!< Obsoletes: dependencies. */
102 /*@refcounted@*/ /*@null@*/
103 rpmfi fi; /*!< File information. */
105 uint_32 color; /*!< Color bit(s) from package dependencies. */
106 uint_32 pkgFileSize; /*!< No. of bytes in package file (approx). */
108 /*@exposed@*/ /*@dependent@*/ /*@null@*/
109 fnpyKey key; /*!< (TR_ADDED) Retrieval key. */
110 /*@owned@*/ /*@null@*/
111 rpmRelocation * relocs; /*!< (TR_ADDED) Payload file relocations. */
112 int nrelocs; /*!< (TR_ADDED) No. of relocations. */
113 int autorelocatex; /*!< (TR_ADDED) Auto relocation entry index. */
114 /*@refcounted@*/ /*@null@*/
115 FD_t fd; /*!< (TR_ADDED) Payload file descriptor. */
117 /*@-fielduse@*/ /* LCL: confused by union? */
119 /*@exposed@*/ /*@dependent@*/ /*@null@*/
122 /*@exposed@*/ /*@dependent@*/ /*@null@*/
132 * Iterator across transaction elements, forward on install, backward on erase.
136 rpmts ts; /*!< transaction set. */
137 int reverse; /*!< reversed traversal? */
138 int ocsave; /*!< last returned iterator index. */
139 int oc; /*!< iterator index. */
142 #endif /* _RPMTE_INTERNAL */
149 * Destroy a transaction element.
150 * @param te transaction element
151 * @return NULL always
154 rpmte rpmteFree(/*@only@*/ /*@null@*/ rpmte te)
155 /*@globals fileSystem @*/
156 /*@modifies te, fileSystem @*/;
159 * Create a transaction element.
160 * @param ts transaction set
162 * @param type TR_ADDED/TR_REMOVED
163 * @param key (TR_ADDED) package retrieval key (e.g. file name)
164 * @param relocs (TR_ADDED) package file relocations
165 * @param dboffset (TR_REMOVED) rpmdb instance
166 * @param pkgKey associated added package (if any)
167 * @return new transaction element
169 /*@only@*/ /*@null@*/
170 rpmte rpmteNew(const rpmts ts, Header h, rpmElementType type,
171 /*@exposed@*/ /*@dependent@*/ /*@null@*/ fnpyKey key,
172 /*@null@*/ rpmRelocation * relocs,
174 /*@exposed@*/ /*@dependent@*/ /*@null@*/ alKey pkgKey)
175 /*@globals rpmGlobalMacroContext, h_errno, fileSystem @*/
176 /*@modifies ts, h, rpmGlobalMacroContext, fileSystem @*/;
179 * Retrieve type of transaction element.
180 * @param te transaction element
183 rpmElementType rpmteType(rpmte te)
187 * Retrieve name string of transaction element.
188 * @param te transaction element
189 * @return name string
192 extern const char * rpmteN(rpmte te)
196 * Retrieve epoch string of transaction element.
197 * @param te transaction element
198 * @return epoch string
200 /*@observer@*/ /*@null@*/
201 extern const char * rpmteE(rpmte te)
205 * Retrieve version string of transaction element.
206 * @param te transaction element
207 * @return version string
209 /*@observer@*/ /*@null@*/
210 extern const char * rpmteV(rpmte te)
214 * Retrieve release string of transaction element.
215 * @param te transaction element
216 * @return release string
218 /*@observer@*/ /*@null@*/
219 extern const char * rpmteR(rpmte te)
223 * Retrieve arch string of transaction element.
224 * @param te transaction element
225 * @return arch string
227 /*@observer@*/ /*@null@*/
228 extern const char * rpmteA(rpmte te)
232 * Retrieve os string of transaction element.
233 * @param te transaction element
236 /*@observer@*/ /*@null@*/
237 extern const char * rpmteO(rpmte te)
241 * Retrieve color bits of transaction element.
242 * @param te transaction element
245 uint_32 rpmteColor(rpmte te)
249 * Set color bits of transaction element.
250 * @param te transaction element
251 * @param color new color bits
252 * @return previous color bits
254 uint_32 rpmteSetColor(rpmte te, uint_32 color)
258 * Retrieve last instance installed to the database.
259 * @param te transaction element
260 * @return last install instance.
262 unsigned int rpmteDBInstance(rpmte te)
266 * Set last instance installed to the database.
267 * @param te transaction element
268 * @param instance Database instance of last install element.
269 * @return last install instance.
271 void rpmteSetDBInstance(rpmte te, unsigned int instance)
275 * Retrieve size in bytes of package file.
276 * @todo Signature header is estimated at 256b.
277 * @param te transaction element
278 * @return size in bytes of package file.
280 uint_32 rpmtePkgFileSize(rpmte te)
284 * Retrieve tsort tree depth of transaction element.
285 * @param te transaction element
288 int rpmteDepth(rpmte te)
292 * Set tsort tree depth of transaction element.
293 * @param te transaction element
294 * @param ndepth new depth
295 * @return previous depth
297 int rpmteSetDepth(rpmte te, int ndepth)
301 * Retrieve tsort no. of predecessors of transaction element.
302 * @param te transaction element
303 * @return no. of predecessors
305 int rpmteNpreds(rpmte te)
309 * Set tsort no. of predecessors of transaction element.
310 * @param te transaction element
311 * @param npreds new no. of predecessors
312 * @return previous no. of predecessors
314 int rpmteSetNpreds(rpmte te, int npreds)
318 * Retrieve tree index of transaction element.
319 * @param te transaction element
322 int rpmteTree(rpmte te)
326 * Set tree index of transaction element.
327 * @param te transaction element
328 * @param ntree new tree index
329 * @return previous tree index
331 int rpmteSetTree(rpmte te, int ntree)
335 * Retrieve parent transaction element.
336 * @param te transaction element
337 * @return parent transaction element
339 /*@observer@*/ /*@unused@*/
340 rpmte rpmteParent(rpmte te)
344 * Set parent transaction element.
345 * @param te transaction element
346 * @param pte new parent transaction element
347 * @return previous parent transaction element
350 rpmte rpmteSetParent(rpmte te, rpmte pte)
354 * Retrieve number of children of transaction element.
355 * @param te transaction element
358 int rpmteDegree(rpmte te)
362 * Set number of children of transaction element.
363 * @param te transaction element
364 * @param ndegree new number of children
365 * @return previous number of children
367 int rpmteSetDegree(rpmte te, int ndegree)
371 * Retrieve tsort info for transaction element.
372 * @param te transaction element
375 tsortInfo rpmteTSI(rpmte te)
379 * Destroy tsort info of transaction element.
380 * @param te transaction element
382 void rpmteFreeTSI(rpmte te)
386 * Initialize tsort info of transaction element.
387 * @param te transaction element
389 void rpmteNewTSI(rpmte te)
393 * Destroy dependency set info of transaction element.
394 * @param te transaction element
397 void rpmteCleanDS(rpmte te)
401 * Retrieve pkgKey of TR_ADDED transaction element.
402 * @param te transaction element
405 /*@exposed@*/ /*@dependent@*/ /*@null@*/
406 alKey rpmteAddedKey(rpmte te)
410 * Set pkgKey of TR_ADDED transaction element.
411 * @param te transaction element
412 * @param npkgKey new pkgKey
413 * @return previous pkgKey
415 /*@exposed@*/ /*@dependent@*/ /*@null@*/
416 alKey rpmteSetAddedKey(rpmte te,
417 /*@exposed@*/ /*@dependent@*/ /*@null@*/ alKey npkgKey)
421 * Retrieve dependent pkgKey of TR_REMOVED transaction element.
422 * @param te transaction element
423 * @return dependent pkgKey
425 /*@exposed@*/ /*@dependent@*/ /*@null@*/
426 alKey rpmteDependsOnKey(rpmte te)
430 * Retrieve rpmdb instance of TR_REMOVED transaction element.
431 * @param te transaction element
432 * @return rpmdb instance
434 int rpmteDBOffset(rpmte te)
438 * Retrieve name-version-release string from transaction element.
439 * @param te transaction element
440 * @return name-version-release string
443 extern const char * rpmteNEVR(rpmte te)
447 * Retrieve name-version-release.arch string from transaction element.
448 * @param te transaction element
449 * @return name-version-release.arch string
453 extern const char * rpmteNEVRA(rpmte te)
458 * Retrieve file handle from transaction element.
459 * @param te transaction element
460 * @return file handle
462 FD_t rpmteFd(rpmte te)
466 * Retrieve key from transaction element.
467 * @param te transaction element
471 fnpyKey rpmteKey(rpmte te)
475 * Retrieve dependency tag set from transaction element.
476 * @param te transaction element
477 * @param tag dependency tag
478 * @return dependency tag set
480 rpmds rpmteDS(rpmte te, rpmTag tag)
484 * Retrieve file info tag set from transaction element.
485 * @param te transaction element
486 * @param tag file info tag (RPMTAG_BASENAMES)
487 * @return file info tag set
489 rpmfi rpmteFI(rpmte te, rpmTag tag)
493 * Calculate transaction element dependency colors/refs from file info.
494 * @param te transaction element
495 * @param tag dependency tag (RPMTAG_PROVIDENAME, RPMTAG_REQUIRENAME)
498 void rpmteColorDS(rpmte te, rpmTag tag)
503 * Return transaction element index.
504 * @param tsi transaction element iterator
505 * @return transaction element index
507 int rpmtsiOc(rpmtsi tsi)
511 * Destroy transaction element iterator.
512 * @param tsi transaction element iterator
513 * @return NULL always
515 /*@unused@*/ /*@null@*/
516 rpmtsi rpmtsiFree(/*@only@*//*@null@*/ rpmtsi tsi)
517 /*@globals fileSystem @*/
518 /*@modifies fileSystem @*/;
521 * Destroy transaction element iterator.
522 * @param tsi transaction element iterator
525 * @return NULL always
528 rpmtsi XrpmtsiFree(/*@only@*//*@null@*/ rpmtsi tsi,
529 const char * fn, unsigned int ln)
530 /*@globals fileSystem @*/
531 /*@modifies fileSystem @*/;
532 #define rpmtsiFree(_tsi) XrpmtsiFree(_tsi, __FILE__, __LINE__)
535 * Create transaction element iterator.
536 * @param ts transaction set
537 * @return transaction element iterator
539 /*@unused@*/ /*@only@*/
540 rpmtsi rpmtsiInit(rpmts ts)
544 * Create transaction element iterator.
545 * @param ts transaction set
548 * @return transaction element iterator
550 /*@unused@*/ /*@only@*/
551 rpmtsi XrpmtsiInit(rpmts ts,
552 const char * fn, unsigned int ln)
554 #define rpmtsiInit(_ts) XrpmtsiInit(_ts, __FILE__, __LINE__)
557 * Return next transaction element of type.
558 * @param tsi transaction element iterator
559 * @param type transaction element type selector (0 for any)
560 * @return next transaction element of type, NULL on termination
562 /*@dependent@*/ /*@null@*/
563 rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type)