summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-08-20 13:02:05 +0300
committerPanu Matilainen <pmatilai@redhat.com>2009-08-20 13:02:05 +0300
commit10772ac7dfad60cb5a20681d22cf851468d0a8f9 (patch)
tree3600efe4eb1b9b1732d2ca769dcf9bee810466f8 /build
parent634a67d055444593a47a21e9e9ea00df65e63d63 (diff)
downloadlibrpm-tizen-10772ac7dfad60cb5a20681d22cf851468d0a8f9.tar.gz
librpm-tizen-10772ac7dfad60cb5a20681d22cf851468d0a8f9.tar.bz2
librpm-tizen-10772ac7dfad60cb5a20681d22cf851468d0a8f9.zip
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
Diffstat (limited to 'build')
-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;
}