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
|
|
|
|
2004-10-10 02:23:00 +08:00
|
|
|
int addReqProv(/*@unused@*/ Spec spec, Header h, /*@unused@*/ rpmTag tagN,
|
|
|
|
const char * N, const char * EVR, rpmsenseFlags Flags,
|
2001-04-29 09:05:43 +08:00
|
|
|
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
|
|
|
|
2004-10-10 02:23:00 +08:00
|
|
|
if (Flags & RPMSENSE_PROVIDES) {
|
1999-07-23 01:48:31 +08:00
|
|
|
nametag = RPMTAG_PROVIDENAME;
|
|
|
|
versiontag = RPMTAG_PROVIDEVERSION;
|
|
|
|
flagtag = RPMTAG_PROVIDEFLAGS;
|
2004-10-10 02:23:00 +08:00
|
|
|
extra = Flags & RPMSENSE_FIND_PROVIDES;
|
|
|
|
} else if (Flags & 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;
|
2004-10-10 02:23:00 +08:00
|
|
|
} else if (Flags & RPMSENSE_CONFLICTS) {
|
1998-01-13 05:31:29 +08:00
|
|
|
nametag = RPMTAG_CONFLICTNAME;
|
|
|
|
versiontag = RPMTAG_CONFLICTVERSION;
|
|
|
|
flagtag = RPMTAG_CONFLICTFLAGS;
|
2004-10-10 02:23:00 +08:00
|
|
|
} else if (Flags & RPMSENSE_PREREQ) {
|
1998-01-13 05:31:29 +08:00
|
|
|
nametag = RPMTAG_REQUIRENAME;
|
|
|
|
versiontag = RPMTAG_REQUIREVERSION;
|
|
|
|
flagtag = RPMTAG_REQUIREFLAGS;
|
2004-10-10 02:23:00 +08:00
|
|
|
extra = Flags & _ALL_REQUIRES_MASK;
|
|
|
|
} else if (Flags & RPMSENSE_TRIGGER) {
|
1998-03-21 06:38:00 +08:00
|
|
|
nametag = RPMTAG_TRIGGERNAME;
|
|
|
|
versiontag = RPMTAG_TRIGGERVERSION;
|
|
|
|
flagtag = RPMTAG_TRIGGERFLAGS;
|
|
|
|
indextag = RPMTAG_TRIGGERINDEX;
|
2004-10-10 02:23:00 +08:00
|
|
|
extra = Flags & 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;
|
2004-10-10 02:23:00 +08:00
|
|
|
extra = Flags & _ALL_REQUIRES_MASK;
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
|
|
|
|
2004-10-10 02:23:00 +08:00
|
|
|
Flags = (Flags & RPMSENSE_SENSEMASK) | extra;
|
2000-07-06 04:39:15 +08:00
|
|
|
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@-branchstate@*/
|
2004-10-10 02:23:00 +08:00
|
|
|
if (EVR == NULL)
|
|
|
|
EVR = "";
|
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--;
|
2004-10-10 02:23:00 +08:00
|
|
|
if (strcmp(names[len], N))
|
1999-08-25 06:26:55 +08:00
|
|
|
continue;
|
|
|
|
if (flagtag && versions != NULL &&
|
2004-10-10 02:23:00 +08:00
|
|
|
(strcmp(versions[len], EVR) || flags[len] != Flags))
|
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. */
|
2004-10-10 02:23:00 +08:00
|
|
|
xx = headerAddOrAppendEntry(h, nametag, RPM_STRING_ARRAY_TYPE, &N, 1);
|
1998-01-13 05:31:29 +08:00
|
|
|
if (flagtag) {
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = headerAddOrAppendEntry(h, versiontag,
|
2004-10-10 02:23:00 +08:00
|
|
|
RPM_STRING_ARRAY_TYPE, &EVR, 1);
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = headerAddOrAppendEntry(h, flagtag,
|
2004-10-10 02:23:00 +08:00
|
|
|
RPM_INT32_TYPE, &Flags, 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 */
|
2004-10-10 02:23:00 +08:00
|
|
|
return addReqProv(NULL, h, RPMTAG_REQUIRENAME, reqname, featureEVR,
|
|
|
|
RPMSENSE_RPMLIB|(RPMSENSE_LESS|RPMSENSE_EQUAL), 0);
|
2000-07-11 10:12:49 +08:00
|
|
|
}
|
2002-06-24 03:47:08 +08:00
|
|
|
/*@=boundswrite@*/
|