This patch enables the creator to target more than one version using <=> operators in the Provides line. Resolves: rhbz#699745 --- loader/driverdisk.c | 4 ++-- loader/rpmextract.c | 47 +++++++++++++++++++++++++++++++++++++++++++---- loader/rpmextract.h | 4 ++-- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/loader/driverdisk.c b/loader/driverdisk.c index 4b77d03..d8a307c 100644 --- a/loader/driverdisk.c +++ b/loader/driverdisk.c @@ -68,7 +68,7 @@ extern uint64_t flags; * Provides: <dep> = <version> * we use it to check if kernel-modules = <kernelversion> */ -int dlabelProvides(const char* dep, const char* version, void *userptr) +int dlabelProvides(const char* dep, const char* version, uint32_t sense, void *userptr) { char *kernelver = (char*)userptr; @@ -77,7 +77,7 @@ int dlabelProvides(const char* dep, const char* version, void *userptr) if (version == NULL) return -1; - return strcmp(dep, "kernel-modules") || strcmp(version, kernelver); + return strcmp(dep, "kernel-modules") || matchVersions(kernelver, sense, version); } /* diff --git a/loader/rpmextract.c b/loader/rpmextract.c index fafe46e..fd5cc6b 100644 --- a/loader/rpmextract.c +++ b/loader/rpmextract.c @@ -85,6 +85,21 @@ const char * headerGetString(Header h, rpmTag tag) } /* + * + */ + +int matchVersions(const char *version, uint32_t sense, const char *senseversion) +{ + int r = rpmvercmp(version, senseversion); + + if(r<0 && !(sense & RPMSENSE_LESS) return 1; + else if(r==0 && !(sense & RPMSENSE_EQUAL) return 1; + else if(r>0 && !(sense & RPMSENSE_GREATER) return 1; + + return 0; +} + +/* * explode source RPM into the current directory * use filters to skip packages and files we do not need */ @@ -154,23 +169,34 @@ int explodeRPM(const char *source, while (deps) { struct rpmtd_s tddep; struct rpmtd_s tdver; + struct rpmtd_s tdsense; + const char *depname; const char *depversion; + uint32_t depsense; - if (!headerGet(h, RPMTAG_PROVIDES, &tddep, HEADERGET_MINMEM)) + if (!headerGet(h, RPMTAG_REQUIRES, &tddep, HEADERGET_MINMEM)) break; - if (!headerGet(h, RPMTAG_PROVIDEVERSION, &tdver, HEADERGET_MINMEM)){ + if (!headerGet(h, RPMTAG_REQUIREVERSION, &tdver, HEADERGET_MINMEM)){ + rpmtdFreeData(&tddep); + break; + } + + if (!headerGet(h, RPMTAG_REQUIREFLAGS, &tdsense, HEADERGET_MINMEM)){ rpmtdFreeData(&tddep); + rpmtdFreeData(&tdver); break; } /* iterator */ while ((depname = rpmtdNextString(&tddep))) { depversion = rpmtdNextString(&tdver); - if (deps(depname, depversion, userptr)) { + depsense = rpmtdNextUint32(&tdsense); + if (deps(depname, depversion, depsense, userptr)) { rpmtdFreeData(&tddep); rpmtdFreeData(&tdver); + rpmtdFreeData(&tdsense); Fclose(fdi); return EXIT_BADDEPS; } @@ -178,6 +204,7 @@ int explodeRPM(const char *source, rpmtdFreeData(&tddep); rpmtdFreeData(&tdver); + rpmtdFreeData(&tdsense); break; } @@ -186,8 +213,12 @@ int explodeRPM(const char *source, while (provides) { struct rpmtd_s tddep; struct rpmtd_s tdver; + struct rpmtd_s tdsense; + const char *depname; const char *depversion; + uint32_t depsense; + int found = 0; if (!headerGet(h, RPMTAG_PROVIDES, &tddep, HEADERGET_MINMEM)) @@ -198,16 +229,24 @@ int explodeRPM(const char *source, break; } + if (!headerGet(h, RPMTAG_PROVIDEFLAGS, &tdsense, HEADERGET_MINMEM)){ + rpmtdFreeData(&tddep); + rpmtdFreeData(&tdver); + break; + } + /* iterator */ while ((depname = rpmtdNextString(&tddep))) { depversion = rpmtdNextString(&tdver); - if (!provides(depname, depversion, userptr)) { + depsense = rpmtdNextUint32(&tdsense); + if (!provides(depname, depversion, depsense, userptr)) { found++; } } rpmtdFreeData(&tddep); rpmtdFreeData(&tdver); + rpmtdFreeData(&tdsense); if (found<=0){ Fclose(fdi); diff --git a/loader/rpmextract.h b/loader/rpmextract.h index 20a5cc8..bf5b65e 100644 --- a/loader/rpmextract.h +++ b/loader/rpmextract.h @@ -31,8 +31,8 @@ #define BUFFERSIZE 1024 /* both filter functions return 0 - match, 1 - match not found */ -typedef int (*filterfunc)(const char* name, const struct stat *fstat, void *userptr); -typedef int (*dependencyfunc)(const char* depname, const char* depversion, void *userptr); +typedef int (*filterfunc)(const char* name, const struct stat *fstat, const uint32_t sense, void *userptr); +typedef int (*dependencyfunc)(const char* depname, const char* depversion, const uint32_t sense, void *userptr); int explodeRPM(const char* file, filterfunc filter, -- 1.7.4.4 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list