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);
102 * Create and load a dependency set.
104 * @param tagN type of dependency
105 * @param flags unused
106 * @return new dependency set
108 rpmds rpmdsNew(Header h, rpmTagVal tagN, int flags);
111 * Return new formatted dependency string.
112 * @param dspfx formatted dependency string prefix
113 * @param ds dependency set
114 * @return new formatted dependency (malloc'ed)
116 char * rpmdsNewDNEVR(const char * dspfx, const rpmds ds);
119 * Create, load and initialize a dependency for this header.
121 * @param tagN type of dependency
122 * @param Flags comparison flags
123 * @return new dependency set
125 rpmds rpmdsThis(Header h, rpmTagVal tagN, rpmsenseFlags Flags);
128 * Create, load and initialize a dependency set of size 1.
129 * @param tagN type of dependency
131 * @param EVR epoch:version-release
132 * @param Flags comparison flags
133 * @return new dependency set
135 rpmds rpmdsSingle(rpmTagVal tagN, const char * N, const char * EVR, rpmsenseFlags Flags);
138 * Return a new dependency set of size 1 from the current iteration index
139 * @param ds dependency set
140 * @return new dependency set
142 rpmds rpmdsCurrent(rpmds ds);
145 * Return dependency set count.
146 * @param ds dependency set
147 * @return current count
149 int rpmdsCount(const rpmds ds);
152 * Return dependency set index.
153 * @param ds dependency set
154 * @return current index
156 int rpmdsIx(const rpmds ds);
159 * Set dependency set index.
160 * @param ds dependency set
161 * @param ix new index
162 * @return current index
164 int rpmdsSetIx(rpmds ds, int ix);
167 * Return current formatted dependency string.
168 * @param ds dependency set
169 * @return current dependency DNEVR, NULL on invalid
171 const char * rpmdsDNEVR(const rpmds ds);
174 * Return current dependency name.
175 * @param ds dependency set
176 * @return current dependency name, NULL on invalid
178 const char * rpmdsN(const rpmds ds);
181 * Return current dependency epoch-version-release.
182 * @param ds dependency set
183 * @return current dependency EVR, NULL on invalid
185 const char * rpmdsEVR(const rpmds ds);
188 * Return current dependency flags.
189 * @param ds dependency set
190 * @return current dependency flags, 0 on invalid
192 rpmsenseFlags rpmdsFlags(const rpmds ds);
195 * Return current dependency type.
196 * @param ds dependency set
197 * @return current dependency type, 0 on invalid
199 rpmTagVal rpmdsTagN(const rpmds ds);
202 * Return dependency header instance, ie whether the dependency comes from
203 * an installed header or not.
204 * @param ds dependency set
205 * @return header instance of dependency (0 for not installed)
207 unsigned int rpmdsInstance(rpmds ds);
210 * Return current "Don't promote Epoch:" flag.
212 * This flag controls for Epoch: promotion when a dependency set is
213 * compared. If the flag is set (for already installed packages), then
214 * an unspecified value will be treated as Epoch: 0. Otherwise (for added
215 * packages), the Epoch: portion of the comparison is skipped if the value
216 * is not specified, i.e. an unspecified Epoch: is assumed to be equal
217 * in dependency comparisons.
219 * @param ds dependency set
220 * @return current "Don't promote Epoch:" flag
222 int rpmdsNoPromote(const rpmds ds);
225 * Set "Don't promote Epoch:" flag.
226 * @param ds dependency set
227 * @param nopromote Should an unspecified Epoch: be treated as Epoch: 0?
228 * @return previous "Don't promote Epoch:" flag
230 int rpmdsSetNoPromote(rpmds ds, int nopromote);
233 * Return current dependency color.
234 * @param ds dependency set
235 * @return current dependency color
237 rpm_color_t rpmdsColor(const rpmds ds);
240 * Return current dependency color.
241 * @param ds dependency set
242 * @param color new dependency color
243 * @return previous dependency color
245 rpm_color_t rpmdsSetColor(const rpmds ds, rpm_color_t color);
248 * Notify of results of dependency match.
249 * @param ds dependency set
250 * @param where where dependency was resolved (or NULL)
251 * @param rc 0 == YES, otherwise NO
253 /* FIX: rpmMessage annotation is a lie */
254 void rpmdsNotify(rpmds ds, const char * where, int rc);
257 * Return next dependency set iterator index.
258 * @param ds dependency set
259 * @return dependency set iterator index, -1 on termination
261 int rpmdsNext(rpmds ds);
264 * Initialize dependency set iterator.
265 * @param ds dependency set
266 * @return dependency set
268 rpmds rpmdsInit(rpmds ds);
271 * Find a dependency set element using binary search.
272 * @param ds dependency set to search
273 * @param ods dependency set element to find.
274 * @return dependency index (or -1 if not found)
276 int rpmdsFind(rpmds ds, const rpmds ods);
279 * Merge a dependency set maintaining (N,EVR,Flags) sorted order.
280 * @retval *dsp (merged) dependency set
281 * @param ods dependency set to merge
282 * @return (merged) dependency index
284 int rpmdsMerge(rpmds * dsp, rpmds ods);
287 * Search a sorted dependency set for an element that overlaps.
288 * A boolean result is saved (if allocated) and accessible through
289 * rpmdsResult(ods) afterwards.
290 * @param ds dependency set to search
291 * @param ods dependency set element to find.
292 * @return dependency index (or -1 if not found)
294 int rpmdsSearch(rpmds ds, rpmds ods);
297 * Compare two versioned dependency ranges, looking for overlap.
298 * @param A 1st dependency
299 * @param B 2nd dependency
300 * @return 1 if dependencies overlap, 0 otherwise
302 int rpmdsCompare(const rpmds A, const rpmds B);
305 * Compare package provides dependencies from header with a single dependency.
307 * @param req dependency set
308 * @param nopromote Don't promote Epoch: in comparison?
309 * @return 1 if any dependency overlaps, 0 otherwise
311 int rpmdsAnyMatchesDep (const Header h, const rpmds req, int nopromote);
314 * Compare package provides dependencies from header with a single dependency.
316 * @param ix index in header provides
317 * @param req dependency set
318 * @param nopromote Don't promote Epoch: in comparison?
319 * @return 1 if any dependency overlaps, 0 otherwise
321 int rpmdsMatchesDep (const Header h, int ix, const rpmds req, int nopromote);
324 * Compare package name-version-release from header with a single dependency.
326 * @param req dependency set
327 * @param nopromote Don't promote Epoch: in comparison?
328 * @return 1 if dependency overlaps, 0 otherwise
330 int rpmdsNVRMatchesDep(const Header h, const rpmds req, int nopromote);
333 * Load rpmlib provides into a dependency set.
334 * @retval *dsp (loaded) depedency set
335 * @param tblp rpmlib provides table (NULL uses internal table)
336 * @return 0 on success
338 int rpmdsRpmlib(rpmds * dsp, const void * tblp);