2000-08-28 03:18:25 +08:00
|
|
|
/** \ingroup rpmbuild
|
|
|
|
* \file build/reqprov.c
|
2000-01-25 04:02:32 +08:00
|
|
|
* Add dependency tags to package header(s).
|
|
|
|
*/
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#include "system.h"
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1998-07-31 06:09:42 +08:00
|
|
|
#include "rpmbuild.h"
|
2000-12-13 04:03:45 +08:00
|
|
|
#include "debug.h"
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1999-10-05 03:40:03 +08:00
|
|
|
int addReqProv(/*@unused@*/ Spec spec, Header h,
|
2001-04-29 09:05:43 +08:00
|
|
|
rpmsenseFlags depFlags, const char *depName, const char *depEVR,
|
|
|
|
int index)
|
1996-06-08 02:32:10 +08:00
|
|
|
{
|
2001-04-29 09:05:43 +08:00
|
|
|
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
|
|
|
|
HFD_t hfd = headerFreeData;
|
|
|
|
const char ** names;
|
2001-06-12 12:10:21 +08:00
|
|
|
rpmTagType dnt;
|
|
|
|
rpmTag nametag = 0;
|
|
|
|
rpmTag versiontag = 0;
|
|
|
|
rpmTag flagtag = 0;
|
|
|
|
rpmTag indextag = 0;
|
1998-01-13 05:31:29 +08:00
|
|
|
int len;
|
2001-04-29 09:05:43 +08:00
|
|
|
rpmsenseFlags extra = RPMSENSE_ANY;
|
2001-10-16 22:58:57 +08:00
|
|
|
int xx;
|
1996-06-08 02:32:10 +08:00
|
|
|
|
2001-01-11 22:13:04 +08:00
|
|
|
if (depFlags & RPMSENSE_PROVIDES) {
|
1999-07-23 01:48:31 +08:00
|
|
|
nametag = RPMTAG_PROVIDENAME;
|
|
|
|
versiontag = RPMTAG_PROVIDEVERSION;
|
|
|
|
flagtag = RPMTAG_PROVIDEFLAGS;
|
2001-01-11 22:13:04 +08:00
|
|
|
extra = depFlags & RPMSENSE_FIND_PROVIDES;
|
|
|
|
} else if (depFlags & RPMSENSE_OBSOLETES) {
|
2000-07-10 07:10:25 +08:00
|
|
|
nametag = RPMTAG_OBSOLETENAME;
|
1999-08-21 05:05:18 +08:00
|
|
|
versiontag = RPMTAG_OBSOLETEVERSION;
|
|
|
|
flagtag = RPMTAG_OBSOLETEFLAGS;
|
2001-01-11 22:13:04 +08:00
|
|
|
} else if (depFlags & RPMSENSE_CONFLICTS) {
|
1998-01-13 05:31:29 +08:00
|
|
|
nametag = RPMTAG_CONFLICTNAME;
|
|
|
|
versiontag = RPMTAG_CONFLICTVERSION;
|
|
|
|
flagtag = RPMTAG_CONFLICTFLAGS;
|
2001-01-11 22:13:04 +08:00
|
|
|
} else if (depFlags & RPMSENSE_PREREQ) {
|
1998-01-13 05:31:29 +08:00
|
|
|
nametag = RPMTAG_REQUIRENAME;
|
|
|
|
versiontag = RPMTAG_REQUIREVERSION;
|
|
|
|
flagtag = RPMTAG_REQUIREFLAGS;
|
2001-01-11 22:13:04 +08:00
|
|
|
extra = depFlags & _ALL_REQUIRES_MASK;
|
|
|
|
} else if (depFlags & RPMSENSE_TRIGGER) {
|
1998-03-21 06:38:00 +08:00
|
|
|
nametag = RPMTAG_TRIGGERNAME;
|
|
|
|
versiontag = RPMTAG_TRIGGERVERSION;
|
|
|
|
flagtag = RPMTAG_TRIGGERFLAGS;
|
|
|
|
indextag = RPMTAG_TRIGGERINDEX;
|
2001-01-11 22:13:04 +08:00
|
|
|
extra = depFlags & RPMSENSE_TRIGGER;
|
1998-03-21 06:38:00 +08:00
|
|
|
} else {
|
1998-01-13 05:31:29 +08:00
|
|
|
nametag = RPMTAG_REQUIRENAME;
|
|
|
|
versiontag = RPMTAG_REQUIREVERSION;
|
|
|
|
flagtag = RPMTAG_REQUIREFLAGS;
|
2001-01-11 22:13:04 +08:00
|
|
|
extra = depFlags & _ALL_REQUIRES_MASK;
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
|
|
|
|
2002-12-31 10:12:02 +08:00
|
|
|
depFlags = (depFlags & RPMSENSE_SENSEMASK) | extra;
|
2000-07-06 04:39:15 +08:00
|
|
|
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@-branchstate@*/
|
2001-01-11 22:13:04 +08:00
|
|
|
if (depEVR == NULL)
|
|
|
|
depEVR = "";
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@=branchstate@*/
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1999-08-25 06:26:55 +08:00
|
|
|
/* Check for duplicate dependencies. */
|
2001-04-29 09:05:43 +08:00
|
|
|
if (hge(h, nametag, &dnt, (void **) &names, &len)) {
|
|
|
|
const char ** versions = NULL;
|
2001-06-12 12:10:21 +08:00
|
|
|
rpmTagType dvt = RPM_STRING_ARRAY_TYPE;
|
1999-08-25 06:26:55 +08:00
|
|
|
int *flags = NULL;
|
|
|
|
int *indexes = NULL;
|
1999-08-25 07:27:48 +08:00
|
|
|
int duplicate = 0;
|
1999-08-25 06:26:55 +08:00
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
if (flagtag) {
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = hge(h, versiontag, &dvt, (void **) &versions, NULL);
|
|
|
|
xx = hge(h, flagtag, NULL, (void **) &flags, NULL);
|
1996-08-15 05:02:54 +08:00
|
|
|
}
|
2000-07-10 07:10:25 +08:00
|
|
|
if (indextag)
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = hge(h, indextag, NULL, (void **) &indexes, NULL);
|
2000-07-10 07:10:25 +08:00
|
|
|
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@-boundsread@*/
|
1999-08-25 06:26:55 +08:00
|
|
|
while (len > 0) {
|
1998-01-13 05:31:29 +08:00
|
|
|
len--;
|
2001-01-11 22:13:04 +08:00
|
|
|
if (strcmp(names[len], depName))
|
1999-08-25 06:26:55 +08:00
|
|
|
continue;
|
|
|
|
if (flagtag && versions != NULL &&
|
2002-12-31 10:12:02 +08:00
|
|
|
(strcmp(versions[len], depEVR) || flags[len] != depFlags))
|
1999-08-25 06:26:55 +08:00
|
|
|
continue;
|
|
|
|
if (indextag && indexes != NULL && indexes[len] != index)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* This is a duplicate dependency. */
|
1999-08-25 07:27:48 +08:00
|
|
|
duplicate = 1;
|
2000-07-06 04:39:15 +08:00
|
|
|
|
1999-08-25 06:26:55 +08:00
|
|
|
break;
|
1996-08-15 05:02:54 +08:00
|
|
|
}
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@=boundsread@*/
|
2001-04-29 09:05:43 +08:00
|
|
|
names = hfd(names, dnt);
|
|
|
|
versions = hfd(versions, dvt);
|
1999-08-25 07:27:48 +08:00
|
|
|
if (duplicate)
|
1999-08-25 06:26:55 +08:00
|
|
|
return 0;
|
1996-08-15 05:02:54 +08:00
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1999-08-25 06:26:55 +08:00
|
|
|
/* Add this dependency. */
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = headerAddOrAppendEntry(h, nametag, RPM_STRING_ARRAY_TYPE, &depName, 1);
|
1998-01-13 05:31:29 +08:00
|
|
|
if (flagtag) {
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = headerAddOrAppendEntry(h, versiontag,
|
2001-01-11 22:13:04 +08:00
|
|
|
RPM_STRING_ARRAY_TYPE, &depEVR, 1);
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = headerAddOrAppendEntry(h, flagtag,
|
2001-01-11 22:13:04 +08:00
|
|
|
RPM_INT32_TYPE, &depFlags, 1);
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
2000-07-10 07:10:25 +08:00
|
|
|
if (indextag)
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = headerAddOrAppendEntry(h, indextag, RPM_INT32_TYPE, &index, 1);
|
1996-08-15 05:02:54 +08:00
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
return 0;
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
2000-07-11 10:12:49 +08:00
|
|
|
|
2002-06-24 03:47:08 +08:00
|
|
|
/*@-boundswrite@*/
|
2000-07-11 10:12:49 +08:00
|
|
|
int rpmlibNeedsFeature(Header h, const char * feature, const char * featureEVR)
|
|
|
|
{
|
|
|
|
char * reqname = alloca(sizeof("rpmlib()") + strlen(feature));
|
|
|
|
|
|
|
|
(void) stpcpy( stpcpy( stpcpy(reqname, "rpmlib("), feature), ")");
|
|
|
|
|
|
|
|
/* XXX 1st arg is unused */
|
2000-11-12 19:11:49 +08:00
|
|
|
return addReqProv(NULL, h, RPMSENSE_RPMLIB|(RPMSENSE_LESS|RPMSENSE_EQUAL),
|
2000-07-11 10:12:49 +08:00
|
|
|
reqname, featureEVR, 0);
|
|
|
|
}
|
2002-06-24 03:47:08 +08:00
|
|
|
/*@=boundswrite@*/
|