rpm  4.5
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 
13 /*@-exportlocal@*/
14 /*@unchecked@*/
15 extern int _rpmts_debug;
16 /*@unchecked@*/
17 extern int _rpmts_stats;
18 /*@unchecked@*/
19 extern int _fps_debug;
20 /*@=exportlocal@*/
21 
25 typedef enum rpmVSFlags_e {
27  RPMVSF_NOHDRCHK = (1 << 0),
28  RPMVSF_NEEDPAYLOAD = (1 << 1),
29  /* bit(s) 2-7 unused */
30  RPMVSF_NOSHA1HEADER = (1 << 8),
31  RPMVSF_NOMD5HEADER = (1 << 9), /* unimplemented */
32  RPMVSF_NODSAHEADER = (1 << 10),
33  RPMVSF_NORSAHEADER = (1 << 11),
34  /* bit(s) 12-15 unused */
35  RPMVSF_NOSHA1 = (1 << 16), /* unimplemented */
36  RPMVSF_NOMD5 = (1 << 17),
37  RPMVSF_NODSA = (1 << 18),
38  RPMVSF_NORSA = (1 << 19)
39  /* bit(s) 20-31 unused */
40 } rpmVSFlags;
41 
45 typedef enum rpmTSType_e {
49 } rpmTSType;
50 
51 #define _RPMVSF_NODIGESTS \
52  ( RPMVSF_NOSHA1HEADER | \
53  RPMVSF_NOMD5HEADER | \
54  RPMVSF_NOSHA1 | \
55  RPMVSF_NOMD5 )
56 
57 #define _RPMVSF_NOSIGNATURES \
58  ( RPMVSF_NODSAHEADER | \
59  RPMVSF_NORSAHEADER | \
60  RPMVSF_NODSA | \
61  RPMVSF_NORSA )
62 
63 #define _RPMVSF_NOHEADER \
64  ( RPMVSF_NOSHA1HEADER | \
65  RPMVSF_NOMD5HEADER | \
66  RPMVSF_NODSAHEADER | \
67  RPMVSF_NORSAHEADER )
68 
69 #define _RPMVSF_NOPAYLOAD \
70  ( RPMVSF_NOSHA1 | \
71  RPMVSF_NOMD5 | \
72  RPMVSF_NODSA | \
73  RPMVSF_NORSA )
74 
78 typedef enum rpmtsOpX_e {
98 } rpmtsOpX;
99 
100 #if defined(_RPMTS_INTERNAL)
101 
102 #include "rpmhash.h" /* XXX hashTable */
103 #include "rpmal.h" /* XXX availablePackage/relocateFileList ,*/
104 
105 /*@unchecked@*/
106 /*@-exportlocal@*/
107 extern int _cacheDependsRC;
108 /*@=exportlocal@*/
109 
112 typedef /*@abstract@*/ struct diskspaceInfo_s * rpmDiskSpaceInfo;
113 
117 struct diskspaceInfo_s {
118  unsigned long f_bsize;
119  unsigned long f_frsize;
120  unsigned long long f_blocks;
121  unsigned long long f_bfree;
122  signed long long f_bavail;
123  unsigned long long f_files;
124  unsigned long long f_ffree;
125  signed long long f_favail;
126  unsigned long f_fsid;
127  unsigned long f_flag;
128  unsigned long f_namemax;
130  signed long long bneeded;
131  signed long long ineeded;
132  dev_t dev;
133 };
134 
138 #define adj_fs_blocks(_nb) (((_nb) * 21) / 20)
139 
140 #define BLOCK_ROUND(size, block) (((size) + (block) - 1) / (block))
141 
144 typedef enum tsStage_e {
145  TSM_UNKNOWN = 0,
146  TSM_INSTALL = 7,
147  TSM_ERASE = 8,
148 } tsmStage;
149 
153 struct rpmts_s {
154  rpmdepFlags depFlags;
155  rpmtransFlags transFlags;
156  tsmStage goal;
157  rpmTSType type;
159 /*@refcounted@*/ /*@null@*/
160  rpmdb sdb;
161  int sdbmode;
162 /*@null@*/
163  int (*solve) (rpmts ts, rpmds key, const void * data)
164  /*@modifies ts @*/;
165 /*@relnull@*/
166  const void * solveData;
167  int nsuggests;
168 /*@only@*/ /*@null@*/
169  const void ** suggests;
171 /*@observer@*/ /*@null@*/
172  rpmCallbackFunction notify;
173 /*@observer@*/ /*@null@*/
174  rpmCallbackData notifyData;
176 /*@null@*/
177  rpmPRCO PRCO;
179 /*@refcounted@*/ /*@null@*/
180  rpmps probs;
181  rpmprobFilterFlags ignoreSet;
184  int filesystemCount;
185 /*@dependent@*/ /*@null@*/
186  const char ** filesystems;
187 /*@only@*/ /*@null@*/
188  rpmDiskSpaceInfo dsi;
190 /*@refcounted@*/ /*@null@*/
191  rpmdb rdb;
192  int dbmode;
193 /*@only@*/
194  hashTable ht;
196 /*@only@*/ /*@null@*/
197  int * removedPackages;
198  int numRemovedPackages;
199  int allocedRemovedPackages;
201 /*@only@*/
202  rpmal addedPackages;
203  int numAddedPackages;
205 /*@only@*/
206  rpmal erasedPackages;
207  int numErasedPackages;
209 #ifndef DYING
210 /*@only@*/
211  rpmal availablePackages;
212  int numAvailablePackages;
213 #endif
214 
215 /*@refcounted@*/ /*@null@*/
216  rpmsx sx;
218 /*@null@*/
219  rpmte relocateElement;
221 /*@owned@*/ /*@relnull@*/
222  rpmte * order;
223  int orderCount;
224  int orderAlloced;
225  int unorderedSuccessors;
226  int ntrees;
227  int maxDepth;
229 /*@dependent@*/
230  rpmte teInstall;
231 /*@dependent@*/
232  rpmte teErase;
234  int selinuxEnabled;
235  int chrootDone;
236 /*@only@*/ /*@null@*/
237  const char * rootDir;
238 /*@only@*/ /*@null@*/
239  const char * currDir;
240 /*@null@*/
241  FD_t scriptFd;
242  int delta;
243  int_32 tid;
245  uint_32 color;
246  uint_32 prefcolor;
248  rpmVSFlags vsflags;
250 /*@observer@*/ /*@dependent@*/ /*@null@*/
251  const char * fn;
252  int_32 sigtag;
253  int_32 sigtype;
254 /*@null@*/
255  const void * sig;
256  int_32 siglen;
258 /*@only@*/ /*@null@*/
259  const unsigned char * pkpkt;
260  size_t pkpktlen;
261  unsigned char pksignid[8];
263  struct rpmop_s ops[RPMTS_OP_MAX];
264 
265 /*@null@*/
266  pgpDig dig;
268 /*@null@*/
269  Spec spec;
271 #ifdef DYING
272 /*@kept@*/ /*@null@*/
273  rpmtsScore score;
274 #endif
275 
276  uint_32 arbgoal;
278 /*@refs@*/
279  int nrefs;
280 };
281 #endif /* _RPMTS_INTERNAL */
282 
283 #ifdef __cplusplus
284 extern "C" {
285 #endif
286 
292 int rpmtsCheck(rpmts ts)
293  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
294  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
295 int rpmrbCheck(rpmts ts)
296  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
297  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
298 
315 int rpmtsOrder(rpmts ts)
316  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
317  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
318 int rpmrbOrder(rpmts ts)
319  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
320  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
321 
339 int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
340  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
341  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
342 int rpmrbRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
343  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
344  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
345 
355  int running, rpmte rbte)
356  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
357  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
358 
365 /*@unused@*/ /*@null@*/
366 rpmts rpmtsUnlink (/*@killref@*/ /*@only@*/ rpmts ts,
367  const char * msg)
368  /*@modifies ts @*/;
369 
371 /*@-exportlocal@*/
372 /*@null@*/
373 rpmts XrpmtsUnlink (/*@killref@*/ /*@only@*/ rpmts ts,
374  const char * msg, const char * fn, unsigned ln)
375  /*@modifies ts @*/;
376 /*@=exportlocal@*/
377 #define rpmtsUnlink(_ts, _msg) XrpmtsUnlink(_ts, _msg, __FILE__, __LINE__)
378 
385 /*@unused@*/
386 rpmts rpmtsLink (rpmts ts, const char * msg)
387  /*@modifies ts @*/;
388 
391  const char * msg, const char * fn, unsigned ln)
392  /*@modifies ts @*/;
393 #define rpmtsLink(_ts, _msg) XrpmtsLink(_ts, _msg, __FILE__, __LINE__)
394 
400 int rpmtsCloseDB(rpmts ts)
401  /*@globals fileSystem @*/
402  /*@modifies ts, fileSystem @*/;
403 
410 int rpmtsOpenDB(rpmts ts, int dbmode)
411  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
412  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
413 
421 int rpmtsInitDB(rpmts ts, int dbmode)
422  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
423  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
424 
430 int rpmtsRebuildDB(rpmts ts)
431  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
432  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
433 
439 int rpmtsVerifyDB(rpmts ts)
440  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
441  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
442 
451 /*@only@*/ /*@null@*/
453  /*@null@*/ const void * keyp, size_t keylen)
454  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
455  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
456 
462 /*@-exportlocal@*/
464  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
465  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState */;
466 /*@=exportlocal@*/
467 
473 /*@-exportlocal@*/
474 int rpmtsCloseSDB(rpmts ts)
475  /*@globals fileSystem @*/
476  /*@modifies ts, fileSystem @*/;
477 /*@=exportlocal@*/
478 
485 /*@-exportlocal@*/
486 int rpmtsOpenSDB(rpmts ts, int dbmode)
487  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
488  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
489 /*@=exportlocal@*/
490 
498 /*@-exportlocal@*/
499 int rpmtsSolve(rpmts ts, rpmds ds, const void * data)
500  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
501  /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
502 /*@=exportlocal@*/
503 
511 /*@unused@*/
512 int rpmtsAvailable(rpmts ts, const rpmds ds)
513  /*@globals fileSystem @*/
514  /*@modifies ts, fileSystem @*/;
515 
524  int (*solve) (rpmts ts, rpmds ds, const void * data),
525  const void * solveData)
526  /*@modifies ts @*/;
527 
534  /*@*/;
535 
546 void rpmtsSetType(rpmts ts, rpmTSType type)
547  /*@modifies ts @*/;
548 
555  /*@*/;
556 
562 void rpmtsSetARBGoal(rpmts ts, uint_32 goal)
563  /*@modifies ts @*/;
564 
570 /*@null@*/
572  /*@modifies ts @*/;
573 
578 void rpmtsCleanDig(rpmts ts)
579  /*@modifies ts @*/;
580 
585 void rpmtsClean(rpmts ts)
586  /*@globals fileSystem, internalState @*/
587  /*@modifies ts, fileSystem , internalState@*/;
588 
593 void rpmtsEmpty(rpmts ts)
594  /*@globals fileSystem, internalState @*/
595  /*@modifies ts, fileSystem, internalState @*/;
596 
602 /*@null@*/
603 rpmts rpmtsFree(/*@killref@*/ /*@only@*//*@null@*/ rpmts ts)
604  /*@globals fileSystem, internalState @*/
605  /*@modifies ts, fileSystem, internalState @*/;
606 
613  /*@*/;
614 
622  /*@modifies ts @*/;
623 
630 int rpmtsUnorderedSuccessors(rpmts ts, int first)
631  /*@modifies ts @*/;
632 
638 /*@observer@*/ /*@null@*/
639 extern const char * rpmtsRootDir(rpmts ts)
640  /*@*/;
641 
647 void rpmtsSetRootDir(rpmts ts, /*@null@*/ const char * rootDir)
648  /*@modifies ts @*/;
649 
655 /*@observer@*/ /*@null@*/
656 extern const char * rpmtsCurrDir(rpmts ts)
657  /*@*/;
658 
664 void rpmtsSetCurrDir(rpmts ts, /*@null@*/ const char * currDir)
665  /*@modifies ts @*/;
666 
672 /*@null@*/
674  /*@*/;
675 
681 void rpmtsSetScriptFd(rpmts ts, /*@null@*/ FD_t scriptFd)
682  /*@modifies ts, scriptFd @*/;
683 
690  /*@*/;
691 
697 int rpmtsChrootDone(rpmts ts)
698  /*@*/;
699 
706 int rpmtsSetChrootDone(rpmts ts, int chrootDone)
707  /*@modifies ts @*/;
708 
714 /*@null@*/
715 rpmsx rpmtsREContext(const rpmts ts)
716  /*@modifies ts @*/;
717 
724 int rpmtsSetREContext(rpmts ts, rpmsx sx)
725  /*@modifies ts, sx @*/;
726 
733  /*@*/;
734 
742  /*@modifies ts @*/;
743 
749 int_32 rpmtsSigtag(const rpmts ts)
750  /*@*/;
751 
757 int_32 rpmtsSigtype(const rpmts ts)
758  /*@*/;
759 
765 /*@observer@*/ /*@null@*/
766 extern const void * rpmtsSig(const rpmts ts)
767  /*@*/;
768 
774 int_32 rpmtsSiglen(const rpmts ts)
775  /*@*/;
776 
786 int rpmtsSetSig(rpmts ts,
787  int_32 sigtag, int_32 sigtype,
788  /*@kept@*/ /*@null@*/ const void * sig, int_32 siglen)
789  /*@modifies ts @*/;
790 
796 /*@exposed@*/ /*@null@*/
798  /*@*/;
799 
805 /*@exposed@*/ /*@null@*/
807  /*@*/;
808 
814 /*@-exportlocal@*/
815 /*@exposed@*/ /*@null@*/
817  /*@*/;
818 /*@=exportlocal@*/
819 
825 /*@null@*/
827  /*@*/;
828 
834 /*@null@*/
836  /*@*/;
837 
843 int rpmtsInitDSI(const rpmts ts)
844  /*@globals fileSystem, internalState @*/
845  /*@modifies ts, fileSystem, internalState @*/;
846 
856 void rpmtsUpdateDSI(const rpmts ts, dev_t dev,
857  uint_32 fileSize, uint_32 prevSize, uint_32 fixupSize,
858  fileAction action)
859  /*@modifies ts @*/;
860 
866 void rpmtsCheckDSIProblems(const rpmts ts, const rpmte te)
867  /*@modifies ts @*/;
868 
880 /*@null@*/
881 void * rpmtsNotify(rpmts ts, rpmte te,
882  rpmCallbackType what, unsigned long long amount, unsigned long long total)
883  /*@*/;
884 
890 int rpmtsNElements(rpmts ts)
891  /*@*/;
892 
899 /*@null@*/ /*@dependent@*/
900 rpmte rpmtsElement(rpmts ts, int ix)
901  /*@*/;
902 
909  /*@*/;
910 
917  /*@*/;
918 
926  /*@modifies ts @*/;
927 
934  /*@*/;
935 
943  /*@modifies ts @*/;
944 
950 /*@null@*/
951 Spec rpmtsSpec(rpmts ts)
952  /*@*/;
953 
960 /*@null@*/
961 Spec rpmtsSetSpec(rpmts ts, /*@null@*/ Spec spec)
962  /*@modifies ts @*/;
963 
969 /*@null@*/
971  /*@*/;
972 
979 /*@null@*/
980 rpmte rpmtsSetRelocateElement(rpmts ts, /*@null@*/ rpmte relocateElement)
981  /*@modifies ts @*/;
982 
989  /*@*/;
990 
997  /*@*/;
998 
1006  /*@modifies ts @*/;
1007 
1014 /*@relnull@*/
1015 rpmop rpmtsOp(rpmts ts, rpmtsOpX opx)
1016  /*@*/;
1017 
1030  /*@observer@*/ rpmCallbackFunction notify,
1031  /*@observer@*/ rpmCallbackData notifyData)
1032  /*@modifies ts @*/;
1033 
1038 /*@newref@*/
1039 rpmts rpmtsCreate(void)
1040  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
1041  /*@modifies rpmGlobalMacroContext, fileSystem, internalState @*/;
1042 
1057  /*@exposed@*/ /*@null@*/ const fnpyKey key, int upgrade,
1058  /*@null@*/ rpmRelocation relocs)
1059  /*@globals rpmcliPackagesTotal, rpmGlobalMacroContext, h_errno,
1060  fileSystem, internalState @*/
1061  /*@modifies ts, h, rpmcliPackagesTotal, rpmGlobalMacroContext,
1062  fileSystem, internalState @*/;
1063 
1071 int rpmtsAddEraseElement(rpmts ts, Header h, int dboffset)
1072  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
1073  /*@modifies ts, h, rpmGlobalMacroContext, fileSystem, internalState @*/;
1074 
1075 #if !defined(SWIG)
1076 #if defined(_RPMTS_INTERNAL)
1077 
1083 /*@unused@*/ static inline
1084 int rpmtsPrint(/*@null@*/ rpmts ts, /*@null@*/ FILE * fp)
1085  /*@globals fileSystem @*/
1086  /*@modifies ts, *fp, fileSystem @*/
1087 {
1088  int tid = rpmtsGetTid(ts);
1089  time_t ttid = tid;
1090  rpmtsi tsi;
1091  rpmte te;
1092 
1093  if (fp == NULL)
1094  fp = stderr;
1095 
1096  fprintf(fp, _("=== Transaction at %-24.24s (0x%08x):\n"), ctime(&ttid),tid);
1097  tsi = rpmtsiInit(ts);
1098  while ((te = rpmtsiNext(tsi, 0)) != NULL)
1099  fprintf(fp, "t%s> %s\n", (rpmteType(te) == TR_ADDED ? "I" : "E"),
1100  rpmteNEVRA(te));
1101  tsi = rpmtsiFree(tsi);
1102  return 0;
1103 }
1104 #endif /* defined(_RPMTS_INTERNAL) */
1105 #endif /* !defined(SWIG) */
1106 
1107 #ifdef __cplusplus
1108 }
1109 #endif
1110 
1111 
1112 #endif /* H_RPMTS */