1 /* rpmarchive: spit out the main archive portion of a package */
4 const char *__progname;
13 int main(int argc, char **argv)
21 setprogname(argv[0]); /* Retrofit glibc __progname */
23 fdi = fdDup(STDIN_FILENO);
25 fdi = Fopen(argv[1], "r.ufdio");
28 fprintf(stderr, "%s: %s: %s\n", argv[0],
29 (argc == 1 ? "<stdin>" : argv[1]), Fstrerror(fdi));
32 fdo = fdDup(STDOUT_FILENO);
34 { rpmts ts = rpmtsCreate();
35 rpmVSFlags vsflags = 0;
37 /* XXX retain the ageless behavior of rpm2cpio */
38 vsflags |= _RPMVSF_NODIGESTS;
39 vsflags |= _RPMVSF_NOSIGNATURES;
40 vsflags |= RPMVSF_NOHDRCHK;
41 (void) rpmtsSetVSFlags(ts, vsflags);
44 rc = rpmReadPackageFile(ts, fdi, "rpm2cpio", &h);
52 case RPMRC_NOTTRUSTED:
55 fprintf(stderr, _("argument is not an RPM package\n"));
60 fprintf(stderr, _("error reading header from package\n"));
65 /* Retrieve type of payload compression. */
66 { const char * payload_compressor = NULL;
69 if (!headerGetEntry(h, RPMTAG_PAYLOADCOMPRESSOR, NULL,
70 (void **) &payload_compressor, NULL))
71 payload_compressor = "gzip";
72 rpmio_flags = t = alloca(sizeof("r.gzdio"));
74 if (!strcmp(payload_compressor, "gzip"))
75 t = stpcpy(t, ".gzdio");
76 if (!strcmp(payload_compressor, "bzip2"))
77 t = stpcpy(t, ".bzdio");
80 gzdi = Fdopen(fdi, rpmio_flags); /* XXX gzdi == fdi */
82 fprintf(stderr, _("cannot re-open payload: %s\n"), Fstrerror(gzdi));
86 rc = ufdCopy(gzdi, fdo);
87 rc = (rc <= 0) ? EXIT_FAILURE : EXIT_SUCCESS;
90 Fclose(gzdi); /* XXX gzdi == fdi */