00001 #ifndef H_RPMTS
00002 #define H_RPMTS
00003
00009 #include "rpmps.h"
00010 #include "rpmfi.h"
00011 #include "rpmsw.h"
00012 #include "rpmsx.h"
00013 #include <rpmpgp.h>
00014
00015
00016
00017 extern int _rpmts_debug;
00018
00019 extern int _rpmts_macros;
00020
00021 extern int _rpmts_stats;
00022
00023 extern int _fps_debug;
00024
00025
00029 typedef pgpVSFlags rpmVSFlags;
00030
00035 typedef enum rpmdepFlags_e {
00036 RPMDEPS_FLAG_NONE = 0,
00037 RPMDEPS_FLAG_NOUPGRADE = (1 << 0),
00038 RPMDEPS_FLAG_NOREQUIRES = (1 << 1),
00039 RPMDEPS_FLAG_NOCONFLICTS = (1 << 2),
00040 RPMDEPS_FLAG_NOOBSOLETES = (1 << 3),
00041 RPMDEPS_FLAG_NOPARENTDIRS = (1 << 4),
00042 RPMDEPS_FLAG_NOLINKTOS = (1 << 5),
00043 RPMDEPS_FLAG_ANACONDA = (1 << 6),
00044 RPMDEPS_FLAG_NOSUGGEST = (1 << 7),
00045 RPMDEPS_FLAG_ADDINDEPS = (1 << 8),
00046 RPMDEPS_FLAG_DEPLOOPS = (1 << 9)
00047 } rpmdepFlags;
00048
00053 typedef enum rpmtransFlags_e {
00054 RPMTRANS_FLAG_NONE = 0,
00055 RPMTRANS_FLAG_TEST = (1 << 0),
00056 RPMTRANS_FLAG_BUILD_PROBS = (1 << 1),
00057 RPMTRANS_FLAG_NOSCRIPTS = (1 << 2),
00058 RPMTRANS_FLAG_JUSTDB = (1 << 3),
00059 RPMTRANS_FLAG_NOTRIGGERS = (1 << 4),
00060 RPMTRANS_FLAG_NODOCS = (1 << 5),
00061 RPMTRANS_FLAG_ALLFILES = (1 << 6),
00062
00063 RPMTRANS_FLAG_KEEPOBSOLETE = (1 << 7),
00064
00065 RPMTRANS_FLAG_NOCONTEXTS = (1 << 8),
00066 RPMTRANS_FLAG_DIRSTASH = (1 << 9),
00067 RPMTRANS_FLAG_REPACKAGE = (1 << 10),
00069 RPMTRANS_FLAG_PKGCOMMIT = (1 << 11),
00070
00071 RPMTRANS_FLAG_PKGUNDO = (1 << 12),
00072
00073 RPMTRANS_FLAG_COMMIT = (1 << 13),
00074
00075 RPMTRANS_FLAG_UNDO = (1 << 14),
00076
00077
00078
00079 RPMTRANS_FLAG_NOTRIGGERPREIN= (1 << 16),
00080 RPMTRANS_FLAG_NOPRE = (1 << 17),
00081 RPMTRANS_FLAG_NOPOST = (1 << 18),
00082 RPMTRANS_FLAG_NOTRIGGERIN = (1 << 19),
00083 RPMTRANS_FLAG_NOTRIGGERUN = (1 << 20),
00084 RPMTRANS_FLAG_NOPREUN = (1 << 21),
00085 RPMTRANS_FLAG_NOPOSTUN = (1 << 22),
00086 RPMTRANS_FLAG_NOTRIGGERPOSTUN = (1 << 23),
00087
00088 RPMTRANS_FLAG_NOPAYLOAD = (1 << 24),
00089
00090 RPMTRANS_FLAG_APPLYONLY = (1 << 25),
00091
00092
00093 RPMTRANS_FLAG_NOFDIGESTS = (1 << 27),
00094
00095 RPMTRANS_FLAG_NOCONFIGS = (1 << 30),
00096
00097 } rpmtransFlags;
00098
00099 #define _noTransScripts \
00100 ( RPMTRANS_FLAG_NOPRE | \
00101 RPMTRANS_FLAG_NOPOST | \
00102 RPMTRANS_FLAG_NOPREUN | \
00103 RPMTRANS_FLAG_NOPOSTUN \
00104 )
00105
00106 #define _noTransTriggers \
00107 ( RPMTRANS_FLAG_NOTRIGGERPREIN | \
00108 RPMTRANS_FLAG_NOTRIGGERIN | \
00109 RPMTRANS_FLAG_NOTRIGGERUN | \
00110 RPMTRANS_FLAG_NOTRIGGERPOSTUN \
00111 )
00112
00116 typedef enum rpmtsOpX_e {
00117 RPMTS_OP_TOTAL = 0,
00118 RPMTS_OP_CHECK = 1,
00119 RPMTS_OP_ORDER = 2,
00120 RPMTS_OP_FINGERPRINT = 3,
00121 RPMTS_OP_REPACKAGE = 4,
00122 RPMTS_OP_INSTALL = 5,
00123 RPMTS_OP_ERASE = 6,
00124 RPMTS_OP_SCRIPTLETS = 7,
00125 RPMTS_OP_COMPRESS = 8,
00126 RPMTS_OP_UNCOMPRESS = 9,
00127 RPMTS_OP_DIGEST = 10,
00128 RPMTS_OP_SIGNATURE = 11,
00129 RPMTS_OP_DBADD = 12,
00130 RPMTS_OP_DBREMOVE = 13,
00131 RPMTS_OP_DBGET = 14,
00132 RPMTS_OP_DBPUT = 15,
00133 RPMTS_OP_DBDEL = 16,
00134 RPMTS_OP_READHDR = 17,
00135 RPMTS_OP_HDRLOAD = 18,
00136 RPMTS_OP_HDRGET = 19,
00137 RPMTS_OP_DEBUG = 20,
00138 RPMTS_OP_MAX = 20
00139 } rpmtsOpX;
00140
00144 typedef enum rpmTSType_e {
00145 RPMTRANS_TYPE_NORMAL = 0,
00146 RPMTRANS_TYPE_ROLLBACK = (1 << 0),
00147 RPMTRANS_TYPE_AUTOROLLBACK = (1 << 1)
00148 } rpmTSType;
00149
00152 typedef enum tsStage_e {
00153 TSM_UNKNOWN = 0,
00154 TSM_INSTALL = 7,
00155 TSM_ERASE = 8,
00156 } tsmStage;
00157
00158 #if defined(_RPMTS_INTERNAL)
00159
00160 #include "rpmhash.h"
00161 #include "rpmal.h"
00162
00163
00164
00165 extern int _cacheDependsRC;
00166
00167
00170 typedef struct diskspaceInfo_s * rpmDiskSpaceInfo;
00171
00175 struct diskspaceInfo_s {
00176 unsigned long f_bsize;
00177 unsigned long f_frsize;
00178 unsigned long long f_blocks;
00179 unsigned long long f_bfree;
00180 signed long long f_bavail;
00181 unsigned long long f_files;
00182 unsigned long long f_ffree;
00183 signed long long f_favail;
00184 unsigned long f_fsid;
00185 unsigned long f_flag;
00186 unsigned long f_namemax;
00188 signed long long bneeded;
00189 signed long long ineeded;
00190 dev_t dev;
00191 };
00192
00196 #define adj_fs_blocks(_nb) (((_nb) * 21) / 20)
00197
00198 #define BLOCK_ROUND(size, block) (((size) + (block) - 1) / (block))
00199
00203 struct rpmts_s {
00204 rpmdepFlags depFlags;
00205 rpmtransFlags transFlags;
00206 tsmStage goal;
00207 rpmTSType type;
00209
00210 rpmdb sdb;
00211 int sdbmode;
00212
00213 int (*solve) (rpmts ts, rpmds key, const void * data)
00214 ;
00215
00216 const void * solveData;
00217 int nsuggests;
00218
00219 const void ** suggests;
00221
00222 rpmCallbackFunction notify;
00223
00224 rpmCallbackData notifyData;
00226
00227 rpmPRCO PRCO;
00229
00230 rpmps probs;
00231 rpmprobFilterFlags ignoreSet;
00234 uint32_t filesystemCount;
00235
00236 const char ** filesystems;
00237
00238 rpmDiskSpaceInfo dsi;
00240
00241 rpmdb rdb;
00242 int dbmode;
00243
00244 hashTable ht;
00246
00247 int * removedPackages;
00248 int numRemovedPackages;
00249 int allocedRemovedPackages;
00251
00252 rpmal addedPackages;
00253 int numAddedPackages;
00255
00256 rpmal erasedPackages;
00257 int numErasedPackages;
00259 #ifndef DYING
00260
00261 rpmal availablePackages;
00262 int numAvailablePackages;
00263 #endif
00264
00265
00266 rpmsx sx;
00268
00269 rpmte relocateElement;
00271
00272 rpmte * order;
00273 int orderCount;
00274 int orderAlloced;
00275 int unorderedSuccessors;
00276 int ntrees;
00277 int maxDepth;
00279
00280 rpmte teInstall;
00281
00282 rpmte teErase;
00284 int selinuxEnabled;
00285 int chrootDone;
00286
00287 const char * rootDir;
00288
00289 const char * currDir;
00290
00291 FD_t scriptFd;
00292 int delta;
00293 uint32_t tid;
00295 uint32_t color;
00296 uint32_t prefcolor;
00298
00299 const char * fn;
00301
00302 const unsigned char * pkpkt;
00303 size_t pkpktlen;
00304 unsigned char pksignid[8];
00306 struct rpmop_s ops[RPMTS_OP_MAX];
00307
00308
00309 pgpDig dig;
00311
00312 Spec spec;
00314 uint32_t arbgoal;
00316
00317 int nrefs;
00318 };
00319 #endif
00320
00321 #ifdef __cplusplus
00322 extern "C" {
00323 #endif
00324
00335 int rpmtsCheck(rpmts ts)
00336
00337 ;
00338
00355 int rpmtsOrder(rpmts ts)
00356
00357 ;
00358
00376 int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
00377
00378 ;
00379
00388 rpmRC rpmtsRollback(rpmts rbts, rpmprobFilterFlags ignoreSet,
00389 int running, rpmte rbte)
00390
00391 ;
00392
00399
00400 rpmts rpmtsUnlink ( rpmts ts,
00401 const char * msg)
00402 ;
00403
00405
00406
00407 rpmts XrpmtsUnlink ( rpmts ts,
00408 const char * msg, const char * fn, unsigned ln)
00409 ;
00410
00411 #define rpmtsUnlink(_ts, _msg) XrpmtsUnlink(_ts, _msg, __FILE__, __LINE__)
00412
00419
00420 rpmts rpmtsLink (rpmts ts, const char * msg)
00421 ;
00422
00424 rpmts XrpmtsLink (rpmts ts,
00425 const char * msg, const char * fn, unsigned ln)
00426 ;
00427 #define rpmtsLink(_ts, _msg) XrpmtsLink(_ts, _msg, __FILE__, __LINE__)
00428
00434 int rpmtsCloseDB(rpmts ts)
00435
00436 ;
00437
00444 int rpmtsOpenDB(rpmts ts, int dbmode)
00445
00446 ;
00447
00455 int rpmtsInitDB(rpmts ts, int dbmode)
00456
00457 ;
00458
00464 int rpmtsRebuildDB(rpmts ts)
00465
00466 ;
00467
00473 int rpmtsVerifyDB(rpmts ts)
00474
00475 ;
00476
00485
00486 rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
00487 const void * keyp, size_t keylen)
00488
00489 ;
00490
00497
00498 rpmRC rpmtsFindPubkey(rpmts ts, void * _dig)
00499
00500 ;
00501
00502
00511 rpmRC rpmtsImportPubkey(const rpmts ts,
00512 const unsigned char * pkt, ssize_t pktlen)
00513
00514
00515
00516 ;
00517
00523
00524 int rpmtsCloseSDB(rpmts ts)
00525
00526 ;
00527
00528
00535
00536 int rpmtsOpenSDB(rpmts ts, int dbmode)
00537
00538 ;
00539
00540
00548
00549 int rpmtsSolve(rpmts ts, rpmds ds, const void * data)
00550
00551 ;
00552
00553
00561
00562 int rpmtsAvailable(rpmts ts, const rpmds ds)
00563
00564 ;
00565
00573 int rpmtsSetSolveCallback(rpmts ts,
00574 int (*solve) (rpmts ts, rpmds ds, const void * data),
00575 const void * solveData)
00576 ;
00577
00583 rpmTSType rpmtsType(rpmts ts)
00584 ;
00585
00596 void rpmtsSetType(rpmts ts, rpmTSType type)
00597 ;
00598
00604 uint32_t rpmtsARBGoal(rpmts ts)
00605 ;
00606
00612 void rpmtsSetARBGoal(rpmts ts, uint32_t goal)
00613 ;
00614
00620
00621 rpmps rpmtsProblems(rpmts ts)
00622 ;
00623
00628 void rpmtsCleanDig(rpmts ts)
00629 ;
00630
00635 void rpmtsClean(rpmts ts)
00636
00637 ;
00638
00643 void rpmtsEmpty(rpmts ts)
00644
00645 ;
00646
00652
00653 rpmts rpmtsFree( rpmts ts)
00654
00655 ;
00656
00662 rpmVSFlags rpmtsVSFlags(rpmts ts)
00663 ;
00664
00671 rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags)
00672 ;
00673
00680 int rpmtsUnorderedSuccessors(rpmts ts, int first)
00681 ;
00682
00688
00689 extern const char * rpmtsRootDir(rpmts ts)
00690 ;
00691
00697 void rpmtsSetRootDir(rpmts ts, const char * rootDir)
00698 ;
00699
00705
00706 extern const char * rpmtsCurrDir(rpmts ts)
00707 ;
00708
00714 void rpmtsSetCurrDir(rpmts ts, const char * currDir)
00715 ;
00716
00722
00723 FD_t rpmtsScriptFd(rpmts ts)
00724 ;
00725
00731 void rpmtsSetScriptFd(rpmts ts, FD_t scriptFd)
00732 ;
00733
00739 int rpmtsSELinuxEnabled(rpmts ts)
00740 ;
00741
00747 int rpmtsChrootDone(rpmts ts)
00748 ;
00749
00756 int rpmtsSetChrootDone(rpmts ts, int chrootDone)
00757 ;
00758
00764
00765 rpmsx rpmtsREContext(const rpmts ts)
00766 ;
00767
00774 int rpmtsSetREContext(rpmts ts, rpmsx sx)
00775 ;
00776
00782 uint32_t rpmtsGetTid(rpmts ts)
00783 ;
00784
00791 uint32_t rpmtsSetTid(rpmts ts, uint32_t tid)
00792 ;
00793
00799 pgpDig rpmtsDig(rpmts ts)
00800 ;
00801
00807
00808
00809 pgpDigParams rpmtsPubkey(const rpmts ts)
00810 ;
00811
00812
00818
00819 rpmdb rpmtsGetRdb(rpmts ts)
00820 ;
00821
00827
00828 rpmPRCO rpmtsPRCO(rpmts ts)
00829 ;
00830
00836 int rpmtsInitDSI(const rpmts ts)
00837
00838 ;
00839
00849 void rpmtsUpdateDSI(const rpmts ts, dev_t dev,
00850 uint32_t fileSize, uint32_t prevSize, uint32_t fixupSize,
00851 fileAction action)
00852 ;
00853
00859 void rpmtsCheckDSIProblems(const rpmts ts, const rpmte te)
00860 ;
00861
00873
00874 void * rpmtsNotify(rpmts ts, rpmte te,
00875 rpmCallbackType what, uint64_t amount, uint64_t total)
00876 ;
00877
00883 int rpmtsNElements(rpmts ts)
00884 ;
00885
00892
00893 rpmte rpmtsElement(rpmts ts, int ix)
00894 ;
00895
00901 rpmprobFilterFlags rpmtsFilterFlags(rpmts ts)
00902 ;
00903
00909 rpmtransFlags rpmtsFlags(rpmts ts)
00910 ;
00911
00918 rpmtransFlags rpmtsSetFlags(rpmts ts, rpmtransFlags transFlags)
00919 ;
00920
00926 rpmdepFlags rpmtsDFlags(rpmts ts)
00927 ;
00928
00935 rpmdepFlags rpmtsSetDFlags(rpmts ts, rpmdepFlags depFlags)
00936 ;
00937
00943
00944 Spec rpmtsSpec(rpmts ts)
00945 ;
00946
00953
00954 Spec rpmtsSetSpec(rpmts ts, Spec spec)
00955 ;
00956
00962
00963 rpmte rpmtsRelocateElement(rpmts ts)
00964 ;
00965
00972
00973 rpmte rpmtsSetRelocateElement(rpmts ts, rpmte relocateElement)
00974 ;
00975
00981 tsmStage rpmtsGoal(rpmts ts)
00982 ;
00983
00990 tsmStage rpmtsSetGoal(rpmts ts, tsmStage goal)
00991 ;
00992
00998 int rpmtsDBMode(rpmts ts)
00999 ;
01000
01007 int rpmtsSetDBMode(rpmts ts, int dbmode)
01008 ;
01009
01015 uint32_t rpmtsColor(rpmts ts)
01016 ;
01017
01023 uint32_t rpmtsPrefColor(rpmts ts)
01024 ;
01025
01032 uint32_t rpmtsSetColor(rpmts ts, uint32_t color)
01033 ;
01034
01041
01042 rpmop rpmtsOp(rpmts ts, rpmtsOpX opx)
01043 ;
01044
01056 int rpmtsSetNotifyCallback(rpmts ts,
01057 rpmCallbackFunction notify,
01058 rpmCallbackData notifyData)
01059 ;
01060
01065
01066 rpmts rpmtsCreate(void)
01067
01068 ;
01069
01070
01071
01072 extern int rpmcliPackagesTotal;
01073
01074
01088 int rpmtsAddInstallElement(rpmts ts, Header h,
01089 const fnpyKey key, int upgrade,
01090 rpmRelocation relocs)
01091
01092
01093
01094 ;
01095
01103 int rpmtsAddEraseElement(rpmts ts, Header h, int dboffset)
01104
01105 ;
01106
01107 #if !defined(SWIG)
01108 #if defined(_RPMTS_PRINT)
01109
01115 static inline
01116 int rpmtsPrint( rpmts ts, FILE * fp)
01117
01118
01119 {
01120 int tid = rpmtsGetTid(ts);
01121 time_t ttid = tid;
01122 rpmtsi tsi;
01123 rpmte te;
01124
01125 if (fp == NULL)
01126 fp = stderr;
01127
01128 fprintf(fp, _("=== Transaction at %-24.24s (0x%08x):\n"), ctime(&ttid),tid);
01129 tsi = rpmtsiInit(ts);
01130 while ((te = rpmtsiNext(tsi, 0)) != NULL)
01131 fprintf(fp, "t%s> %s\n", (rpmteType(te) == TR_ADDED ? "I" : "E"),
01132 rpmteNEVRA(te));
01133 tsi = rpmtsiFree(tsi);
01134 return 0;
01135 }
01136 #endif
01137 #endif
01138
01139 #ifdef __cplusplus
01140 }
01141 #endif
01142
01143
01144 #endif