1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
|
#ifndef H_RPMTS
#define H_RPMTS
/** \ingroup rpmts
* \file lib/rpmts.h
* Structures and prototypes used for an rpmTransactionSet
*/
#include <rpmhash.h> /* XXX hashTable */
#include "rpmal.h" /* XXX availablePackage/relocateFileList ,*/
/*@unchecked@*/
/*@-exportlocal@*/
extern int _ts_debug;
/*@=exportlocal@*/
/*@unchecked@*/
/*@-exportlocal@*/
extern int _cacheDependsRC;
/*@=exportlocal@*/
typedef enum tsStage_e {
TSM_UNKNOWN = 0,
TSM_INSTALL = 7,
TSM_ERASE = 8,
} tsmStage;
/** \ingroup rpmts
* The set of packages to be installed/removed atomically.
*/
struct rpmTransactionSet_s {
rpmtsFlags transFlags; /*!< Bit(s) to control operation. */
tsmStage goal; /*!< Transaction goal (i.e. mode) */
/*@null@*/
int (*solve) (rpmTransactionSet ts, const rpmDepSet key)
/*@modifies ts @*/; /*!< Search for NEVRA key. */
int nsuggests; /*!< No. of depCheck suggestions. */
/*@only@*/ /*@null@*/
const void ** suggests; /*!< Possible depCheck suggestions. */
/*@refcounted@*/ /*@null@*/
rpmdb sdb; /*!< Solve database handle. */
/*@observer@*/ /*@null@*/
rpmCallbackFunction notify; /*!< Callback function. */
/*@observer@*/ /*@null@*/
rpmCallbackData notifyData; /*!< Callback private data. */
/*@refcounted@*/ /*@null@*/
rpmProblemSet probs; /*!< Current problems in transaction. */
rpmprobFilterFlags ignoreSet;
/*!< Bits to filter current problems. */
int filesystemCount; /*!< No. of mounted filesystems. */
/*@dependent@*/ /*@null@*/
const char ** filesystems; /*!< Mounted filesystem names. */
/*@only@*/ /*@null@*/
struct diskspaceInfo * di; /*!< Per filesystem disk/inode usage. */
int dbmode; /*!< Database open mode. */
/*@refcounted@*/ /*@null@*/
rpmdb rdb; /*!< Install database handle. */
/*@only@*/
hashTable ht; /*!< Fingerprint hash table. */
/*@only@*/ /*@null@*/
int * removedPackages; /*!< Set of packages being removed. */
int numRemovedPackages; /*!< No. removed package instances. */
int allocedRemovedPackages; /*!< Size of removed packages array. */
/*@only@*/
availableList addedPackages;/*!< Set of packages being installed. */
int numAddedPackages; /*!< No. added package instances. */
/*@only@*/
availableList availablePackages;
/*!< Universe of available packages. */
int numAvailablePackages; /*!< No. available package instances. */
/*@owned@*/
transactionElement * order; /*!< Packages sorted by dependencies. */
int orderCount; /*!< No. of transaction elements. */
int orderAlloced; /*!< No. of allocated transaction elements. */
int chrootDone; /*!< Has chroot(2) been been done? */
/*@only@*/ /*@null@*/
const char * rootDir; /*!< Path to top of install tree. */
/*@only@*/ /*@null@*/
const char * currDir; /*!< Current working directory. */
/*@null@*/
FD_t scriptFd; /*!< Scriptlet stdout/stderr. */
int delta; /*!< Delta for reallocation. */
int_32 tid; /*!< Transaction id. */
int verify_legacy; /*!< Verify legacy signatures? */
int nodigests; /*!< Verify digests? */
int nosignatures; /*!< Verify signatures? */
int vsflags; /*!< Signature verification flags. */
#define _RPMTS_VSF_NODIGESTS (1 << 0)
#define _RPMTS_VSF_NOSIGNATURES (1 << 1)
#define _RPMTS_VSF_VERIFY_LEGACY (1 << 2)
/*@observer@*/ /*@dependent@*/ /*@null@*/
const char * fn; /*!< Current package fn. */
int_32 sigtag; /*!< Current package signature tag. */
int_32 sigtype; /*!< Current package signature data type. */
/*@null@*/ const void * sig; /*!< Current package signature. */
int_32 siglen; /*!< Current package signature length. */
/*@only@*/ /*@null@*/
const unsigned char * pkpkt;/*!< Current pubkey packet. */
size_t pkpktlen; /*!< Current pubkey packet length. */
unsigned char pksignid[8]; /*!< Current pubkey fingerprint. */
/*@null@*/
struct pgpDig_s * dig; /*!< Current signature/pubkey parametrs. */
/*@refs@*/ int nrefs; /*!< Reference count. */
};
#ifdef __cplusplus
extern "C" {
#endif
/** \ingroup rpmts
* Check that all dependencies can be resolved.
* @param ts transaction set
* @return 0 on success
*/
int rpmtsCheck(rpmTransactionSet ts)
/*@globals fileSystem, internalState @*/
/*@modifies ts, fileSystem, internalState @*/;
/** \ingroup rpmts
* Determine package order in a transaction set according to dependencies.
*
* Order packages, returning error if circular dependencies cannot be
* eliminated by removing PreReq's from the loop(s). Only dependencies from
* added or removed packages are used to determine ordering using a
* topological sort (Knuth vol. 1, p. 262). Use rpmtsCheck() to verify
* that all dependencies can be resolved.
*
* The final order ends up as installed packages followed by removed packages,
* with packages removed for upgrades immediately following the new package
* to be installed.
*
* The operation would be easier if we could sort the addedPackages array in the
* transaction set, but we store indexes into the array in various places.
*
* @param ts transaction set
* @return no. of (added) packages that could not be ordered
*/
int rpmtsOrder(rpmTransactionSet ts)
/*@globals fileSystem, internalState@*/
/*@modifies ts, fileSystem, internalState @*/;
/** \ingroup rpmts
* Process all packages in a transaction set.
*
* @param ts transaction set
* @param okProbs previously known problems (or NULL)
* @param ignoreSet bits to filter problem types
* @return 0 on success, -1 on error, >0 with newProbs set
*/
int rpmtsRun(rpmTransactionSet ts,
rpmProblemSet okProbs,
rpmprobFilterFlags ignoreSet)
/*@globals rpmGlobalMacroContext,
fileSystem, internalState@*/
/*@modifies ts, rpmGlobalMacroContext,
fileSystem, internalState @*/;
/** \ingroup rpmts
* Unreference a transaction instance.
* @param ts transaction set
* @param msg
* @return NULL always
*/
/*@unused@*/ /*@null@*/
rpmTransactionSet rpmtsUnlink (/*@killref@*/ /*@only@*/ rpmTransactionSet ts,
const char * msg)
/*@modifies ts @*/;
/** @todo Remove debugging entry from the ABI. */
/*@null@*/
rpmTransactionSet XrpmtsUnlink (/*@killref@*/ /*@only@*/ rpmTransactionSet ts,
const char * msg, const char * fn, unsigned ln)
/*@modifies ts @*/;
#define rpmtsUnlink(_ts, _msg) XrpmtsUnlink(_ts, _msg, __FILE__, __LINE__)
/** \ingroup rpmts
* Reference a transaction set instance.
* @param ts transaction set
* @param msg
* @return new transaction set reference
*/
/*@unused@*/
rpmTransactionSet rpmtsLink (rpmTransactionSet ts, const char * msg)
/*@modifies ts @*/;
/** @todo Remove debugging entry from the ABI. */
rpmTransactionSet XrpmtsLink (rpmTransactionSet ts,
const char * msg, const char * fn, unsigned ln)
/*@modifies ts @*/;
#define rpmtsLink(_ts, _msg) XrpmtsLink(_ts, _msg, __FILE__, __LINE__)
/** \ingroup rpmts
* Close the database used by the transaction.
* @param ts transaction set
* @return 0 on success
*/
int rpmtsCloseDB(rpmTransactionSet ts)
/*@globals fileSystem @*/
/*@modifies ts, fileSystem @*/;
/** \ingroup rpmts
* Open the database used by the transaction.
* @param ts transaction set
* @param dbmode O_RDONLY or O_RDWR
* @return 0 on success
*/
int rpmtsOpenDB(rpmTransactionSet ts, int dbmode)
/*@globals fileSystem, internalState @*/
/*@modifies ts, fileSystem, internalState @*/;
/** \ingroup rpmts
* Return transaction database iterator.
* @param ts transaction set
* @param rpmtag rpm tag
* @param keyp key data (NULL for sequential access)
* @param keylen key data length (0 will use strlen(keyp))
* @return NULL on failure
*/
/*@only@*/ /*@null@*/
rpmdbMatchIterator rpmtsInitIterator(const rpmTransactionSet ts, int rpmtag,
/*@null@*/ const void * keyp, size_t keylen)
/*@globals fileSystem @*/
/*@modifies ts, fileSystem @*/;
/**
* Attempt to solve a needed dependency.
* @param ts transaction set
* @param ds dependency set
* @return 0 if resolved (and added to ts), 1 not found
*/
/*@-exportlocal@*/
int rpmtsSolve(rpmTransactionSet ts, rpmDepSet ds)
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
/*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
/*@=exportlocal@*/
/**
* Attempt to solve a needed dependency.
* @param ts transaction set
* @param ds dependency set
* @return 0 if resolved (and added to ts), 1 not found
*/
/*@unused@*/
int rpmtsAvailable(rpmTransactionSet ts, const rpmDepSet ds)
/*@globals fileSystem @*/
/*@modifies ts, fileSystem @*/;
/**
* Return (and clear) current transaction set problems.
* @param ts transaction set
* @return current problem set (or NULL)
*/
/*@null@*/
rpmProblemSet rpmtsGetProblems(rpmTransactionSet ts)
/*@modifies ts @*/;
/** \ingroup rpmts
* Re-create an empty transaction set.
* @param ts transaction set
*/
void rpmtsClean(rpmTransactionSet ts)
/*@modifies ts @*/;
/** \ingroup rpmts
* Destroy transaction set, closing the database as well.
* @param ts transaction set
* @return NULL always
*/
/*@null@*/
rpmTransactionSet
rpmtsFree(/*@killref@*/ /*@only@*//*@null@*/ rpmTransactionSet ts)
/*@globals fileSystem @*/
/*@modifies ts, fileSystem @*/;
/** \ingroup rpmts
* Set verify signatures flag(s).
* @param ts transaction set
* @param vsflags new verify signatures flags
* @retrun previous value
*/
int rpmtsSetVerifySigFlags(rpmTransactionSet ts, int vsflags)
/*@modifies ts @*/;
/** \ingroup rpmts
* Get transaction rootDir, i.e. path to chroot(2).
* @param ts transaction set
* @return transaction rootDir
*/
/*@observer@*/ /*@null@*/
const char * rpmtsGetRootDir(rpmTransactionSet ts)
/*@*/;
/** \ingroup rpmts
* Set transaction rootDir, i.e. path to chroot(2).
* @param ts transaction set
* @param rootDir new transaction rootDir (or NULL)
*/
void rpmtsSetRootDir(rpmTransactionSet ts, /*@null@*/ const char * rootDir)
/*@modifies ts @*/;
/** \ingroup rpmts
* Get transaction currDir, i.e. current directory before chroot(2).
* @param ts transaction set
* @return transaction currDir
*/
/*@observer@*/ /*@null@*/
const char * rpmtsGetCurrDir(rpmTransactionSet ts)
/*@*/;
/** \ingroup rpmts
* Set transaction currDir, i.e. current directory before chroot(2).
* @param ts transaction set
* @param currDir new transaction currDir (or NULL)
*/
void rpmtsSetCurrDir(rpmTransactionSet ts, /*@null@*/ const char * currDir)
/*@modifies ts @*/;
/** \ingroup rpmts
* Get transaction script file handle, i.e. stdout/stderr on scriptlet execution
* @param ts transaction set
* @return transaction script file handle
*/
/*@null@*/
FD_t rpmtsGetScriptFd(rpmTransactionSet ts)
/*@*/;
/** \ingroup rpmts
* Set transaction script file handle, i.e. stdout/stderr on scriptlet execution
* @param ts transaction set
* @param scriptFd new script file handle (or NULL)
*/
void rpmtsSetScriptFd(rpmTransactionSet ts, /*@null@*/ FD_t scriptFd)
/*@modifies ts, scriptFd @*/;
/** \ingroup rpmts
* Get chrootDone flag, i.e. has chroot(2) been performed?
* @param ts transaction set
* @return chrootDone flag
*/
int rpmtsGetChrootDone(rpmTransactionSet ts)
/*@*/;
/** \ingroup rpmts
* Set chrootDone flag, i.e. has chroot(2) been performed?
* @param ts transaction set
* @param chrootDone new chrootDone flag
* @return previous chrootDone flag
*/
int rpmtsSetChrootDone(rpmTransactionSet ts, int chrootDone)
/*@modifies ts @*/;
/** \ingroup rpmts
* Get transaction id, i.e. transaction time stamp.
* @param ts transaction set
* @return chrootDone flag
*/
int_32 rpmtsGetTid(rpmTransactionSet ts)
/*@*/;
/** \ingroup rpmts
* Set transaction id, i.e. transaction time stamp.
* @param ts transaction set
* @param tid new transaction id
* @return previous transaction id
*/
int_32 rpmtsSetTid(rpmTransactionSet ts, int_32 tid)
/*@modifies ts @*/;
/** \ingroup rpmts
* Get transaction database handle.
* @param ts transaction set
* @return transaction database handle
*/
/*@null@*/
rpmdb rpmtsGetRdb(rpmTransactionSet ts)
/*@*/;
/** \ingroup rpmts
* Get transaction flags, i.e. bits to control rpmtsRun().
* @param ts transaction set
* @return transaction flags
*/
rpmtsFlags rpmtsGetFlags(rpmTransactionSet ts)
/*@*/;
/** \ingroup rpmts
* Set transaction flags, i.e. bits to control rpmtsRun().
* @param ts transaction set
* @param transFlags new transaction flags
* @return previous transaction flags
*/
rpmtsFlags rpmtsSetFlags(rpmTransactionSet ts, rpmtsFlags transFlags)
/*@modifies ts @*/;
/** \ingroup rpmts
* Set transaction notify callback function and argument.
*
* @warning This call must be made before rpmtsRun() for
* install/upgrade/freshen to "work".
*
* @param ts transaction set
* @param notify progress callback
* @param notifyData progress callback private data
* @return 0 on success
*/
int rpmtsSetNotifyCallback(rpmTransactionSet ts,
/*@observer@*/ rpmCallbackFunction notify,
/*@observer@*/ rpmCallbackData notifyData)
/*@modifies ts @*/;
/** \ingroup rpmts
* Create an empty transaction set.
* @return new transaction set
*/
/*@only@*/
rpmTransactionSet rpmtsCreate(void)
/*@*/;
/** \ingroup rpmts
* Add package to be installed to transaction set.
*
* If fd is NULL, the callback set by rpmtsSetNotifyCallback() is used to
* open and close the file descriptor. If Header is NULL, the fd is always
* used, otherwise fd is only needed (and only opened) for actual package
* installation.
*
* @warning The fd argument has been eliminated, and is assumed always NULL.
*
* @param ts transaction set
* @param h header
* @param key package retrieval key (e.g. file name)
* @param upgrade is package being upgraded?
* @param relocs package file relocations
* @return 0 on success, 1 on I/O error, 2 needs capabilities
*/
int rpmtsAddPackage(rpmTransactionSet ts, Header h,
/*@exposed@*/ /*@null@*/ const fnpyKey key, int upgrade,
/*@null@*/ rpmRelocation * relocs)
/*@globals fileSystem, internalState @*/
/*@modifies ts, h, fileSystem, internalState @*/;
/** \ingroup rpmts
* Add package to universe of possible packages to install in transaction set.
* @warning The key parameter is non-functional.
* @param ts transaction set
* @param h header
* @param key package private data
*/
/*@unused@*/
void rpmtsAvailablePackage(rpmTransactionSet ts, Header h,
/*@exposed@*/ /*@null@*/ fnpyKey key)
/*@modifies h, ts @*/;
/** \ingroup rpmts
* Add package to be erased to transaction set.
* @param ts transaction set
* @param h header
* @param dboffset rpm database instance
* @return 0 on success
*/
int rpmtsRemovePackage(rpmTransactionSet ts, Header h, int dboffset)
/*@modifies ts, h @*/;
/** \ingroup rpmts
* Retrieve keys from ordered transaction set.
* @todo Removed packages have no keys, returned as interleaved NULL pointers.
* @param ts transaction set
* @retval ep address of returned element array pointer (or NULL)
* @retval nep address of no. of returned elements (or NULL)
* @return 0 always
*/
/*@unused@*/
int rpmtsGetKeys(rpmTransactionSet ts,
/*@null@*/ /*@out@*/ fnpyKey ** ep,
/*@null@*/ /*@out@*/ int * nep)
/*@modifies ts, ep, nep @*/;
/**
* Return (malloc'd) header name-version-release string.
* @param h header
* @retval np name tag value
* @return name-version-release string
*/
/*@only@*/ char * hGetNEVR(Header h, /*@out@*/ const char ** np )
/*@modifies *np @*/;
#ifdef __cplusplus
}
#endif
#endif /* H_RPMTS */
|