diff options
author | jbj <devnull@localhost> | 2001-06-12 04:10:21 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2001-06-12 04:10:21 +0000 |
commit | 1b87bd9ef75810794edede55d94c25c5d1e94d41 (patch) | |
tree | 64ad442a900ff06b72085c92ac2ccc2507f3e176 /build | |
parent | 03f527390168680d98f13ada0dbf6be4cd17dc9c (diff) | |
download | librpm-tizen-1b87bd9ef75810794edede55d94c25c5d1e94d41.tar.gz librpm-tizen-1b87bd9ef75810794edede55d94c25c5d1e94d41.tar.bz2 librpm-tizen-1b87bd9ef75810794edede55d94c25c5d1e94d41.zip |
- remove dead code frpm popt table reorg.
- more CLI typedefs/prototypes moved from rpmlib.h to rpmcli.h.
- rpm --verify skips files in non-installed states.
- rpm --verify skips content checks for %ghost files.
- rpm --verify displays config/doc/gnost/license/readme atrrs for files.
- rpm --verify checks immutable header region digest if available.
- rpmbuild adds header region digest (SHA1 as string).
- use rpmTag* typedefs in new hge/hae/hme/hre header vectors.
CVS patchset: 4854
CVS date: 2001/06/12 04:10:21
Diffstat (limited to 'build')
-rw-r--r-- | build/files.c | 14 | ||||
-rw-r--r-- | build/pack.c | 79 | ||||
-rw-r--r-- | build/parsePreamble.c | 56 | ||||
-rw-r--r-- | build/reqprov.c | 12 |
4 files changed, 96 insertions, 65 deletions
diff --git a/build/files.c b/build/files.c index 466359104..a5cea7f12 100644 --- a/build/files.c +++ b/build/files.c @@ -249,9 +249,9 @@ static void timeCheck(int tc, Header h) /*@modifies internalState @*/ { HGE_t hge = (HGE_t)headerGetEntryMinMemory; HFD_t hfd = headerFreeData; - int *mtime; + int * mtime; const char ** files; - int fnt; + rpmTagType fnt; int count, x; time_t currentTime = time(NULL); @@ -2119,9 +2119,9 @@ top: typedef struct { /*@observer@*/ /*@null@*/ const char * msg; /*@observer@*/ const char * argv[4]; - int ntag; - int vtag; - int ftag; + rpmTag ntag; + rpmTag vtag; + rpmTag ftag; int mask; int xor; } DepMsg_t; @@ -2339,9 +2339,9 @@ static void printDeps(Header h) HGE_t hge = (HGE_t)headerGetEntryMinMemory; HFD_t hfd = headerFreeData; const char ** names = NULL; - int dnt = -1; + rpmTagType dnt = -1; const char ** versions = NULL; - int dvt = -1; + rpmTagType dvt = -1; int * flags = NULL; DepMsg_t * dm; int count; diff --git a/build/pack.c b/build/pack.c index b15f9d6b6..cb14e398e 100644 --- a/build/pack.c +++ b/build/pack.c @@ -255,14 +255,18 @@ static int processScriptFiles(Spec spec, Package pkg) return 0; } -int readRPM(const char *fileName, Spec *specp, struct rpmlead *lead, Header *sigs, - CSA_t csa) +int readRPM(const char *fileName, Spec *specp, struct rpmlead *lead, + Header *sigs, CSA_t csa) { FD_t fdi; Spec spec; rpmRC rc; + int ec; + + fdi = (fileName != NULL) + ? Fopen(fileName, "r.ufdio") + : fdDup(STDIN_FILENO); - fdi = (fileName != NULL) ? Fopen(fileName, "r.ufdio") : fdDup(STDIN_FILENO); if (fdi == NULL || Ferror(fdi)) { rpmError(RPMERR_BADMAGIC, _("readRPM: open %s: %s\n"), (fileName ? fileName : "<stdin>"), @@ -279,7 +283,12 @@ int readRPM(const char *fileName, Spec *specp, struct rpmlead *lead, Header *sig return RPMERR_BADMAGIC; } - (void)Fseek(fdi, 0, SEEK_SET); /* XXX FIXME: EPIPE */ + /* XXX FIXME: EPIPE on <stdin> */ + if (Fseek(fdi, 0, SEEK_SET) == -1) { + rpmError(RPMERR_FSEEK, _("%s: Fseek failed: %s\n"), + (fileName ? fileName : "<stdin>"), Fstrerror(fdi)); + return RPMERR_FSEEK; + } /* Reallocate build data structures */ spec = newSpec(); @@ -288,7 +297,7 @@ int readRPM(const char *fileName, Spec *specp, struct rpmlead *lead, Header *sig /* XXX the header just allocated will be allocated again */ spec->packages->header = headerFree(spec->packages->header); - /* Read the rpm lead and header */ + /* Read the rpm lead, signatures, and header */ rc = rpmReadPackageInfo(fdi, sigs, &spec->packages->header); switch (rc) { case RPMRC_BADMAGIC: @@ -320,19 +329,28 @@ int readRPM(const char *fileName, Spec *specp, struct rpmlead *lead, Header *sig return 0; } +static unsigned char header_magic[8] = { + 0x8e, 0xad, 0xe8, 0x01, 0x00, 0x00, 0x00, 0x00 +}; + int writeRPM(Header *hdrp, const char *fileName, int type, CSA_t csa, char *passPhrase, const char **cookie) { FD_t fd = NULL; FD_t ifd = NULL; int rc, count, sigtype; - const char *sigtarget; + const char * sigtarget; const char * rpmio_flags = NULL; + const char * sha1 = NULL; char *s; char buf[BUFSIZ]; - Header h = *hdrp; + Header h; Header sig = NULL; + /* Transfer header reference form *hdrp to h. */ + h = headerLink(*hdrp); + *hdrp = headerFree(*hdrp); + if (Fileno(csa->cpioFdIn) < 0) { csa->cpioArchiveSize = 0; /* Add a bogus archive size to the Header */ @@ -340,18 +358,6 @@ int writeRPM(Header *hdrp, const char *fileName, int type, &csa->cpioArchiveSize, 1); } -#ifdef DYING - /* Choose how filenames are represented. */ - if (_noDirTokens) - expandFilelist(h); - else { - compressFilelist(h); - /* Binary packages with dirNames cannot be installed by legacy rpm. */ - if (type == RPMLEAD_BINARY) - rpmlibNeedsFeature(h, "CompressedFileNames", "3.0.4-1"); - } -#endif - /* Binary packages now have explicit Provides: name = version-release. */ if (type == RPMLEAD_BINARY) providePackageNVR(h); @@ -394,21 +400,21 @@ int writeRPM(Header *hdrp, const char *fileName, int type, } /* Reallocate the header into one contiguous region. */ - /*@-refcounttrans -usereleased@*/ - *hdrp = h = headerReload(h, RPMTAG_HEADERIMMUTABLE); + h = headerReload(h, RPMTAG_HEADERIMMUTABLE); if (h == NULL) { /* XXX can't happen */ rc = RPMERR_RELOAD; goto exit; } - /*@=refcounttrans =usereleased@*/ + /* Re-reference reallocated header. */ + *hdrp = headerLink(h); /* * Write the header+archive into a temp file so that the size of * archive (after compression) can be added to the header. */ if (makeTempFile(NULL, &sigtarget, &fd)) { - rpmError(RPMERR_CREATE, _("Unable to open temp file.\n")); rc = RPMERR_CREATE; + rpmError(RPMERR_CREATE, _("Unable to open temp file.\n")); goto exit; } @@ -434,8 +440,10 @@ int writeRPM(Header *hdrp, const char *fileName, int type, * This used to be done using headerModifyEntry(), but now that headers * have regions, the value is scribbled directly into the header data * area. Some new scheme for adding the final archive size will have - * to be devised if headerGetEntry() ever changes to return a pointer - * to memory not in the region. <shrug> + * to be devised if headerGetEntryMinMemory() ever changes to return + * a pointer to memory not in the region, probably by appending + * the archive size to the header region rather than including the + * archive size within the header region. */ if (Fileno(csa->cpioFdIn) < 0) { HGE_t hge = (HGE_t)headerGetEntryMinMemory; @@ -444,10 +452,18 @@ int writeRPM(Header *hdrp, const char *fileName, int type, *archiveSize = csa->cpioArchiveSize; } - (void)Fseek(fd, 0, SEEK_SET); + (void) Fflush(fd); + if (Fseek(fd, sizeof(header_magic), SEEK_SET) == -1) { + rc = RPMERR_FSEEK; + rpmError(RPMERR_FSEEK, _("%s: Fseek failed: %s\n"), + sigtarget, Fstrerror(fd)); + } - if (headerWrite(fd, h, HEADER_MAGIC_YES)) + fdInitSHA1(fd); + if (headerWrite(fd, h, HEADER_MAGIC_NO)) rc = RPMERR_NOSPACE; + (void) Fflush(fd); + fdFiniSHA1(fd, (void **)&sha1, NULL, 1); (void) Fclose(fd); fd = NULL; @@ -465,6 +481,11 @@ int writeRPM(Header *hdrp, const char *fileName, int type, rpmMessage(RPMMESS_NORMAL, _("Generating signature: %d\n"), sigtype); (void) rpmAddSignature(sig, sigtarget, sigtype, passPhrase); } + + if (sha1) { + (void) headerAddEntry(sig, RPMTAG_SHA1HEADER, RPM_STRING_TYPE, sha1, 1); + sha1 = _free(sha1); + } /* Reallocate the signature into one contiguous region. */ sig = headerReload(sig, RPMTAG_HEADERSIGNATURES); @@ -577,6 +598,8 @@ int writeRPM(Header *hdrp, const char *fileName, int type, rc = 0; exit: + sha1 = _free(sha1); + h = headerFree(h); sig = rpmFreeSignature(sig); if (ifd) { (void) Fclose(ifd); @@ -596,9 +619,7 @@ exit: else (void) Unlink(fileName); - /*@-nullstate@*/ /* FIX: *hdrp may be NULL */ return rc; - /*@=nullstate@*/ } static int_32 copyTags[] = { diff --git a/build/parsePreamble.c b/build/parsePreamble.c index a11e5ce71..efb5a4f58 100644 --- a/build/parsePreamble.c +++ b/build/parsePreamble.c @@ -13,7 +13,7 @@ /** */ -/*@observer@*/ static int_32 copyTagsDuringParse[] = { +/*@observer@*/ static rpmTag copyTagsDuringParse[] = { RPMTAG_EPOCH, RPMTAG_VERSION, RPMTAG_RELEASE, @@ -33,7 +33,7 @@ /** */ -/*@observer@*/ static int requiredTags[] = { +/*@observer@*/ static rpmTag requiredTags[] = { RPMTAG_NAME, RPMTAG_VERSION, RPMTAG_RELEASE, @@ -187,13 +187,14 @@ static inline char * findLastChar(char * s) /** */ -static int isMemberInEntry(Header h, const char *name, int tag) +static int isMemberInEntry(Header h, const char *name, rpmTag tag) /*@*/ { HGE_t hge = (HGE_t)headerGetEntryMinMemory; HFD_t hfd = headerFreeData; const char ** names; - int type, count; + rpmTagType type; + int count; if (!hge(h, tag, &type, (void **)&names, &count)) return -1; @@ -246,18 +247,22 @@ static int checkForValidArchitectures(Spec spec) } /** + * Check that required tags are present in header. + * @param h header + * @param NVR package name-version-release + * @return 0 if OK */ -static int checkForRequired(Header h, const char *name) +static int checkForRequired(Header h, const char * NVR) /*@*/ { int res = 0; - int *p; + rpmTag * p; for (p = requiredTags; *p != 0; p++) { if (!headerIsEntry(h, *p)) { rpmError(RPMERR_BADSPEC, _("%s field must be present in package: %s\n"), - tagName(*p), name); + tagName(*p), NVR); res = 1; } } @@ -266,8 +271,12 @@ static int checkForRequired(Header h, const char *name) } /** + * Check that no duplicate tags are present in header. + * @param h header + * @param NVR package name-version-release + * @return 0 if OK */ -static int checkForDuplicates(Header h, const char *name) +static int checkForDuplicates(Header h, const char * NVR) /*@modifies h @*/ { int res = 0; @@ -281,7 +290,7 @@ static int checkForDuplicates(Header h, const char *name) if (tag != lastTag) continue; rpmError(RPMERR_BADSPEC, _("Duplicate %s entries in package: %s\n"), - tagName(tag), name); + tagName(tag), NVR); res = 1; } headerFreeIterator(hi); @@ -292,7 +301,7 @@ static int checkForDuplicates(Header h, const char *name) /** */ static struct optionalTag { - int ot_tag; + rpmTag ot_tag; /*@observer@*/ /*@null@*/ const char * ot_mac; } optionalTags[] = { { RPMTAG_VENDOR, "%{vendor}" }, @@ -432,12 +441,12 @@ static int handlePreambleTag(Spec spec, Package pkg, int tag, const char *macro, { HGE_t hge = (HGE_t)headerGetEntryMinMemory; HFD_t hfd = headerFreeData; - char *field = spec->line; - char *end; - char **array; + char * field = spec->line; + char * end; + char ** array; int multiToken = 0; rpmsenseFlags tagflags; - int type; + rpmTagType type; int len; int num; int rc; @@ -680,7 +689,7 @@ static int handlePreambleTag(Spec spec, Package pkg, int tag, const char *macro, /** */ typedef struct PreambleRec_s { - int tag; + rpmTag tag; int len; int multiLang; /*@observer@*/ /*@null@*/ const char * token; @@ -806,10 +815,10 @@ int parsePreamble(Spec spec, int initialPackage) char *name, *linep; int flag; Package pkg; - char fullName[BUFSIZ]; + char NVR[BUFSIZ]; char lang[BUFSIZ]; - strcpy(fullName, "(main package)"); + strcpy(NVR, "(main package)"); pkg = newPackage(spec); @@ -831,10 +840,10 @@ int parsePreamble(Spec spec, int initialPackage) if (flag == PART_SUBNAME) { const char * mainName; (void) headerNVR(spec->packages->header, &mainName, NULL, NULL); - sprintf(fullName, "%s-%s", mainName, name); + sprintf(NVR, "%s-%s", mainName, name); } else - strcpy(fullName, name); - (void) headerAddEntry(pkg->header, RPMTAG_NAME, RPM_STRING_TYPE, fullName, 1); + strcpy(NVR, name); + (void) headerAddEntry(pkg->header, RPMTAG_NAME, RPM_STRING_TYPE, NVR, 1); } if ((rc = readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS)) > 0) { @@ -882,13 +891,14 @@ int parsePreamble(Spec spec, int initialPackage) if (pkg == spec->packages) fillOutMainPackage(pkg->header); - if (checkForDuplicates(pkg->header, fullName)) + if (checkForDuplicates(pkg->header, NVR)) return RPMERR_BADSPEC; if (pkg != spec->packages) - headerCopyTags(spec->packages->header, pkg->header, copyTagsDuringParse); + headerCopyTags(spec->packages->header, pkg->header, + (int_32 *)copyTagsDuringParse); - if (checkForRequired(pkg->header, fullName)) + if (checkForRequired(pkg->header, NVR)) return RPMERR_BADSPEC; return nextPart; diff --git a/build/reqprov.c b/build/reqprov.c index efba0b377..98df9bdce 100644 --- a/build/reqprov.c +++ b/build/reqprov.c @@ -15,11 +15,11 @@ int addReqProv(/*@unused@*/ Spec spec, Header h, HGE_t hge = (HGE_t)headerGetEntryMinMemory; HFD_t hfd = headerFreeData; const char ** names; - int dnt; - int nametag = 0; - int versiontag = 0; - int flagtag = 0; - int indextag = 0; + rpmTagType dnt; + rpmTag nametag = 0; + rpmTag versiontag = 0; + rpmTag flagtag = 0; + rpmTag indextag = 0; int len; rpmsenseFlags extra = RPMSENSE_ANY; @@ -62,7 +62,7 @@ int addReqProv(/*@unused@*/ Spec spec, Header h, /* Check for duplicate dependencies. */ if (hge(h, nametag, &dnt, (void **) &names, &len)) { const char ** versions = NULL; - int dvt = RPM_STRING_ARRAY_TYPE; + rpmTagType dvt = RPM_STRING_ARRAY_TYPE; int *flags = NULL; int *indexes = NULL; int duplicate = 0; |