6 * Structures and prototypes used for an "rpmts" transaction set.
11 #include <rpm/rpmtypes.h>
12 #include <rpm/rpmte.h>
13 #include <rpm/rpmps.h>
14 #include <rpm/rpmsw.h>
15 #include <rpm/rpmpgp.h>
16 #include <rpm/rpmfi.h>
17 #include <rpm/rpmcallback.h>
23 extern int _rpmts_stats;
26 * Bit(s) to control rpmtsRun() operation.
28 enum rpmtransFlags_e {
29 RPMTRANS_FLAG_NONE = 0,
30 RPMTRANS_FLAG_TEST = (1 << 0), /*!< from --test */
31 RPMTRANS_FLAG_BUILD_PROBS = (1 << 1), /*!< don't process payload */
32 RPMTRANS_FLAG_NOSCRIPTS = (1 << 2), /*!< from --noscripts */
33 RPMTRANS_FLAG_JUSTDB = (1 << 3), /*!< from --justdb */
34 RPMTRANS_FLAG_NOTRIGGERS = (1 << 4), /*!< from --notriggers */
35 RPMTRANS_FLAG_NODOCS = (1 << 5), /*!< from --excludedocs */
36 RPMTRANS_FLAG_ALLFILES = (1 << 6), /*!< from --allfiles */
38 RPMTRANS_FLAG_NOCONTEXTS = (1 << 8), /*!< from --nocontexts */
39 /* bits 9-15 unused */
40 RPMTRANS_FLAG_NOTRIGGERPREIN= (1 << 16), /*!< from --notriggerprein */
41 RPMTRANS_FLAG_NOPRE = (1 << 17), /*!< from --nopre */
42 RPMTRANS_FLAG_NOPOST = (1 << 18), /*!< from --nopost */
43 RPMTRANS_FLAG_NOTRIGGERIN = (1 << 19), /*!< from --notriggerin */
44 RPMTRANS_FLAG_NOTRIGGERUN = (1 << 20), /*!< from --notriggerun */
45 RPMTRANS_FLAG_NOPREUN = (1 << 21), /*!< from --nopreun */
46 RPMTRANS_FLAG_NOPOSTUN = (1 << 22), /*!< from --nopostun */
47 RPMTRANS_FLAG_NOTRIGGERPOSTUN = (1 << 23), /*!< from --notriggerpostun */
48 RPMTRANS_FLAG_NOPRETRANS = (1 << 24), /*!< from --nopretrans */
49 RPMTRANS_FLAG_NOPOSTTRANS = (1 << 25), /*!< from --noposttrans */
50 RPMTRANS_FLAG_NOCOLLECTIONS = (1 << 26), /*!< from --nocollections */
51 RPMTRANS_FLAG_NOMD5 = (1 << 27), /*!< from --nomd5 */
52 RPMTRANS_FLAG_NOFILEDIGEST = (1 << 27), /*!< from --nofiledigest (alias to --nomd5) */
53 /* bits 28-29 unused */
54 RPMTRANS_FLAG_NOCONFIGS = (1 << 30), /*!< from --noconfigs */
55 RPMTRANS_FLAG_DEPLOOPS = (1 << 31) /*!< from --deploops */
58 typedef rpmFlags rpmtransFlags;
60 #define _noTransScripts \
61 ( RPMTRANS_FLAG_NOPRE | \
62 RPMTRANS_FLAG_NOPOST | \
63 RPMTRANS_FLAG_NOPREUN | \
64 RPMTRANS_FLAG_NOPOSTUN | \
65 RPMTRANS_FLAG_NOPRETRANS | \
66 RPMTRANS_FLAG_NOPOSTTRANS \
69 #define _noTransTriggers \
70 ( RPMTRANS_FLAG_NOTRIGGERPREIN | \
71 RPMTRANS_FLAG_NOTRIGGERIN | \
72 RPMTRANS_FLAG_NOTRIGGERUN | \
73 RPMTRANS_FLAG_NOTRIGGERPOSTUN \
76 /* Avoid unnecessary breakage for stuff referring to these unused flags */
77 #define RPMTRANS_FLAG_NOPAYLOAD 0
78 #define RPMTRANS_FLAG_APPLYONLY 0
79 #define RPMTRANS_FLAG_KEEPOBSOLETE 0
80 #define RPMTRANS_FLAG_DIRSTASH 0
81 #define RPMTRANS_FLAG_REPACKAGE 0
82 #define RPMTRANS_FLAG_PKGCOMMIT 0
83 #define RPMTRANS_FLAG_PKGUNDO 0
84 #define RPMTRANS_FLAG_COMMIT 0
85 #define RPMTRANS_FLAG_UNDO 0
86 #define RPMTRANS_FLAG_REVERSE 0
87 #define RPMTRANS_FLAG_NOSUGGEST 0
88 #define RPMTRANS_FLAG_ADDINDEPS 0
91 * Bit(s) to control digest and signature verification.
95 RPMVSF_NOHDRCHK = (1 << 0),
96 RPMVSF_NEEDPAYLOAD = (1 << 1),
97 /* bit(s) 2-7 unused */
98 RPMVSF_NOSHA1HEADER = (1 << 8),
99 RPMVSF_NOMD5HEADER = (1 << 9), /* unimplemented */
100 RPMVSF_NODSAHEADER = (1 << 10),
101 RPMVSF_NORSAHEADER = (1 << 11), /* unimplemented */
102 /* bit(s) 12-15 unused */
103 RPMVSF_NOSHA1 = (1 << 16), /* unimplemented */
104 RPMVSF_NOMD5 = (1 << 17),
105 RPMVSF_NODSA = (1 << 18),
106 RPMVSF_NORSA = (1 << 19)
107 /* bit(s) 16-31 unused */
110 typedef rpmFlags rpmVSFlags;
112 #define _RPMVSF_NODIGESTS \
113 ( RPMVSF_NOSHA1HEADER | \
114 RPMVSF_NOMD5HEADER | \
118 #define _RPMVSF_NOSIGNATURES \
119 ( RPMVSF_NODSAHEADER | \
120 RPMVSF_NORSAHEADER | \
124 #define _RPMVSF_NOHEADER \
125 ( RPMVSF_NOSHA1HEADER | \
126 RPMVSF_NOMD5HEADER | \
127 RPMVSF_NODSAHEADER | \
130 #define _RPMVSF_NOPAYLOAD \
137 * Indices for timestamps.
139 typedef enum rpmtsOpX_e {
143 RPMTS_OP_FINGERPRINT = 3,
144 RPMTS_OP_INSTALL = 5,
146 RPMTS_OP_SCRIPTLETS = 7,
147 RPMTS_OP_COMPRESS = 8,
148 RPMTS_OP_UNCOMPRESS = 9,
149 RPMTS_OP_DIGEST = 10,
150 RPMTS_OP_SIGNATURE = 11,
152 RPMTS_OP_DBREMOVE = 13,
160 * Perform dependency resolution on the transaction set.
162 * Any problems found by rpmtsCheck() can be examined by retrieving the
163 * problem set with rpmtsProblems(), success here only means that
164 * the resolution was successfully attempted for all packages in the set.
166 * @param ts transaction set
167 * @return 0 on success
169 int rpmtsCheck(rpmts ts);
172 * Determine package order in a transaction set according to dependencies.
174 * Order packages, returning error if circular dependencies cannot be
175 * eliminated by removing Requires's from the loop(s). Only dependencies from
176 * added or removed packages are used to determine ordering using a
177 * topological sort (Knuth vol. 1, p. 262). Use rpmtsCheck() to verify
178 * that all dependencies can be resolved.
180 * The final order ends up as installed packages followed by removed packages,
181 * with packages removed for upgrades immediately following the new package
184 * @param ts transaction set
185 * @return no. of (added) packages that could not be ordered
187 int rpmtsOrder(rpmts ts);
190 * Process all package elements in a transaction set. Before calling
191 * rpmtsRun be sure to have:
193 * - setup the rpm root dir via rpmtsSetRoot().
194 * - setup the rpm notify callback via rpmtsSetNotifyCallback().
195 * - setup the rpm transaction flags via rpmtsSetFlags().
197 * Additionally, though not required you may want to:
199 * - setup the rpm verify signature flags via rpmtsSetVSFlags().
201 * @param ts transaction set
202 * @param okProbs unused
203 * @param ignoreSet bits to filter problem types
204 * @return 0 on success, -1 on error, >0 with newProbs set
206 int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet);
209 * Reference a transaction set instance.
210 * @param ts transaction set
211 * @return new transaction set reference
213 rpmts rpmtsLink (rpmts ts);
216 * Close the database used by the transaction.
217 * @param ts transaction set
218 * @return 0 on success
220 int rpmtsCloseDB(rpmts ts);
223 * Open the database used by the transaction.
224 * @param ts transaction set
225 * @param dbmode O_RDONLY or O_RDWR
226 * @return 0 on success
228 int rpmtsOpenDB(rpmts ts, int dbmode);
231 * Initialize the database used by the transaction.
232 * @deprecated An explicit rpmdbInit() is almost never needed.
233 * @param ts transaction set
234 * @param dbmode O_RDONLY or O_RDWR
235 * @return 0 on success
237 int rpmtsInitDB(rpmts ts, int dbmode);
240 * Return the transaction database mode
241 * @param ts transaction set
242 * @return O_RDONLY, O_RDWR or -1 (lazy opens disabled)
244 int rpmtsGetDBMode(rpmts ts);
247 * Set the transaction database mode. Only permitted when when backing
248 * database hasn't been opened yet (ie rpmtsGetRdb(ts) == NULL)
249 * @param ts transaction set
250 * @param dbmode O_RDONLY, O_RDWR or -1 (disable lazy opens)
251 * @return 0 on success, 1 on error
253 int rpmtsSetDBMode(rpmts ts, int dbmode);
256 * Rebuild the database used by the transaction.
257 * @param ts transaction set
258 * @return 0 on success
260 int rpmtsRebuildDB(rpmts ts);
263 * Verify the database used by the transaction.
264 * @param ts transaction set
265 * @return 0 on success
267 int rpmtsVerifyDB(rpmts ts);
270 * Return transaction database iterator.
271 * @param ts transaction set
272 * @param rpmtag database index tag
273 * @param keyp key data (NULL for sequential access)
274 * @param keylen key data length (0 will use strlen(keyp))
275 * @return NULL on failure
277 rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmDbiTagVal rpmtag,
278 const void * keyp, size_t keylen);
281 * Import public key packet(s).
282 * @todo Implicit --update policy for gpg-pubkey headers.
283 * @param ts transaction set
284 * @param pkt pgp pubkey packet(s)
285 * @param pktlen pgp pubkey length
286 * @return RPMRC_OK/RPMRC_FAIL
288 rpmRC rpmtsImportPubkey(rpmts ts, const unsigned char * pkt, size_t pktlen);
291 * Retrieve handle for keyring used for this transaction set
292 * @param ts transaction set
293 * @param autoload load default keyring if keyring is not set
294 * @return keyring handle (or NULL)
296 rpmKeyring rpmtsGetKeyring(rpmts ts, int autoload);
299 * Set keyring to use for this transaction set.
300 * Keyring can be only changed while the underlying rpm database is not
302 * @param ts transaction set
303 * @param keyring keyring handle (NULL to free current keyring)
304 * @return 0 on success, -1 on error
306 int rpmtsSetKeyring(rpmts ts, rpmKeyring keyring);
309 * Set dependency solver callback.
310 * @param ts transaction set
311 * @param (*solve) dependency solver callback
312 * @param solveData dependency solver callback data (opaque)
313 * @return 0 on success
315 int rpmtsSetSolveCallback(rpmts ts,
316 int (*solve) (rpmts ts, rpmds ds, const void * data),
317 const void * solveData);
320 * Return current transaction set problems.
321 * @param ts transaction set
322 * @return current problem set (or NULL if no problems)
324 rpmps rpmtsProblems(rpmts ts);
327 * Clean current transaction problem set.
328 * @param ts transaction set
330 void rpmtsCleanProblems(rpmts ts);
333 * Free memory needed only for dependency checks and ordering.
334 * @param ts transaction set
336 void rpmtsClean(rpmts ts);
339 * Re-create an empty transaction set.
340 * @param ts transaction set
342 void rpmtsEmpty(rpmts ts);
345 * Destroy transaction set, closing the database as well.
346 * @param ts transaction set
347 * @return NULL always
349 rpmts rpmtsFree(rpmts ts);
352 * Get verify signatures flag(s).
353 * @param ts transaction set
354 * @return verify signatures flags
356 rpmVSFlags rpmtsVSFlags(rpmts ts);
359 * Set verify signatures flag(s).
360 * @param ts transaction set
361 * @param vsflags new verify signatures flags
362 * @return previous value
364 rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags);
367 * Get transaction rootDir, i.e. path to chroot(2).
368 * @param ts transaction set
369 * @return transaction rootDir
371 const char * rpmtsRootDir(rpmts ts);
374 * Set transaction rootDir, i.e. path to chroot(2).
375 * @param ts transaction set
376 * @param rootDir new transaction rootDir (or NULL)
377 * @return 0 on success, -1 on error (invalid rootDir)
379 int rpmtsSetRootDir(rpmts ts, const char * rootDir);
382 * Get transaction script file handle, i.e. stdout/stderr on scriptlet execution
383 * @param ts transaction set
384 * @return transaction script file handle
386 FD_t rpmtsScriptFd(rpmts ts);
389 * Set transaction script file handle, i.e. stdout/stderr on scriptlet execution
390 * @param ts transaction set
391 * @param scriptFd new script file handle (or NULL)
393 void rpmtsSetScriptFd(rpmts ts, FD_t scriptFd);
396 * Get transaction id, i.e. transaction time stamp.
397 * @param ts transaction set
398 * @return transaction id
400 rpm_tid_t rpmtsGetTid(rpmts ts);
403 * Set transaction id, i.e. transaction time stamp.
404 * @param ts transaction set
405 * @param tid new transaction id
406 * @return previous transaction id
408 rpm_tid_t rpmtsSetTid(rpmts ts, rpm_tid_t tid);
411 * Get transaction set database handle.
412 * @param ts transaction set
413 * @return transaction database handle
415 rpmdb rpmtsGetRdb(rpmts ts);
418 * Perform transaction progress notify callback.
419 * @param ts transaction set
420 * @param te current transaction element
421 * @param what type of call back
422 * @param amount current value
423 * @param total final value
424 * @return callback dependent pointer
426 void * rpmtsNotify(rpmts ts, rpmte te,
427 rpmCallbackType what, rpm_loff_t amount, rpm_loff_t total);
429 int rpmtsSuspendResumeDBLock(rpmts ts, int mode);
432 * Return number of (ordered) transaction set elements.
433 * @param ts transaction set
434 * @return no. of transaction set elements
436 int rpmtsNElements(rpmts ts);
439 * Return (ordered) transaction set element.
440 * @param ts transaction set
441 * @param ix transaction element index
442 * @return transaction element (or NULL)
444 rpmte rpmtsElement(rpmts ts, int ix);
447 * Get problem ignore bit mask, i.e. bits to filter encountered problems.
448 * @param ts transaction set
449 * @return ignore bit mask
451 rpmprobFilterFlags rpmtsFilterFlags(rpmts ts);
454 * Get transaction flags, i.e. bits that control rpmtsRun().
455 * @param ts transaction set
456 * @return transaction flags
458 rpmtransFlags rpmtsFlags(rpmts ts);
461 * Set transaction flags, i.e. bits that control rpmtsRun().
462 * @param ts transaction set
463 * @param transFlags new transaction flags
464 * @return previous transaction flags
466 rpmtransFlags rpmtsSetFlags(rpmts ts, rpmtransFlags transFlags);
469 * Retrieve color bits of transaction set.
470 * @param ts transaction set
473 rpm_color_t rpmtsColor(rpmts ts);
476 * Retrieve prefered file color
477 * @param ts transaction set
480 rpm_color_t rpmtsPrefColor(rpmts ts);
483 * Set color bits of transaction set.
484 * @param ts transaction set
485 * @param color new color bits
486 * @return previous color bits
488 rpm_color_t rpmtsSetColor(rpmts ts, rpm_color_t color);
491 * Set prefered file color
492 * @param ts transaction set
493 * @param color new color bits
494 * @return previous color bits
496 rpm_color_t rpmtsSetPrefColor(rpmts ts, rpm_color_t color);
499 * Retrieve operation timestamp from a transaction set.
500 * @param ts transaction set
501 * @param opx operation timestamp index
502 * @return pointer to operation timestamp.
504 rpmop rpmtsOp(rpmts ts, rpmtsOpX opx);
507 * Get the plugins associated with a transaction set
508 * @param ts transaction set
511 rpmPlugins rpmtsPlugins(rpmts ts);
514 * Set transaction notify callback function and argument.
516 * @warning This call must be made before rpmtsRun() for
517 * install/upgrade/freshen to function correctly.
519 * @param ts transaction set
520 * @param notify progress callback
521 * @param notifyData progress callback private data
522 * @return 0 on success
524 int rpmtsSetNotifyCallback(rpmts ts,
525 rpmCallbackFunction notify,
526 rpmCallbackData notifyData);
529 * Create an empty transaction set.
530 * @return new transaction set
532 rpmts rpmtsCreate(void);
535 * Add package to be installed to transaction set.
537 * The transaction set is checked for duplicate package names.
538 * If found, the package with the "newest" EVR will be replaced.
540 * @param ts transaction set
542 * @param key package retrieval key (e.g. file name)
543 * @param upgrade is package being upgraded?
544 * @param relocs package file relocations
545 * @return 0 on success, 1 on I/O error, 2 needs capabilities
547 int rpmtsAddInstallElement(rpmts ts, Header h,
548 const fnpyKey key, int upgrade,
549 rpmRelocation * relocs);
552 * Add package to be erased to transaction set.
553 * @param ts transaction set
555 * @param dboffset ununsed
556 * @return 0 on success, 1 on error (not installed)
558 int rpmtsAddEraseElement(rpmts ts, Header h, int dboffset);
561 * Destroy transaction element iterator.
562 * @param tsi transaction element iterator
563 * @return NULL always
565 rpmtsi rpmtsiFree(rpmtsi tsi);
568 * Create transaction element iterator.
569 * @param ts transaction set
570 * @return transaction element iterator
572 rpmtsi rpmtsiInit(rpmts ts);
575 * Return next transaction element of type.
576 * @param tsi transaction element iterator
577 * @param types transaction element type selector (0 for any)
578 * @return next transaction element of type, NULL on termination
580 rpmte rpmtsiNext(rpmtsi tsi, rpmElementTypes types);