diff options
-rw-r--r-- | lib/psm.c | 18 | ||||
-rw-r--r-- | rpm2cpio.c | 20 |
2 files changed, 11 insertions, 27 deletions
@@ -40,7 +40,7 @@ struct rpmpsm_s { rpmte te; /*!< current transaction element */ rpmfi fi; /*!< transaction element file info */ const char * stepName; - const char * rpmio_flags; + char * rpmio_flags; char * failedFile; int scriptTag; /*!< Scriptlet data tag. */ int progTag; /*!< Scriptlet interpreter tag. */ @@ -1127,6 +1127,7 @@ rpmpsm rpmpsmFree(rpmpsm psm) (void) rpmpsmUnlink(psm, RPMDBG_M("rpmpsmFree")); + free(psm->rpmio_flags); memset(psm, 0, sizeof(*psm)); /* XXX trash and burn */ psm = _free(psm); @@ -1619,22 +1620,13 @@ rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage) break; case PSM_RPMIO_FLAGS: - { const char * payload_compressor = NULL; + { const char *compr = NULL; struct rpmtd_s pc; Header h = rpmteHeader(psm->te); headerGet(h, RPMTAG_PAYLOADCOMPRESSOR, &pc, HEADERGET_DEFAULT); - payload_compressor = rpmtdGetString(&pc); - if (!payload_compressor) - payload_compressor = "gzip"; - if (!strcmp(payload_compressor, "gzip")) - psm->rpmio_flags = "r.gzdio"; - if (!strcmp(payload_compressor, "bzip2")) - psm->rpmio_flags = "r.bzdio"; - if (!strcmp(payload_compressor, "xz")) - psm->rpmio_flags = "r.xzdio"; - if (!strcmp(payload_compressor, "lzma")) - psm->rpmio_flags = "r.lzdio"; + compr = rpmtdGetString(&pc); + psm->rpmio_flags = rstrscat(NULL, "r.", compr ? compr : "gzip", NULL); rpmtdFreeData(&pc); headerFree(h); diff --git a/rpm2cpio.c b/rpm2cpio.c index 787c0ae22..1270ea89d 100644 --- a/rpm2cpio.c +++ b/rpm2cpio.c @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) { FD_t fdi, fdo; Header h; - char * rpmio_flags; + char * rpmio_flags = NULL; rpmRC rc; FD_t gzdi; @@ -70,26 +70,18 @@ int main(int argc, char *argv[]) } /* Retrieve type of payload compression. */ - { const char * payload_compressor = NULL; + { const char *compr = NULL; struct rpmtd_s pc; headerGet(h, RPMTAG_PAYLOADCOMPRESSOR, &pc, HEADERGET_DEFAULT); - payload_compressor = rpmtdGetString(&pc); - if (!payload_compressor) - payload_compressor = "gzip"; - - if (!strcmp(payload_compressor, "gzip")) - rpmio_flags = "r.gzdio"; - if (!strcmp(payload_compressor, "bzip2")) - rpmio_flags = "r.bzdio"; - if (!strcmp(payload_compressor, "xz")) - rpmio_flags = "r.xzdio"; - if (!strcmp(payload_compressor, "lzma")) - rpmio_flags = "r.lzdio"; + compr = rpmtdGetString(&pc); + rpmio_flags = rstrscat(NULL, "r.", compr ? compr : "gzip", NULL); rpmtdFreeData(&pc); } gzdi = Fdopen(fdi, rpmio_flags); /* XXX gzdi == fdi */ + free(rpmio_flags); + if (gzdi == NULL) { fprintf(stderr, _("cannot re-open payload: %s\n"), Fstrerror(gzdi)); exit(EXIT_FAILURE); |