4 /** \ingroup rpmdep rpmtrans
6 * Structure(s) used for dependency tag sets.
9 #include <rpmlib.h> /* for rpmds */
18 extern int _rpmds_debug;
22 extern int _rpmds_nopromote;
25 * Dependency Attributes.
27 typedef enum rpmsenseFlags_e {
29 RPMSENSE_SERIAL = (1 << 0), /*!< @todo Legacy. */
30 RPMSENSE_LESS = (1 << 1),
31 RPMSENSE_GREATER = (1 << 2),
32 RPMSENSE_EQUAL = (1 << 3),
33 RPMSENSE_PROVIDES = (1 << 4), /* only used internally by builds */
34 RPMSENSE_CONFLICTS = (1 << 5), /* only used internally by builds */
35 /* bit 6 used to be RPMSENSE_PREREQ */
36 #define RPMSENSE_PREREQ RPMSENSE_ANY
37 RPMSENSE_OBSOLETES = (1 << 7), /* only used internally by builds */
38 RPMSENSE_INTERP = (1 << 8), /*!< Interpreter used by scriptlet. */
39 RPMSENSE_SCRIPT_PRE = ((1 << 9)|RPMSENSE_PREREQ), /*!< %pre dependency. */
40 RPMSENSE_SCRIPT_POST = ((1 << 10)|RPMSENSE_PREREQ), /*!< %post dependency. */
41 RPMSENSE_SCRIPT_PREUN = ((1 << 11)|RPMSENSE_PREREQ), /*!< %preun dependency. */
42 RPMSENSE_SCRIPT_POSTUN = ((1 << 12)|RPMSENSE_PREREQ), /*!< %postun dependency. */
43 RPMSENSE_SCRIPT_VERIFY = (1 << 13), /*!< %verify dependency. */
44 RPMSENSE_FIND_REQUIRES = (1 << 14), /*!< find-requires generated dependency. */
45 RPMSENSE_FIND_PROVIDES = (1 << 15), /*!< find-provides generated dependency. */
47 RPMSENSE_TRIGGERIN = (1 << 16), /*!< %triggerin dependency. */
48 RPMSENSE_TRIGGERUN = (1 << 17), /*!< %triggerun dependency. */
49 RPMSENSE_TRIGGERPOSTUN = (1 << 18), /*!< %triggerpostun dependency. */
50 RPMSENSE_MISSINGOK = (1 << 19), /*!< suggests/enhances hint. */
51 RPMSENSE_SCRIPT_PREP = (1 << 20), /*!< %prep build dependency. */
52 RPMSENSE_SCRIPT_BUILD = (1 << 21), /*!< %build build dependency. */
53 RPMSENSE_SCRIPT_INSTALL = (1 << 22),/*!< %install build dependency. */
54 RPMSENSE_SCRIPT_CLEAN = (1 << 23), /*!< %clean build dependency. */
55 RPMSENSE_RPMLIB = ((1 << 24) | RPMSENSE_PREREQ), /*!< rpmlib(feature) dependency. */
56 RPMSENSE_TRIGGERPREIN = (1 << 25), /*!< @todo Implement %triggerprein. */
57 RPMSENSE_KEYRING = (1 << 26),
58 RPMSENSE_PATCHES = (1 << 27),
59 RPMSENSE_CONFIG = (1 << 28)
62 #define RPMSENSE_SENSEMASK 15 /* Mask to get senses, ie serial, */
63 /* less, greater, equal. */
65 #define RPMSENSE_TRIGGER \
66 (RPMSENSE_TRIGGERIN | RPMSENSE_TRIGGERUN | RPMSENSE_TRIGGERPOSTUN)
68 #define _ALL_REQUIRES_MASK (\
70 RPMSENSE_SCRIPT_PRE | \
71 RPMSENSE_SCRIPT_POST | \
72 RPMSENSE_SCRIPT_PREUN | \
73 RPMSENSE_SCRIPT_POSTUN | \
74 RPMSENSE_SCRIPT_VERIFY | \
75 RPMSENSE_FIND_REQUIRES | \
76 RPMSENSE_SCRIPT_PREP | \
77 RPMSENSE_SCRIPT_BUILD | \
78 RPMSENSE_SCRIPT_INSTALL | \
79 RPMSENSE_SCRIPT_CLEAN | \
83 #define _notpre(_x) ((_x) & ~RPMSENSE_PREREQ)
84 #define _INSTALL_ONLY_MASK \
85 _notpre(RPMSENSE_SCRIPT_PRE|RPMSENSE_SCRIPT_POST|RPMSENSE_RPMLIB|RPMSENSE_KEYRING)
86 #define _ERASE_ONLY_MASK \
87 _notpre(RPMSENSE_SCRIPT_PREUN|RPMSENSE_SCRIPT_POSTUN)
89 #define isLegacyPreReq(_x) (((_x) & _ALL_REQUIRES_MASK) == RPMSENSE_PREREQ)
90 #define isInstallPreReq(_x) ((_x) & _INSTALL_ONLY_MASK)
91 #define isErasePreReq(_x) ((_x) & _ERASE_ONLY_MASK)
94 * Unreference a dependency set instance.
95 * @param ds dependency set
99 rpmds rpmdsUnlink (rpmds ds, const char * msg);
101 * Reference a dependency set instance.
102 * @param ds dependency set
104 * @return new dependency set reference
106 rpmds rpmdsLink (rpmds ds, const char * msg);
109 * Destroy a dependency set.
110 * @param ds dependency set
111 * @return NULL always
113 rpmds rpmdsFree(rpmds ds);
115 * Create and load a dependency set.
116 * @deprecated Only scareMem = 0 will be permitted.
118 * @param tagN type of dependency
119 * @param flags scareMem(0x1)
120 * @return new dependency set
122 rpmds rpmdsNew(Header h, rpmTag tagN, int flags);
125 * Return new formatted dependency string.
126 * @param dspfx formatted dependency string prefix
127 * @param ds dependency set
128 * @return new formatted dependency (malloc'ed)
130 char * rpmdsNewDNEVR(const char * dspfx, const rpmds ds);
133 * Create, load and initialize a dependency for this header.
135 * @param tagN type of dependency
136 * @param Flags comparison flags
137 * @return new dependency set
139 rpmds rpmdsThis(Header h, rpmTag tagN, int32_t Flags);
142 * Create, load and initialize a dependency set of size 1.
143 * @param tagN type of dependency
145 * @param EVR epoch:version-release
146 * @param Flags comparison flags
147 * @return new dependency set
149 rpmds rpmdsSingle(rpmTag tagN, const char * N, const char * EVR, int32_t Flags);
152 * Return dependency set count.
153 * @param ds dependency set
154 * @return current count
156 int rpmdsCount(const rpmds ds);
159 * Return dependency set index.
160 * @param ds dependency set
161 * @return current index
163 int rpmdsIx(const rpmds ds);
166 * Set dependency set index.
167 * @param ds dependency set
168 * @param ix new index
169 * @return current index
171 int rpmdsSetIx(rpmds ds, int ix);
174 * Return current formatted dependency string.
175 * @param ds dependency set
176 * @return current dependency DNEVR, NULL on invalid
178 extern const char * rpmdsDNEVR(const rpmds ds);
181 * Return current dependency name.
182 * @param ds dependency set
183 * @return current dependency name, NULL on invalid
185 extern const char * rpmdsN(const rpmds ds);
188 * Return current dependency epoch-version-release.
189 * @param ds dependency set
190 * @return current dependency EVR, NULL on invalid
192 extern const char * rpmdsEVR(const rpmds ds);
195 * Return current dependency flags.
196 * @param ds dependency set
197 * @return current dependency flags, 0 on invalid
199 int32_t rpmdsFlags(const rpmds ds);
202 * Return current dependency type.
203 * @param ds dependency set
204 * @return current dependency type, 0 on invalid
206 rpmTag rpmdsTagN(const rpmds ds);
209 * Return dependency build time.
210 * @param ds dependency set
211 * @return dependency build time, 0 on invalid
213 time_t rpmdsBT(const rpmds ds);
216 * Set dependency build time.
217 * @param ds dependency set
218 * @param BT build time
219 * @return dependency build time, 0 on invalid
221 time_t rpmdsSetBT(const rpmds ds, time_t BT);
224 * Return current "Don't promote Epoch:" flag.
226 * This flag controls for Epoch: promotion when a dependency set is
227 * compared. If the flag is set (for already installed packages), then
228 * an unspecified value will be treated as Epoch: 0. Otherwise (for added
229 * packages), the Epoch: portion of the comparison is skipped if the value
230 * is not specified, i.e. an unspecified Epoch: is assumed to be equal
231 * in dependency comparisons.
233 * @param ds dependency set
234 * @return current "Don't promote Epoch:" flag
236 int rpmdsNoPromote(const rpmds ds);
239 * Set "Don't promote Epoch:" flag.
240 * @param ds dependency set
241 * @param nopromote Should an unspecified Epoch: be treated as Epoch: 0?
242 * @return previous "Don't promote Epoch:" flag
244 int rpmdsSetNoPromote(rpmds ds, int nopromote);
247 * Return current dependency color.
248 * @param ds dependency set
249 * @return current dependency color
251 uint32_t rpmdsColor(const rpmds ds);
254 * Return current dependency color.
255 * @param ds dependency set
256 * @param color new dependency color
257 * @return previous dependency color
259 uint32_t rpmdsSetColor(const rpmds ds, uint32_t color);
262 * Return current dependency file refs.
263 * @param ds dependency set
264 * @return current dependency file refs, -1 on global
266 int32_t rpmdsRefs(const rpmds ds);
269 * Return current dependency color.
270 * @param ds dependency set
271 * @param refs new dependency refs
272 * @return previous dependency refs
274 int32_t rpmdsSetRefs(const rpmds ds, int32_t refs);
277 * Notify of results of dependency match.
278 * @param ds dependency set
279 * @param where where dependency was resolved (or NULL)
280 * @param rc 0 == YES, otherwise NO
282 /* FIX: rpmMessage annotation is a lie */
283 void rpmdsNotify(rpmds ds, const char * where, int rc);
286 * Return next dependency set iterator index.
287 * @param ds dependency set
288 * @return dependency set iterator index, -1 on termination
290 int rpmdsNext(rpmds ds);
293 * Initialize dependency set iterator.
294 * @param ds dependency set
295 * @return dependency set
297 rpmds rpmdsInit(rpmds ds);
300 * Find a dependency set element using binary search.
301 * @param ds dependency set to search
302 * @param ods dependency set element to find.
303 * @return dependency index (or -1 if not found)
305 int rpmdsFind(rpmds ds, const rpmds ods);
308 * Merge a dependency set maintaining (N,EVR,Flags) sorted order.
309 * @retval *dsp (merged) dependency set
310 * @param ods dependency set to merge
311 * @return (merged) dependency index
313 int rpmdsMerge(rpmds * dsp, rpmds ods);
316 * Compare two versioned dependency ranges, looking for overlap.
317 * @param A 1st dependency
318 * @param B 2nd dependency
319 * @return 1 if dependencies overlap, 0 otherwise
321 int rpmdsCompare(const rpmds A, const rpmds B);
324 * Report a Requires: or Conflicts: dependency problem.
325 * @param ps transaction set problems
326 * @param pkgNEVR package name/epoch/version/release
327 * @param ds dependency set
328 * @param suggestedKeys filename or python object address
329 * @param adding dependency problem is from added package set?
331 void rpmdsProblem(rpmps ps, const char * pkgNEVR, const rpmds ds,
332 const fnpyKey * suggestedKeys,
336 * Compare package provides dependencies from header with a single dependency.
338 * @param req dependency set
339 * @param nopromote Don't promote Epoch: in comparison?
340 * @return 1 if any dependency overlaps, 0 otherwise
342 int rpmdsAnyMatchesDep (const Header h, const rpmds req, int nopromote);
345 * Compare package name-version-release from header with a single dependency.
347 * @param req dependency set
348 * @param nopromote Don't promote Epoch: in comparison?
349 * @return 1 if dependency overlaps, 0 otherwise
351 int rpmdsNVRMatchesDep(const Header h, const rpmds req, int nopromote);