diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2007-12-01 21:06:00 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2007-12-01 21:06:00 +0200 |
commit | fb90b8b4eb46c4008326e07b4866f4bf0875df83 (patch) | |
tree | cc65f32a0cafaf9efec3c82cc77a71dc9a51913c | |
parent | c4f116eec34eb283d37dca84b6a38c9fb38537e5 (diff) | |
download | rpm-fb90b8b4eb46c4008326e07b4866f4bf0875df83.tar.gz rpm-fb90b8b4eb46c4008326e07b4866f4bf0875df83.tar.bz2 rpm-fb90b8b4eb46c4008326e07b4866f4bf0875df83.zip |
More rpmlead exorcizing
- remove unnecessary type parameter to writeRPM(), header knows what it is
- remove unnecessary lead argument to readRPM(), it's unused anyway
- drop lead from cpioSourceArchive struct
-rw-r--r-- | build/buildio.h | 5 | ||||
-rw-r--r-- | build/pack.c | 31 | ||||
-rw-r--r-- | tools/rpminject.c | 10 |
3 files changed, 14 insertions, 32 deletions
diff --git a/build/buildio.h b/build/buildio.h index f2ab33fc5..b324e7cbb 100644 --- a/build/buildio.h +++ b/build/buildio.h @@ -20,21 +20,18 @@ typedef struct cpioSourceArchive_s { unsigned int cpioArchiveSize; FD_t cpioFdIn; rpmfi cpioList; - struct rpmlead * lead; /* XXX FIXME: exorcize lead/arch/os */ } * CSA_t; /** * Read rpm package components from file. * @param fileName file name of package (or NULL to use stdin) * @retval specp spec structure to carry package header (or NULL) - * @retval lead package lead * @retval sigs package signature * @param csa * @return 0 on success */ int readRPM(const char * fileName, rpmSpec * specp, - struct rpmlead * lead, Header * sigs, CSA_t csa); @@ -47,7 +44,6 @@ int readRPM(const char * fileName, * @retval *hdrp header to write (final header is returned). * @retval *pkgidp header+payload MD5 of package (NULL to disable). * @param fileName file name of package - * @param type RPMLEAD_SOURCE/RPMLEAD_BINARY * @param csa * @param passPhrase * @retval cookie generated cookie (i.e build host/time) @@ -55,7 +51,6 @@ int readRPM(const char * fileName, */ int writeRPM(Header * hdrp, unsigned char ** pkgidp, const char * fileName, - int type, CSA_t csa, char * passPhrase, const char ** cookie); diff --git a/build/pack.c b/build/pack.c index a6e57cbde..e85d4c131 100644 --- a/build/pack.c +++ b/build/pack.c @@ -263,7 +263,7 @@ static int processScriptFiles(rpmSpec spec, Package pkg) return 0; } -int readRPM(const char *fileName, rpmSpec *specp, struct rpmlead *lead, +int readRPM(const char *fileName, rpmSpec *specp, Header *sigs, CSA_t csa) { FD_t fdi; @@ -282,14 +282,6 @@ int readRPM(const char *fileName, rpmSpec *specp, struct rpmlead *lead, return RPMLOG_ERR; } - /* Get copy of lead */ - if ((rc = Fread(lead, sizeof(char), RPMLEAD_SIZE, fdi)) != RPMLEAD_SIZE) { - rpmlog(RPMLOG_ERR, _("readRPM: read %s: %s\n"), - (fileName ? fileName : "<stdin>"), - Fstrerror(fdi)); - return RPMLOG_ERR; - } - /* XXX FIXME: EPIPE on <stdin> */ if (Fseek(fdi, 0, SEEK_SET) == -1) { rpmlog(RPMLOG_ERR, _("%s: Fseek failed: %s\n"), @@ -348,7 +340,7 @@ int readRPM(const char *fileName, rpmSpec *specp, struct rpmlead *lead, } int writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileName, - int type, CSA_t csa, char *passPhrase, const char **cookie) + CSA_t csa, char *passPhrase, const char **cookie) { FD_t fd = NULL; FD_t ifd = NULL; @@ -360,7 +352,7 @@ int writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileName, char buf[BUFSIZ]; Header h; Header sig = NULL; - int rc = 0; + int rc = 0, isSource; /* Transfer header reference form *hdrp to h. */ h = headerLink(*hdrp); @@ -370,18 +362,16 @@ int writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileName, *pkgidp = NULL; /* Binary packages now have explicit Provides: name = version-release. */ - if (type == RPMLEAD_BINARY) + isSource = headerIsSource(h); + if (isSource) providePackageNVR(h); /* Save payload information */ - switch(type) { - case RPMLEAD_SOURCE: + if (isSource) rpmio_flags = rpmExpand("%{?_source_payload}", NULL); - break; - case RPMLEAD_BINARY: + else rpmio_flags = rpmExpand("%{?_binary_payload}", NULL); - break; - } + if (!(rpmio_flags && *rpmio_flags)) { rpmio_flags = _free(rpmio_flags); rpmio_flags = xstrdup("w9.gzdio"); @@ -698,8 +688,7 @@ int packageBinaries(rpmSpec spec) csa->cpioFdIn = fdNew("init (packageBinaries)"); csa->cpioList = rpmfiLink(pkg->cpioList, "packageBinaries"); - rc = writeRPM(&pkg->header, NULL, fn, RPMLEAD_BINARY, - csa, spec->passPhrase, NULL); + rc = writeRPM(&pkg->header, NULL, fn, csa, spec->passPhrase, NULL); csa->cpioList = rpmfiFree(csa->cpioList); csa->cpioFdIn = fdFree(csa->cpioFdIn, "init (packageBinaries)"); @@ -739,7 +728,7 @@ int packageSources(rpmSpec spec) csa->cpioList = rpmfiLink(spec->sourceCpioList, "packageSources"); spec->sourcePkgId = NULL; - rc = writeRPM(&spec->sourceHeader, &spec->sourcePkgId, fn, RPMLEAD_SOURCE, + rc = writeRPM(&spec->sourceHeader, &spec->sourcePkgId, fn, csa, spec->passPhrase, &(spec->cookie)); csa->cpioList = rpmfiFree(csa->cpioList); diff --git a/tools/rpminject.c b/tools/rpminject.c index a13143faa..3d806c746 100644 --- a/tools/rpminject.c +++ b/tools/rpminject.c @@ -367,7 +367,6 @@ headerInject(Header *hdrp, cmd_t *cmds[], int ncmds) static int rewriteRPM(const char *fni, const char *fno, cmd_t *cmds[], int ncmds) { - struct rpmlead lead; /* XXX FIXME: exorcize lead/arch/os */ Header sigs; rpmSpec spec; struct cpioSourceArchive_s csabuf, *csa = &csabuf; @@ -376,10 +375,9 @@ rewriteRPM(const char *fni, const char *fno, cmd_t *cmds[], int ncmds) csa->cpioArchiveSize = 0; csa->cpioFdIn = fdNew("init (rewriteRPM)"); csa->cpioList = NULL; - csa->lead = &lead; /* XXX FIXME: exorcize lead/arch/os */ /* Read rpm and (partially) recreate spec/pkg control structures */ - if ((rc = readRPM(fni, &spec, &lead, &sigs, csa)) != 0) + if ((rc = readRPM(fni, &spec, &sigs, csa)) != 0) return rc; /* Inject new strings into header tags */ @@ -387,11 +385,11 @@ rewriteRPM(const char *fni, const char *fno, cmd_t *cmds[], int ncmds) goto exit; /* Rewrite the rpm */ - if (lead.type == RPMLEAD_SOURCE) { - rc = writeRPM(&spec->packages->header, NULL, fno, (int)lead.type, + if (headerIsSource(spec->packages->header)) { + rc = writeRPM(&spec->packages->header, NULL, fno, csa, spec->passPhrase, &(spec->cookie)); } else { - rc = writeRPM(&spec->packages->header, NULL, fno, (int)lead.type, + rc = writeRPM(&spec->packages->header, NULL, fno, csa, spec->passPhrase, NULL); } |