rpm  5.2.1
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 "rpmsx.h"
12 #include <rpmpgp.h> /* XXX pgpVSFlags */
13 
14 /*@-exportlocal@*/
15 /*@unchecked@*/
16 extern int _rpmts_debug;
17 /*@unchecked@*/
18 extern int _rpmts_macros;
19 /*@unchecked@*/
20 extern int _rpmts_stats;
21 /*@unchecked@*/
22 extern int _fps_debug;
23 /*@=exportlocal@*/
24 
29 
34 typedef enum rpmdepFlags_e {
42  RPMDEPS_FLAG_ANACONDA = (1 << 6),
46 } rpmdepFlags;
47 
52 typedef enum rpmtransFlags_e {
54  RPMTRANS_FLAG_TEST = (1 << 0),
57  RPMTRANS_FLAG_JUSTDB = (1 << 3),
59  RPMTRANS_FLAG_NODOCS = (1 << 5),
61  /* 7 unused */
67 /*@-enummemuse@*/
68  RPMTRANS_FLAG_PKGUNDO = (1 << 12),
69 /*@=enummemuse@*/
70  RPMTRANS_FLAG_COMMIT = (1 << 13),
71 /*@-enummemuse@*/
72  RPMTRANS_FLAG_UNDO = (1 << 14),
73 /*@=enummemuse@*/
75 
77  RPMTRANS_FLAG_NOPRE = (1 << 17),
78  RPMTRANS_FLAG_NOPOST = (1 << 18),
81  RPMTRANS_FLAG_NOPREUN = (1 << 21),
82  RPMTRANS_FLAG_NOPOSTUN = (1 << 22),
84 /*@-enummemuse@*/
86 /*@=enummemuse@*/
87  RPMTRANS_FLAG_NORPMDB = (1 << 25),
88  /* 26 unused */
93  /* 31 unused */
95 
96 #define _noTransScripts \
97  ( RPMTRANS_FLAG_NOPRETRANS | \
98  RPMTRANS_FLAG_NOPRE | \
99  RPMTRANS_FLAG_NOPOST | \
100  RPMTRANS_FLAG_NOPREUN | \
101  RPMTRANS_FLAG_NOPOSTUN | \
102  RPMTRANS_FLAG_NOPOSTTRANS \
103  )
104 
105 #define _noTransTriggers \
106  ( RPMTRANS_FLAG_NOTRIGGERPREIN | \
107  RPMTRANS_FLAG_NOTRIGGERIN | \
108  RPMTRANS_FLAG_NOTRIGGERUN | \
109  RPMTRANS_FLAG_NOTRIGGERPOSTUN \
110  )
111 
115 typedef enum rpmtsOpX_e {
138 } rpmtsOpX;
139 
143 typedef enum rpmTSType_e {
147 } rpmTSType;
148 
151 typedef enum tsStage_e {
155 } tsmStage;
156 
157 #if defined(_RPMTS_INTERNAL)
158 
159 #include "rpmhash.h" /* XXX hashTable */
160 #include "rpmkeyring.h"
161 #include "rpmal.h" /* XXX availablePackage/relocateFileList ,*/
162 
163 /*@unchecked@*/
164 /*@-exportlocal@*/
165 extern int _cacheDependsRC;
166 /*@=exportlocal@*/
167 
170 typedef /*@abstract@*/ struct diskspaceInfo_s * rpmDiskSpaceInfo;
171 
175 struct diskspaceInfo_s {
176  unsigned long f_bsize;
177  unsigned long f_frsize;
178  unsigned long long f_blocks;
179  unsigned long long f_bfree;
180  signed long long f_bavail;
181  unsigned long long f_files;
182  unsigned long long f_ffree;
183  signed long long f_favail;
184  unsigned long f_fsid;
185  unsigned long f_flag;
186  unsigned long f_namemax;
188  signed long long bneeded;
189  signed long long ineeded;
190  dev_t dev;
191 };
192 
196 #define adj_fs_blocks(_nb) (((_nb) * 21) / 20)
197 
198 #define BLOCK_ROUND(size, block) (((size) + (block) - 1) / (block))
199 
203 struct rpmts_s {
204  struct rpmioItem_s _item;
205  rpmdepFlags depFlags;
206  rpmtransFlags transFlags;
207  tsmStage goal;
208  rpmTSType type;
210 /*@refcounted@*/ /*@null@*/
211  rpmdb sdb;
212  int sdbmode;
213 /*@null@*/
214  int (*solve) (rpmts ts, rpmds key, const void * data)
215  /*@modifies ts @*/;
216 /*@relnull@*/
217  const void * solveData;
218  int nsuggests;
219 /*@only@*/ /*@null@*/
220  const void ** suggests;
222 /*@observer@*/ /*@null@*/
223  rpmCallbackFunction notify;
224 /*@observer@*/ /*@null@*/
225  rpmCallbackData notifyData;
227 /*@null@*/
228  rpmPRCO PRCO;
230 /*@refcounted@*/ /*@null@*/
231  rpmps probs;
232  rpmprobFilterFlags ignoreSet;
235  rpmuint32_t filesystemCount;
236 /*@dependent@*/ /*@null@*/
237  const char ** filesystems;
238 /*@only@*/ /*@relnull@*/
239  rpmDiskSpaceInfo dsi;
241 /*@refcounted@*/ /*@null@*/
242  rpmdb rdb;
243  int dbmode;
244 /*@only@*/
245  hashTable ht;
247 /*@only@*/ /*@null@*/
248  int * removedPackages;
249  int numRemovedPackages;
250  int allocedRemovedPackages;
252 /*@only@*/
253  rpmal addedPackages;
254  int numAddedPackages;
256 /*@only@*/
257  rpmal erasedPackages;
258  int numErasedPackages;
260 #ifndef DYING
261 /*@only@*/
262  rpmal availablePackages;
263  int numAvailablePackages;
264 #endif
265 
266 /*@refcounted@*/ /*@null@*/
267  rpmsx sx;
269 /*@null@*/
270  rpmte relocateElement;
272 /*@owned@*/ /*@relnull@*/
273  rpmte * order;
274  int orderCount;
275  int orderAlloced;
276  int unorderedSuccessors;
277  int ntrees;
278  int maxDepth;
280 /*@dependent@*/ /*@relnull@*/
281  rpmte teInstall;
282 /*@dependent@*/ /*@relnull@*/
283  rpmte teErase;
285  int selinuxEnabled;
286  int chrootDone;
287 /*@only@*/ /*@null@*/
288  const char * rootDir;
289 /*@only@*/ /*@null@*/
290  const char * currDir;
291 /*@null@*/
292  FD_t scriptFd;
293  int delta;
294  rpmuint32_t tid[2];
296  rpmuint32_t color;
297  rpmuint32_t prefcolor;
299 /*@observer@*/ /*@dependent@*/ /*@null@*/
300  const char * fn;
302 /*@refcounted@*/ /*@relnull@*/
303  rpmKeyring keyring;
304 /*@relnull@*/
305  rpmuint8_t * pkpkt;
306  size_t pkpktlen;
307  rpmuint8_t pksignid[8];
309  struct rpmop_s ops[RPMTS_OP_MAX];
310 
311 /*@refcounted@*/ /*@relnull@*/
312  pgpDig dig;
314 /*@null@*/
315  Spec spec;
317  rpmuint32_t arbgoal;
319 #if defined(__LCLINT__)
320 /*@refs@*/
321  int nrefs;
322 #endif
323 };
324 #endif /* _RPMTS_INTERNAL */
325 
326 #ifdef __cplusplus
327 extern "C" {
328 #endif
329 
340 int rpmtsCheck(rpmts ts)
341  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
342  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
343 
360 int rpmtsOrder(rpmts ts)
361  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
362  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
363 
381 int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
382  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
383  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
384 
394  int running, rpmte rbte)
395  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
396  /*@modifies rbts, rbte, rpmGlobalMacroContext, fileSystem, internalState @*/;
397 
404 /*@unused@*/ /*@null@*/
405 rpmts rpmtsUnlink (/*@killref@*/ /*@only@*/ rpmts ts,
406  const char * msg)
407  /*@modifies ts @*/;
408 #define rpmtsUnlink(_ts, _msg) \
409  ((rpmts) rpmioUnlinkPoolItem((rpmioItem)(_ts), _msg, __FILE__, __LINE__))
410 
417 /*@unused@*/ /*@newref@*/
418 rpmts rpmtsLink (rpmts ts, const char * msg)
419  /*@modifies ts @*/;
420 #define rpmtsLink(_ts, _msg) \
421  ((rpmts) rpmioLinkPoolItem((rpmioItem)(_ts), _msg, __FILE__, __LINE__))
422 
428 int rpmtsCloseDB(rpmts ts)
429  /*@globals fileSystem @*/
430  /*@modifies ts, fileSystem @*/;
431 
438 int rpmtsOpenDB(rpmts ts, int dbmode)
439  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
440  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
441 
449 int rpmtsInitDB(rpmts ts, int dbmode)
450  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
451  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
452 
458 int rpmtsRebuildDB(rpmts ts)
459  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
460  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
461 
467 int rpmtsVerifyDB(rpmts ts)
468  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
469  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
470 
479 /*@only@*/ /*@null@*/
480 rpmmi rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
481  /*@null@*/ const void * keyp, size_t keylen)
482  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
483  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
484 
491 /*@-exportlocal@*/
492 rpmRC rpmtsFindPubkey(rpmts ts, /*@null@*/ void * _dig)
493  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
494  /*@modifies ts, _dig, rpmGlobalMacroContext, fileSystem, internalState */;
495 /*@=exportlocal@*/
496 
502 /*@-exportlocal@*/
503 int rpmtsCloseSDB(rpmts ts)
504  /*@globals fileSystem @*/
505  /*@modifies ts, fileSystem @*/;
506 /*@=exportlocal@*/
507 
514 /*@-exportlocal@*/
515 int rpmtsOpenSDB(rpmts ts, int dbmode)
516  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
517  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
518 /*@=exportlocal@*/
519 
527 /*@-exportlocal@*/
528 int rpmtsSolve(rpmts ts, rpmds ds, const void * data)
529  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
530  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
531 /*@=exportlocal@*/
532 
540 /*@unused@*/
541 int rpmtsAvailable(rpmts ts, const rpmds ds)
542  /*@globals fileSystem, internalState @*/
543  /*@modifies ts, fileSystem, internalState @*/;
544 
553  int (*solve) (rpmts ts, rpmds ds, const void * data),
554  const void * solveData)
555  /*@modifies ts @*/;
556 
563  /*@*/;
564 
575 void rpmtsSetType(rpmts ts, rpmTSType type)
576  /*@modifies ts @*/;
577 
584  /*@*/;
585 
591 void rpmtsSetARBGoal(rpmts ts, rpmuint32_t goal)
592  /*@modifies ts @*/;
593 
599 /*@null@*/
601  /*@modifies ts @*/;
602 
607 void rpmtsCleanDig(rpmts ts)
608  /*@globals fileSystem @*/
609  /*@modifies ts, fileSystem @*/;
610 
615 void rpmtsClean(rpmts ts)
616  /*@globals fileSystem, internalState @*/
617  /*@modifies ts, fileSystem , internalState@*/;
618 
623 void rpmtsEmpty(rpmts ts)
624  /*@globals fileSystem, internalState @*/
625  /*@modifies ts, fileSystem, internalState @*/;
626 
632 /*@null@*/
633 rpmts rpmtsFree(/*@killref@*/ /*@null@*/ rpmts ts)
634  /*@globals fileSystem, internalState @*/
635  /*@modifies ts, fileSystem, internalState @*/;
636 #define rpmtsFree(_ts) \
637  ((rpmts) rpmioFreePoolItem((rpmioItem)(_ts), __FUNCTION__, __FILE__, __LINE__))
638 
645 void * rpmtsGetKeyring(rpmts ts, int autoload)
646  /*@*/;
647 
654 int rpmtsSetKeyring(rpmts ts, void * _keyring)
655  /*modifies ts, _keyring @*/;
656 
663  /*@*/;
664 
672  /*@modifies ts @*/;
673 
680 int rpmtsUnorderedSuccessors(rpmts ts, int first)
681  /*@modifies ts @*/;
682 
688 /*@observer@*/ /*@null@*/
689 extern const char * rpmtsRootDir(rpmts ts)
690  /*@*/;
691 
697 void rpmtsSetRootDir(rpmts ts, /*@null@*/ const char * rootDir)
698  /*@modifies ts @*/;
699 
705 /*@observer@*/ /*@null@*/
706 extern const char * rpmtsCurrDir(rpmts ts)
707  /*@*/;
708 
714 void rpmtsSetCurrDir(rpmts ts, /*@null@*/ const char * currDir)
715  /*@modifies ts @*/;
716 
717 #if defined(_RPMTS_INTERNAL) /* XXX avoid FD_t in API. */
718 
723 /*@null@*/
725  /*@*/;
726 
732 void rpmtsSetScriptFd(rpmts ts, /*@null@*/ FD_t scriptFd)
733  /*@globals fileSystem @*/
734  /*@modifies ts, scriptFd, fileSystem @*/;
735 #endif
736 
743  /*@*/;
744 
750 int rpmtsChrootDone(rpmts ts)
751  /*@*/;
752 
759 int rpmtsSetChrootDone(rpmts ts, int chrootDone)
760  /*@modifies ts @*/;
761 
768  /*@*/;
769 
777  /*@modifies ts @*/;
778 
785  /*@globals fileSystem @*/
786  /*@modifies fileSystem @*/;
787 
793 /*@-exportlocal@*/
794 /*@exposed@*/ /*@null@*/
796  /*@globals fileSystem @*/
797  /*@modifies fileSystem @*/;
798 /*@=exportlocal@*/
799 
805 /*@null@*/
807  /*@*/;
808 
814 /*@null@*/
816  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
817  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
818 
824 int rpmtsInitDSI(const rpmts ts)
825  /*@globals fileSystem, internalState @*/
826  /*@modifies ts, fileSystem, internalState @*/;
827 
837 void rpmtsUpdateDSI(const rpmts ts, dev_t dev,
838  rpmuint32_t fileSize, rpmuint32_t prevSize, rpmuint32_t fixupSize,
839  int _action)
840  /*@modifies ts @*/;
841 
847 void rpmtsCheckDSIProblems(const rpmts ts, const rpmte te)
848  /*@modifies ts @*/;
849 
861 /*@null@*/
862 void * rpmtsNotify(rpmts ts, rpmte te,
863  rpmCallbackType what, rpmuint64_t amount, rpmuint64_t total)
864  /*@modifies te @*/;
865 
871 int rpmtsNElements(rpmts ts)
872  /*@*/;
873 
880 /*@null@*/ /*@dependent@*/
881 rpmte rpmtsElement(rpmts ts, int ix)
882  /*@*/;
883 
890  /*@*/;
891 
898  /*@*/;
899 
907  /*@modifies ts @*/;
908 
915  /*@*/;
916 
924  /*@modifies ts @*/;
925 
931 /*@null@*/
932 Spec rpmtsSpec(rpmts ts)
933  /*@*/;
934 
941 /*@null@*/
942 Spec rpmtsSetSpec(rpmts ts, /*@null@*/ Spec spec)
943  /*@modifies ts @*/;
944 
950 /*@null@*/
952  /*@*/;
953 
960 /*@null@*/
961 rpmte rpmtsSetRelocateElement(rpmts ts, /*@null@*/ rpmte relocateElement)
962  /*@modifies ts @*/;
963 
970  /*@*/;
971 
979  /*@modifies ts @*/;
980 
986 int rpmtsDBMode(rpmts ts)
987  /*@*/;
988 
995 int rpmtsSetDBMode(rpmts ts, int dbmode)
996  /*@modifies ts @*/;
997 
1004  /*@*/;
1005 
1012  /*@*/;
1013 
1021  /*@modifies ts @*/;
1022 
1029 /*@relnull@*/
1030 rpmop rpmtsOp(rpmts ts, rpmtsOpX opx)
1031  /*@*/;
1032 
1045  /*@observer@*/ rpmCallbackFunction notify,
1046  /*@observer@*/ rpmCallbackData notifyData)
1047  /*@modifies ts @*/;
1048 
1053 /*@newref@*/
1054 rpmts rpmtsCreate(void)
1055  /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
1056  /*@modifies rpmGlobalMacroContext, internalState @*/;
1057 
1058 /*@-redecl@*/
1059 /*@unchecked@*/
1060 extern int rpmcliPackagesTotal;
1061 /*@=redecl@*/
1062 
1077  /*@exposed@*/ /*@null@*/ const fnpyKey key, int upgrade,
1078  /*@null@*/ rpmRelocation relocs)
1079  /*@globals rpmcliPackagesTotal, rpmGlobalMacroContext, h_errno,
1080  fileSystem, internalState @*/
1081  /*@modifies ts, h, rpmcliPackagesTotal, rpmGlobalMacroContext,
1082  fileSystem, internalState @*/;
1083 
1091 int rpmtsAddEraseElement(rpmts ts, Header h, int dboffset)
1092  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
1093  /*@modifies ts, h, rpmGlobalMacroContext, fileSystem, internalState @*/;
1094 
1095 #if !defined(SWIG)
1096 #if defined(_RPMTS_PRINT)
1097 
1103 /*@unused@*/ static inline
1104 int rpmtsPrint(/*@null@*/ rpmts ts, /*@null@*/ FILE * fp)
1105  /*@globals fileSystem @*/
1106  /*@modifies ts, *fp, fileSystem @*/
1107 {
1108  rpmuint32_t tid = rpmtsGetTid(ts);
1109  time_t ttid = tid;
1110  rpmtsi tsi;
1111  rpmte te;
1112 
1113  if (fp == NULL)
1114  fp = stderr;
1115 
1116  fprintf(fp, _("=== Transaction at %-24.24s (0x%08x):\n"), ctime(&ttid),tid);
1117  tsi = rpmtsiInit(ts);
1118  while ((te = rpmtsiNext(tsi, 0)) != NULL)
1119  fprintf(fp, "t%s> %s\n", (rpmteType(te) == TR_ADDED ? "I" : "E"),
1120  rpmteNEVRA(te));
1121  tsi = rpmtsiFree(tsi);
1122  return 0;
1123 }
1124 #endif /* defined(_RPMTS_PRINT) */
1125 #endif /* !defined(SWIG) */
1126 
1127 #ifdef __cplusplus
1128 }
1129 #endif
1130 
1131 
1132 #endif /* H_RPMTS */