1996-06-08 02:32:10 +08:00
|
|
|
/* reqprov.c -- require/provide handling */
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#include "system.h"
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1998-09-28 06:03:52 +08:00
|
|
|
#include "intl.h"
|
1998-07-31 06:09:42 +08:00
|
|
|
#include "rpmbuild.h"
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1998-03-21 06:38:00 +08:00
|
|
|
int addReqProv(Spec spec, Package pkg,
|
|
|
|
int flag, char *name, char *version, int index)
|
1996-06-08 02:32:10 +08:00
|
|
|
{
|
1998-01-13 05:31:29 +08:00
|
|
|
char **names;
|
|
|
|
char **versions = NULL;
|
|
|
|
int *flags = NULL;
|
1998-03-21 06:38:00 +08:00
|
|
|
int *indexes = NULL;
|
1998-01-13 05:31:29 +08:00
|
|
|
int nametag = 0;
|
|
|
|
int versiontag = 0;
|
|
|
|
int flagtag = 0;
|
1998-03-21 06:38:00 +08:00
|
|
|
int indextag = 0;
|
1998-01-13 05:31:29 +08:00
|
|
|
int len;
|
|
|
|
int extra = 0;
|
1996-06-08 02:32:10 +08:00
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
if (flag & RPMSENSE_PROVIDES) {
|
|
|
|
nametag = RPMTAG_PROVIDES;
|
|
|
|
} else if (flag & RPMSENSE_OBSOLETES) {
|
|
|
|
nametag = RPMTAG_OBSOLETES;
|
|
|
|
} else if (flag & RPMSENSE_CONFLICTS) {
|
|
|
|
nametag = RPMTAG_CONFLICTNAME;
|
|
|
|
versiontag = RPMTAG_CONFLICTVERSION;
|
|
|
|
flagtag = RPMTAG_CONFLICTFLAGS;
|
|
|
|
} else if (flag & RPMSENSE_PREREQ) {
|
|
|
|
nametag = RPMTAG_REQUIRENAME;
|
|
|
|
versiontag = RPMTAG_REQUIREVERSION;
|
|
|
|
flagtag = RPMTAG_REQUIREFLAGS;
|
|
|
|
extra = RPMSENSE_PREREQ;
|
1998-03-21 06:38:00 +08:00
|
|
|
} else if (flag & RPMSENSE_TRIGGER) {
|
|
|
|
nametag = RPMTAG_TRIGGERNAME;
|
|
|
|
versiontag = RPMTAG_TRIGGERVERSION;
|
|
|
|
flagtag = RPMTAG_TRIGGERFLAGS;
|
|
|
|
indextag = RPMTAG_TRIGGERINDEX;
|
|
|
|
extra = flag & RPMSENSE_TRIGGER;
|
|
|
|
} else {
|
1998-01-13 05:31:29 +08:00
|
|
|
nametag = RPMTAG_REQUIRENAME;
|
|
|
|
versiontag = RPMTAG_REQUIREVERSION;
|
|
|
|
flagtag = RPMTAG_REQUIREFLAGS;
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
flag = (flag & RPMSENSE_SENSEMASK) | extra;
|
|
|
|
if (!version) {
|
|
|
|
version = "";
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
if (headerGetEntry(pkg->header, nametag, NULL, (void *) &names, &len)) {
|
|
|
|
if (flagtag) {
|
|
|
|
headerGetEntry(pkg->header, versiontag, NULL,
|
|
|
|
(void *) &versions, NULL);
|
|
|
|
headerGetEntry(pkg->header, flagtag, NULL, (void *) &flags, NULL);
|
1996-08-15 05:02:54 +08:00
|
|
|
}
|
1998-03-21 06:38:00 +08:00
|
|
|
if (indextag) {
|
|
|
|
headerGetEntry(pkg->header, indextag, NULL,
|
|
|
|
(void *) &indexes, NULL);
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
while (len) {
|
|
|
|
len--;
|
|
|
|
if (!strcmp(names[len], name)) {
|
|
|
|
if (!flagtag ||
|
|
|
|
(!strcmp(versions[len], version) && flags[len] == flag)) {
|
1998-03-21 06:38:00 +08:00
|
|
|
if (!indextag || (index == indexes[len])) {
|
|
|
|
/* The same */
|
|
|
|
FREE(names);
|
|
|
|
FREE(versions);
|
|
|
|
return 0;
|
|
|
|
}
|
1996-08-15 05:02:54 +08:00
|
|
|
}
|
1996-07-21 07:00:33 +08:00
|
|
|
}
|
1996-08-15 05:02:54 +08:00
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
FREE(names);
|
|
|
|
FREE(versions);
|
1996-08-15 05:02:54 +08:00
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
|
|
headerAddOrAppendEntry(pkg->header, nametag,
|
|
|
|
RPM_STRING_ARRAY_TYPE, &name, 1);
|
|
|
|
if (flagtag) {
|
|
|
|
headerAddOrAppendEntry(pkg->header, versiontag,
|
|
|
|
RPM_STRING_ARRAY_TYPE, &version, 1);
|
|
|
|
headerAddOrAppendEntry(pkg->header, flagtag,
|
|
|
|
RPM_INT32_TYPE, &flag, 1);
|
1996-06-08 02:32:10 +08:00
|
|
|
}
|
1998-03-21 06:38:00 +08:00
|
|
|
if (indextag) {
|
|
|
|
headerAddOrAppendEntry(pkg->header, 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
|
|
|
}
|