4 /** \ingroup rpmts rpmte
6 * Structures used for an "rpmte" transaction element.
11 extern int _rpmte_debug;
14 * Transaction element ordering chain linkage.
16 typedef struct tsortInfo_s * tsortInfo;
19 * Transaction element iterator.
21 typedef struct rpmtsi_s * rpmtsi;
24 * Transaction element type.
26 typedef enum rpmElementType_e {
27 TR_ADDED = (1 << 0), /*!< Package will be installed. */
28 TR_REMOVED = (1 << 1) /*!< Package will be removed. */
31 #if defined(_RPMTE_INTERNAL)
33 * Dependncy ordering information.
40 #define tsi_count tsi_u.count
41 #define tsi_suc tsi_u.suc
42 struct tsortInfo_s * tsi_next;
49 * A single package instance to be installed/removed atomically.
52 rpmElementType type; /*!< Package disposition (installed/removed). */
54 Header h; /*!< Package header. */
55 const char * NEVR; /*!< Package name-version-release. */
56 const char * NEVRA; /*!< Package name-version-release.arch. */
57 const char * name; /*!< Name: */
59 char * version; /*!< Version: */
60 char * release; /*!< Release: */
61 const char * arch; /*!< Architecture hint. */
62 const char * os; /*!< Operating system hint. */
63 int archScore; /*!< (TR_ADDED) Arch score. */
64 int osScore; /*!< (TR_ADDED) Os score. */
65 int isSource; /*!< (TR_ADDED) source rpm? */
67 rpmte parent; /*!< Parent transaction element. */
68 int degree; /*!< No. of immediate children. */
69 int npreds; /*!< No. of predecessors. */
70 int tree; /*!< Tree index. */
71 int depth; /*!< Depth in dependency tree. */
72 int breadth; /*!< Breadth in dependency tree. */
73 unsigned int db_instance; /*!< Database Instance after add */
74 tsortInfo tsi; /*!< Dependency ordering chains. */
76 rpmds this; /*!< This package's provided NEVR. */
77 rpmds provides; /*!< Provides: dependencies. */
78 rpmds requires; /*!< Requires: dependencies. */
79 rpmds conflicts; /*!< Conflicts: dependencies. */
80 rpmds obsoletes; /*!< Obsoletes: dependencies. */
81 rpmfi fi; /*!< File information. */
83 uint_32 color; /*!< Color bit(s) from package dependencies. */
84 uint_32 pkgFileSize; /*!< No. of bytes in package file (approx). */
86 fnpyKey key; /*!< (TR_ADDED) Retrieval key. */
87 rpmRelocation * relocs; /*!< (TR_ADDED) Payload file relocations. */
88 int nrelocs; /*!< (TR_ADDED) No. of relocations. */
89 int autorelocatex; /*!< (TR_ADDED) Auto relocation entry index. */
90 FD_t fd; /*!< (TR_ADDED) Payload file descriptor. */
103 * Iterator across transaction elements, forward on install, backward on erase.
106 rpmts ts; /*!< transaction set. */
107 int reverse; /*!< reversed traversal? */
108 int ocsave; /*!< last returned iterator index. */
109 int oc; /*!< iterator index. */
112 #endif /* _RPMTE_INTERNAL */
119 * Destroy a transaction element.
120 * @param te transaction element
121 * @return NULL always
123 rpmte rpmteFree(rpmte te);
126 * Create a transaction element.
127 * @param ts transaction set
129 * @param type TR_ADDED/TR_REMOVED
130 * @param key (TR_ADDED) package retrieval key (e.g. file name)
131 * @param relocs (TR_ADDED) package file relocations
132 * @param dboffset (TR_REMOVED) rpmdb instance
133 * @param pkgKey associated added package (if any)
134 * @return new transaction element
136 rpmte rpmteNew(const rpmts ts, Header h, rpmElementType type,
138 rpmRelocation * relocs,
143 * Retrieve header from transaction element.
144 * @param te transaction element
147 extern Header rpmteHeader(rpmte te);
150 * Save header into transaction element.
151 * @param te transaction element
153 * @return NULL always
155 extern Header rpmteSetHeader(rpmte te, Header h);
158 * Retrieve type of transaction element.
159 * @param te transaction element
162 rpmElementType rpmteType(rpmte te);
165 * Retrieve name string of transaction element.
166 * @param te transaction element
167 * @return name string
169 extern const char * rpmteN(rpmte te);
172 * Retrieve epoch string of transaction element.
173 * @param te transaction element
174 * @return epoch string
176 extern const char * rpmteE(rpmte te);
179 * Retrieve version string of transaction element.
180 * @param te transaction element
181 * @return version string
183 extern const char * rpmteV(rpmte te);
186 * Retrieve release string of transaction element.
187 * @param te transaction element
188 * @return release string
190 extern const char * rpmteR(rpmte te);
193 * Retrieve arch string of transaction element.
194 * @param te transaction element
195 * @return arch string
197 extern const char * rpmteA(rpmte te);
200 * Retrieve os string of transaction element.
201 * @param te transaction element
204 extern const char * rpmteO(rpmte te);
207 * Retrieve isSource attribute of transaction element.
208 * @param te transaction element
209 * @return isSource attribute
211 extern int rpmteIsSource(rpmte te);
214 * Retrieve color bits of transaction element.
215 * @param te transaction element
218 uint_32 rpmteColor(rpmte te);
221 * Set color bits of transaction element.
222 * @param te transaction element
223 * @param color new color bits
224 * @return previous color bits
226 uint_32 rpmteSetColor(rpmte te, uint_32 color);
229 * Retrieve last instance installed to the database.
230 * @param te transaction element
231 * @return last install instance.
233 unsigned int rpmteDBInstance(rpmte te);
236 * Set last instance installed to the database.
237 * @param te transaction element
238 * @param instance Database instance of last install element.
239 * @return last install instance.
241 void rpmteSetDBInstance(rpmte te, unsigned int instance);
244 * Retrieve size in bytes of package file.
245 * @todo Signature header is estimated at 256b.
246 * @param te transaction element
247 * @return size in bytes of package file.
249 uint_32 rpmtePkgFileSize(rpmte te);
252 * Retrieve dependency tree depth of transaction element.
253 * @param te transaction element
256 int rpmteDepth(rpmte te);
259 * Set dependency tree depth of transaction element.
260 * @param te transaction element
261 * @param ndepth new depth
262 * @return previous depth
264 int rpmteSetDepth(rpmte te, int ndepth);
267 * Retrieve dependency tree breadth of transaction element.
268 * @param te transaction element
271 int rpmteBreadth(rpmte te);
274 * Set dependency tree breadth of transaction element.
275 * @param te transaction element
276 * @param nbreadth new breadth
277 * @return previous breadth
279 int rpmteSetBreadth(rpmte te, int nbreadth);
282 * Retrieve tsort no. of predecessors of transaction element.
283 * @param te transaction element
284 * @return no. of predecessors
286 int rpmteNpreds(rpmte te);
289 * Set tsort no. of predecessors of transaction element.
290 * @param te transaction element
291 * @param npreds new no. of predecessors
292 * @return previous no. of predecessors
294 int rpmteSetNpreds(rpmte te, int npreds);
297 * Retrieve tree index of transaction element.
298 * @param te transaction element
301 int rpmteTree(rpmte te);
304 * Set tree index of transaction element.
305 * @param te transaction element
306 * @param ntree new tree index
307 * @return previous tree index
309 int rpmteSetTree(rpmte te, int ntree);
312 * Retrieve parent transaction element.
313 * @param te transaction element
314 * @return parent transaction element
316 rpmte rpmteParent(rpmte te);
319 * Set parent transaction element.
320 * @param te transaction element
321 * @param pte new parent transaction element
322 * @return previous parent transaction element
324 rpmte rpmteSetParent(rpmte te, rpmte pte);
327 * Retrieve number of children of transaction element.
328 * @param te transaction element
331 int rpmteDegree(rpmte te);
334 * Set number of children of transaction element.
335 * @param te transaction element
336 * @param ndegree new number of children
337 * @return previous number of children
339 int rpmteSetDegree(rpmte te, int ndegree);
342 * Retrieve tsort info for transaction element.
343 * @param te transaction element
346 tsortInfo rpmteTSI(rpmte te);
349 * Destroy tsort info of transaction element.
350 * @param te transaction element
352 void rpmteFreeTSI(rpmte te);
355 * Initialize tsort info of transaction element.
356 * @param te transaction element
358 void rpmteNewTSI(rpmte te);
361 * Destroy dependency set info of transaction element.
362 * @param te transaction element
364 void rpmteCleanDS(rpmte te);
367 * Retrieve pkgKey of TR_ADDED transaction element.
368 * @param te transaction element
371 alKey rpmteAddedKey(rpmte te);
374 * Set pkgKey of TR_ADDED transaction element.
375 * @param te transaction element
376 * @param npkgKey new pkgKey
377 * @return previous pkgKey
379 alKey rpmteSetAddedKey(rpmte te,
383 * Retrieve dependent pkgKey of TR_REMOVED transaction element.
384 * @param te transaction element
385 * @return dependent pkgKey
387 alKey rpmteDependsOnKey(rpmte te);
390 * Retrieve rpmdb instance of TR_REMOVED transaction element.
391 * @param te transaction element
392 * @return rpmdb instance
394 int rpmteDBOffset(rpmte te);
397 * Retrieve name-version-release string from transaction element.
398 * @param te transaction element
399 * @return name-version-release string
401 extern const char * rpmteNEVR(rpmte te);
404 * Retrieve name-version-release.arch string from transaction element.
405 * @param te transaction element
406 * @return name-version-release.arch string
408 extern const char * rpmteNEVRA(rpmte te);
411 * Retrieve file handle from transaction element.
412 * @param te transaction element
413 * @return file handle
415 FD_t rpmteFd(rpmte te);
418 * Retrieve key from transaction element.
419 * @param te transaction element
422 fnpyKey rpmteKey(rpmte te);
425 * Retrieve dependency tag set from transaction element.
426 * @param te transaction element
427 * @param tag dependency tag
428 * @return dependency tag set
430 rpmds rpmteDS(rpmte te, rpmTag tag);
433 * Retrieve file info tag set from transaction element.
434 * @param te transaction element
435 * @param tag file info tag (RPMTAG_BASENAMES)
436 * @return file info tag set
438 rpmfi rpmteFI(rpmte te, rpmTag tag);
441 * Calculate transaction element dependency colors/refs from file info.
442 * @param te transaction element
443 * @param tag dependency tag (RPMTAG_PROVIDENAME, RPMTAG_REQUIRENAME)
445 void rpmteColorDS(rpmte te, rpmTag tag);
448 * Return transaction element index.
449 * @param tsi transaction element iterator
450 * @return transaction element index
452 int rpmtsiOc(rpmtsi tsi);
455 * Destroy transaction element iterator.
456 * @param tsi transaction element iterator
457 * @return NULL always
459 rpmtsi rpmtsiFree(rpmtsi tsi);
462 * Destroy transaction element iterator.
463 * @param tsi transaction element iterator
466 * @return NULL always
468 rpmtsi XrpmtsiFree(rpmtsi tsi,
469 const char * fn, unsigned int ln);
470 #define rpmtsiFree(_tsi) XrpmtsiFree(_tsi, __FILE__, __LINE__)
473 * Create transaction element iterator.
474 * @param ts transaction set
475 * @return transaction element iterator
477 rpmtsi rpmtsiInit(rpmts ts);
480 * Create transaction element iterator.
481 * @param ts transaction set
484 * @return transaction element iterator
486 rpmtsi XrpmtsiInit(rpmts ts,
487 const char * fn, unsigned int ln);
488 #define rpmtsiInit(_ts) XrpmtsiInit(_ts, __FILE__, __LINE__)
491 * Return next transaction element of type.
492 * @param tsi transaction element iterator
493 * @param type transaction element type selector (0 for any)
494 * @return next transaction element of type, NULL on termination
496 rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type);