/
reqprov.c
68 lines (53 loc) · 1.7 KB
/
reqprov.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/** \ingroup rpmbuild
* \file build/reqprov.c
* Add dependency tags to package header(s).
*/
#include "system.h"
#include <rpm/header.h>
#include <rpm/rpmstring.h>
#include <rpm/rpmlog.h>
#include "rpmbuild_internal.h"
#include "debug.h"
int addReqProv(Package pkg, rpmTagVal tagN,
const char * N, const char * EVR, rpmsenseFlags Flags,
uint32_t index)
{
rpmds newds, *dsp = NULL;
dsp = packageDependencies(pkg, tagN);
/* rpmlib() dependency sanity:
* - Provides are permitted only for source packages
* - Otherwise only requires
* - Ensure sense bit
*/
if (rstreqn(N, "rpmlib(", sizeof("rpmlib(")-1)) {
if (tagN != RPMTAG_REQUIRENAME &&
(tagN == RPMTAG_PROVIDENAME && !(Flags & RPMSENSE_RPMLIB)))
return 1;
Flags |= RPMSENSE_RPMLIB;
}
newds = rpmdsSinglePoolTix(pkg->pool, tagN, N, EVR,
rpmSanitizeDSFlags(tagN, Flags), index);
rpmdsMerge(dsp, newds);
rpmdsFree(newds);
return 0;
}
rpmRC addReqProvPkg(void *cbdata, rpmTagVal tagN,
const char * N, const char *EVR, rpmsenseFlags Flags,
int index)
{
Package pkg = (Package)cbdata;
return addReqProv(pkg, tagN, N, EVR, Flags, index) ? RPMRC_FAIL : RPMRC_OK;
}
int rpmlibNeedsFeature(Package pkg, const char * feature, const char * featureEVR)
{
char *reqname = NULL;
int flags = RPMSENSE_RPMLIB|RPMSENSE_LESS|RPMSENSE_EQUAL;
int res;
/* XXX HACK: avoid changing rpmlibNeedsFeature() for just one user */
if (rstreq(feature, "DynamicBuildRequires"))
flags |= RPMSENSE_MISSINGOK;
rasprintf(&reqname, "rpmlib(%s)", feature);
res = addReqProv(pkg, RPMTAG_REQUIRENAME, reqname, featureEVR, flags, 0);
free(reqname);
return res;
}