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_nopromote;
23 * Dependency Attributes.
25 enum rpmsenseFlags_e {
27 RPMSENSE_LESS = (1 << 1),
28 RPMSENSE_GREATER = (1 << 2),
29 RPMSENSE_EQUAL = (1 << 3),
31 RPMSENSE_POSTTRANS = (1 << 5), /*!< %posttrans dependency */
32 RPMSENSE_PREREQ = (1 << 6), /* legacy prereq dependency */
33 RPMSENSE_PRETRANS = (1 << 7), /*!< Pre-transaction dependency. */
34 RPMSENSE_INTERP = (1 << 8), /*!< Interpreter used by scriptlet. */
35 RPMSENSE_SCRIPT_PRE = (1 << 9), /*!< %pre dependency. */
36 RPMSENSE_SCRIPT_POST = (1 << 10), /*!< %post dependency. */
37 RPMSENSE_SCRIPT_PREUN = (1 << 11), /*!< %preun dependency. */
38 RPMSENSE_SCRIPT_POSTUN = (1 << 12), /*!< %postun dependency. */
39 RPMSENSE_SCRIPT_VERIFY = (1 << 13), /*!< %verify dependency. */
40 RPMSENSE_FIND_REQUIRES = (1 << 14), /*!< find-requires generated dependency. */
41 RPMSENSE_FIND_PROVIDES = (1 << 15), /*!< find-provides generated dependency. */
43 RPMSENSE_TRIGGERIN = (1 << 16), /*!< %triggerin dependency. */
44 RPMSENSE_TRIGGERUN = (1 << 17), /*!< %triggerun dependency. */
45 RPMSENSE_TRIGGERPOSTUN = (1 << 18), /*!< %triggerpostun dependency. */
46 RPMSENSE_MISSINGOK = (1 << 19), /*!< suggests/enhances hint. */
47 /* bits 20-23 unused */
48 RPMSENSE_RPMLIB = (1 << 24), /*!< rpmlib(feature) dependency. */
49 RPMSENSE_TRIGGERPREIN = (1 << 25), /*!< %triggerprein dependency. */
50 RPMSENSE_KEYRING = (1 << 26),
52 RPMSENSE_CONFIG = (1 << 28)
55 typedef rpmFlags rpmsenseFlags;
57 #define RPMSENSE_SENSEMASK 15 /* Mask to get senses, ie serial, */
58 /* less, greater, equal. */
60 #define RPMSENSE_TRIGGER \
61 (RPMSENSE_TRIGGERPREIN | RPMSENSE_TRIGGERIN | RPMSENSE_TRIGGERUN | RPMSENSE_TRIGGERPOSTUN)
63 #define _ALL_REQUIRES_MASK (\
65 RPMSENSE_SCRIPT_PRE | \
66 RPMSENSE_SCRIPT_POST | \
67 RPMSENSE_SCRIPT_PREUN | \
68 RPMSENSE_SCRIPT_POSTUN | \
69 RPMSENSE_SCRIPT_VERIFY | \
70 RPMSENSE_FIND_REQUIRES | \
74 RPMSENSE_POSTTRANS | \
78 #define _notpre(_x) ((_x) & ~RPMSENSE_PREREQ)
79 #define _INSTALL_ONLY_MASK \
80 _notpre(RPMSENSE_SCRIPT_PRE|RPMSENSE_SCRIPT_POST|RPMSENSE_RPMLIB|RPMSENSE_KEYRING|RPMSENSE_PRETRANS|RPMSENSE_POSTTRANS)
81 #define _ERASE_ONLY_MASK \
82 _notpre(RPMSENSE_SCRIPT_PREUN|RPMSENSE_SCRIPT_POSTUN)
84 #define isLegacyPreReq(_x) (((_x) & _ALL_REQUIRES_MASK) == RPMSENSE_PREREQ)
85 #define isInstallPreReq(_x) ((_x) & _INSTALL_ONLY_MASK)
86 #define isErasePreReq(_x) ((_x) & _ERASE_ONLY_MASK)
89 * Reference a dependency set instance.
90 * @param ds dependency set
91 * @return new dependency set reference
93 rpmds rpmdsLink(rpmds ds);
96 * Destroy a dependency set.
97 * @param ds dependency set
100 rpmds rpmdsFree(rpmds ds);
103 * Create and load a dependency set.
105 * @param tagN type of dependency
106 * @param flags unused
107 * @return new dependency set
109 rpmds rpmdsNew(Header h, rpmTagVal tagN, int flags);
112 * Create and load a dependency set.
113 * @param pool shared string pool (or NULL for private pool)
115 * @param tagN type of dependency
116 * @param flags unused
117 * @return new dependency set
119 rpmds rpmdsNewPool(rpmstrPool pool, Header h, rpmTagVal tagN, int flags);
122 * Return new formatted dependency string.
123 * @param dspfx formatted dependency string prefix
124 * @param ds dependency set
125 * @return new formatted dependency (malloc'ed)
127 char * rpmdsNewDNEVR(const char * dspfx, const rpmds ds);
130 * Create, load and initialize a dependency for this header.
132 * @param tagN type of dependency
133 * @param Flags comparison flags
134 * @return new dependency set
136 rpmds rpmdsThis(Header h, rpmTagVal tagN, rpmsenseFlags Flags);
139 * Create, load and initialize a dependency set of size 1.
140 * @param tagN type of dependency
142 * @param EVR epoch:version-release
143 * @param Flags comparison flags
144 * @return new dependency set
146 rpmds rpmdsSingle(rpmTagVal tagN, const char * N, const char * EVR, rpmsenseFlags Flags);
149 * Return a new dependency set of size 1 from the current iteration index
150 * @param ds dependency set
151 * @return new dependency set
153 rpmds rpmdsCurrent(rpmds ds);
156 * Return dependency set count.
157 * @param ds dependency set
158 * @return current count
160 int rpmdsCount(const rpmds ds);
163 * Return dependency set index.
164 * @param ds dependency set
165 * @return current index
167 int rpmdsIx(const rpmds ds);
170 * Set dependency set index.
171 * @param ds dependency set
172 * @param ix new index
173 * @return current index
175 int rpmdsSetIx(rpmds ds, int ix);
178 * Return current formatted dependency string.
179 * @param ds dependency set
180 * @return current dependency DNEVR, NULL on invalid
182 const char * rpmdsDNEVR(const rpmds ds);
185 * Return current dependency name.
186 * @param ds dependency set
187 * @return current dependency name, NULL on invalid
189 const char * rpmdsN(const rpmds ds);
192 * Return current dependency epoch-version-release.
193 * @param ds dependency set
194 * @return current dependency EVR, NULL on invalid
196 const char * rpmdsEVR(const rpmds ds);
199 * Return current dependency flags.
200 * @param ds dependency set
201 * @return current dependency flags, 0 on invalid
203 rpmsenseFlags rpmdsFlags(const rpmds ds);
206 * Return current dependency type.
207 * @param ds dependency set
208 * @return current dependency type, 0 on invalid
210 rpmTagVal rpmdsTagN(const rpmds ds);
213 * Return dependency header instance, ie whether the dependency comes from
214 * an installed header or not.
215 * @param ds dependency set
216 * @return header instance of dependency (0 for not installed)
218 unsigned int rpmdsInstance(rpmds ds);
221 * Return current "Don't promote Epoch:" flag.
223 * This flag controls for Epoch: promotion when a dependency set is
224 * compared. If the flag is set (for already installed packages), then
225 * an unspecified value will be treated as Epoch: 0. Otherwise (for added
226 * packages), the Epoch: portion of the comparison is skipped if the value
227 * is not specified, i.e. an unspecified Epoch: is assumed to be equal
228 * in dependency comparisons.
230 * @param ds dependency set
231 * @return current "Don't promote Epoch:" flag
233 int rpmdsNoPromote(const rpmds ds);
236 * Set "Don't promote Epoch:" flag.
237 * @param ds dependency set
238 * @param nopromote Should an unspecified Epoch: be treated as Epoch: 0?
239 * @return previous "Don't promote Epoch:" flag
241 int rpmdsSetNoPromote(rpmds ds, int nopromote);
244 * Return current dependency color.
245 * @param ds dependency set
246 * @return current dependency color
248 rpm_color_t rpmdsColor(const rpmds ds);
251 * Return current dependency color.
252 * @param ds dependency set
253 * @param color new dependency color
254 * @return previous dependency color
256 rpm_color_t rpmdsSetColor(const rpmds ds, rpm_color_t color);
259 * Notify of results of dependency match.
260 * @param ds dependency set
261 * @param where where dependency was resolved (or NULL)
262 * @param rc 0 == YES, otherwise NO
264 /* FIX: rpmMessage annotation is a lie */
265 void rpmdsNotify(rpmds ds, const char * where, int rc);
268 * Return next dependency set iterator index.
269 * @param ds dependency set
270 * @return dependency set iterator index, -1 on termination
272 int rpmdsNext(rpmds ds);
275 * Initialize dependency set iterator.
276 * @param ds dependency set
277 * @return dependency set
279 rpmds rpmdsInit(rpmds ds);
282 * Find a dependency set element using binary search.
283 * @param ds dependency set to search
284 * @param ods dependency set element to find.
285 * @return dependency index (or -1 if not found)
287 int rpmdsFind(rpmds ds, const rpmds ods);
290 * Merge a dependency set maintaining (N,EVR,Flags) sorted order.
291 * @retval *dsp (merged) dependency set
292 * @param ods dependency set to merge
293 * @return (merged) dependency index
295 int rpmdsMerge(rpmds * dsp, rpmds ods);
298 * Search a sorted dependency set for an element that overlaps.
299 * A boolean result is saved (if allocated) and accessible through
300 * rpmdsResult(ods) afterwards.
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 rpmdsSearch(rpmds ds, rpmds ods);
308 * Compare two versioned dependency ranges, looking for overlap.
309 * @param A 1st dependency
310 * @param B 2nd dependency
311 * @return 1 if dependencies overlap, 0 otherwise
313 int rpmdsCompare(const rpmds A, const rpmds B);
316 * Compare package provides dependencies from header with a single dependency.
318 * @param req dependency set
319 * @param nopromote Don't promote Epoch: in comparison?
320 * @return 1 if any dependency overlaps, 0 otherwise
322 int rpmdsAnyMatchesDep (const Header h, const rpmds req, int nopromote);
325 * Compare package provides dependencies from header with a single dependency.
327 * @param ix index in header provides
328 * @param req dependency set
329 * @param nopromote Don't promote Epoch: in comparison?
330 * @return 1 if any dependency overlaps, 0 otherwise
332 int rpmdsMatchesDep (const Header h, int ix, const rpmds req, int nopromote);
335 * Compare package name-version-release from header with a single dependency.
337 * @param req dependency set
338 * @param nopromote Don't promote Epoch: in comparison?
339 * @return 1 if dependency overlaps, 0 otherwise
341 int rpmdsNVRMatchesDep(const Header h, const rpmds req, int nopromote);
344 * Load rpmlib provides into a dependency set.
345 * @retval *dsp (loaded) depedency set
346 * @param tblp rpmlib provides table (NULL uses internal table)
347 * @return 0 on success
349 int rpmdsRpmlib(rpmds * dsp, const void * tblp);