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