c00609d575b6a189f3eda5e714fed4980a560586
[platform/upstream/rpm.git] / lib / rpmts.h
1 #ifndef H_RPMTS
2 #define H_RPMTS
3
4 /** \ingroup rpmts
5  * \file lib/rpmts.h
6  * Structures and prototypes used for an "rpmts" transaction set.
7  */
8
9 #include "rpmps.h"
10 #include "rpmsw.h"
11
12 /*@-exportlocal@*/
13 /*@unchecked@*/
14 extern int _rpmts_debug;
15 /*@unchecked@*/
16 extern int _rpmts_stats;
17 /*@unchecked@*/
18 extern int _fps_debug;
19 /*@=exportlocal@*/
20
21 /**
22  * Bit(s) to control digest and signature verification.
23  */
24 typedef enum rpmVSFlags_e {
25     RPMVSF_DEFAULT      = 0,
26     RPMVSF_NOHDRCHK     = (1 <<  0),
27     RPMVSF_NEEDPAYLOAD  = (1 <<  1),
28     /* bit(s) 2-7 unused */
29     RPMVSF_NOSHA1HEADER = (1 <<  8),
30     RPMVSF_NOMD5HEADER  = (1 <<  9),    /* unimplemented */
31     RPMVSF_NODSAHEADER  = (1 << 10),
32     RPMVSF_NORSAHEADER  = (1 << 11),    /* unimplemented */
33     /* bit(s) 12-15 unused */
34     RPMVSF_NOSHA1       = (1 << 16),    /* unimplemented */
35     RPMVSF_NOMD5        = (1 << 17),
36     RPMVSF_NODSA        = (1 << 18),
37     RPMVSF_NORSA        = (1 << 19)
38     /* bit(s) 16-31 unused */
39 } rpmVSFlags;
40
41 #define _RPMVSF_NODIGESTS       \
42   ( RPMVSF_NOSHA1HEADER |       \
43     RPMVSF_NOMD5HEADER |        \
44     RPMVSF_NOSHA1 |             \
45     RPMVSF_NOMD5 )
46
47 #define _RPMVSF_NOSIGNATURES    \
48   ( RPMVSF_NODSAHEADER |        \
49     RPMVSF_NORSAHEADER |        \
50     RPMVSF_NODSA |              \
51     RPMVSF_NORSA )
52
53 #define _RPMVSF_NOHEADER        \
54   ( RPMVSF_NOSHA1HEADER |       \
55     RPMVSF_NOMD5HEADER |        \
56     RPMVSF_NODSAHEADER |        \
57     RPMVSF_NORSAHEADER )
58
59 #define _RPMVSF_NOPAYLOAD       \
60   ( RPMVSF_NOSHA1 |             \
61     RPMVSF_NOMD5 |              \
62     RPMVSF_NODSA |              \
63     RPMVSF_NORSA )
64
65 /**
66  * Indices for timestamps.
67  */
68 typedef enum rpmtsOpX_e {
69     RPMTS_OP_TOTAL              =  0,
70     RPMTS_OP_CHECK              =  1,
71     RPMTS_OP_ORDER              =  2,
72     RPMTS_OP_FINGERPRINT        =  3,
73     RPMTS_OP_REPACKAGE          =  4,
74     RPMTS_OP_INSTALL            =  5,
75     RPMTS_OP_ERASE              =  6,
76     RPMTS_OP_SCRIPTLETS         =  7,
77     RPMTS_OP_COMPRESS           =  8,
78     RPMTS_OP_UNCOMPRESS         =  9,
79     RPMTS_OP_DIGEST             = 10,
80     RPMTS_OP_SIGNATURE          = 11,
81     RPMTS_OP_DBADD              = 12,
82     RPMTS_OP_DBREMOVE           = 13,
83     RPMTS_OP_DBGET              = 14,
84     RPMTS_OP_DBPUT              = 15,
85     RPMTS_OP_DBDEL              = 16,
86     RPMTS_OP_MAX                = 17
87 } rpmtsOpX;
88
89 #if defined(_RPMTS_INTERNAL)
90
91 #include "rpmhash.h"    /* XXX hashTable */
92 #include "rpmal.h"      /* XXX availablePackage/relocateFileList ,*/
93
94 /*@unchecked@*/
95 /*@-exportlocal@*/
96 extern int _cacheDependsRC;
97 /*@=exportlocal@*/
98
99 /** \ingroup rpmts
100  */
101 typedef /*@abstract@*/ struct diskspaceInfo_s * rpmDiskSpaceInfo;
102
103 /** \ingroup rpmts
104  */
105 struct diskspaceInfo_s {
106     dev_t dev;                  /*!< File system device number. */
107     signed long bneeded;        /*!< No. of blocks needed. */
108     signed long ineeded;        /*!< No. of inodes needed. */
109     int bsize;                  /*!< File system block size. */
110     signed long long bavail;    /*!< No. of blocks available. */
111     signed long long iavail;    /*!< No. of inodes available. */
112 };
113
114 /** \ingroup rpmts
115  * Adjust for root only reserved space. On linux e2fs, this is 5%.
116  */
117 #define adj_fs_blocks(_nb)      (((_nb) * 21) / 20)
118
119 /* argon thought a shift optimization here was a waste of time...  he's
120    probably right :-( */
121 #define BLOCK_ROUND(size, block) (((size) + (block) - 1) / (block))
122
123 /** \ingroup rpmts
124  */
125 typedef enum tsStage_e {
126     TSM_UNKNOWN         =  0,
127     TSM_INSTALL         =  7,
128     TSM_ERASE           =  8,
129 } tsmStage;
130
131 /** \ingroup rpmts
132  * The set of packages to be installed/removed atomically.
133  */
134 struct rpmts_s {
135     rpmtransFlags transFlags;   /*!< Bit(s) to control operation. */
136     tsmStage goal;              /*!< Transaction goal (i.e. mode) */
137
138 /*@refcounted@*/ /*@null@*/
139     rpmdb sdb;                  /*!< Solve database handle. */
140     int sdbmode;                /*!< Solve database open mode. */
141 /*@null@*/
142     int (*solve) (rpmts ts, rpmds key, const void * data)
143         /*@modifies ts @*/;     /*!< Search for NEVRA key. */
144 /*@relnull@*/
145     const void * solveData;     /*!< Solve callback data */
146     int nsuggests;              /*!< No. of depCheck suggestions. */
147 /*@only@*/ /*@null@*/
148     const void ** suggests;     /*!< Possible depCheck suggestions. */
149
150 /*@observer@*/ /*@null@*/
151     rpmCallbackFunction notify; /*!< Callback function. */
152 /*@observer@*/ /*@null@*/
153     rpmCallbackData notifyData; /*!< Callback private data. */
154
155 /*@refcounted@*/ /*@null@*/
156     rpmps probs;                /*!< Current problems in transaction. */
157     rpmprobFilterFlags ignoreSet;
158                                 /*!< Bits to filter current problems. */
159
160     int filesystemCount;        /*!< No. of mounted filesystems. */
161 /*@dependent@*/ /*@null@*/
162     const char ** filesystems;  /*!< Mounted filesystem names. */
163 /*@only@*/ /*@null@*/
164     rpmDiskSpaceInfo dsi;       /*!< Per filesystem disk/inode usage. */
165
166 /*@refcounted@*/ /*@null@*/
167     rpmdb rdb;                  /*!< Install database handle. */
168     int dbmode;                 /*!< Install database open mode. */
169 /*@only@*/
170     hashTable ht;               /*!< Fingerprint hash table. */
171
172 /*@only@*/ /*@null@*/
173     int * removedPackages;      /*!< Set of packages being removed. */
174     int numRemovedPackages;     /*!< No. removed package instances. */
175     int allocedRemovedPackages; /*!< Size of removed packages array. */
176
177 /*@only@*/
178     rpmal addedPackages;        /*!< Set of packages being installed. */
179     int numAddedPackages;       /*!< No. added package instances. */
180
181 #ifndef DYING
182 /*@only@*/
183     rpmal availablePackages;    /*!< Universe of available packages. */
184     int numAvailablePackages;   /*!< No. available package instances. */
185 #endif
186
187 /*@null@*/
188     rpmte relocateElement;      /*!< Element to use when relocating packages. */
189
190 /*@owned@*/ /*@relnull@*/
191     rpmte * order;              /*!< Packages sorted by dependencies. */
192     int orderCount;             /*!< No. of transaction elements. */
193     int orderAlloced;           /*!< No. of allocated transaction elements. */
194     int unorderedSuccessors;    /*!< Index of 1st element of successors. */
195
196     int chrootDone;             /*!< Has chroot(2) been been done? */
197 /*@only@*/ /*@null@*/
198     const char * rootDir;       /*!< Path to top of install tree. */
199 /*@only@*/ /*@null@*/
200     const char * currDir;       /*!< Current working directory. */
201 /*@null@*/
202     FD_t scriptFd;              /*!< Scriptlet stdout/stderr. */
203     int delta;                  /*!< Delta for reallocation. */
204     int_32 tid;                 /*!< Transaction id. */
205
206     uint_32 color;              /*!< Transaction color bits. */
207
208     rpmVSFlags vsflags;         /*!< Signature/digest verification flags. */
209
210 /*@observer@*/ /*@dependent@*/ /*@null@*/
211     const char * fn;            /*!< Current package fn. */
212     int_32  sigtag;             /*!< Current package signature tag. */
213     int_32  sigtype;            /*!< Current package signature data type. */
214 /*@null@*/
215     const void * sig;           /*!< Current package signature. */
216     int_32 siglen;              /*!< Current package signature length. */
217
218 /*@only@*/ /*@null@*/
219     const unsigned char * pkpkt;/*!< Current pubkey packet. */
220     size_t pkpktlen;            /*!< Current pubkey packet length. */
221     unsigned char pksignid[8];  /*!< Current pubkey fingerprint. */
222
223     struct rpmop_s ops[RPMTS_OP_MAX];
224
225 /*@null@*/
226     pgpDig dig;                 /*!< Current signature/pubkey parameters. */
227
228 /*@null@*/
229     Spec spec;                  /*!< Spec file control structure. */
230
231 /*@refs@*/
232     int nrefs;                  /*!< Reference count. */
233
234 };
235 #endif  /* _RPMTS_INTERNAL */
236
237 #ifdef __cplusplus
238 extern "C" {
239 #endif
240
241 /** \ingroup rpmts
242  * Check that all dependencies can be resolved.
243  * @param ts            transaction set
244  * @return              0 on success
245  */
246 int rpmtsCheck(rpmts ts)
247         /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
248         /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
249
250 /** \ingroup rpmts
251  * Determine package order in a transaction set according to dependencies.
252  *
253  * Order packages, returning error if circular dependencies cannot be
254  * eliminated by removing Requires's from the loop(s). Only dependencies from
255  * added or removed packages are used to determine ordering using a
256  * topological sort (Knuth vol. 1, p. 262). Use rpmtsCheck() to verify
257  * that all dependencies can be resolved.
258  *
259  * The final order ends up as installed packages followed by removed packages,
260  * with packages removed for upgrades immediately following the new package
261  * to be installed.
262  *
263  * @param ts            transaction set
264  * @return              no. of (added) packages that could not be ordered
265  */
266 int rpmtsOrder(rpmts ts)
267         /*@globals fileSystem, internalState@*/
268         /*@modifies ts, fileSystem, internalState @*/;
269
270 /** \ingroup rpmts
271  * Process all package elements in a transaction set.
272  *
273  * @param ts            transaction set
274  * @param okProbs       previously known problems (or NULL)
275  * @param ignoreSet     bits to filter problem types
276  * @return              0 on success, -1 on error, >0 with newProbs set
277  */
278 int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
279         /*@globals rpmGlobalMacroContext,
280                 fileSystem, internalState@*/
281         /*@modifies ts, rpmGlobalMacroContext,
282                 fileSystem, internalState @*/;
283
284 /** \ingroup rpmts
285  * Unreference a transaction instance.
286  * @param ts            transaction set
287  * @param msg
288  * @return              NULL always
289  */
290 /*@unused@*/ /*@null@*/
291 rpmts rpmtsUnlink (/*@killref@*/ /*@only@*/ rpmts ts,
292                 const char * msg)
293         /*@modifies ts @*/;
294
295 /** @todo Remove debugging entry from the ABI. */
296 /*@-exportlocal@*/
297 /*@null@*/
298 rpmts XrpmtsUnlink (/*@killref@*/ /*@only@*/ rpmts ts,
299                 const char * msg, const char * fn, unsigned ln)
300         /*@modifies ts @*/;
301 /*@=exportlocal@*/
302 #define rpmtsUnlink(_ts, _msg)  XrpmtsUnlink(_ts, _msg, __FILE__, __LINE__)
303
304 /** \ingroup rpmts
305  * Reference a transaction set instance.
306  * @param ts            transaction set
307  * @param msg
308  * @return              new transaction set reference
309  */
310 /*@unused@*/
311 rpmts rpmtsLink (rpmts ts, const char * msg)
312         /*@modifies ts @*/;
313
314 /** @todo Remove debugging entry from the ABI. */
315 rpmts XrpmtsLink (rpmts ts,
316                 const char * msg, const char * fn, unsigned ln)
317         /*@modifies ts @*/;
318 #define rpmtsLink(_ts, _msg)    XrpmtsLink(_ts, _msg, __FILE__, __LINE__)
319
320 /** \ingroup rpmts
321  * Close the database used by the transaction.
322  * @param ts            transaction set
323  * @return              0 on success
324  */
325 int rpmtsCloseDB(rpmts ts)
326         /*@globals fileSystem @*/
327         /*@modifies ts, fileSystem @*/;
328
329 /** \ingroup rpmts
330  * Open the database used by the transaction.
331  * @param ts            transaction set
332  * @param dbmode        O_RDONLY or O_RDWR
333  * @return              0 on success
334  */
335 int rpmtsOpenDB(rpmts ts, int dbmode)
336         /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
337         /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
338
339 /** \ingroup rpmts
340  * Initialize the database used by the transaction.
341  * @deprecated An explicit rpmdbInit() is almost never needed.
342  * @param ts            transaction set
343  * @param dbmode        O_RDONLY or O_RDWR
344  * @return              0 on success
345  */
346 int rpmtsInitDB(rpmts ts, int dbmode)
347         /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
348         /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
349
350 /** \ingroup rpmts
351  * Rebuild the database used by the transaction.
352  * @param ts            transaction set
353  * @return              0 on success
354  */
355 int rpmtsRebuildDB(rpmts ts)
356         /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
357         /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
358
359 /** \ingroup rpmts
360  * Verify the database used by the transaction.
361  * @param ts            transaction set
362  * @return              0 on success
363  */
364 int rpmtsVerifyDB(rpmts ts)
365         /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
366         /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
367
368 /** \ingroup rpmts
369  * Return transaction database iterator.
370  * @param ts            transaction set
371  * @param rpmtag        rpm tag
372  * @param keyp          key data (NULL for sequential access)
373  * @param keylen        key data length (0 will use strlen(keyp))
374  * @return              NULL on failure
375  */
376 /*@only@*/ /*@null@*/
377 rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
378                         /*@null@*/ const void * keyp, size_t keylen)
379         /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
380         /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
381
382 /**
383  * Retrieve pubkey from rpm database.
384  * @param ts            rpm transaction
385  * @return              RPMRC_OK on success, RPMRC_NOKEY if not found
386  */
387 rpmRC rpmtsFindPubkey(rpmts ts)
388         /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
389         /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState */;
390
391 /** \ingroup rpmts
392  * Close the database used by the transaction to solve dependencies.
393  * @param ts            transaction set
394  * @return              0 on success
395  */
396 /*@-exportlocal@*/
397 int rpmtsCloseSDB(rpmts ts)
398         /*@globals fileSystem @*/
399         /*@modifies ts, fileSystem @*/;
400 /*@=exportlocal@*/
401
402 /** \ingroup rpmts
403  * Open the database used by the transaction to solve dependencies.
404  * @param ts            transaction set
405  * @param dbmode        O_RDONLY or O_RDWR
406  * @return              0 on success
407  */
408 /*@-exportlocal@*/
409 int rpmtsOpenSDB(rpmts ts, int dbmode)
410         /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
411         /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
412 /*@=exportlocal@*/
413
414 /**
415  * Attempt to solve a needed dependency using the solve database.
416  * @param ts            transaction set
417  * @param ds            dependency set
418  * @param data          opaque data associated with callback
419  * @return              -1 retry, 0 ignore, 1 not found
420  */
421 /*@-exportlocal@*/
422 int rpmtsSolve(rpmts ts, rpmds ds, const void * data)
423         /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
424         /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
425 /*@=exportlocal@*/
426
427 /**
428  * Attempt to solve a needed dependency using memory resident tables.
429  * @deprecated This function will move from rpmlib to the python bindings.
430  * @param ts            transaction set
431  * @param ds            dependency set
432  * @return              0 if resolved (and added to ts), 1 not found
433  */
434 /*@unused@*/
435 int rpmtsAvailable(rpmts ts, const rpmds ds)
436         /*@globals fileSystem @*/
437         /*@modifies ts, fileSystem @*/;
438
439 /**
440  * Set dependency solver callback.
441  * @param ts            transaction set
442  * @param (*solve)      dependency solver callback
443  * @param solveData     dependency solver callback data (opaque)
444  * @return              0 on success
445  */
446 int rpmtsSetSolveCallback(rpmts ts,
447                 int (*solve) (rpmts ts, rpmds ds, const void * data),
448                 const void * solveData)
449         /*@modifies ts @*/;
450
451 /**
452  * Return current transaction set problems.
453  * @param ts            transaction set
454  * @return              current problem set (or NULL)
455  */
456 /*@null@*/
457 rpmps rpmtsProblems(rpmts ts)
458         /*@modifies ts @*/;
459
460 /** \ingroup rpmts
461  * Free signature verification data.
462  * @param ts            transaction set
463  */
464 void rpmtsCleanDig(rpmts ts)
465         /*@modifies ts @*/;
466
467 /** \ingroup rpmts
468  * Free memory needed only for dependency checks and ordering.
469  * @param ts            transaction set
470  */
471 void rpmtsClean(rpmts ts)
472         /*@globals fileSystem, internalState @*/
473         /*@modifies ts, fileSystem , internalState@*/;
474
475 /** \ingroup rpmts
476  * Re-create an empty transaction set.
477  * @param ts            transaction set
478  */
479 void rpmtsEmpty(rpmts ts)
480         /*@globals fileSystem, internalState @*/
481         /*@modifies ts, fileSystem, internalState @*/;
482
483 /** \ingroup rpmts
484  * Destroy transaction set, closing the database as well.
485  * @param ts            transaction set
486  * @return              NULL always
487  */
488 /*@null@*/
489 rpmts rpmtsFree(/*@killref@*/ /*@only@*//*@null@*/ rpmts ts)
490         /*@globals fileSystem, internalState @*/
491         /*@modifies ts, fileSystem, internalState @*/;
492
493 /** \ingroup rpmts
494  * Get verify signatures flag(s).
495  * @param ts            transaction set
496  * @return              verify signatures flags
497  */
498 rpmVSFlags rpmtsVSFlags(rpmts ts)
499         /*@*/;
500
501 /** \ingroup rpmts
502  * Set verify signatures flag(s).
503  * @param ts            transaction set
504  * @param vsflags       new verify signatures flags
505  * @return              previous value
506  */
507 rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags)
508         /*@modifies ts @*/;
509
510 /** \ingroup rpmts
511  * Set index of 1st element of successors.
512  * @param ts            transaction set
513  * @param first         new index of 1st element of successors
514  * @return              previous value
515  */
516 int rpmtsUnorderedSuccessors(rpmts ts, int first)
517         /*@modifies ts @*/;
518
519 /** \ingroup rpmts
520  * Get transaction rootDir, i.e. path to chroot(2).
521  * @param ts            transaction set
522  * @return              transaction rootDir
523  */
524 /*@observer@*/ /*@null@*/
525 extern const char * rpmtsRootDir(rpmts ts)
526         /*@*/;
527
528 /** \ingroup rpmts
529  * Set transaction rootDir, i.e. path to chroot(2).
530  * @param ts            transaction set
531  * @param rootDir       new transaction rootDir (or NULL)
532  */
533 void rpmtsSetRootDir(rpmts ts, /*@null@*/ const char * rootDir)
534         /*@modifies ts @*/;
535
536 /** \ingroup rpmts
537  * Get transaction currDir, i.e. current directory before chroot(2).
538  * @param ts            transaction set
539  * @return              transaction currDir
540  */
541 /*@observer@*/ /*@null@*/
542 extern const char * rpmtsCurrDir(rpmts ts)
543         /*@*/;
544
545 /** \ingroup rpmts
546  * Set transaction currDir, i.e. current directory before chroot(2).
547  * @param ts            transaction set
548  * @param currDir       new transaction currDir (or NULL)
549  */
550 void rpmtsSetCurrDir(rpmts ts, /*@null@*/ const char * currDir)
551         /*@modifies ts @*/;
552
553 /** \ingroup rpmts
554  * Get transaction script file handle, i.e. stdout/stderr on scriptlet execution
555  * @param ts            transaction set
556  * @return              transaction script file handle
557  */
558 /*@null@*/
559 FD_t rpmtsScriptFd(rpmts ts)
560         /*@*/;
561
562 /** \ingroup rpmts
563  * Set transaction script file handle, i.e. stdout/stderr on scriptlet execution
564  * @param ts            transaction set
565  * @param scriptFd      new script file handle (or NULL)
566  */
567 void rpmtsSetScriptFd(rpmts ts, /*@null@*/ FD_t scriptFd)
568         /*@modifies ts, scriptFd @*/;
569
570 /** \ingroup rpmts
571  * Get chrootDone flag, i.e. has chroot(2) been performed?
572  * @param ts            transaction set
573  * @return              chrootDone flag
574  */
575 int rpmtsChrootDone(rpmts ts)
576         /*@*/;
577
578 /** \ingroup rpmts
579  * Set chrootDone flag, i.e. has chroot(2) been performed?
580  * @param ts            transaction set
581  * @param chrootDone    new chrootDone flag
582  * @return              previous chrootDone flag
583  */
584 int rpmtsSetChrootDone(rpmts ts, int chrootDone)
585         /*@modifies ts @*/;
586
587 /** \ingroup rpmts
588  * Get transaction id, i.e. transaction time stamp.
589  * @param ts            transaction set
590  * @return              chrootDone flag
591  */
592 int_32 rpmtsGetTid(rpmts ts)
593         /*@*/;
594
595 /** \ingroup rpmts
596  * Set transaction id, i.e. transaction time stamp.
597  * @param ts            transaction set
598  * @param tid           new transaction id
599  * @return              previous transaction id
600  */
601 int_32 rpmtsSetTid(rpmts ts, int_32 tid)
602         /*@modifies ts @*/;
603
604 /** \ingroup rpmts
605  * Get signature tag.
606  * @param ts            transaction set
607  * @return              signature tag
608  */
609 int_32 rpmtsSigtag(const rpmts ts)
610         /*@*/;
611
612 /** \ingroup rpmts
613  * Get signature tag type.
614  * @param ts            transaction set
615  * @return              signature tag type
616  */
617 int_32 rpmtsSigtype(const rpmts ts)
618         /*@*/;
619
620 /** \ingroup rpmts
621  * Get signature tag data, i.e. from header.
622  * @param ts            transaction set
623  * @return              signature tag data
624  */
625 /*@observer@*/ /*@null@*/
626 extern const void * rpmtsSig(const rpmts ts)
627         /*@*/;
628
629 /** \ingroup rpmts
630  * Get signature tag data length, i.e. no. of bytes of data.
631  * @param ts            transaction set
632  * @return              signature tag data length
633  */
634 int_32 rpmtsSiglen(const rpmts ts)
635         /*@*/;
636
637 /** \ingroup rpmts
638  * Set signature tag info, i.e. from header.
639  * @param ts            transaction set
640  * @param sigtag        signature tag
641  * @param sigtype       signature tag type
642  * @param sig           signature tag data
643  * @param siglen        signature tag data length
644  * @return              0 always
645  */
646 int rpmtsSetSig(rpmts ts,
647                 int_32 sigtag, int_32 sigtype,
648                 /*@kept@*/ /*@null@*/ const void * sig, int_32 siglen)
649         /*@modifies ts @*/;
650
651 /** \ingroup rpmts
652  * Get OpenPGP packet parameters, i.e. signature/pubkey constants.
653  * @param ts            transaction set
654  * @return              signature/pubkey constants.
655  */
656 /*@exposed@*/ /*@null@*/
657 pgpDig rpmtsDig(rpmts ts)
658         /*@*/;
659
660 /** \ingroup rpmts
661  * Get OpenPGP signature constants.
662  * @param ts            transaction set
663  * @return              signature constants.
664  */
665 /*@exposed@*/ /*@null@*/
666 pgpDigParams rpmtsSignature(const rpmts ts)
667         /*@*/;
668
669 /** \ingroup rpmts
670  * Get OpenPGP pubkey constants.
671  * @param ts            transaction set
672  * @return              pubkey constants.
673  */
674 /*@exposed@*/ /*@null@*/
675 pgpDigParams rpmtsPubkey(const rpmts ts)
676         /*@*/;
677
678 /** \ingroup rpmts
679  * Get transaction set database handle.
680  * @param ts            transaction set
681  * @return              transaction database handle
682  */
683 /*@null@*/
684 rpmdb rpmtsGetRdb(rpmts ts)
685         /*@*/;
686
687 /** \ingroup rpmts
688  * Initialize disk space info for each and every mounted file systems.
689  * @param ts            transaction set
690  * @return              0 on success
691  */
692 int rpmtsInitDSI(const rpmts ts)
693         /*@globals fileSystem, internalState @*/
694         /*@modifies ts, fileSystem, internalState @*/;
695
696 /** \ingroup rpmts
697  * Update disk space info for a file.
698  * @param ts            transaction set
699  * @param dev           mount point device
700  * @param fileSize      file size
701  * @param prevSize      previous file size (if upgrading)
702  * @param fixupSize     size difference (if
703  * @param action        file disposition
704  */
705 void rpmtsUpdateDSI(const rpmts ts, dev_t dev,
706                 uint_32 fileSize, uint_32 prevSize, uint_32 fixupSize,
707                 fileAction action)
708         /*@modifies ts @*/;
709
710 /** \ingroup rpmts
711  * Check a transaction element for disk space problems.
712  * @param ts            transaction set
713  * @param te            current transaction element
714  */
715 void rpmtsCheckDSIProblems(const rpmts ts, const rpmte te)
716         /*@modifies ts @*/;
717
718 /**
719  * Perform transaction progress notify callback.
720  * @param ts            transaction set
721  * @param te            current transaction element
722  * @param what          type of call back
723  * @param amount        current value
724  * @param total         final value
725  * @return              callback dependent pointer
726  */
727 /*@null@*/
728 void * rpmtsNotify(rpmts ts, rpmte te,
729                 rpmCallbackType what, unsigned long amount, unsigned long total)
730         /*@*/;
731
732 /**
733  * Return number of (ordered) transaction set elements.
734  * @param ts            transaction set
735  * @return              no. of transaction set elements
736  */
737 int rpmtsNElements(rpmts ts)
738         /*@*/;
739
740 /**
741  * Return (ordered) transaction set element.
742  * @param ts            transaction set
743  * @param ix            transaction element index
744  * @return              transaction element (or NULL)
745  */
746 /*@null@*/ /*@dependent@*/
747 rpmte rpmtsElement(rpmts ts, int ix)
748         /*@*/;
749
750 /** \ingroup rpmts
751  * Get problem ignore bit mask, i.e. bits to filter encountered problems.
752  * @param ts            transaction set
753  * @return              ignore bit mask
754  */
755 rpmprobFilterFlags rpmtsFilterFlags(rpmts ts)
756         /*@*/;
757
758 /** \ingroup rpmts
759  * Get transaction flags, i.e. bits that control rpmtsRun().
760  * @param ts            transaction set
761  * @return              transaction flags
762  */
763 rpmtransFlags rpmtsFlags(rpmts ts)
764         /*@*/;
765
766 /** \ingroup rpmts
767  * Set transaction flags, i.e. bits that control rpmtsRun().
768  * @param ts            transaction set
769  * @param transFlags    new transaction flags
770  * @return              previous transaction flags
771  */
772 rpmtransFlags rpmtsSetFlags(rpmts ts, rpmtransFlags transFlags)
773         /*@modifies ts @*/;
774
775 /** \ingroup rpmts
776  * Get spec control structure from transaction set.
777  * @param ts            transaction set
778  * @return              spec control structure
779  */
780 /*@null@*/
781 Spec rpmtsSpec(rpmts ts)
782         /*@*/;
783
784 /** \ingroup rpmts
785  * Set a spec control structure in transaction set.
786  * @param ts            transaction set
787  * @param spec          new spec control structure
788  * @return              previous spec control structure
789  */
790 /*@null@*/
791 Spec rpmtsSetSpec(rpmts ts, /*@null@*/ Spec spec)
792         /*@modifies ts @*/;
793
794 /** \ingroup rpmts
795  * Get current relocate transaction element.
796  * @param ts            transaction set
797  * @return              current relocate transaction element
798  */
799 /*@null@*/
800 rpmte rpmtsRelocateElement(rpmts ts)
801         /*@*/;
802
803 /** \ingroup rpmts
804  * Set current relocate transaction element.
805  * @param ts            transaction set
806  * @param relocateElement new relocate transaction element
807  * @return              previous relocate transaction element
808  */
809 /*@null@*/
810 rpmte rpmtsSetRelocateElement(rpmts ts, /*@null@*/ rpmte relocateElement)
811         /*@modifies ts @*/;
812
813 /**
814  * Retrieve color bits of transaction set.
815  * @param ts            transaction set
816  * @return              color bits
817  */
818 uint_32 rpmtsColor(rpmts ts)
819         /*@*/;
820
821 /**
822  * Set color bits of transaction set.
823  * @param ts            transaction set
824  * @param color         new color bits
825  * @return              previous color bits
826  */
827 uint_32 rpmtsSetColor(rpmts ts, uint_32 color)
828         /*@modifies ts @*/;
829
830 /**
831  * Retrieve operation timestamp from a transaction set.
832  * @param ts            transaction set
833  * @param opx           operation timestamp index
834  * @return              pointer to operation timestamp.
835  */
836 /*@null@*/
837 rpmop rpmtsOp(rpmts ts, rpmtsOpX opx)
838         /*@*/;
839
840 /** \ingroup rpmts
841  * Set transaction notify callback function and argument.
842  *
843  * @warning This call must be made before rpmtsRun() for
844  *      install/upgrade/freshen to function correctly.
845  *
846  * @param ts            transaction set
847  * @param notify        progress callback
848  * @param notifyData    progress callback private data
849  * @return              0 on success
850  */
851 int rpmtsSetNotifyCallback(rpmts ts,
852                 /*@observer@*/ rpmCallbackFunction notify,
853                 /*@observer@*/ rpmCallbackData notifyData)
854         /*@modifies ts @*/;
855
856 /** \ingroup rpmts
857  * Create an empty transaction set.
858  * @return              new transaction set
859  */
860 /*@newref@*/
861 rpmts rpmtsCreate(void)
862         /*@globals rpmGlobalMacroContext, internalState @*/
863         /*@modifies rpmGlobalMacroContext, internalState @*/;
864
865 /** \ingroup rpmts
866  * Add package to be installed to transaction set.
867  *
868  * The transaction set is checked for duplicate package names.
869  * If found, the package with the "newest" EVR will be replaced.
870  *
871  * @param ts            transaction set
872  * @param h             header
873  * @param key           package retrieval key (e.g. file name)
874  * @param upgrade       is package being upgraded?
875  * @param relocs        package file relocations
876  * @return              0 on success, 1 on I/O error, 2 needs capabilities
877  */
878 int rpmtsAddInstallElement(rpmts ts, Header h,
879                 /*@exposed@*/ /*@null@*/ const fnpyKey key, int upgrade,
880                 /*@null@*/ rpmRelocation * relocs)
881         /*@globals rpmcliPackagesTotal, rpmGlobalMacroContext,
882                 fileSystem, internalState @*/
883         /*@modifies ts, h, rpmcliPackagesTotal, rpmGlobalMacroContext,
884                 fileSystem, internalState @*/;
885
886 /** \ingroup rpmts
887  * Add package to be erased to transaction set.
888  * @param ts            transaction set
889  * @param h             header
890  * @param dboffset      rpm database instance
891  * @return              0 on success
892  */
893 int rpmtsAddEraseElement(rpmts ts, Header h, int dboffset)
894         /*@globals fileSystem @*/
895         /*@modifies ts, h, fileSystem @*/;
896
897 /** \ingroup rpmts
898  * Retrieve keys from ordered transaction set.
899  * @todo Removed packages have no keys, returned as interleaved NULL pointers.
900  * @param ts            transaction set
901  * @retval ep           address of returned element array pointer (or NULL)
902  * @retval nep          address of no. of returned elements (or NULL)
903  * @return              0 always
904  */
905 /*@unused@*/
906 int rpmtsGetKeys(rpmts ts,
907                 /*@null@*/ /*@out@*/ fnpyKey ** ep,
908                 /*@null@*/ /*@out@*/ int * nep)
909         /*@globals fileSystem, internalState @*/
910         /*@modifies ts, ep, nep, fileSystem, internalState @*/;
911
912 /**
913  * Return (malloc'd) header name-version-release string.
914  * @param h             header
915  * @retval np           name tag value
916  * @return              name-version-release string
917  */
918 /*@only@*/ char * hGetNEVR(Header h, /*@null@*/ /*@out@*/ const char ** np )
919         /*@modifies *np @*/;
920
921 /**
922  * Return header color.
923  * @param h             header
924  * @return              header color
925  */
926 uint_32 hGetColor(Header h)
927         /*@modifies h @*/;
928
929 #ifdef __cplusplus
930 }
931 #endif
932
933 #endif  /* H_RPMTS */