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 */
32 RPMSENSE_PRETRANS = (1 << 7), /*!< Pre-transaction 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),
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 | \
73 #define _notpre(_x) ((_x) & ~RPMSENSE_PREREQ)
74 #define _INSTALL_ONLY_MASK \
75 _notpre(RPMSENSE_SCRIPT_PRE|RPMSENSE_SCRIPT_POST|RPMSENSE_RPMLIB|RPMSENSE_KEYRING|RPMSENSE_PRETRANS)
76 #define _ERASE_ONLY_MASK \
77 _notpre(RPMSENSE_SCRIPT_PREUN|RPMSENSE_SCRIPT_POSTUN)
79 #define isLegacyPreReq(_x) (((_x) & _ALL_REQUIRES_MASK) == RPMSENSE_PREREQ)
80 #define isInstallPreReq(_x) ((_x) & _INSTALL_ONLY_MASK)
81 #define isErasePreReq(_x) ((_x) & _ERASE_ONLY_MASK)
84 * Reference a dependency set instance.
85 * @param ds dependency set
86 * @return new dependency set reference
88 rpmds rpmdsLink(rpmds ds);
91 * Destroy a dependency set.
92 * @param ds dependency set
95 rpmds rpmdsFree(rpmds ds);
97 * Create and load a dependency set.
99 * @param tagN type of dependency
100 * @param flags unused
101 * @return new dependency set
103 rpmds rpmdsNew(Header h, rpmTag tagN, int flags);
106 * Return new formatted dependency string.
107 * @param dspfx formatted dependency string prefix
108 * @param ds dependency set
109 * @return new formatted dependency (malloc'ed)
111 char * rpmdsNewDNEVR(const char * dspfx, const rpmds ds);
114 * Create, load and initialize a dependency for this header.
116 * @param tagN type of dependency
117 * @param Flags comparison flags
118 * @return new dependency set
120 rpmds rpmdsThis(Header h, rpmTag tagN, rpmsenseFlags Flags);
123 * Create, load and initialize a dependency set of size 1.
124 * @param tagN type of dependency
126 * @param EVR epoch:version-release
127 * @param Flags comparison flags
128 * @return new dependency set
130 rpmds rpmdsSingle(rpmTag tagN, const char * N, const char * EVR, rpmsenseFlags Flags);
133 * Return a new dependency set of size 1 from the current iteration index
134 * @param ds dependency set
135 * @return new dependency set
137 rpmds rpmdsCurrent(rpmds ds);
140 * Return dependency set count.
141 * @param ds dependency set
142 * @return current count
144 int rpmdsCount(const rpmds ds);
147 * Return dependency set index.
148 * @param ds dependency set
149 * @return current index
151 int rpmdsIx(const rpmds ds);
154 * Set dependency set index.
155 * @param ds dependency set
156 * @param ix new index
157 * @return current index
159 int rpmdsSetIx(rpmds ds, int ix);
162 * Return current formatted dependency string.
163 * @param ds dependency set
164 * @return current dependency DNEVR, NULL on invalid
166 const char * rpmdsDNEVR(const rpmds ds);
169 * Return current dependency name.
170 * @param ds dependency set
171 * @return current dependency name, NULL on invalid
173 const char * rpmdsN(const rpmds ds);
176 * Return current dependency epoch-version-release.
177 * @param ds dependency set
178 * @return current dependency EVR, NULL on invalid
180 const char * rpmdsEVR(const rpmds ds);
183 * Return current dependency flags.
184 * @param ds dependency set
185 * @return current dependency flags, 0 on invalid
187 rpmsenseFlags rpmdsFlags(const rpmds ds);
190 * Return current dependency type.
191 * @param ds dependency set
192 * @return current dependency type, 0 on invalid
194 rpmTag rpmdsTagN(const rpmds ds);
197 * Return dependency header instance, ie whether the dependency comes from
198 * an installed header or not.
199 * @param ds dependency set
200 * @return header instance of dependency (0 for not installed)
202 unsigned int rpmdsInstance(rpmds ds);
205 * Return current "Don't promote Epoch:" flag.
207 * This flag controls for Epoch: promotion when a dependency set is
208 * compared. If the flag is set (for already installed packages), then
209 * an unspecified value will be treated as Epoch: 0. Otherwise (for added
210 * packages), the Epoch: portion of the comparison is skipped if the value
211 * is not specified, i.e. an unspecified Epoch: is assumed to be equal
212 * in dependency comparisons.
214 * @param ds dependency set
215 * @return current "Don't promote Epoch:" flag
217 int rpmdsNoPromote(const rpmds ds);
220 * Set "Don't promote Epoch:" flag.
221 * @param ds dependency set
222 * @param nopromote Should an unspecified Epoch: be treated as Epoch: 0?
223 * @return previous "Don't promote Epoch:" flag
225 int rpmdsSetNoPromote(rpmds ds, int nopromote);
228 * Return current dependency color.
229 * @param ds dependency set
230 * @return current dependency color
232 rpm_color_t rpmdsColor(const rpmds ds);
235 * Return current dependency color.
236 * @param ds dependency set
237 * @param color new dependency color
238 * @return previous dependency color
240 rpm_color_t rpmdsSetColor(const rpmds ds, rpm_color_t color);
243 * Notify of results of dependency match.
244 * @param ds dependency set
245 * @param where where dependency was resolved (or NULL)
246 * @param rc 0 == YES, otherwise NO
248 /* FIX: rpmMessage annotation is a lie */
249 void rpmdsNotify(rpmds ds, const char * where, int rc);
252 * Return next dependency set iterator index.
253 * @param ds dependency set
254 * @return dependency set iterator index, -1 on termination
256 int rpmdsNext(rpmds ds);
259 * Initialize dependency set iterator.
260 * @param ds dependency set
261 * @return dependency set
263 rpmds rpmdsInit(rpmds ds);
266 * Find a dependency set element using binary search.
267 * @param ds dependency set to search
268 * @param ods dependency set element to find.
269 * @return dependency index (or -1 if not found)
271 int rpmdsFind(rpmds ds, const rpmds ods);
274 * Merge a dependency set maintaining (N,EVR,Flags) sorted order.
275 * @retval *dsp (merged) dependency set
276 * @param ods dependency set to merge
277 * @return (merged) dependency index
279 int rpmdsMerge(rpmds * dsp, rpmds ods);
282 * Search a sorted dependency set for an element that overlaps.
283 * A boolean result is saved (if allocated) and accessible through
284 * rpmdsResult(ods) afterwards.
285 * @param ds dependency set to search
286 * @param ods dependency set element to find.
287 * @return dependency index (or -1 if not found)
289 int rpmdsSearch(rpmds ds, rpmds ods);
292 * Compare two versioned dependency ranges, looking for overlap.
293 * @param A 1st dependency
294 * @param B 2nd dependency
295 * @return 1 if dependencies overlap, 0 otherwise
297 int rpmdsCompare(const rpmds A, const rpmds B);
300 * Compare package provides dependencies from header with a single dependency.
302 * @param req dependency set
303 * @param nopromote Don't promote Epoch: in comparison?
304 * @return 1 if any dependency overlaps, 0 otherwise
306 int rpmdsAnyMatchesDep (const Header h, const rpmds req, int nopromote);
309 * Compare package name-version-release from header with a single dependency.
311 * @param req dependency set
312 * @param nopromote Don't promote Epoch: in comparison?
313 * @return 1 if dependency overlaps, 0 otherwise
315 int rpmdsNVRMatchesDep(const Header h, const rpmds req, int nopromote);
318 * Load rpmlib provides into a dependency set.
319 * @retval *dsp (loaded) depedency set
320 * @param tblp rpmlib provides table (NULL uses internal table)
321 * @return 0 on success
323 int rpmdsRpmlib(rpmds * dsp, void * tblp);