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 | \
77 #define _notpre(_x) ((_x) & ~RPMSENSE_PREREQ)
78 #define _INSTALL_ONLY_MASK \
79 _notpre(RPMSENSE_SCRIPT_PRE|RPMSENSE_SCRIPT_POST|RPMSENSE_RPMLIB|RPMSENSE_KEYRING|RPMSENSE_PRETRANS|RPMSENSE_POSTTRANS)
80 #define _ERASE_ONLY_MASK \
81 _notpre(RPMSENSE_SCRIPT_PREUN|RPMSENSE_SCRIPT_POSTUN)
83 #define isLegacyPreReq(_x) (((_x) & _ALL_REQUIRES_MASK) == RPMSENSE_PREREQ)
84 #define isInstallPreReq(_x) ((_x) & _INSTALL_ONLY_MASK)
85 #define isErasePreReq(_x) ((_x) & _ERASE_ONLY_MASK)
88 * Reference a dependency set instance.
89 * @param ds dependency set
90 * @return new dependency set reference
92 rpmds rpmdsLink(rpmds ds);
95 * Destroy a dependency set.
96 * @param ds dependency set
99 rpmds rpmdsFree(rpmds ds);
101 * Create and load a dependency set.
103 * @param tagN type of dependency
104 * @param flags unused
105 * @return new dependency set
107 rpmds rpmdsNew(Header h, rpmTagVal tagN, int flags);
110 * Return new formatted dependency string.
111 * @param dspfx formatted dependency string prefix
112 * @param ds dependency set
113 * @return new formatted dependency (malloc'ed)
115 char * rpmdsNewDNEVR(const char * dspfx, const rpmds ds);
118 * Create, load and initialize a dependency for this header.
120 * @param tagN type of dependency
121 * @param Flags comparison flags
122 * @return new dependency set
124 rpmds rpmdsThis(Header h, rpmTagVal tagN, rpmsenseFlags Flags);
127 * Create, load and initialize a dependency set of size 1.
128 * @param tagN type of dependency
130 * @param EVR epoch:version-release
131 * @param Flags comparison flags
132 * @return new dependency set
134 rpmds rpmdsSingle(rpmTagVal tagN, const char * N, const char * EVR, rpmsenseFlags Flags);
137 * Return a new dependency set of size 1 from the current iteration index
138 * @param ds dependency set
139 * @return new dependency set
141 rpmds rpmdsCurrent(rpmds ds);
144 * Return dependency set count.
145 * @param ds dependency set
146 * @return current count
148 int rpmdsCount(const rpmds ds);
151 * Return dependency set index.
152 * @param ds dependency set
153 * @return current index
155 int rpmdsIx(const rpmds ds);
158 * Set dependency set index.
159 * @param ds dependency set
160 * @param ix new index
161 * @return current index
163 int rpmdsSetIx(rpmds ds, int ix);
166 * Return current formatted dependency string.
167 * @param ds dependency set
168 * @return current dependency DNEVR, NULL on invalid
170 const char * rpmdsDNEVR(const rpmds ds);
173 * Return current dependency name.
174 * @param ds dependency set
175 * @return current dependency name, NULL on invalid
177 const char * rpmdsN(const rpmds ds);
180 * Return current dependency epoch-version-release.
181 * @param ds dependency set
182 * @return current dependency EVR, NULL on invalid
184 const char * rpmdsEVR(const rpmds ds);
187 * Return current dependency flags.
188 * @param ds dependency set
189 * @return current dependency flags, 0 on invalid
191 rpmsenseFlags rpmdsFlags(const rpmds ds);
194 * Return current dependency type.
195 * @param ds dependency set
196 * @return current dependency type, 0 on invalid
198 rpmTagVal rpmdsTagN(const rpmds ds);
201 * Return dependency header instance, ie whether the dependency comes from
202 * an installed header or not.
203 * @param ds dependency set
204 * @return header instance of dependency (0 for not installed)
206 unsigned int rpmdsInstance(rpmds ds);
209 * Return current "Don't promote Epoch:" flag.
211 * This flag controls for Epoch: promotion when a dependency set is
212 * compared. If the flag is set (for already installed packages), then
213 * an unspecified value will be treated as Epoch: 0. Otherwise (for added
214 * packages), the Epoch: portion of the comparison is skipped if the value
215 * is not specified, i.e. an unspecified Epoch: is assumed to be equal
216 * in dependency comparisons.
218 * @param ds dependency set
219 * @return current "Don't promote Epoch:" flag
221 int rpmdsNoPromote(const rpmds ds);
224 * Set "Don't promote Epoch:" flag.
225 * @param ds dependency set
226 * @param nopromote Should an unspecified Epoch: be treated as Epoch: 0?
227 * @return previous "Don't promote Epoch:" flag
229 int rpmdsSetNoPromote(rpmds ds, int nopromote);
232 * Return current dependency color.
233 * @param ds dependency set
234 * @return current dependency color
236 rpm_color_t rpmdsColor(const rpmds ds);
239 * Return current dependency color.
240 * @param ds dependency set
241 * @param color new dependency color
242 * @return previous dependency color
244 rpm_color_t rpmdsSetColor(const rpmds ds, rpm_color_t color);
247 * Notify of results of dependency match.
248 * @param ds dependency set
249 * @param where where dependency was resolved (or NULL)
250 * @param rc 0 == YES, otherwise NO
252 /* FIX: rpmMessage annotation is a lie */
253 void rpmdsNotify(rpmds ds, const char * where, int rc);
256 * Return next dependency set iterator index.
257 * @param ds dependency set
258 * @return dependency set iterator index, -1 on termination
260 int rpmdsNext(rpmds ds);
263 * Initialize dependency set iterator.
264 * @param ds dependency set
265 * @return dependency set
267 rpmds rpmdsInit(rpmds ds);
270 * Find a dependency set element using binary search.
271 * @param ds dependency set to search
272 * @param ods dependency set element to find.
273 * @return dependency index (or -1 if not found)
275 int rpmdsFind(rpmds ds, const rpmds ods);
278 * Merge a dependency set maintaining (N,EVR,Flags) sorted order.
279 * @retval *dsp (merged) dependency set
280 * @param ods dependency set to merge
281 * @return (merged) dependency index
283 int rpmdsMerge(rpmds * dsp, rpmds ods);
286 * Search a sorted dependency set for an element that overlaps.
287 * A boolean result is saved (if allocated) and accessible through
288 * rpmdsResult(ods) afterwards.
289 * @param ds dependency set to search
290 * @param ods dependency set element to find.
291 * @return dependency index (or -1 if not found)
293 int rpmdsSearch(rpmds ds, rpmds ods);
296 * Compare two versioned dependency ranges, looking for overlap.
297 * @param A 1st dependency
298 * @param B 2nd dependency
299 * @return 1 if dependencies overlap, 0 otherwise
301 int rpmdsCompare(const rpmds A, const rpmds B);
304 * Compare package provides dependencies from header with a single dependency.
306 * @param req dependency set
307 * @param nopromote Don't promote Epoch: in comparison?
308 * @return 1 if any dependency overlaps, 0 otherwise
310 int rpmdsAnyMatchesDep (const Header h, const rpmds req, int nopromote);
313 * Compare package name-version-release from header with a single dependency.
315 * @param req dependency set
316 * @param nopromote Don't promote Epoch: in comparison?
317 * @return 1 if dependency overlaps, 0 otherwise
319 int rpmdsNVRMatchesDep(const Header h, const rpmds req, int nopromote);
322 * Load rpmlib provides into a dependency set.
323 * @retval *dsp (loaded) depedency set
324 * @param tblp rpmlib provides table (NULL uses internal table)
325 * @return 0 on success
327 int rpmdsRpmlib(rpmds * dsp, const void * tblp);