rpm  4.18.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/rpmutil.h>
13 #include <rpm/rpmps.h>
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
21 extern int _rpmds_nopromote;
22 
28  RPMSENSE_LESS = (1 << 1),
29  RPMSENSE_GREATER = (1 << 2),
30  RPMSENSE_EQUAL = (1 << 3),
31  /* bit 4 unused */
32  RPMSENSE_POSTTRANS = (1 << 5),
33  RPMSENSE_PREREQ = (1 << 6), /* legacy prereq dependency */
34  RPMSENSE_PRETRANS = (1 << 7),
35  RPMSENSE_INTERP = (1 << 8),
36  RPMSENSE_SCRIPT_PRE = (1 << 9),
37  RPMSENSE_SCRIPT_POST = (1 << 10),
38  RPMSENSE_SCRIPT_PREUN = (1 << 11),
39  RPMSENSE_SCRIPT_POSTUN = (1 << 12),
40  RPMSENSE_SCRIPT_VERIFY = (1 << 13),
41  RPMSENSE_FIND_REQUIRES = (1 << 14),
42  RPMSENSE_FIND_PROVIDES = (1 << 15),
44  RPMSENSE_TRIGGERIN = (1 << 16),
45  RPMSENSE_TRIGGERUN = (1 << 17),
46  RPMSENSE_TRIGGERPOSTUN = (1 << 18),
47  RPMSENSE_MISSINGOK = (1 << 19),
48  /* bits 20-23 unused */
49  RPMSENSE_RPMLIB = (1 << 24),
50  RPMSENSE_TRIGGERPREIN = (1 << 25),
51  RPMSENSE_KEYRING = (1 << 26),
52  /* bit 27 unused */
53  RPMSENSE_CONFIG = (1 << 28),
54  RPMSENSE_META = (1 << 29),
55 };
56 
58 
59 #define RPMSENSE_SENSEMASK 15 /* Mask to get senses, ie serial, */
60  /* less, greater, equal. */
61 
62 #define RPMSENSE_TRIGGER \
63  (RPMSENSE_TRIGGERPREIN | RPMSENSE_TRIGGERIN | RPMSENSE_TRIGGERUN | RPMSENSE_TRIGGERPOSTUN)
64 
65 #define _ALL_REQUIRES_MASK (\
66  RPMSENSE_INTERP | \
67  RPMSENSE_SCRIPT_PRE | \
68  RPMSENSE_SCRIPT_POST | \
69  RPMSENSE_SCRIPT_PREUN | \
70  RPMSENSE_SCRIPT_POSTUN | \
71  RPMSENSE_SCRIPT_VERIFY | \
72  RPMSENSE_FIND_REQUIRES | \
73  RPMSENSE_RPMLIB | \
74  RPMSENSE_KEYRING | \
75  RPMSENSE_PRETRANS | \
76  RPMSENSE_POSTTRANS | \
77  RPMSENSE_PREREQ | \
78  RPMSENSE_META | \
79  RPMSENSE_MISSINGOK)
80 
81 #define _notpre(_x) ((_x) & ~RPMSENSE_PREREQ)
82 #define _INSTALL_ONLY_MASK \
83  _notpre(RPMSENSE_SCRIPT_PRE|RPMSENSE_SCRIPT_POST|RPMSENSE_RPMLIB|RPMSENSE_KEYRING|RPMSENSE_PRETRANS|RPMSENSE_POSTTRANS)
84 #define _ERASE_ONLY_MASK \
85  _notpre(RPMSENSE_SCRIPT_PREUN|RPMSENSE_SCRIPT_POSTUN)
86 #define _UNORDERED_ONLY_MASK \
87  _notpre(RPMSENSE_RPMLIB|RPMSENSE_CONFIG|RPMSENSE_PRETRANS|RPMSENSE_POSTTRANS|RPMSENSE_SCRIPT_VERIFY|RPMSENSE_META)
88 #define _FORCE_ORDER_ONLY_MASK \
89  _notpre(RPMSENSE_SCRIPT_PRE|RPMSENSE_SCRIPT_POST|RPMSENSE_SCRIPT_PREUN|RPMSENSE_SCRIPT_POSTUN)
90 
91 #define isLegacyPreReq(_x) (((_x) & _ALL_REQUIRES_MASK) == RPMSENSE_PREREQ)
92 #define isInstallPreReq(_x) ((_x) & _INSTALL_ONLY_MASK)
93 #define isErasePreReq(_x) ((_x) & _ERASE_ONLY_MASK)
94 #define isUnorderedReq(_x) ((_x) & _UNORDERED_ONLY_MASK && \
95  !((_x) & _FORCE_ORDER_ONLY_MASK))
96 #define isTransientReq(_x) (isInstallPreReq(_x) && \
97  !isErasePreReq(_x) && \
98  !((_x) & RPMSENSE_META))
99 
107 
114 rpmsenseFlags rpmParseDSFlags(const char *str, size_t len);
115 
122 
129 
137 rpmds rpmdsNew(Header h, rpmTagVal tagN, int flags);
138 
145 char * rpmdsNewDNEVR(const char * dspfx, const rpmds ds);
146 
155 
164 rpmds rpmdsSingle(rpmTagVal tagN, const char * N, const char * EVR, rpmsenseFlags Flags);
165 
172 
180 
186 int rpmdsCount(const rpmds ds);
187 
193 int rpmdsIx(const rpmds ds);
194 
201 int rpmdsSetIx(rpmds ds, int ix);
202 
208 const char * rpmdsDNEVR(const rpmds ds);
209 
215 char rpmdsD(const rpmds ds);
216 
222 rpmTagVal rpmdsDToTagN(char deptype);
223 
229 const char * rpmdsN(const rpmds ds);
230 
236 const char * rpmdsEVR(const rpmds ds);
237 
243 int rpmdsTi(const rpmds ds);
244 
251 
258 
265 
272 
279 
286 unsigned int rpmdsInstance(rpmds ds);
287 
294 
301 
308 int rpmdsNoPromote(const rpmds ds);
309 
317 int rpmdsSetNoPromote(rpmds ds, int nopromote);
318 
325 
333 
339 int rpmdsNext(rpmds ds);
340 
347 
354 int rpmdsFind(rpmds ds, const rpmds ods);
355 
362 int rpmdsMerge(rpmds * dsp, rpmds ods);
363 
372 int rpmdsSearch(rpmds ds, rpmds ods);
373 
380 int rpmdsCompare(const rpmds A, const rpmds B);
381 
389 int rpmdsAnyMatchesDep (const Header h, const rpmds req, int nopromote);
390 
399 int rpmdsMatchesDep (const Header h, int ix, const rpmds req, int nopromote);
400 
408 int rpmdsNVRMatchesDep(const Header h, const rpmds req, int nopromote);
409 
416 int rpmdsRpmlib(rpmds * dsp, const void * tblp);
417 
426 rpmds rpmdsNewPool(rpmstrPool pool, Header h, rpmTagVal tagN, int flags);
427 
437  Header h, rpmTagVal tagN, rpmsenseFlags Flags);
438 
449  const char * N, const char * EVR, rpmsenseFlags Flags);
450 
462  const char * N, const char * EVR,
463  rpmsenseFlags Flags, int triggerIndex);
464 
472 int rpmdsRpmlibPool(rpmstrPool pool, rpmds * dsp, const void * tblp);
473 
474 
475 typedef enum rpmrichOp_e {
483  RPMRICHOP_UNLESS = 8
485 
486 typedef enum rpmrichParseType_e {
487  RPMRICH_PARSE_SIMPLE = 1, /* standard N <=> EVR dep */
488  RPMRICH_PARSE_ENTER = 2, /* entering sub-dependency */
489  RPMRICH_PARSE_LEAVE = 3, /* leaving sub-dependency */
490  RPMRICH_PARSE_OP = 4 /* parsed a rich dependency op */
492 
493 typedef rpmRC (*rpmrichParseFunction) (void *cbdata, rpmrichParseType type,
494  const char *n, int nl, const char *e, int el, rpmsenseFlags sense,
495  rpmrichOp op, char **emsg);
496 
505 rpmRC rpmrichParse(const char **dstrp, char **emsg, rpmrichParseFunction cb, void *cbdata);
506 
516 rpmRC rpmrichParseForTag(const char **dstrp, char **emsg, rpmrichParseFunction cb, void *cbdata, rpmTagVal tagN);
517 
518 
525 
531 const char *rpmrichOpStr(rpmrichOp op);
532 
542 rpmRC rpmdsParseRichDep(rpmds dep, rpmds *leftds, rpmds *rightds, rpmrichOp *op, char **emsg);
543 
544 #ifdef __cplusplus
545 }
546 #endif
547 
548 #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.
RPM_GNUC_DEPRECATED int rpmdsSetNoPromote(rpmds ds, int nopromote)
Obsolete, do not use.
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.
RPM_GNUC_DEPRECATED int rpmdsNoPromote(const rpmds ds)
Obsolete, do not use.
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.
rpmsenseFlags_e
Dependency Attributes.
Definition: rpmds.h:26
rpmds rpmdsSinglePool(rpmstrPool pool, rpmTagVal tagN, const char *N, const char *EVR, rpmsenseFlags Flags)
Create, load and initialize a dependency set of size 1.
@ RPMSENSE_FIND_PROVIDES
Definition: rpmds.h:42
@ RPMSENSE_GREATER
Definition: rpmds.h:29
@ RPMSENSE_SCRIPT_POSTUN
Definition: rpmds.h:39
@ RPMSENSE_TRIGGERPREIN
Definition: rpmds.h:50
@ RPMSENSE_INTERP
Definition: rpmds.h:35
@ RPMSENSE_PREREQ
Definition: rpmds.h:33
@ RPMSENSE_TRIGGERUN
Definition: rpmds.h:45
@ RPMSENSE_LESS
Definition: rpmds.h:28
@ RPMSENSE_EQUAL
Definition: rpmds.h:30
@ RPMSENSE_ANY
Definition: rpmds.h:27
@ RPMSENSE_FIND_REQUIRES
Definition: rpmds.h:41
@ RPMSENSE_MISSINGOK
Definition: rpmds.h:47
@ RPMSENSE_TRIGGERIN
Definition: rpmds.h:44
@ RPMSENSE_TRIGGERPOSTUN
Definition: rpmds.h:46
@ RPMSENSE_META
Definition: rpmds.h:54
@ RPMSENSE_SCRIPT_PRE
Definition: rpmds.h:36
@ RPMSENSE_SCRIPT_VERIFY
Definition: rpmds.h:40
@ RPMSENSE_SCRIPT_PREUN
Definition: rpmds.h:38
@ RPMSENSE_RPMLIB
Definition: rpmds.h:49
@ RPMSENSE_KEYRING
Definition: rpmds.h:51
@ RPMSENSE_SCRIPT_POST
Definition: rpmds.h:37
@ RPMSENSE_POSTTRANS
Definition: rpmds.h:32
@ RPMSENSE_PRETRANS
Definition: rpmds.h:34
@ RPMSENSE_CONFIG
Definition: rpmds.h:53
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:486
@ RPMRICH_PARSE_ENTER
Definition: rpmds.h:488
@ RPMRICH_PARSE_OP
Definition: rpmds.h:490
@ RPMRICH_PARSE_LEAVE
Definition: rpmds.h:489
@ RPMRICH_PARSE_SIMPLE
Definition: rpmds.h:487
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:493
int rpmdsIsRich(rpmds dep)
Return if current depenency is rich.
rpmFlags rpmsenseFlags
Definition: rpmds.h:57
int rpmdsRpmlibPool(rpmstrPool pool, rpmds *dsp, const void *tblp)
Load rpmlib provides into a dependency set.
rpmrichOp_e
Definition: rpmds.h:475
@ RPMRICHOP_UNLESS
Definition: rpmds.h:483
@ RPMRICHOP_IF
Definition: rpmds.h:479
@ RPMRICHOP_OR
Definition: rpmds.h:478
@ RPMRICHOP_ELSE
Definition: rpmds.h:480
@ RPMRICHOP_WITHOUT
Definition: rpmds.h:482
@ RPMRICHOP_AND
Definition: rpmds.h:477
@ RPMRICHOP_WITH
Definition: rpmds.h:481
@ RPMRICHOP_SINGLE
Definition: rpmds.h:476
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
Structures and prototypes used for an "rpmps" problem set.
Typedefs for RPM abstract data types.
struct rpmstrPool_s * rpmstrPool
Definition: rpmtypes.h:84
Miscellaneous utility macros:
#define RPM_GNUC_DEPRECATED
Definition: rpmutil.h:81