rpm  4.17.0
rpmds.h
Go to the documentation of this file.
1 #ifndef H_RPMDS
2 #define H_RPMDS
3 
9 #include <time.h>
10 
11 #include <rpm/rpmtypes.h>
12 #include <rpm/rpmps.h>
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
20 extern int _rpmds_nopromote;
21 
27  RPMSENSE_LESS = (1 << 1),
28  RPMSENSE_GREATER = (1 << 2),
29  RPMSENSE_EQUAL = (1 << 3),
30  /* bit 4 unused */
31  RPMSENSE_POSTTRANS = (1 << 5),
32  RPMSENSE_PREREQ = (1 << 6), /* legacy prereq dependency */
33  RPMSENSE_PRETRANS = (1 << 7),
34  RPMSENSE_INTERP = (1 << 8),
35  RPMSENSE_SCRIPT_PRE = (1 << 9),
36  RPMSENSE_SCRIPT_POST = (1 << 10),
37  RPMSENSE_SCRIPT_PREUN = (1 << 11),
38  RPMSENSE_SCRIPT_POSTUN = (1 << 12),
39  RPMSENSE_SCRIPT_VERIFY = (1 << 13),
40  RPMSENSE_FIND_REQUIRES = (1 << 14),
41  RPMSENSE_FIND_PROVIDES = (1 << 15),
43  RPMSENSE_TRIGGERIN = (1 << 16),
44  RPMSENSE_TRIGGERUN = (1 << 17),
45  RPMSENSE_TRIGGERPOSTUN = (1 << 18),
46  RPMSENSE_MISSINGOK = (1 << 19),
47  /* bits 20-23 unused */
48  RPMSENSE_RPMLIB = (1 << 24),
49  RPMSENSE_TRIGGERPREIN = (1 << 25),
50  RPMSENSE_KEYRING = (1 << 26),
51  /* bit 27 unused */
52  RPMSENSE_CONFIG = (1 << 28),
53  RPMSENSE_META = (1 << 29),
54 };
55 
57 
58 #define RPMSENSE_SENSEMASK 15 /* Mask to get senses, ie serial, */
59  /* less, greater, equal. */
60 
61 #define RPMSENSE_TRIGGER \
62  (RPMSENSE_TRIGGERPREIN | RPMSENSE_TRIGGERIN | RPMSENSE_TRIGGERUN | RPMSENSE_TRIGGERPOSTUN)
63 
64 #define _ALL_REQUIRES_MASK (\
65  RPMSENSE_INTERP | \
66  RPMSENSE_SCRIPT_PRE | \
67  RPMSENSE_SCRIPT_POST | \
68  RPMSENSE_SCRIPT_PREUN | \
69  RPMSENSE_SCRIPT_POSTUN | \
70  RPMSENSE_SCRIPT_VERIFY | \
71  RPMSENSE_FIND_REQUIRES | \
72  RPMSENSE_RPMLIB | \
73  RPMSENSE_KEYRING | \
74  RPMSENSE_PRETRANS | \
75  RPMSENSE_POSTTRANS | \
76  RPMSENSE_PREREQ | \
77  RPMSENSE_META | \
78  RPMSENSE_MISSINGOK)
79 
80 #define _notpre(_x) ((_x) & ~RPMSENSE_PREREQ)
81 #define _INSTALL_ONLY_MASK \
82  _notpre(RPMSENSE_SCRIPT_PRE|RPMSENSE_SCRIPT_POST|RPMSENSE_RPMLIB|RPMSENSE_KEYRING|RPMSENSE_PRETRANS|RPMSENSE_POSTTRANS)
83 #define _ERASE_ONLY_MASK \
84  _notpre(RPMSENSE_SCRIPT_PREUN|RPMSENSE_SCRIPT_POSTUN)
85 #define _UNORDERED_ONLY_MASK \
86  _notpre(RPMSENSE_RPMLIB|RPMSENSE_CONFIG|RPMSENSE_PRETRANS|RPMSENSE_POSTTRANS|RPMSENSE_SCRIPT_VERIFY|RPMSENSE_META)
87 #define _FORCE_ORDER_ONLY_MASK \
88  _notpre(RPMSENSE_SCRIPT_PRE|RPMSENSE_SCRIPT_POST|RPMSENSE_SCRIPT_PREUN|RPMSENSE_SCRIPT_POSTUN)
89 
90 #define isLegacyPreReq(_x) (((_x) & _ALL_REQUIRES_MASK) == RPMSENSE_PREREQ)
91 #define isInstallPreReq(_x) ((_x) & _INSTALL_ONLY_MASK)
92 #define isErasePreReq(_x) ((_x) & _ERASE_ONLY_MASK)
93 #define isUnorderedReq(_x) ((_x) & _UNORDERED_ONLY_MASK && \
94  !((_x) & _FORCE_ORDER_ONLY_MASK))
95 #define isTransientReq(_x) (isInstallPreReq(_x) && \
96  !isErasePreReq(_x) && \
97  !((_x) & RPMSENSE_META))
98 
106 
113 rpmsenseFlags rpmParseDSFlags(const char *str, size_t len);
114 
121 
128 
136 rpmds rpmdsNew(Header h, rpmTagVal tagN, int flags);
137 
144 char * rpmdsNewDNEVR(const char * dspfx, const rpmds ds);
145 
154 
163 rpmds rpmdsSingle(rpmTagVal tagN, const char * N, const char * EVR, rpmsenseFlags Flags);
164 
171 
179 
185 int rpmdsCount(const rpmds ds);
186 
192 int rpmdsIx(const rpmds ds);
193 
200 int rpmdsSetIx(rpmds ds, int ix);
201 
207 const char * rpmdsDNEVR(const rpmds ds);
208 
214 char rpmdsD(const rpmds ds);
215 
221 rpmTagVal rpmdsDToTagN(char deptype);
222 
228 const char * rpmdsN(const rpmds ds);
229 
235 const char * rpmdsEVR(const rpmds ds);
236 
242 int rpmdsTi(const rpmds ds);
243 
250 
257 
264 
271 
278 
285 unsigned int rpmdsInstance(rpmds ds);
286 
293 
300 
306 int rpmdsNoPromote(const rpmds ds);
307 
314 int rpmdsSetNoPromote(rpmds ds, int nopromote);
315 
322 
330 
336 int rpmdsNext(rpmds ds);
337 
344 
351 int rpmdsFind(rpmds ds, const rpmds ods);
352 
359 int rpmdsMerge(rpmds * dsp, rpmds ods);
360 
369 int rpmdsSearch(rpmds ds, rpmds ods);
370 
377 int rpmdsCompare(const rpmds A, const rpmds B);
378 
386 int rpmdsAnyMatchesDep (const Header h, const rpmds req, int nopromote);
387 
396 int rpmdsMatchesDep (const Header h, int ix, const rpmds req, int nopromote);
397 
405 int rpmdsNVRMatchesDep(const Header h, const rpmds req, int nopromote);
406 
413 int rpmdsRpmlib(rpmds * dsp, const void * tblp);
414 
423 rpmds rpmdsNewPool(rpmstrPool pool, Header h, rpmTagVal tagN, int flags);
424 
434  Header h, rpmTagVal tagN, rpmsenseFlags Flags);
435 
446  const char * N, const char * EVR, rpmsenseFlags Flags);
447 
459  const char * N, const char * EVR,
460  rpmsenseFlags Flags, int triggerIndex);
461 
469 int rpmdsRpmlibPool(rpmstrPool pool, rpmds * dsp, const void * tblp);
470 
471 
472 typedef enum rpmrichOp_e {
480  RPMRICHOP_UNLESS = 8
482 
483 typedef enum rpmrichParseType_e {
484  RPMRICH_PARSE_SIMPLE = 1, /* standard N <=> EVR dep */
485  RPMRICH_PARSE_ENTER = 2, /* entering sub-dependency */
486  RPMRICH_PARSE_LEAVE = 3, /* leaving sub-dependency */
487  RPMRICH_PARSE_OP = 4 /* parsed a rich dependency op */
489 
490 typedef rpmRC (*rpmrichParseFunction) (void *cbdata, rpmrichParseType type,
491  const char *n, int nl, const char *e, int el, rpmsenseFlags sense,
492  rpmrichOp op, char **emsg);
493 
502 rpmRC rpmrichParse(const char **dstrp, char **emsg, rpmrichParseFunction cb, void *cbdata);
503 
513 rpmRC rpmrichParseForTag(const char **dstrp, char **emsg, rpmrichParseFunction cb, void *cbdata, rpmTagVal tagN);
514 
515 
522 
528 const char *rpmrichOpStr(rpmrichOp op);
529 
539 rpmRC rpmdsParseRichDep(rpmds dep, rpmds *leftds, rpmds *rightds, rpmrichOp *op, char **emsg);
540 
541 #ifdef __cplusplus
542 }
543 #endif
544 
545 #endif /* H_RPMDS */
const char * rpmdsEVR(const rpmds ds)
Return current dependency epoch-version-release.
int rpmdsIsWeak(rpmds ds)
Return whether dependency is weak.
int rpmdsIx(const rpmds ds)
Return dependency set index.
rpmsenseFlags rpmSanitizeDSFlags(rpmTagVal tagN, rpmsenseFlags Flags)
Return only those flags allowed for given type of dependencies.
rpmds rpmdsNewPool(rpmstrPool pool, Header h, rpmTagVal tagN, int flags)
Create and load a dependency set.
rpmds rpmdsCurrent(rpmds ds)
Return a new dependency set of size 1 from the current iteration index.
rpmds rpmdsSinglePoolTix(rpmstrPool pool, rpmTagVal tagN, const char *N, const char *EVR, rpmsenseFlags Flags, int triggerIndex)
Create, load and initialize a trigger dependency set of size 1.
int rpmdsTi(const rpmds ds)
Return current dependency triggerindex.
int rpmdsCompare(const rpmds A, const rpmds B)
Compare two versioned dependency ranges, looking for overlap.
int rpmdsFind(rpmds ds, const rpmds ods)
Find a dependency set element using binary search.
unsigned int rpmdsInstance(rpmds ds)
Return dependency header instance, ie whether the dependency comes from an installed header or not.
int rpmdsPutToHeader(rpmds ds, Header h)
Write content of the dependency set to the header.
rpm_color_t rpmdsSetColor(const rpmds ds, rpm_color_t color)
Return current dependency color.
const char * rpmdsN(const rpmds ds)
Return current dependency name.
rpmds rpmdsSingle(rpmTagVal tagN, const char *N, const char *EVR, rpmsenseFlags Flags)
Create, load and initialize a dependency set of size 1.
rpmds rpmdsThis(Header h, rpmTagVal tagN, rpmsenseFlags Flags)
Create, load and initialize a dependency for this header.
rpmds rpmdsNew(Header h, rpmTagVal tagN, int flags)
Create and load a dependency set.
int rpmdsMerge(rpmds *dsp, rpmds ods)
Merge a dependency set maintaining (N,EVR,Flags) sorted order.
rpmTagVal rpmdsTagF(const rpmds ds)
Return current dependency type.
rpmTagVal rpmdsTagEVR(const rpmds ds)
Return current dependency type.
char rpmdsD(const rpmds ds)
Return one char indicating the type of the dependency.
rpmds rpmdsThisPool(rpmstrPool pool, Header h, rpmTagVal tagN, rpmsenseFlags Flags)
Create, load and initialize a dependency for this header.
rpmds rpmdsFree(rpmds ds)
Destroy a dependency set.
rpmTagVal rpmdsTagTi(const rpmds ds)
Return current dependency type.
int rpmdsSetIx(rpmds ds, int ix)
Set dependency set index.
int rpmdsSearch(rpmds ds, rpmds ods)
Search a sorted dependency set for an element that overlaps.
int rpmdsIsReverse(rpmds ds)
Return whether dependency is reversed.
int rpmdsCount(const rpmds ds)
Return dependency set count.
rpmTagVal rpmdsTagN(const rpmds ds)
Return current dependency type.
rpmds rpmdsLink(rpmds ds)
Reference a dependency set instance.
rpmTagVal rpmdsDToTagN(char deptype)
Return matching tagN for one char dependency type description.
int rpmdsMatchesDep(const Header h, int ix, const rpmds req, int nopromote)
Compare package provides dependencies from header with a single dependency.
int rpmdsNVRMatchesDep(const Header h, const rpmds req, int nopromote)
Compare package name-version-release from header with a single dependency.
rpmsenseFlags rpmParseDSFlags(const char *str, size_t len)
Convert a string to the sense flags.
rpmsenseFlags rpmdsFlags(const rpmds ds)
Return current dependency flags.
rpmds rpmdsInit(rpmds ds)
Initialize dependency set iterator.
char * rpmdsNewDNEVR(const char *dspfx, const rpmds ds)
Return new formatted dependency string.
const char * rpmdsDNEVR(const rpmds ds)
Return current formatted dependency string.
int rpmdsAnyMatchesDep(const Header h, const rpmds req, int nopromote)
Compare package provides dependencies from header with a single dependency.
rpm_color_t rpmdsColor(const rpmds ds)
Return current dependency color.
int rpmdsNext(rpmds ds)
Return next dependency set iterator index.
int rpmdsNoPromote(const rpmds ds)
Obsolete, do not use.
rpmsenseFlags_e
Dependency Attributes.
Definition: rpmds.h:25
rpmds rpmdsSinglePool(rpmstrPool pool, rpmTagVal tagN, const char *N, const char *EVR, rpmsenseFlags Flags)
Create, load and initialize a dependency set of size 1.
int rpmdsSetNoPromote(rpmds ds, int nopromote)
Obsolete, do not use.
@ RPMSENSE_FIND_PROVIDES
Definition: rpmds.h:41
@ RPMSENSE_GREATER
Definition: rpmds.h:28
@ RPMSENSE_SCRIPT_POSTUN
Definition: rpmds.h:38
@ RPMSENSE_TRIGGERPREIN
Definition: rpmds.h:49
@ RPMSENSE_INTERP
Definition: rpmds.h:34
@ RPMSENSE_PREREQ
Definition: rpmds.h:32
@ RPMSENSE_TRIGGERUN
Definition: rpmds.h:44
@ RPMSENSE_LESS
Definition: rpmds.h:27
@ RPMSENSE_EQUAL
Definition: rpmds.h:29
@ RPMSENSE_ANY
Definition: rpmds.h:26
@ RPMSENSE_FIND_REQUIRES
Definition: rpmds.h:40
@ RPMSENSE_MISSINGOK
Definition: rpmds.h:46
@ RPMSENSE_TRIGGERIN
Definition: rpmds.h:43
@ RPMSENSE_TRIGGERPOSTUN
Definition: rpmds.h:45
@ RPMSENSE_META
Definition: rpmds.h:53
@ RPMSENSE_SCRIPT_PRE
Definition: rpmds.h:35
@ RPMSENSE_SCRIPT_VERIFY
Definition: rpmds.h:39
@ RPMSENSE_SCRIPT_PREUN
Definition: rpmds.h:37
@ RPMSENSE_RPMLIB
Definition: rpmds.h:48
@ RPMSENSE_KEYRING
Definition: rpmds.h:50
@ RPMSENSE_SCRIPT_POST
Definition: rpmds.h:36
@ RPMSENSE_POSTTRANS
Definition: rpmds.h:31
@ RPMSENSE_PRETRANS
Definition: rpmds.h:33
@ RPMSENSE_CONFIG
Definition: rpmds.h:52
rpm_tag_t rpmTagVal
Definition: rpmtypes.h:30
uint32_t rpmFlags
Definition: rpmtypes.h:42
uint32_t rpm_color_t
Definition: rpmtypes.h:38
enum rpmRC_e rpmRC
Package read return codes.
struct rpmds_s * rpmds
Definition: rpmtypes.h:65
struct headerToken_s * Header
RPM header and data retrieval types.
Definition: rpmtypes.h:24
rpmrichParseType_e
Definition: rpmds.h:483
@ RPMRICH_PARSE_ENTER
Definition: rpmds.h:485
@ RPMRICH_PARSE_OP
Definition: rpmds.h:487
@ RPMRICH_PARSE_LEAVE
Definition: rpmds.h:486
@ RPMRICH_PARSE_SIMPLE
Definition: rpmds.h:484
enum rpmrichParseType_e rpmrichParseType
int rpmdsRpmlib(rpmds *dsp, const void *tblp)
Load rpmlib provides into a dependency set.
rpmRC(* rpmrichParseFunction)(void *cbdata, rpmrichParseType type, const char *n, int nl, const char *e, int el, rpmsenseFlags sense, rpmrichOp op, char **emsg)
Definition: rpmds.h:490
int rpmdsIsRich(rpmds dep)
Return if current depenency is rich.
rpmFlags rpmsenseFlags
Definition: rpmds.h:56
int rpmdsRpmlibPool(rpmstrPool pool, rpmds *dsp, const void *tblp)
Load rpmlib provides into a dependency set.
rpmrichOp_e
Definition: rpmds.h:472
@ RPMRICHOP_UNLESS
Definition: rpmds.h:480
@ RPMRICHOP_IF
Definition: rpmds.h:476
@ RPMRICHOP_OR
Definition: rpmds.h:475
@ RPMRICHOP_ELSE
Definition: rpmds.h:477
@ RPMRICHOP_WITHOUT
Definition: rpmds.h:479
@ RPMRICHOP_AND
Definition: rpmds.h:474
@ RPMRICHOP_WITH
Definition: rpmds.h:478
@ RPMRICHOP_SINGLE
Definition: rpmds.h:473
const char * rpmrichOpStr(rpmrichOp op)
Return a string representation of the rich dependency op.
rpmRC rpmrichParseForTag(const char **dstrp, char **emsg, rpmrichParseFunction cb, void *cbdata, rpmTagVal tagN)
Parse a rich dependency string for a specific tag.
int _rpmds_nopromote
rpmRC rpmrichParse(const char **dstrp, char **emsg, rpmrichParseFunction cb, void *cbdata)
Parse a rich dependency string.
rpmRC rpmdsParseRichDep(rpmds dep, rpmds *leftds, rpmds *rightds, rpmrichOp *op, char **emsg)
Parse a rich dependency string.
enum rpmrichOp_e rpmrichOp
struct rpmstrPool_s * rpmstrPool
Definition: rpmtypes.h:84