Use headerNVR throughout.
More const's. CVS patchset: 3216 CVS date: 1999/08/06 22:52:49
This commit is contained in:
parent
0343b15e55
commit
64c9a2d1cf
44
build/pack.c
44
build/pack.c
|
@ -16,24 +16,17 @@ static int addFileToArrayTag(Spec spec, char *file, Header h, int tag);
|
|||
static int cpio_gzip(FD_t fdo, CSA_t *csa);
|
||||
static int cpio_copy(FD_t fdo, CSA_t *csa);
|
||||
|
||||
static int genSourceRpmName(Spec spec)
|
||||
static inline int genSourceRpmName(Spec spec)
|
||||
{
|
||||
char *name, *version, *release;
|
||||
char fileName[BUFSIZ];
|
||||
if (spec->sourceRpmName == NULL) {
|
||||
const char *name, *version, *release;
|
||||
char fileName[BUFSIZ];
|
||||
|
||||
if (spec->sourceRpmName) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
headerGetEntry(spec->packages->header, RPMTAG_NAME,
|
||||
NULL, (void **)&name, NULL);
|
||||
headerGetEntry(spec->packages->header, RPMTAG_VERSION,
|
||||
NULL, (void **)&version, NULL);
|
||||
headerGetEntry(spec->packages->header, RPMTAG_RELEASE,
|
||||
NULL, (void **)&release, NULL);
|
||||
sprintf(fileName, "%s-%s-%s.%ssrc.rpm", name, version, release,
|
||||
headerNVR(spec->packages->header, &name, &version, &release);
|
||||
sprintf(fileName, "%s-%s-%s.%ssrc.rpm", name, version, release,
|
||||
spec->noSource ? "no" : "");
|
||||
spec->sourceRpmName = strdup(fileName);
|
||||
spec->sourceRpmName = strdup(fileName);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -217,14 +210,13 @@ int readRPM(const char *fileName, Spec *specp, struct rpmlead *lead, Header *sig
|
|||
return 0;
|
||||
}
|
||||
|
||||
int writeRPM(Header header, const char *fileName, int type,
|
||||
int writeRPM(Header h, const char *fileName, int type,
|
||||
CSA_t *csa, char *passPhrase, char **cookie)
|
||||
{
|
||||
FD_t fd, ifd;
|
||||
int rc, count, sigtype;
|
||||
int archnum, osnum;
|
||||
const char *sigtarget;
|
||||
char *name, *version, *release;
|
||||
char buf[BUFSIZ];
|
||||
Header sig;
|
||||
struct rpmlead lead;
|
||||
|
@ -232,7 +224,7 @@ int writeRPM(Header header, const char *fileName, int type,
|
|||
if (fdFileno(csa->cpioFdIn) < 0) {
|
||||
csa->cpioArchiveSize = 0;
|
||||
/* Add a bogus archive size to the Header */
|
||||
headerAddEntry(header, RPMTAG_ARCHIVESIZE, RPM_INT32_TYPE,
|
||||
headerAddEntry(h, RPMTAG_ARCHIVESIZE, RPM_INT32_TYPE,
|
||||
&csa->cpioArchiveSize, 1);
|
||||
}
|
||||
|
||||
|
@ -240,7 +232,7 @@ int writeRPM(Header header, const char *fileName, int type,
|
|||
if (cookie) {
|
||||
sprintf(buf, "%s %d", buildHost(), (int) time(NULL));
|
||||
*cookie = strdup(buf);
|
||||
headerAddEntry(header, RPMTAG_COOKIE, RPM_STRING_TYPE, *cookie, 1);
|
||||
headerAddEntry(h, RPMTAG_COOKIE, RPM_STRING_TYPE, *cookie, 1);
|
||||
}
|
||||
|
||||
/* Write the header */
|
||||
|
@ -248,7 +240,7 @@ int writeRPM(Header header, const char *fileName, int type,
|
|||
rpmError(RPMERR_CREATE, _("Unable to open temp file"));
|
||||
return RPMERR_CREATE;
|
||||
}
|
||||
headerWrite(fd, header, HEADER_MAGIC_YES);
|
||||
headerWrite(fd, h, HEADER_MAGIC_YES);
|
||||
|
||||
/* Write the archive and get the size */
|
||||
if (csa->cpioList != NULL) {
|
||||
|
@ -268,11 +260,11 @@ int writeRPM(Header header, const char *fileName, int type,
|
|||
|
||||
/* Now set the real archive size in the Header */
|
||||
if (fdFileno(csa->cpioFdIn) < 0) {
|
||||
headerModifyEntry(header, RPMTAG_ARCHIVESIZE,
|
||||
headerModifyEntry(h, RPMTAG_ARCHIVESIZE,
|
||||
RPM_INT32_TYPE, &csa->cpioArchiveSize, 1);
|
||||
}
|
||||
(void)fdLseek(fd, 0, SEEK_SET);
|
||||
headerWrite(fd, header, HEADER_MAGIC_YES);
|
||||
headerWrite(fd, h, HEADER_MAGIC_YES);
|
||||
|
||||
fdClose(fd);
|
||||
|
||||
|
@ -286,10 +278,10 @@ int writeRPM(Header header, const char *fileName, int type,
|
|||
}
|
||||
|
||||
/* Now write the lead */
|
||||
headerGetEntry(header, RPMTAG_NAME, NULL, (void **)&name, NULL);
|
||||
headerGetEntry(header, RPMTAG_VERSION, NULL, (void **)&version, NULL);
|
||||
headerGetEntry(header, RPMTAG_RELEASE, NULL, (void **)&release, NULL);
|
||||
sprintf(buf, "%s-%s-%s", name, version, release);
|
||||
{ const char *name, *version, *release;
|
||||
headerNVR(h, &name, &version, &release);
|
||||
sprintf(buf, "%s-%s-%s", name, version, release);
|
||||
}
|
||||
|
||||
if (fdFileno(csa->cpioFdIn) < 0) {
|
||||
rpmGetArchInfo(NULL, &archnum);
|
||||
|
|
|
@ -5,12 +5,15 @@
|
|||
#include "depends.h"
|
||||
#include "misc.h"
|
||||
|
||||
static int headerNVR(Header h, const char **np, const char **vp, const char **rp)
|
||||
int headerNVR(Header h, const char **np, const char **vp, const char **rp)
|
||||
{
|
||||
int type, count;
|
||||
headerGetEntry(h, RPMTAG_NAME, &type, (void **) np, &count);
|
||||
headerGetEntry(h, RPMTAG_VERSION, &type, (void **) vp, &count);
|
||||
headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) rp, &count);
|
||||
if (np && !headerGetEntry(h, RPMTAG_NAME, &type, (void **) np, &count))
|
||||
*np = NULL;
|
||||
if (vp && !headerGetEntry(h, RPMTAG_VERSION, &type, (void **) vp, &count))
|
||||
*vp = NULL;
|
||||
if (rp && !headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) rp, &count))
|
||||
*rp = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -54,8 +57,8 @@ static void alFree(struct availableList * al)
|
|||
if (al->list[i].relocs) {
|
||||
r = al->list[i].relocs;
|
||||
while (r->oldPath || r->newPath) {
|
||||
if (r->oldPath) free(r->oldPath);
|
||||
if (r->newPath) free(r->newPath);
|
||||
if (r->oldPath) xfree(r->oldPath);
|
||||
if (r->newPath) xfree(r->newPath);
|
||||
r++;
|
||||
}
|
||||
|
||||
|
@ -511,8 +514,7 @@ int headerMatchesDepFlags(Header h, const char *reqName, const char * reqInfo, i
|
|||
sprintf(buf, "%d", *epochval);
|
||||
epoch = buf;
|
||||
}
|
||||
headerGetEntry(h, RPMTAG_VERSION, &type, (void **)&version, &count);
|
||||
headerGetEntry(h, RPMTAG_RELEASE, &type, (void **)&release, &count);
|
||||
headerNVR(h, NULL, &version, &release);
|
||||
|
||||
/* Parse requires version into components */
|
||||
Revr = strdup(reqInfo);
|
||||
|
|
|
@ -636,7 +636,7 @@ int installBinaryPackage(const char * rootdir, rpmdb db, FD_t fd, Header h,
|
|||
struct sharedFileInfo * sharedList, FD_t scriptFd)
|
||||
{
|
||||
int rc;
|
||||
char * name, * version, * release;
|
||||
const char * name, * version, * release;
|
||||
int fileCount, type, count;
|
||||
struct fileInfo * files;
|
||||
int_32 installTime;
|
||||
|
@ -657,9 +657,7 @@ int installBinaryPackage(const char * rootdir, rpmdb db, FD_t fd, Header h,
|
|||
if (flags & RPMTRANS_FLAG_JUSTDB)
|
||||
flags |= RPMTRANS_FLAG_NOSCRIPTS;
|
||||
|
||||
headerGetEntry(h, RPMTAG_NAME, &type, (void **) &name, &fileCount);
|
||||
headerGetEntry(h, RPMTAG_VERSION, &type, (void **) &version, &fileCount);
|
||||
headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &fileCount);
|
||||
headerNVR(h, &name, &version, &release);
|
||||
|
||||
rpmMessage(RPMMESS_DEBUG, _("package: %s-%s-%s files test = %d\n"),
|
||||
name, version, release, flags & RPMTRANS_FLAG_TEST);
|
||||
|
|
56
lib/lookup.c
56
lib/lookup.c
|
@ -13,8 +13,7 @@ int findMatches(rpmdb db, const char * name, const char * version,
|
|||
int gotMatches;
|
||||
int rc;
|
||||
int i;
|
||||
char * pkgRelease, * pkgVersion;
|
||||
int count, type;
|
||||
const char * pkgRelease, * pkgVersion;
|
||||
int goodRelease, goodVersion;
|
||||
Header h;
|
||||
|
||||
|
@ -28,33 +27,30 @@ int findMatches(rpmdb db, const char * name, const char * version,
|
|||
|
||||
/* make sure the version and releases match */
|
||||
for (i = 0; i < matches->count; i++) {
|
||||
if (matches->recs[i].recOffset) {
|
||||
h = rpmdbGetRecord(db, matches->recs[i].recOffset);
|
||||
if (h == NULL) {
|
||||
rpmError(RPMERR_DBCORRUPT,
|
||||
_("cannot read header at %d for lookup"),
|
||||
matches->recs[i].recOffset);
|
||||
dbiFreeIndexRecord(*matches);
|
||||
return 2;
|
||||
}
|
||||
if (matches->recs[i].recOffset == 0)
|
||||
continue;
|
||||
|
||||
headerGetEntry(h, RPMTAG_VERSION, &type, (void **) &pkgVersion,
|
||||
&count);
|
||||
headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) &pkgRelease,
|
||||
&count);
|
||||
|
||||
goodRelease = goodVersion = 1;
|
||||
|
||||
if (release && strcmp(release, pkgRelease)) goodRelease = 0;
|
||||
if (version && strcmp(version, pkgVersion)) goodVersion = 0;
|
||||
|
||||
if (goodRelease && goodVersion)
|
||||
gotMatches = 1;
|
||||
else
|
||||
matches->recs[i].recOffset = 0;
|
||||
|
||||
headerFree(h);
|
||||
h = rpmdbGetRecord(db, matches->recs[i].recOffset);
|
||||
if (h == NULL) {
|
||||
rpmError(RPMERR_DBCORRUPT,_("cannot read header at %d for lookup"),
|
||||
matches->recs[i].recOffset);
|
||||
dbiFreeIndexRecord(*matches);
|
||||
return 2;
|
||||
}
|
||||
|
||||
headerNVR(h, NULL, &pkgVersion, &pkgRelease);
|
||||
|
||||
goodRelease = goodVersion = 1;
|
||||
|
||||
if (release && strcmp(release, pkgRelease)) goodRelease = 0;
|
||||
if (version && strcmp(version, pkgVersion)) goodVersion = 0;
|
||||
|
||||
if (goodRelease && goodVersion)
|
||||
gotMatches = 1;
|
||||
else
|
||||
matches->recs[i].recOffset = 0;
|
||||
|
||||
headerFree(h);
|
||||
}
|
||||
|
||||
if (!gotMatches) {
|
||||
|
@ -70,11 +66,9 @@ int findMatches(rpmdb db, const char * name, const char * version,
|
|||
/* 2 error */
|
||||
int rpmdbFindByHeader(rpmdb db, Header h, dbiIndexSet * matches)
|
||||
{
|
||||
char * name, * version, * release;
|
||||
const char * name, * version, * release;
|
||||
|
||||
headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &name, NULL);
|
||||
headerGetEntry(h, RPMTAG_VERSION, NULL, (void **) &version, NULL);
|
||||
headerGetEntry(h, RPMTAG_RELEASE, NULL, (void **) &release, NULL);
|
||||
headerNVR(h, &name, &version, &release);
|
||||
|
||||
return findMatches(db, name, version, release, matches);
|
||||
}
|
||||
|
|
|
@ -47,21 +47,14 @@ void printDepProblems(FILE * fp, struct rpmDependencyConflict * conflicts,
|
|||
|
||||
char * rpmProblemString(rpmProblem prob)
|
||||
{
|
||||
char * name, * version, * release;
|
||||
const char * name, * version, * release;
|
||||
const char * altName, * altVersion, * altRelease;
|
||||
char * buf;
|
||||
char * altName, * altVersion, * altRelease;
|
||||
|
||||
headerGetEntry(prob.h, RPMTAG_NAME, NULL, (void **) &name, NULL);
|
||||
headerGetEntry(prob.h, RPMTAG_VERSION, NULL, (void **) &version, NULL);
|
||||
headerGetEntry(prob.h, RPMTAG_RELEASE, NULL, (void **) &release, NULL);
|
||||
headerNVR(prob.h, &name, &version, &release);
|
||||
|
||||
if (prob.altH) {
|
||||
headerGetEntry(prob.altH, RPMTAG_NAME, NULL, (void **) &altName, NULL);
|
||||
headerGetEntry(prob.altH, RPMTAG_VERSION, NULL, (void **) &altVersion,
|
||||
NULL);
|
||||
headerGetEntry(prob.altH, RPMTAG_RELEASE, NULL, (void **) &altRelease,
|
||||
NULL);
|
||||
}
|
||||
if (prob.altH)
|
||||
headerNVR(prob.altH, &altName, &altVersion, &altRelease);
|
||||
|
||||
buf = malloc(strlen(name) + strlen(version) + strlen(release) + 400);
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ int showQueryPackage(QVA_t *qva, rpmdb db, Header h)
|
|||
int queryFlags = qva->qva_flags;
|
||||
const char *queryFormat = qva->qva_queryFormat;
|
||||
|
||||
char * name, * version, * release;
|
||||
const char * name, * version, * release;
|
||||
int_32 count, type;
|
||||
char * prefix = NULL;
|
||||
char ** fileList, ** fileMD5List;
|
||||
|
@ -165,9 +165,7 @@ int showQueryPackage(QVA_t *qva, rpmdb db, Header h)
|
|||
uint_16 * fileRdevList;
|
||||
int i;
|
||||
|
||||
headerGetEntry(h, RPMTAG_NAME, &type, (void **) &name, &count);
|
||||
headerGetEntry(h, RPMTAG_VERSION, &type, (void **) &version, &count);
|
||||
headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &count);
|
||||
headerNVR(h, &name, &version, &release);
|
||||
|
||||
if (!queryFormat && !queryFlags) {
|
||||
fprintf(fp, "%s-%s-%s\n", name, version, release);
|
||||
|
|
|
@ -262,7 +262,7 @@ int rpmInstall(const char * rootdir, const char ** argv, int transFlags,
|
|||
}
|
||||
|
||||
if (defaultReloc) {
|
||||
free(defaultReloc->oldPath);
|
||||
xfree(defaultReloc->oldPath);
|
||||
defaultReloc->oldPath = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,9 @@ extern "C" {
|
|||
int rpmReadPackageInfo(FD_t fd, Header * signatures, Header * hdr);
|
||||
int rpmReadPackageHeader(FD_t fd, Header * hdr, int * isSource, int * major,
|
||||
int * minor);
|
||||
|
||||
int headerNVR(Header h, const char **np, const char **vp, const char **rp);
|
||||
|
||||
/* 0 = success */
|
||||
/* 1 = bad magic */
|
||||
/* 2 = error */
|
||||
|
@ -321,9 +324,9 @@ int rpmdbFindByHeader(rpmdb db, Header h, dbiIndexSet * matches);
|
|||
|
||||
/* we pass these around as an array with a sentinel */
|
||||
typedef struct rpmRelocation_s {
|
||||
char * oldPath; /* NULL here evals to RPMTAG_DEFAULTPREFIX, this */
|
||||
/* odd behavior is only for backwards compatibility */
|
||||
char * newPath; /* NULL means to omit the file completely! */
|
||||
const char * oldPath; /* NULL here evals to RPMTAG_DEFAULTPREFIX, */
|
||||
/* XXX for backwards compatibility */
|
||||
const char * newPath; /* NULL means to omit the file completely! */
|
||||
} rpmRelocation;
|
||||
|
||||
int rpmInstallSourcePackage(const char * root, FD_t fd, const char ** specFile,
|
||||
|
|
|
@ -227,13 +227,12 @@ static Header relocateFileList(struct availablePackage * alp,
|
|||
int allowBadRelocate)
|
||||
{
|
||||
int numValid, numRelocations;
|
||||
int i, j, madeSwap, rc;
|
||||
int i, j, rc;
|
||||
rpmRelocation * nextReloc, * relocations = NULL;
|
||||
rpmRelocation * rawRelocations = alp->relocs;
|
||||
rpmRelocation tmpReloc;
|
||||
char ** validRelocations, ** actualRelocations;
|
||||
char ** names;
|
||||
char ** origNames;
|
||||
const char ** validRelocations;
|
||||
const char ** names;
|
||||
const char ** origNames;
|
||||
int len = 0;
|
||||
char * newName;
|
||||
int_32 fileCount;
|
||||
|
@ -261,16 +260,19 @@ static Header relocateFileList(struct availablePackage * alp,
|
|||
/* FIXME: default relocations (oldPath == NULL) need to be handled
|
||||
in the UI, not rpmlib */
|
||||
|
||||
relocations[i].oldPath =
|
||||
alloca(strlen(rawRelocations[i].oldPath) + 1);
|
||||
strcpy(relocations[i].oldPath, rawRelocations[i].oldPath);
|
||||
stripTrailingSlashes(relocations[i].oldPath);
|
||||
{ const char *s = rawRelocations[i].oldPath;
|
||||
char *t = alloca(strlen(s) + 1);
|
||||
strcpy(t, s);
|
||||
stripTrailingSlashes(t);
|
||||
relocations[i].oldPath = t;
|
||||
}
|
||||
|
||||
if (rawRelocations[i].newPath) {
|
||||
relocations[i].newPath =
|
||||
alloca(strlen(rawRelocations[i].newPath) + 1);
|
||||
strcpy(relocations[i].newPath, rawRelocations[i].newPath);
|
||||
stripTrailingSlashes(relocations[i].newPath);
|
||||
const char *s = rawRelocations[i].newPath;
|
||||
char *t = alloca(strlen(s) + 1);
|
||||
strcpy(t, s);
|
||||
stripTrailingSlashes(t);
|
||||
relocations[i].newPath = t;
|
||||
} else {
|
||||
relocations[i].newPath = NULL;
|
||||
}
|
||||
|
@ -287,8 +289,10 @@ static Header relocateFileList(struct availablePackage * alp,
|
|||
|
||||
/* stupid bubble sort, but it's probably faster here */
|
||||
for (i = 0; i < numRelocations; i++) {
|
||||
int madeSwap;
|
||||
madeSwap = 0;
|
||||
for (j = 1; j < numRelocations; j++) {
|
||||
rpmRelocation tmpReloc;
|
||||
if (strcmp(relocations[j - 1].oldPath,
|
||||
relocations[j].oldPath) > 0) {
|
||||
tmpReloc = relocations[j - 1];
|
||||
|
@ -301,6 +305,7 @@ static Header relocateFileList(struct availablePackage * alp,
|
|||
}
|
||||
|
||||
if (numValid) {
|
||||
const char ** actualRelocations;
|
||||
actualRelocations = malloc(sizeof(*actualRelocations) * numValid);
|
||||
for (i = 0; i < numValid; i++) {
|
||||
for (j = 0; j < numRelocations; j++) {
|
||||
|
@ -317,8 +322,8 @@ static Header relocateFileList(struct availablePackage * alp,
|
|||
headerAddEntry(h, RPMTAG_INSTPREFIXES, RPM_STRING_ARRAY_TYPE,
|
||||
(void **) actualRelocations, numValid);
|
||||
|
||||
free(actualRelocations);
|
||||
free(validRelocations);
|
||||
xfree(actualRelocations);
|
||||
xfree(validRelocations);
|
||||
}
|
||||
|
||||
headerGetEntry(h, RPMTAG_FILENAMES, NULL, (void **) &names,
|
||||
|
|
|
@ -70,13 +70,13 @@ int removeBinaryPackage(char * prefix, rpmdb db, unsigned int offset,
|
|||
Header h;
|
||||
int i;
|
||||
int fileCount;
|
||||
char * name, * version, * release;
|
||||
const char * name, * version, * release;
|
||||
char * fnbuffer = NULL;
|
||||
dbiIndexSet matches;
|
||||
int fnbuffersize = 0;
|
||||
int prefixLength = strlen(prefix);
|
||||
char ** fileList, ** fileMd5List;
|
||||
int type, count;
|
||||
int type;
|
||||
uint_32 * fileFlagsList;
|
||||
int_16 * fileModesList;
|
||||
int scriptArg;
|
||||
|
@ -91,9 +91,8 @@ int removeBinaryPackage(char * prefix, rpmdb db, unsigned int offset,
|
|||
return 1;
|
||||
}
|
||||
|
||||
headerGetEntry(h, RPMTAG_NAME, &type, (void **) &name, &count);
|
||||
headerGetEntry(h, RPMTAG_VERSION, &type, (void **) &version, &count);
|
||||
headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &count);
|
||||
headerNVR(h, &name, &version, &release);
|
||||
|
||||
/* when we run scripts, we pass an argument which is the number of
|
||||
versions of this package that will be installed when we are finished */
|
||||
if (rpmdbFindPackage(db, name, &matches)) {
|
||||
|
|
|
@ -306,7 +306,7 @@ static int verifyDependencies(rpmdb db, Header h) {
|
|||
struct rpmDependencyConflict * conflicts;
|
||||
int numConflicts;
|
||||
const char * name, * version, * release;
|
||||
int type, count, i;
|
||||
int i;
|
||||
|
||||
rpmdep = rpmtransCreateSet(db, NULL);
|
||||
rpmtransAddPackage(rpmdep, h, NULL, NULL, 0, NULL);
|
||||
|
@ -315,9 +315,7 @@ static int verifyDependencies(rpmdb db, Header h) {
|
|||
rpmtransFree(rpmdep);
|
||||
|
||||
if (numConflicts) {
|
||||
headerGetEntry(h, RPMTAG_NAME, &type, (void **) &name, &count);
|
||||
headerGetEntry(h, RPMTAG_VERSION, &type, (void **) &version, &count);
|
||||
headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) &release, &count);
|
||||
headerNVR(h, &name, &version, &release);
|
||||
fprintf(stdout, _("Unsatisfied dependencies for %s-%s-%s: "),
|
||||
name, version, release);
|
||||
for (i = 0; i < numConflicts; i++) {
|
||||
|
|
710
po/rpm.pot
710
po/rpm.pot
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue