rpm  5.4.10
rpmts.h
Go to the documentation of this file.
1 #ifndef H_RPMTS
2 #define H_RPMTS
3 
9 #include "rpmps.h"
10 #include "rpmsw.h"
11 #include <rpmpgp.h> /* XXX pgpVSFlags */
12 #if defined(_RPMTS_INTERNAL)
13 #include <rpmbag.h>
14 #endif
15 
16 /*@-exportlocal@*/
17 /*@unchecked@*/
18 extern int _rpmts_debug;
19 /*@unchecked@*/
20 extern int _rpmts_macros;
21 /*@unchecked@*/
22 extern int _rpmts_stats;
23 /*@unchecked@*/
24 extern int _fps_debug;
25 /*@=exportlocal@*/
26 
31 
36 typedef enum rpmdepFlags_e {
44  RPMDEPS_FLAG_ANACONDA = (1 << 6),
48 } rpmdepFlags;
49 
54 typedef enum rpmtransFlags_e {
56  RPMTRANS_FLAG_TEST = (1 << 0),
59  RPMTRANS_FLAG_JUSTDB = (1 << 3),
61  RPMTRANS_FLAG_NODOCS = (1 << 5),
63  /* 7 unused */
69 /*@-enummemuse@*/
70  RPMTRANS_FLAG_PKGUNDO = (1 << 12),
71 /*@=enummemuse@*/
72  RPMTRANS_FLAG_COMMIT = (1 << 13),
73 /*@-enummemuse@*/
74  RPMTRANS_FLAG_UNDO = (1 << 14),
75 /*@=enummemuse@*/
77 
79  RPMTRANS_FLAG_NOPRE = (1 << 17),
80  RPMTRANS_FLAG_NOPOST = (1 << 18),
83  RPMTRANS_FLAG_NOPREUN = (1 << 21),
84  RPMTRANS_FLAG_NOPOSTUN = (1 << 22),
86 /*@-enummemuse@*/
88 /*@=enummemuse@*/
89  RPMTRANS_FLAG_NORPMDB = (1 << 25),
90  RPMTRANS_FLAG_NOPOLICY = (1 << 26),
95  /* 31 unused */
97 
98 #define _noTransScripts \
99  ( RPMTRANS_FLAG_NOPRETRANS | \
100  RPMTRANS_FLAG_NOPRE | \
101  RPMTRANS_FLAG_NOPOST | \
102  RPMTRANS_FLAG_NOPREUN | \
103  RPMTRANS_FLAG_NOPOSTUN | \
104  RPMTRANS_FLAG_NOPOSTTRANS \
105  )
106 
107 #define _noTransTriggers \
108  ( RPMTRANS_FLAG_NOTRIGGERPREIN | \
109  RPMTRANS_FLAG_NOTRIGGERIN | \
110  RPMTRANS_FLAG_NOTRIGGERUN | \
111  RPMTRANS_FLAG_NOTRIGGERPOSTUN \
112  )
113 
117 typedef enum rpmtsOpX_e {
140 } rpmtsOpX;
141 
145 typedef enum rpmTSType_e {
149 } rpmTSType;
150 
153 typedef enum tsStage_e {
157 } tsmStage;
158 
159 #if defined(_RPMTS_INTERNAL)
160 
161 #include <rpmbf.h>
162 #include "rpmhash.h" /* XXX hashTable */
163 #include "rpmkeyring.h"
164 #include <rpmtxn.h>
165 #include "rpmal.h" /* XXX availablePackage/relocateFileList ,*/
166 
167 /*@unchecked@*/
168 /*@-exportlocal@*/
169 extern int _cacheDependsRC;
170 /*@=exportlocal@*/
171 
174 typedef /*@abstract@*/ struct diskspaceInfo_s * rpmDiskSpaceInfo;
175 
179 struct diskspaceInfo_s {
180  unsigned long f_bsize;
181  unsigned long f_frsize;
182  unsigned long long f_blocks;
183  unsigned long long f_bfree;
184  signed long long f_bavail;
185  unsigned long long f_files;
186  unsigned long long f_ffree;
187  signed long long f_favail;
188  unsigned long f_fsid;
189  unsigned long f_flag;
190  unsigned long f_namemax;
192  signed long long bneeded;
193  signed long long ineeded;
194  signed long long obneeded;
195  signed long long oineeded;
196  dev_t dev;
197 };
198 
202 #define adj_fs_blocks(_nb) (((_nb) * 21) / 20)
203 
204 #define BLOCK_ROUND(size, block) (((size) + (block) - 1) / (block))
205 
209 struct rpmts_s {
210  struct rpmioItem_s _item;
211  rpmdepFlags depFlags;
212  rpmtransFlags transFlags;
213  tsmStage goal;
214  rpmTSType type;
216 /*@refcounted@*/ /*@null@*/
217  rpmbag bag;
218 /*@null@*/
219  int (*solve) (rpmts ts, rpmds key, const void * data)
220  /*@modifies ts @*/;
221 /*@relnull@*/
222  const void * solveData;
223  int nsuggests;
224 /*@only@*/ /*@null@*/
225  const void ** suggests;
227 /*@observer@*/ /*@null@*/
228  rpmCallbackFunction notify;
229 /*@observer@*/ /*@null@*/
230  rpmCallbackData notifyData;
232 /*@null@*/
233  rpmPRCO PRCO;
235 /*@refcounted@*/ /*@null@*/
236  rpmps probs;
237  rpmprobFilterFlags ignoreSet;
240  rpmuint32_t filesystemCount;
241 /*@dependent@*/ /*@null@*/
242  const char ** filesystems;
243 /*@only@*/ /*@relnull@*/
244  rpmDiskSpaceInfo dsi;
246 /*@refcounted@*/ /*@null@*/
247  rpmdb rdb;
248  int dbmode;
249 /*@only@*/
250  hashTable ht;
251 /*@null@*/
252  rpmtxn txn;
254 /*@refcounted@*/ /*@null@*/
255  rpmbf rbf;
256 /*@only@*/ /*@null@*/
257  uint32_t * removedPackages;
258  int numRemovedPackages;
259  int allocedRemovedPackages;
261 /*@only@*/
262  rpmal addedPackages;
263  int numAddedPackages;
264  int numAddedFiles;
266 /*@only@*/
267  rpmal erasedPackages;
268  int numErasedPackages;
269  int numErasedFiles;
271 #ifndef DYING
272 /*@only@*/
273  rpmal availablePackages;
274  int numAvailablePackages;
275 #endif
276 
277 /*@null@*/
278  rpmte relocateElement;
280 /*@owned@*/ /*@relnull@*/
281  rpmte * order;
282  int orderCount;
283  int orderAlloced;
284  int unorderedSuccessors;
285  int ntrees;
286  int maxDepth;
288 /*@dependent@*/ /*@relnull@*/
289  rpmte teInstall;
290 /*@dependent@*/ /*@relnull@*/
291  rpmte teErase;
293  int selinuxEnabled;
294  int chrootDone;
295 /*@only@*/ /*@null@*/
296  const char * rootDir;
297 /*@only@*/ /*@null@*/
298  const char * currDir;
299 /*@null@*/
300  FD_t scriptFd;
301  int delta;
302  rpmuint32_t tid[2];
304  rpmuint32_t color;
305  rpmuint32_t prefcolor;
307 /*@observer@*/ /*@dependent@*/ /*@null@*/
308  const char * fn;
310 /*@refcounted@*/ /*@relnull@*/
311  rpmKeyring keyring;
312 /*@relnull@*/
313  void * hkp;
315  struct rpmop_s ops[RPMTS_OP_MAX];
316 
317 /*@refcounted@*/ /*@relnull@*/
318  pgpDig dig;
320 /*@null@*/
321  Spec spec;
323  rpmuint32_t arbgoal;
325 #if defined(__LCLINT__)
326 /*@refs@*/
327  int nrefs;
328 #endif
329 };
330 #endif /* _RPMTS_INTERNAL */
331 
332 #ifdef __cplusplus
333 extern "C" {
334 #endif
335 
346 extern int (*rpmtsCheck) (rpmts ts)
347  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
348  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
349 int _rpmtsCheck(rpmts ts)
350  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
351  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
352 
369 extern int (*rpmtsOrder) (rpmts ts)
370  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
371  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
372 int _rpmtsOrder(rpmts ts)
373  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
374  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
375 int _orgrpmtsOrder(rpmts ts)
376  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
377  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
378 
396 extern int (*rpmtsRun) (rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
397  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
398  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
399 int _rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
400  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
401  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
402 
412  int running, rpmte rbte)
413  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
414  /*@modifies rbts, rbte, rpmGlobalMacroContext, fileSystem, internalState @*/;
415 
422 /*@unused@*/ /*@null@*/
423 rpmts rpmtsUnlink (/*@killref@*/ /*@only@*/ rpmts ts,
424  const char * msg)
425  /*@modifies ts @*/;
426 #define rpmtsUnlink(_ts, _msg) \
427  ((rpmts) rpmioUnlinkPoolItem((rpmioItem)(_ts), _msg, __FILE__, __LINE__))
428 
435 /*@unused@*/ /*@newref@*/
436 rpmts rpmtsLink (rpmts ts, const char * msg)
437  /*@modifies ts @*/;
438 #define rpmtsLink(_ts, _msg) \
439  ((rpmts) rpmioLinkPoolItem((rpmioItem)(_ts), _msg, __FILE__, __LINE__))
440 
446 int rpmtsCloseDB(rpmts ts)
447  /*@globals fileSystem @*/
448  /*@modifies ts, fileSystem @*/;
449 
456 int rpmtsOpenDB(rpmts ts, int dbmode)
457  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
458  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
459 
467 static inline /*@unused@*/
468 int rpmtsInitDB(/*@unused@*/ rpmts ts, /*@unused@*/ int dbmode)
469  /*@*/
470 {
471  return -1;
472 }
473 
479 int rpmtsRebuildDB(rpmts ts)
480  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
481  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
482 
489 static inline /*@unused@*/
490 int rpmtsVerifyDB(/*@unused@*/ rpmts ts)
491  /*@*/
492 {
493  return -1;
494 }
495 
504 /*@only@*/ /*@null@*/
505 rpmmi rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
506  /*@null@*/ const void * keyp, size_t keylen)
507  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
508  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
509 
516 /*@-exportlocal@*/
517 rpmRC rpmtsFindPubkey(rpmts ts, /*@null@*/ void * _dig)
518  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
519  /*@modifies ts, _dig, rpmGlobalMacroContext, fileSystem, internalState */;
520 /*@=exportlocal@*/
521 
527 /*@-exportlocal@*/
528 int rpmtsCloseSDB(rpmts ts)
529  /*@globals fileSystem @*/
530  /*@modifies ts, fileSystem @*/;
531 /*@=exportlocal@*/
532 
539 /*@-exportlocal@*/
540 int rpmtsOpenSDB(rpmts ts, int dbmode)
541  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
542  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
543 /*@=exportlocal@*/
544 
552 /*@-exportlocal@*/
553 int rpmtsSolve(rpmts ts, rpmds ds, const void * data)
554  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
555  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
556 /*@=exportlocal@*/
557 
565 /*@unused@*/
566 int rpmtsAvailable(rpmts ts, const rpmds ds)
567  /*@globals fileSystem, internalState @*/
568  /*@modifies ts, fileSystem, internalState @*/;
569 
578  int (*solve) (rpmts ts, rpmds ds, const void * data),
579  const void * solveData)
580  /*@modifies ts @*/;
581 
588  /*@*/;
589 
600 void rpmtsSetType(rpmts ts, rpmTSType type)
601  /*@modifies ts @*/;
602 
609  /*@*/;
610 
616 void rpmtsSetARBGoal(rpmts ts, rpmuint32_t goal)
617  /*@modifies ts @*/;
618 
624 /*@null@*/
626  /*@modifies ts @*/;
627 
632 void rpmtsCleanDig(rpmts ts)
633  /*@globals fileSystem @*/
634  /*@modifies ts, fileSystem @*/;
635 
640 void rpmtsClean(rpmts ts)
641  /*@globals fileSystem, internalState @*/
642  /*@modifies ts, fileSystem , internalState@*/;
643 
648 void rpmtsEmpty(rpmts ts)
649  /*@globals fileSystem, internalState @*/
650  /*@modifies ts, fileSystem, internalState @*/;
651 
657 /*@null@*/
658 rpmts rpmtsFree(/*@killref@*/ /*@null@*/ rpmts ts)
659  /*@globals fileSystem, internalState @*/
660  /*@modifies ts, fileSystem, internalState @*/;
661 #define rpmtsFree(_ts) \
662  ((rpmts) rpmioFreePoolItem((rpmioItem)(_ts), __FUNCTION__, __FILE__, __LINE__))
663 
670 void * rpmtsGetKeyring(rpmts ts, int autoload)
671  /*@*/;
672 
679 int rpmtsSetKeyring(rpmts ts, void * _keyring)
680  /*modifies ts, _keyring @*/;
681 
688  /*@*/;
689 
697  /*@modifies ts @*/;
698 
705 int rpmtsUnorderedSuccessors(rpmts ts, int first)
706  /*@modifies ts @*/;
707 
713 /*@observer@*/ /*@null@*/
714 extern const char * rpmtsRootDir(rpmts ts)
715  /*@*/;
716 
722 void rpmtsSetRootDir(rpmts ts, /*@null@*/ const char * rootDir)
723  /*@modifies ts @*/;
724 
730 /*@observer@*/ /*@null@*/
731 extern const char * rpmtsCurrDir(rpmts ts)
732  /*@*/;
733 
739 void rpmtsSetCurrDir(rpmts ts, /*@null@*/ const char * currDir)
740  /*@modifies ts @*/;
741 
742 #if defined(_RPMTS_INTERNAL) /* XXX avoid FD_t in API. */
743 
748 /*@null@*/
750  /*@*/;
751 
757 void rpmtsSetScriptFd(rpmts ts, /*@null@*/ FD_t scriptFd)
758  /*@globals fileSystem @*/
759  /*@modifies ts, scriptFd, fileSystem @*/;
760 #endif
761 
768  /*@*/;
769 
775 int rpmtsChrootDone(rpmts ts)
776  /*@*/;
777 
784 int rpmtsSetChrootDone(rpmts ts, int chrootDone)
785  /*@modifies ts @*/;
786 
793  /*@*/;
794 
802  /*@modifies ts @*/;
803 
810  /*@globals fileSystem @*/
811  /*@modifies fileSystem @*/;
812 
818 /*@-exportlocal@*/
819 /*@exposed@*/ /*@null@*/
821  /*@globals fileSystem @*/
822  /*@modifies fileSystem @*/;
823 /*@=exportlocal@*/
824 
830 /*@null@*/
832  /*@*/;
833 
839 /*@null@*/
841  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
842  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
843 
849 int rpmtsInitDSI(const rpmts ts)
850  /*@globals fileSystem, internalState @*/
851  /*@modifies ts, fileSystem, internalState @*/;
852 
862 void rpmtsUpdateDSI(const rpmts ts, dev_t dev,
863  rpmuint32_t fileSize, rpmuint32_t prevSize, rpmuint32_t fixupSize,
864  int _action)
865  /*@modifies ts @*/;
866 
872 void rpmtsCheckDSIProblems(const rpmts ts, const rpmte te)
873  /*@modifies ts @*/;
874 
886 /*@null@*/
887 void * rpmtsNotify(rpmts ts, rpmte te,
888  rpmCallbackType what, rpmuint64_t amount, rpmuint64_t total)
889  /*@modifies te @*/;
890 
896 int rpmtsNElements(rpmts ts)
897  /*@*/;
898 
905 /*@null@*/ /*@dependent@*/
906 rpmte rpmtsElement(rpmts ts, int ix)
907  /*@*/;
908 
915  /*@*/;
916 
923  /*@*/;
924 
932  /*@modifies ts @*/;
933 
940  /*@*/;
941 
949  /*@modifies ts @*/;
950 
956 /*@null@*/
957 Spec rpmtsSpec(rpmts ts)
958  /*@*/;
959 
966 /*@null@*/
967 Spec rpmtsSetSpec(rpmts ts, /*@null@*/ Spec spec)
968  /*@modifies ts @*/;
969 
975 /*@null@*/
977  /*@*/;
978 
985 /*@null@*/
986 rpmte rpmtsSetRelocateElement(rpmts ts, /*@null@*/ rpmte relocateElement)
987  /*@modifies ts @*/;
988 
995  /*@*/;
996 
1004  /*@modifies ts @*/;
1005 
1011 int rpmtsDBMode(rpmts ts)
1012  /*@*/;
1013 
1020 int rpmtsSetDBMode(rpmts ts, int dbmode)
1021  /*@modifies ts @*/;
1022 
1029  /*@*/;
1030 
1037  /*@*/;
1038 
1046  /*@modifies ts @*/;
1047 
1054 /*@relnull@*/
1055 rpmop rpmtsOp(rpmts ts, rpmtsOpX opx)
1056  /*@*/;
1057 
1070  /*@observer@*/ rpmCallbackFunction notify,
1071  /*@observer@*/ rpmCallbackData notifyData)
1072  /*@modifies ts @*/;
1073 
1078 /*@newref@*/
1079 rpmts rpmtsCreate(void)
1080  /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
1081  /*@modifies rpmGlobalMacroContext, internalState @*/;
1082 
1083 /*@-redecl@*/
1084 /*@unchecked@*/
1085 extern int rpmcliPackagesTotal;
1086 /*@=redecl@*/
1087 
1102  /*@exposed@*/ /*@null@*/ const fnpyKey key, int upgrade,
1103  /*@null@*/ rpmRelocation relocs)
1104  /*@globals rpmcliPackagesTotal, rpmGlobalMacroContext, h_errno,
1105  fileSystem, internalState @*/
1106  /*@modifies ts, h, rpmcliPackagesTotal, rpmGlobalMacroContext,
1107  fileSystem, internalState @*/;
1108 
1116 int rpmtsAddEraseElement(rpmts ts, Header h, uint32_t hdrNum)
1117  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
1118  /*@modifies ts, h, rpmGlobalMacroContext, fileSystem, internalState @*/;
1119 
1120 #if !defined(SWIG)
1121 #if defined(_RPMTS_PRINT)
1122 
1128 /*@unused@*/ static inline
1129 int rpmtsPrint(/*@null@*/ rpmts ts, /*@null@*/ FILE * fp)
1130  /*@globals fileSystem @*/
1131  /*@modifies ts, *fp, fileSystem @*/
1132 {
1133  rpmuint32_t tid = rpmtsGetTid(ts);
1134  time_t ttid = tid;
1135  rpmtsi tsi;
1136  rpmte te;
1137 
1138  if (fp == NULL)
1139  fp = stderr;
1140 
1141  fprintf(fp, _("=== Transaction at %-24.24s (0x%08x):\n"), ctime(&ttid),tid);
1142  tsi = rpmtsiInit(ts);
1143  while ((te = rpmtsiNext(tsi, (rpmElementType)0)) != NULL)
1144  fprintf(fp, "t%s> %s\n", (rpmteType(te) == TR_ADDED ? "I" : "E"),
1145  rpmteNEVRA(te));
1146  tsi = rpmtsiFree(tsi);
1147  return 0;
1148 }
1149 #endif /* defined(_RPMTS_PRINT) */
1150 #endif /* !defined(SWIG) */
1151 
1152 #ifdef __cplusplus
1153 }
1154 #endif
1155 
1156 
1157 #endif /* H_RPMTS */