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 typedef enum rpmsenseFlags_e {
27 RPMSENSE_LESS = (1 << 1),
28 RPMSENSE_GREATER = (1 << 2),
29 RPMSENSE_EQUAL = (1 << 3),
31 RPMSENSE_PREREQ = (1 << 6), /* legacy prereq dependency */
33 RPMSENSE_INTERP = (1 << 8), /*!< Interpreter used by scriptlet. */
34 RPMSENSE_SCRIPT_PRE = (1 << 9), /*!< %pre dependency. */
35 RPMSENSE_SCRIPT_POST = (1 << 10), /*!< %post dependency. */
36 RPMSENSE_SCRIPT_PREUN = (1 << 11), /*!< %preun dependency. */
37 RPMSENSE_SCRIPT_POSTUN = (1 << 12), /*!< %postun dependency. */
38 RPMSENSE_SCRIPT_VERIFY = (1 << 13), /*!< %verify dependency. */
39 RPMSENSE_FIND_REQUIRES = (1 << 14), /*!< find-requires generated dependency. */
40 RPMSENSE_FIND_PROVIDES = (1 << 15), /*!< find-provides generated dependency. */
42 RPMSENSE_TRIGGERIN = (1 << 16), /*!< %triggerin dependency. */
43 RPMSENSE_TRIGGERUN = (1 << 17), /*!< %triggerun dependency. */
44 RPMSENSE_TRIGGERPOSTUN = (1 << 18), /*!< %triggerpostun dependency. */
45 RPMSENSE_MISSINGOK = (1 << 19), /*!< suggests/enhances hint. */
46 /* bits 20-23 unused */
47 RPMSENSE_RPMLIB = (1 << 24), /*!< rpmlib(feature) dependency. */
48 RPMSENSE_TRIGGERPREIN = (1 << 25), /*!< %triggerprein dependency. */
49 RPMSENSE_KEYRING = (1 << 26),
50 RPMSENSE_PATCHES = (1 << 27),
51 RPMSENSE_CONFIG = (1 << 28)
54 #define RPMSENSE_SENSEMASK 15 /* Mask to get senses, ie serial, */
55 /* less, greater, equal. */
57 #define RPMSENSE_TRIGGER \
58 (RPMSENSE_TRIGGERPREIN | RPMSENSE_TRIGGERIN | RPMSENSE_TRIGGERUN | RPMSENSE_TRIGGERPOSTUN)
60 #define _ALL_REQUIRES_MASK (\
62 RPMSENSE_SCRIPT_PRE | \
63 RPMSENSE_SCRIPT_POST | \
64 RPMSENSE_SCRIPT_PREUN | \
65 RPMSENSE_SCRIPT_POSTUN | \
66 RPMSENSE_SCRIPT_VERIFY | \
67 RPMSENSE_FIND_REQUIRES | \
72 #define _notpre(_x) ((_x) & ~RPMSENSE_PREREQ)
73 #define _INSTALL_ONLY_MASK \
74 _notpre(RPMSENSE_SCRIPT_PRE|RPMSENSE_SCRIPT_POST|RPMSENSE_RPMLIB|RPMSENSE_KEYRING)
75 #define _ERASE_ONLY_MASK \
76 _notpre(RPMSENSE_SCRIPT_PREUN|RPMSENSE_SCRIPT_POSTUN)
78 #define isLegacyPreReq(_x) (((_x) & _ALL_REQUIRES_MASK) == RPMSENSE_PREREQ)
79 #define isInstallPreReq(_x) ((_x) & _INSTALL_ONLY_MASK)
80 #define isErasePreReq(_x) ((_x) & _ERASE_ONLY_MASK)
83 * Unreference a dependency set instance.
84 * @param ds dependency set
87 rpmds rpmdsUnlink(rpmds ds);
90 * Reference a dependency set instance.
91 * @param ds dependency set
92 * @return new dependency set reference
94 rpmds rpmdsLink(rpmds ds);
97 * Destroy a dependency set.
98 * @param ds dependency set
101 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, rpmTag tagN, int flags);
112 * Return new formatted dependency string.
113 * @param dspfx formatted dependency string prefix
114 * @param ds dependency set
115 * @return new formatted dependency (malloc'ed)
117 char * rpmdsNewDNEVR(const char * dspfx, const rpmds ds);
120 * Create, load and initialize a dependency for this header.
122 * @param tagN type of dependency
123 * @param Flags comparison flags
124 * @return new dependency set
126 rpmds rpmdsThis(Header h, rpmTag tagN, rpmsenseFlags Flags);
129 * Create, load and initialize a dependency set of size 1.
130 * @param tagN type of dependency
132 * @param EVR epoch:version-release
133 * @param Flags comparison flags
134 * @return new dependency set
136 rpmds rpmdsSingle(rpmTag tagN, const char * N, const char * EVR, rpmsenseFlags Flags);
139 * Return a new dependency set of size 1 from the current iteration index
140 * @param ds dependency set
141 * @return new dependency set
143 rpmds rpmdsCurrent(rpmds ds);
146 * Return dependency set count.
147 * @param ds dependency set
148 * @return current count
150 int rpmdsCount(const rpmds ds);
153 * Return dependency set index.
154 * @param ds dependency set
155 * @return current index
157 int rpmdsIx(const rpmds ds);
160 * Set dependency set index.
161 * @param ds dependency set
162 * @param ix new index
163 * @return current index
165 int rpmdsSetIx(rpmds ds, int ix);
168 * Return current formatted dependency string.
169 * @param ds dependency set
170 * @return current dependency DNEVR, NULL on invalid
172 const char * rpmdsDNEVR(const rpmds ds);
175 * Return current dependency name.
176 * @param ds dependency set
177 * @return current dependency name, NULL on invalid
179 const char * rpmdsN(const rpmds ds);
182 * Return current dependency epoch-version-release.
183 * @param ds dependency set
184 * @return current dependency EVR, NULL on invalid
186 const char * rpmdsEVR(const rpmds ds);
189 * Return current dependency flags.
190 * @param ds dependency set
191 * @return current dependency flags, 0 on invalid
193 rpmsenseFlags rpmdsFlags(const rpmds ds);
196 * Return current dependency type.
197 * @param ds dependency set
198 * @return current dependency type, 0 on invalid
200 rpmTag rpmdsTagN(const rpmds ds);
203 * Return dependency header instance, ie whether the dependency comes from
204 * an installed header or not.
205 * @param ds dependency set
206 * @return header instance of dependency (0 for not installed)
208 unsigned int rpmdsInstance(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);
328 * Compare two versioned dependency ranges, looking for overlap.
329 * @param A 1st dependency
330 * @param B 2nd dependency
331 * @return 1 if dependencies overlap, 0 otherwise
333 int rpmdsCompare(const rpmds A, const rpmds B);
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);
354 * Load rpmlib provides into a dependency set.
355 * @retval *dsp (loaded) depedency set
356 * @param tblp rpmlib provides table (NULL uses internal table)
357 * @return 0 on success
359 int rpmdsRpmlib(rpmds * dsp, void * tblp);