4 /** \ingroup rpmdep rpmtrans
6 * Structure(s) used for dependency tag sets.
11 #include <rpm/rpmtypes.h>
12 #include <rpm/rpmps.h>
20 extern int _rpmds_debug;
24 extern int _rpmds_nopromote;
27 * Dependency Attributes.
29 typedef enum rpmsenseFlags_e {
31 RPMSENSE_SERIAL = (1 << 0), /*!< @todo Legacy. */
32 RPMSENSE_LESS = (1 << 1),
33 RPMSENSE_GREATER = (1 << 2),
34 RPMSENSE_EQUAL = (1 << 3),
35 RPMSENSE_PROVIDES = (1 << 4), /* only used internally by builds */
36 RPMSENSE_CONFLICTS = (1 << 5), /* only used internally by builds */
37 /* bit 6 used to be RPMSENSE_PREREQ */
38 #define RPMSENSE_PREREQ RPMSENSE_ANY
39 RPMSENSE_OBSOLETES = (1 << 7), /* only used internally by builds */
40 RPMSENSE_INTERP = (1 << 8), /*!< Interpreter used by scriptlet. */
41 RPMSENSE_SCRIPT_PRE = ((1 << 9)|RPMSENSE_PREREQ), /*!< %pre dependency. */
42 RPMSENSE_SCRIPT_POST = ((1 << 10)|RPMSENSE_PREREQ), /*!< %post dependency. */
43 RPMSENSE_SCRIPT_PREUN = ((1 << 11)|RPMSENSE_PREREQ), /*!< %preun dependency. */
44 RPMSENSE_SCRIPT_POSTUN = ((1 << 12)|RPMSENSE_PREREQ), /*!< %postun dependency. */
45 RPMSENSE_SCRIPT_VERIFY = (1 << 13), /*!< %verify dependency. */
46 RPMSENSE_FIND_REQUIRES = (1 << 14), /*!< find-requires generated dependency. */
47 RPMSENSE_FIND_PROVIDES = (1 << 15), /*!< find-provides generated dependency. */
49 RPMSENSE_TRIGGERIN = (1 << 16), /*!< %triggerin dependency. */
50 RPMSENSE_TRIGGERUN = (1 << 17), /*!< %triggerun dependency. */
51 RPMSENSE_TRIGGERPOSTUN = (1 << 18), /*!< %triggerpostun dependency. */
52 RPMSENSE_MISSINGOK = (1 << 19), /*!< suggests/enhances hint. */
53 RPMSENSE_SCRIPT_PREP = (1 << 20), /*!< %prep build dependency. */
54 RPMSENSE_SCRIPT_BUILD = (1 << 21), /*!< %build build dependency. */
55 RPMSENSE_SCRIPT_INSTALL = (1 << 22),/*!< %install build dependency. */
56 RPMSENSE_SCRIPT_CLEAN = (1 << 23), /*!< %clean build dependency. */
57 RPMSENSE_RPMLIB = ((1 << 24) | RPMSENSE_PREREQ), /*!< rpmlib(feature) dependency. */
58 RPMSENSE_TRIGGERPREIN = (1 << 25), /*!< %triggerprein dependency. */
59 RPMSENSE_KEYRING = (1 << 26),
60 RPMSENSE_PATCHES = (1 << 27),
61 RPMSENSE_CONFIG = (1 << 28)
64 #define RPMSENSE_SENSEMASK 15 /* Mask to get senses, ie serial, */
65 /* less, greater, equal. */
67 #define RPMSENSE_TRIGGER \
68 (RPMSENSE_TRIGGERPREIN | RPMSENSE_TRIGGERIN | RPMSENSE_TRIGGERUN | RPMSENSE_TRIGGERPOSTUN)
70 #define _ALL_REQUIRES_MASK (\
72 RPMSENSE_SCRIPT_PRE | \
73 RPMSENSE_SCRIPT_POST | \
74 RPMSENSE_SCRIPT_PREUN | \
75 RPMSENSE_SCRIPT_POSTUN | \
76 RPMSENSE_SCRIPT_VERIFY | \
77 RPMSENSE_FIND_REQUIRES | \
78 RPMSENSE_SCRIPT_PREP | \
79 RPMSENSE_SCRIPT_BUILD | \
80 RPMSENSE_SCRIPT_INSTALL | \
81 RPMSENSE_SCRIPT_CLEAN | \
85 #define _notpre(_x) ((_x) & ~RPMSENSE_PREREQ)
86 #define _INSTALL_ONLY_MASK \
87 _notpre(RPMSENSE_SCRIPT_PRE|RPMSENSE_SCRIPT_POST|RPMSENSE_RPMLIB|RPMSENSE_KEYRING)
88 #define _ERASE_ONLY_MASK \
89 _notpre(RPMSENSE_SCRIPT_PREUN|RPMSENSE_SCRIPT_POSTUN)
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)
96 * Unreference a dependency set instance.
97 * @param ds dependency set
101 rpmds rpmdsUnlink (rpmds ds, const char * msg);
103 * Reference a dependency set instance.
104 * @param ds dependency set
106 * @return new dependency set reference
108 rpmds rpmdsLink (rpmds ds, const char * msg);
111 * Destroy a dependency set.
112 * @param ds dependency set
113 * @return NULL always
115 rpmds rpmdsFree(rpmds ds);
117 * Create and load a dependency set.
118 * @deprecated Only scareMem = 0 will be permitted.
120 * @param tagN type of dependency
121 * @param flags scareMem(0x1)
122 * @return new dependency set
124 rpmds rpmdsNew(Header h, rpmTag tagN, int flags);
127 * Return new formatted dependency string.
128 * @param dspfx formatted dependency string prefix
129 * @param ds dependency set
130 * @return new formatted dependency (malloc'ed)
132 char * rpmdsNewDNEVR(const char * dspfx, const rpmds ds);
135 * Create, load and initialize a dependency for this header.
137 * @param tagN type of dependency
138 * @param Flags comparison flags
139 * @return new dependency set
141 rpmds rpmdsThis(Header h, rpmTag tagN, rpmsenseFlags Flags);
144 * Create, load and initialize a dependency set of size 1.
145 * @param tagN type of dependency
147 * @param EVR epoch:version-release
148 * @param Flags comparison flags
149 * @return new dependency set
151 rpmds rpmdsSingle(rpmTag tagN, const char * N, const char * EVR, rpmsenseFlags Flags);
154 * Return dependency set count.
155 * @param ds dependency set
156 * @return current count
158 int rpmdsCount(const rpmds ds);
161 * Return dependency set index.
162 * @param ds dependency set
163 * @return current index
165 int rpmdsIx(const rpmds ds);
168 * Set dependency set index.
169 * @param ds dependency set
170 * @param ix new index
171 * @return current index
173 int rpmdsSetIx(rpmds ds, int ix);
176 * Return current formatted dependency string.
177 * @param ds dependency set
178 * @return current dependency DNEVR, NULL on invalid
180 const char * rpmdsDNEVR(const rpmds ds);
183 * Return current dependency name.
184 * @param ds dependency set
185 * @return current dependency name, NULL on invalid
187 const char * rpmdsN(const rpmds ds);
190 * Return current dependency epoch-version-release.
191 * @param ds dependency set
192 * @return current dependency EVR, NULL on invalid
194 const char * rpmdsEVR(const rpmds ds);
197 * Return current dependency flags.
198 * @param ds dependency set
199 * @return current dependency flags, 0 on invalid
201 rpmsenseFlags rpmdsFlags(const rpmds ds);
204 * Return current dependency type.
205 * @param ds dependency set
206 * @return current dependency type, 0 on invalid
208 rpmTag rpmdsTagN(const rpmds ds);
211 * Return dependency build time.
212 * @param ds dependency set
213 * @return dependency build time, 0 on invalid
215 time_t rpmdsBT(const rpmds ds);
218 * Set dependency build time.
219 * @param ds dependency set
220 * @param BT build time
221 * @return dependency build time, 0 on invalid
223 time_t rpmdsSetBT(const rpmds ds, time_t BT);
226 * Return current "Don't promote Epoch:" flag.
228 * This flag controls for Epoch: promotion when a dependency set is
229 * compared. If the flag is set (for already installed packages), then
230 * an unspecified value will be treated as Epoch: 0. Otherwise (for added
231 * packages), the Epoch: portion of the comparison is skipped if the value
232 * is not specified, i.e. an unspecified Epoch: is assumed to be equal
233 * in dependency comparisons.
235 * @param ds dependency set
236 * @return current "Don't promote Epoch:" flag
238 int rpmdsNoPromote(const rpmds ds);
241 * Set "Don't promote Epoch:" flag.
242 * @param ds dependency set
243 * @param nopromote Should an unspecified Epoch: be treated as Epoch: 0?
244 * @return previous "Don't promote Epoch:" flag
246 int rpmdsSetNoPromote(rpmds ds, int nopromote);
249 * Return current dependency color.
250 * @param ds dependency set
251 * @return current dependency color
253 rpm_color_t rpmdsColor(const rpmds ds);
256 * Return current dependency color.
257 * @param ds dependency set
258 * @param color new dependency color
259 * @return previous dependency color
261 rpm_color_t rpmdsSetColor(const rpmds ds, rpm_color_t color);
264 * Return current dependency file refs.
265 * @param ds dependency set
266 * @return current dependency file refs, -1 on global
268 int32_t rpmdsRefs(const rpmds ds);
271 * Return current dependency color.
272 * @param ds dependency set
273 * @param refs new dependency refs
274 * @return previous dependency refs
276 int32_t rpmdsSetRefs(const rpmds ds, int32_t refs);
279 * Notify of results of dependency match.
280 * @param ds dependency set
281 * @param where where dependency was resolved (or NULL)
282 * @param rc 0 == YES, otherwise NO
284 /* FIX: rpmMessage annotation is a lie */
285 void rpmdsNotify(rpmds ds, const char * where, int rc);
288 * Return next dependency set iterator index.
289 * @param ds dependency set
290 * @return dependency set iterator index, -1 on termination
292 int rpmdsNext(rpmds ds);
295 * Initialize dependency set iterator.
296 * @param ds dependency set
297 * @return dependency set
299 rpmds rpmdsInit(rpmds ds);
302 * Find a dependency set element using binary search.
303 * @param ds dependency set to search
304 * @param ods dependency set element to find.
305 * @return dependency index (or -1 if not found)
307 int rpmdsFind(rpmds ds, const rpmds ods);
310 * Merge a dependency set maintaining (N,EVR,Flags) sorted order.
311 * @retval *dsp (merged) dependency set
312 * @param ods dependency set to merge
313 * @return (merged) dependency index
315 int rpmdsMerge(rpmds * dsp, rpmds ods);
318 * Search a sorted dependency set for an element that overlaps.
319 * A boolean result is saved (if allocated) and accessible through
320 * rpmdsResult(ods) afterwards.
321 * @param ds dependency set to search
322 * @param ods dependency set element to find.
323 * @return dependency index (or -1 if not found)
325 int rpmdsSearch(rpmds ds, rpmds ods);
329 * Compare two versioned dependency ranges, looking for overlap.
330 * @param A 1st dependency
331 * @param B 2nd dependency
332 * @return 1 if dependencies overlap, 0 otherwise
334 int rpmdsCompare(const rpmds A, const rpmds B);
337 * Report a Requires: or Conflicts: dependency problem.
338 * @param ps transaction set problems
339 * @param pkgNEVR package name/epoch/version/release
340 * @param ds dependency set
341 * @param suggestedKeys filename or python object address
342 * @param adding dependency problem is from added package set?
344 void rpmdsProblem(rpmps ps, const char * pkgNEVR, const rpmds ds,
345 const fnpyKey * suggestedKeys,
349 * Compare package provides dependencies from header with a single dependency.
351 * @param req dependency set
352 * @param nopromote Don't promote Epoch: in comparison?
353 * @return 1 if any dependency overlaps, 0 otherwise
355 int rpmdsAnyMatchesDep (const Header h, const rpmds req, int nopromote);
358 * Compare package name-version-release from header with a single dependency.
360 * @param req dependency set
361 * @param nopromote Don't promote Epoch: in comparison?
362 * @return 1 if dependency overlaps, 0 otherwise
364 int rpmdsNVRMatchesDep(const Header h, const rpmds req, int nopromote);
367 * Load rpmlib provides into a dependency set.
368 * @retval *dsp (loaded) depedency set
369 * @param tblp rpmlib provides table (NULL uses internal table)
370 * @return 0 on success
372 int rpmdsRpmlib(rpmds * dsp, void * tblp);