4 /** \ingroup rpmts rpmte
6 * Structures used for an "rpmte" transaction element.
17 extern int _rpmte_debug;
20 * Transaction element ordering chain linkage.
22 typedef struct tsortInfo_s * tsortInfo;
25 * Transaction element iterator.
27 typedef struct rpmtsi_s * rpmtsi;
30 * Transaction element type.
32 typedef enum rpmElementType_e {
33 TR_ADDED = (1 << 0), /*!< Package will be installed. */
34 TR_REMOVED = (1 << 1) /*!< Package will be removed. */
37 #if defined(_RPMTE_INTERNAL)
39 * Dependncy ordering information.
46 #define tsi_count tsi_u.count
47 #define tsi_suc tsi_u.suc
48 struct tsortInfo_s * tsi_next;
55 * A single package instance to be installed/removed atomically.
58 rpmElementType type; /*!< Package disposition (installed/removed). */
60 Header h; /*!< Package header. */
61 const char * NEVR; /*!< Package name-version-release. */
62 const char * NEVRA; /*!< Package name-version-release.arch. */
63 const char * name; /*!< Name: */
65 char * version; /*!< Version: */
66 char * release; /*!< Release: */
67 const char * arch; /*!< Architecture hint. */
68 const char * os; /*!< Operating system hint. */
69 int archScore; /*!< (TR_ADDED) Arch score. */
70 int osScore; /*!< (TR_ADDED) Os score. */
71 int isSource; /*!< (TR_ADDED) source rpm? */
73 rpmte parent; /*!< Parent transaction element. */
74 int degree; /*!< No. of immediate children. */
75 int npreds; /*!< No. of predecessors. */
76 int tree; /*!< Tree index. */
77 int depth; /*!< Depth in dependency tree. */
78 int breadth; /*!< Breadth in dependency tree. */
79 unsigned int db_instance; /*!< Database Instance after add */
80 tsortInfo tsi; /*!< Dependency ordering chains. */
82 rpmds this; /*!< This package's provided NEVR. */
83 rpmds provides; /*!< Provides: dependencies. */
84 rpmds requires; /*!< Requires: dependencies. */
85 rpmds conflicts; /*!< Conflicts: dependencies. */
86 rpmds obsoletes; /*!< Obsoletes: dependencies. */
87 rpmfi fi; /*!< File information. */
89 uint_32 color; /*!< Color bit(s) from package dependencies. */
90 uint_32 pkgFileSize; /*!< No. of bytes in package file (approx). */
92 fnpyKey key; /*!< (TR_ADDED) Retrieval key. */
93 rpmRelocation * relocs; /*!< (TR_ADDED) Payload file relocations. */
94 int nrelocs; /*!< (TR_ADDED) No. of relocations. */
95 int autorelocatex; /*!< (TR_ADDED) Auto relocation entry index. */
96 FD_t fd; /*!< (TR_ADDED) Payload file descriptor. */
101 rpmalKey dependsOnKey;
109 * Iterator across transaction elements, forward on install, backward on erase.
112 rpmts ts; /*!< transaction set. */
113 int reverse; /*!< reversed traversal? */
114 int ocsave; /*!< last returned iterator index. */
115 int oc; /*!< iterator index. */
118 #endif /* _RPMTE_INTERNAL */
121 * Destroy a transaction element.
122 * @param te transaction element
123 * @return NULL always
125 rpmte rpmteFree(rpmte te);
128 * Create a transaction element.
129 * @param ts transaction set
131 * @param type TR_ADDED/TR_REMOVED
132 * @param key (TR_ADDED) package retrieval key (e.g. file name)
133 * @param relocs (TR_ADDED) package file relocations
134 * @param dboffset (TR_REMOVED) rpmdb instance
135 * @param pkgKey associated added package (if any)
136 * @return new transaction element
138 rpmte rpmteNew(const rpmts ts, Header h, rpmElementType type,
140 rpmRelocation * relocs,
145 * Retrieve header from transaction element.
146 * @param te transaction element
149 extern Header rpmteHeader(rpmte te);
152 * Save header into transaction element.
153 * @param te transaction element
155 * @return NULL always
157 extern Header rpmteSetHeader(rpmte te, Header h);
160 * Retrieve type of transaction element.
161 * @param te transaction element
164 rpmElementType rpmteType(rpmte te);
167 * Retrieve name string of transaction element.
168 * @param te transaction element
169 * @return name string
171 extern const char * rpmteN(rpmte te);
174 * Retrieve epoch string of transaction element.
175 * @param te transaction element
176 * @return epoch string
178 extern const char * rpmteE(rpmte te);
181 * Retrieve version string of transaction element.
182 * @param te transaction element
183 * @return version string
185 extern const char * rpmteV(rpmte te);
188 * Retrieve release string of transaction element.
189 * @param te transaction element
190 * @return release string
192 extern const char * rpmteR(rpmte te);
195 * Retrieve arch string of transaction element.
196 * @param te transaction element
197 * @return arch string
199 extern const char * rpmteA(rpmte te);
202 * Retrieve os string of transaction element.
203 * @param te transaction element
206 extern const char * rpmteO(rpmte te);
209 * Retrieve isSource attribute of transaction element.
210 * @param te transaction element
211 * @return isSource attribute
213 extern int rpmteIsSource(rpmte te);
216 * Retrieve color bits of transaction element.
217 * @param te transaction element
220 uint_32 rpmteColor(rpmte te);
223 * Set color bits of transaction element.
224 * @param te transaction element
225 * @param color new color bits
226 * @return previous color bits
228 uint_32 rpmteSetColor(rpmte te, uint_32 color);
231 * Retrieve last instance installed to the database.
232 * @param te transaction element
233 * @return last install instance.
235 unsigned int rpmteDBInstance(rpmte te);
238 * Set last instance installed to the database.
239 * @param te transaction element
240 * @param instance Database instance of last install element.
241 * @return last install instance.
243 void rpmteSetDBInstance(rpmte te, unsigned int instance);
246 * Retrieve size in bytes of package file.
247 * @todo Signature header is estimated at 256b.
248 * @param te transaction element
249 * @return size in bytes of package file.
251 uint_32 rpmtePkgFileSize(rpmte te);
254 * Retrieve dependency tree depth of transaction element.
255 * @param te transaction element
258 int rpmteDepth(rpmte te);
261 * Set dependency tree depth of transaction element.
262 * @param te transaction element
263 * @param ndepth new depth
264 * @return previous depth
266 int rpmteSetDepth(rpmte te, int ndepth);
269 * Retrieve dependency tree breadth of transaction element.
270 * @param te transaction element
273 int rpmteBreadth(rpmte te);
276 * Set dependency tree breadth of transaction element.
277 * @param te transaction element
278 * @param nbreadth new breadth
279 * @return previous breadth
281 int rpmteSetBreadth(rpmte te, int nbreadth);
284 * Retrieve tsort no. of predecessors of transaction element.
285 * @param te transaction element
286 * @return no. of predecessors
288 int rpmteNpreds(rpmte te);
291 * Set tsort no. of predecessors of transaction element.
292 * @param te transaction element
293 * @param npreds new no. of predecessors
294 * @return previous no. of predecessors
296 int rpmteSetNpreds(rpmte te, int npreds);
299 * Retrieve tree index of transaction element.
300 * @param te transaction element
303 int rpmteTree(rpmte te);
306 * Set tree index of transaction element.
307 * @param te transaction element
308 * @param ntree new tree index
309 * @return previous tree index
311 int rpmteSetTree(rpmte te, int ntree);
314 * Retrieve parent transaction element.
315 * @param te transaction element
316 * @return parent transaction element
318 rpmte rpmteParent(rpmte te);
321 * Set parent transaction element.
322 * @param te transaction element
323 * @param pte new parent transaction element
324 * @return previous parent transaction element
326 rpmte rpmteSetParent(rpmte te, rpmte pte);
329 * Retrieve number of children of transaction element.
330 * @param te transaction element
333 int rpmteDegree(rpmte te);
336 * Set number of children of transaction element.
337 * @param te transaction element
338 * @param ndegree new number of children
339 * @return previous number of children
341 int rpmteSetDegree(rpmte te, int ndegree);
344 * Retrieve tsort info for transaction element.
345 * @param te transaction element
348 tsortInfo rpmteTSI(rpmte te);
351 * Destroy tsort info of transaction element.
352 * @param te transaction element
354 void rpmteFreeTSI(rpmte te);
357 * Initialize tsort info of transaction element.
358 * @param te transaction element
360 void rpmteNewTSI(rpmte te);
363 * Destroy dependency set info of transaction element.
364 * @param te transaction element
366 void rpmteCleanDS(rpmte te);
369 * Retrieve pkgKey of TR_ADDED transaction element.
370 * @param te transaction element
373 rpmalKey rpmteAddedKey(rpmte te);
376 * Set pkgKey of TR_ADDED transaction element.
377 * @param te transaction element
378 * @param npkgKey new pkgKey
379 * @return previous pkgKey
381 rpmalKey rpmteSetAddedKey(rpmte te,
385 * Retrieve dependent pkgKey of TR_REMOVED transaction element.
386 * @param te transaction element
387 * @return dependent pkgKey
389 rpmalKey rpmteDependsOnKey(rpmte te);
392 * Retrieve rpmdb instance of TR_REMOVED transaction element.
393 * @param te transaction element
394 * @return rpmdb instance
396 int rpmteDBOffset(rpmte te);
399 * Retrieve name-version-release string from transaction element.
400 * @param te transaction element
401 * @return name-version-release string
403 extern const char * rpmteNEVR(rpmte te);
406 * Retrieve name-version-release.arch string from transaction element.
407 * @param te transaction element
408 * @return name-version-release.arch string
410 extern const char * rpmteNEVRA(rpmte te);
413 * Retrieve file handle from transaction element.
414 * @param te transaction element
415 * @return file handle
417 FD_t rpmteFd(rpmte te);
420 * Retrieve key from transaction element.
421 * @param te transaction element
424 fnpyKey rpmteKey(rpmte te);
427 * Retrieve dependency tag set from transaction element.
428 * @param te transaction element
429 * @param tag dependency tag
430 * @return dependency tag set
432 rpmds rpmteDS(rpmte te, rpmTag tag);
435 * Retrieve file info tag set from transaction element.
436 * @param te transaction element
437 * @param tag file info tag (RPMTAG_BASENAMES)
438 * @return file info tag set
440 rpmfi rpmteFI(rpmte te, rpmTag tag);
443 * Calculate transaction element dependency colors/refs from file info.
444 * @param te transaction element
445 * @param tag dependency tag (RPMTAG_PROVIDENAME, RPMTAG_REQUIRENAME)
447 void rpmteColorDS(rpmte te, rpmTag tag);
450 * Return transaction element index.
451 * @param tsi transaction element iterator
452 * @return transaction element index
454 int rpmtsiOc(rpmtsi tsi);
457 * Destroy transaction element iterator.
458 * @param tsi transaction element iterator
459 * @return NULL always
461 rpmtsi rpmtsiFree(rpmtsi tsi);
464 * Destroy transaction element iterator.
465 * @param tsi transaction element iterator
468 * @return NULL always
470 rpmtsi XrpmtsiFree(rpmtsi tsi,
471 const char * fn, unsigned int ln);
472 #define rpmtsiFree(_tsi) XrpmtsiFree(_tsi, __FILE__, __LINE__)
475 * Create transaction element iterator.
476 * @param ts transaction set
477 * @return transaction element iterator
479 rpmtsi rpmtsiInit(rpmts ts);
482 * Create transaction element iterator.
483 * @param ts transaction set
486 * @return transaction element iterator
488 rpmtsi XrpmtsiInit(rpmts ts,
489 const char * fn, unsigned int ln);
490 #define rpmtsiInit(_ts) XrpmtsiInit(_ts, __FILE__, __LINE__)
493 * Return next transaction element of type.
494 * @param tsi transaction element iterator
495 * @param type transaction element type selector (0 for any)
496 * @return next transaction element of type, NULL on termination
498 rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type);