diff options
author | jbj <devnull@localhost> | 2000-04-13 17:59:10 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2000-04-13 17:59:10 +0000 |
commit | a6fc8ecb52d57acc8a4c601d49b019a6ae9eac91 (patch) | |
tree | 26cc779dcbb550fbfef76fd8d2a6e48b4041a28a /lib | |
parent | 0c83ea489f9d5f36d3d2e1af06f77396a3f733cb (diff) | |
download | librpm-tizen-a6fc8ecb52d57acc8a4c601d49b019a6ae9eac91.tar.gz librpm-tizen-a6fc8ecb52d57acc8a4c601d49b019a6ae9eac91.tar.bz2 librpm-tizen-a6fc8ecb52d57acc8a4c601d49b019a6ae9eac91.zip |
add explcit "Provides: name = [epoch:]version-release" to headers.
CVS patchset: 3678
CVS date: 2000/04/13 17:59:10
Diffstat (limited to 'lib')
-rw-r--r-- | lib/depends.c | 11 | ||||
-rw-r--r-- | lib/misc.c | 68 | ||||
-rw-r--r-- | lib/misc.h | 2 | ||||
-rw-r--r-- | lib/package.c | 3 | ||||
-rw-r--r-- | lib/rebuilddb.c | 3 |
5 files changed, 87 insertions, 0 deletions
diff --git a/lib/depends.c b/lib/depends.c index c8275dffe..a09179943 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -307,7 +307,9 @@ static void alMakeIndex(struct availableList * al) if (ai->size) return; +#ifdef DYING ai->size = al->size; +#endif for (i = 0; i < al->size; i++) ai->size += al->list[i].providesCount; @@ -316,11 +318,13 @@ static void alMakeIndex(struct availableList * al) k = 0; for (i = 0; i < al->size; i++) { +#ifdef DYING ai->index[k].package = al->list + i; ai->index[k].entry = al->list[i].name; ai->index[k].entryLen = strlen(al->list[i].name); ai->index[k].type = IET_NAME; k++; +#endif for (j = 0; j < al->list[i].providesCount; j++) { ai->index[k].package = al->list + i; @@ -819,6 +823,7 @@ alFileSatisfiesDepend(struct availableList * al, rc = 0; switch (match->type) { case IET_NAME: +#ifdef DYING { const char *pEVR; char *t; int pFlags = RPMSENSE_EQUAL; @@ -835,6 +840,10 @@ alFileSatisfiesDepend(struct availableList * al, if (keyType && keyDepend && rc) rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by added package.\n"), keyType, keyDepend); } break; +#else + rpmError(RPMERR_INTERNAL, _("%s: %s satisfied by added package (shouldn't happen).\n"), keyType, keyDepend); + break; +#endif case IET_PROVIDES: for (i = 0; i < p->providesCount; i++) { const char *proEVR; @@ -933,6 +942,7 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep, goto exit; } +#ifdef DYING mi = rpmdbInitIterator(rpmdep->db, RPMDBI_NAME, keyName, 0); while ((h = rpmdbNextIterator(mi)) != NULL) { unsigned int recOffset = rpmdbGetIteratorOffset(mi); @@ -949,6 +959,7 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep, rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by db packages.\n"), keyType, keyDepend); goto exit; } +#endif /* * New features in rpm spec files add implicit dependencies on rpm diff --git a/lib/misc.c b/lib/misc.c index 344830f60..c054ae927 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -817,3 +817,71 @@ int rpmHeaderGetEntry(Header h, int_32 tag, int_32 *type, } /*@notreached@*/ } + +/* + * Up to rpm 3.0.4, packages implicitly provided their own name-version-release. + * Retrofit an explicit "Provides: name = epoch:version-release. + */ +void providePackageNVR(Header h) +{ + const char *name, *version, *release; + int_32 * epoch; + const char *pEVR; + char *p; + int pFlags = RPMSENSE_EQUAL; + const char ** provides = NULL; + const char ** providesEVR = NULL; + int_32 * provideFlags = NULL; + int providesCount; + int type; + int i; + int bingo = 1; + + /* Generate provides for this package name-version-release. */ + headerNVR(h, &name, &version, &release); + pEVR = p = alloca(21 + strlen(version) + 1 + strlen(release) + 1); + *p = '\0'; + if (headerGetEntry(h, RPMTAG_EPOCH, NULL, (void **) &epoch, NULL)) { + sprintf(p, "%d:", *epoch); + while (*p++) + ; + } + (void) stpcpy( stpcpy( stpcpy(p, version) , "-") , release); + + /* + * Rpm prior to 3.0.3 does not have versioned provides. + * If no provides version info is available, then just add. + */ + if (!headerGetEntry(h, RPMTAG_PROVIDEVERSION, &type, + (void **) &providesEVR, &providesCount)) + goto exit; + + headerGetEntry(h, RPMTAG_PROVIDEFLAGS, &type, + (void **) &provideFlags, &providesCount); + + if (!headerGetEntry(h, RPMTAG_PROVIDENAME, &type, + (void **) &provides, &providesCount)) { + goto exit; + } + + for (i = 0; i < providesCount; i++) { + if (!(provideFlags[i] == RPMSENSE_EQUAL && + !strcmp(name, provides[i]) && !strcmp(pEVR, providesEVR[i]))) + continue; + bingo = 0; + break; + } + +exit: + if (provides) xfree(provides); + if (providesEVR) xfree(providesEVR); + + if (bingo) { + headerAddOrAppendEntry(h, RPMTAG_PROVIDENAME, RPM_STRING_ARRAY_TYPE, + &name, 1); + headerAddOrAppendEntry(h, RPMTAG_PROVIDEVERSION, RPM_STRING_ARRAY_TYPE, + &pEVR, 1); + headerAddOrAppendEntry(h, RPMTAG_PROVIDEFLAGS, RPM_INT32_TYPE, + &pFlags, 1); + } +} diff --git a/lib/misc.h b/lib/misc.h index 30afc9c76..9a435c162 100644 --- a/lib/misc.h +++ b/lib/misc.h @@ -44,6 +44,8 @@ int myGlobPatternP (const char *patternURL); int rpmGlob(const char * patterns, /*@out@*/ int * argcPtr, /*@out@*/ const char *** argvPtr); +void providePackageNVR(Header h); + #ifdef __cplusplus } #endif diff --git a/lib/package.c b/lib/package.c index 53af5b77a..182924cf4 100644 --- a/lib/package.c +++ b/lib/package.c @@ -309,6 +309,9 @@ static int readPackageHeaders(FD_t fd, /*@out@*/struct rpmlead * leadPtr, if (!headerIsEntry(*hdr, RPMTAG_SOURCEPACKAGE)) headerAddEntry(*hdr, RPMTAG_SOURCEPACKAGE, RPM_INT32_TYPE, &true, 1); + } else { + /* Retrofit "Provide: name = EVR" for binary packages. */ + providePackageNVR(*hdr); } break; diff --git a/lib/rebuilddb.c b/lib/rebuilddb.c index a5653bc66..c26ada92f 100644 --- a/lib/rebuilddb.c +++ b/lib/rebuilddb.c @@ -135,6 +135,9 @@ fprintf(stderr, "*** rpmdbRebuild: filterdbdups %d preferdb %d\n", _filterDbDups continue; } + /* Retrofit "Provide: name = EVR" for binary packages. */ + providePackageNVR(h); + if (rpmdbAdd(newdb, h)) { rpmError(RPMERR_INTERNAL, _("cannot add record originally at %d"), _RECNUM); |