summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-08-20 13:02:05 +0300
committerPanu Matilainen <pmatilai@redhat.com>2009-11-25 08:38:27 +0200
commit6e90bd42a577d425add4638afc9e49d05fc4e8b2 (patch)
tree9489a2d7b0dcbbc5ee20225ca5c7cf5718d339e1
parent8b44cc445f944c4bfacfba2efd0ec65f99370d3c (diff)
downloadrpm-6e90bd42a577d425add4638afc9e49d05fc4e8b2.tar.gz
Fix duplicate dependency checking on build
- Broken by commit af8b41c64af39ce07d85fcd92fa78d566747d815 which simplified too much. - There's no guarantee that rpmdsNew() returns a sorted dependency set so rpmdsFind() doesn't work correctly here. Walk the ds manually instead. - With multiple triggers of same type, identical trigger conditions on different trigger script were seen as duplicates (RhBug:490378) - Split the duplicate checking to separate helper function for clarity (cherry picked from commit 10772ac7dfad60cb5a20681d22cf851468d0a8f9)
-rw-r--r--build/reqprov.c62
1 files changed, 42 insertions, 20 deletions
diff --git a/build/reqprov.c b/build/reqprov.c
index 1e69bd218..ba6a1e8c3 100644
--- a/build/reqprov.c
+++ b/build/reqprov.c
@@ -9,6 +9,38 @@
#include <rpm/rpmbuild.h>
#include "debug.h"
+static int isNewDep(Header h, rpmTag nametag,
+ const char *N, const char *EVR, rpmsenseFlags Flags,
+ rpmTag indextag, uint32_t index)
+{
+ int new = 1;
+ struct rpmtd_s idx;
+ rpmds ads = rpmdsNew(h, nametag, 0);
+ rpmds bds = rpmdsSingle(nametag, N, EVR, Flags);
+
+ if (indextag) {
+ headerGet(h, indextag, &idx, HEADERGET_MINMEM);
+ }
+
+ /* XXX there's no guarantee the ds is sorted here so rpmdsFind() wont do */
+ rpmdsInit(ads);
+ while (new && rpmdsNext(ads) >= 0) {
+ if (strcmp(rpmdsN(ads), rpmdsN(bds))) continue;
+ if (strcmp(rpmdsEVR(ads), rpmdsEVR(bds))) continue;
+ if (rpmdsFlags(ads) != rpmdsFlags(bds)) continue;
+ if (indextag && rpmtdSetIndex(&idx, rpmdsIx(ads)) >= 0 &&
+ rpmtdGetNumber(&idx) != index) continue;
+ new = 0;
+ }
+
+ if (indextag) {
+ rpmtdFreeData(&idx);
+ }
+ rpmdsFree(ads);
+ rpmdsFree(bds);
+ return new;
+}
+
int addReqProv(rpmSpec spec, Header h, rpmTag tagN,
const char * N, const char * EVR, rpmsenseFlags Flags,
uint32_t index)
@@ -55,28 +87,18 @@ int addReqProv(rpmSpec spec, Header h, rpmTag tagN,
if (EVR == NULL)
EVR = "";
- /* Check for duplicate dependencies. */
- rpmds hds = rpmdsNew(h, nametag, 0);
- rpmds newds = rpmdsSingle(nametag, N, EVR, Flags);
- /* already got it, don't bother */
- if (rpmdsFind(hds, newds) >= 0) {
- goto exit;
- }
-
- /* Add this dependency. */
- headerPutString(h, nametag, N);
- if (flagtag) {
- headerPutString(h, versiontag, EVR);
- headerPutUint32(h, flagtag, &Flags, 1);
- }
- if (indextag) {
- headerPutUint32(h, indextag, &index, 1);
+ /* Avoid adding duplicate dependencies. */
+ if (isNewDep(h, nametag, N, EVR, Flags, indextag, index)) {
+ headerPutString(h, nametag, N);
+ if (flagtag) {
+ headerPutString(h, versiontag, EVR);
+ headerPutUint32(h, flagtag, &Flags, 1);
+ }
+ if (indextag) {
+ headerPutUint32(h, indextag, &index, 1);
+ }
}
-exit:
- rpmdsFree(hds);
- rpmdsFree(newds);
-
return 0;
}