diff --git a/tests/rpmgeneral.at b/tests/rpmgeneral.at index f9b72b7ddf..34975723ea 100644 --- a/tests/rpmgeneral.at +++ b/tests/rpmgeneral.at @@ -341,8 +341,8 @@ RPMTEST_CHECK([ runroot_other rpm2cpio /data/SRPMS/hello-1.0-1.src.rpm | cpio -t --quiet ], [0], -[hello-1.0.tar.gz -hello.spec +[./hello-1.0.tar.gz +./hello.spec ], []) RPMTEST_CLEANUP diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 84afcc8498..3195c9f75e 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -3,7 +3,6 @@ add_library(cliutils OBJECT cliutils.c cliutils.h) add_executable(rpm rpm.c cliutils) add_executable(rpmdb rpmdb.c cliutils) add_executable(rpmkeys rpmkeys.c cliutils) -add_executable(rpm2cpio rpm2cpio.c cliutils) add_executable(rpmsign rpmsign.c cliutils) add_executable(rpmbuild rpmbuild.c cliutils) add_executable(rpmspec rpmspec.c cliutils) @@ -48,8 +47,15 @@ foreach(cmd rpmverify rpmquery) BYPRODUCTS ${cmd}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${cmd} TYPE BIN) endforeach() +if (WITH_ARCHIVE) + add_custom_target(rpm2cpio ALL COMMAND + ${CMAKE_COMMAND} -E create_symlink rpm2archive rpm2cpio + BYPRODUCTS rpm2cpio) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/rpm2cpio TYPE BIN) +endif() + install(TARGETS - rpm rpmdb rpmkeys rpm2cpio rpmsign rpmbuild rpmspec + rpm rpmdb rpmkeys rpmsign rpmbuild rpmspec rpmlua rpmgraph rpmsort ) install(TARGETS elfdeps rpmdeps rpmuncompress DESTINATION ${RPM_CONFIGDIR}) diff --git a/tools/rpm2cpio.c b/tools/rpm2cpio.c deleted file mode 100644 index 940d6ce389..0000000000 --- a/tools/rpm2cpio.c +++ /dev/null @@ -1,104 +0,0 @@ -/* rpmarchive: spit out the main archive portion of a package */ - -#include "system.h" - -#include /* rpmReadPackageFile .. */ -#include -#include -#include - -#include -#include - -#include "debug.h" - -int main(int argc, char *argv[]) -{ - FD_t fdi, fdo; - Header h; - char * rpmio_flags = NULL; - int rc; - off_t payload_size; - FD_t gzdi; - - xsetprogname(argv[0]); /* Portability call -- see system.h */ - - rpmReadConfigFiles(NULL, NULL); - if (argc == 1) - fdi = fdDup(STDIN_FILENO); - else { - if (rstreq(argv[1], "-h") || rstreq(argv[1], "--help")) { - fprintf(stderr, "Usage: rpm2cpio file.rpm\n"); - exit(EXIT_FAILURE); - } - fdi = Fopen(argv[1], "r.ufdio"); - } - - if (Ferror(fdi)) { - fprintf(stderr, "%s: %s: %s\n", argv[0], - (argc == 1 ? "" : argv[1]), Fstrerror(fdi)); - exit(EXIT_FAILURE); - } - if (isatty(STDOUT_FILENO)) { - fprintf(stderr, "Error: refusing to output cpio data to a terminal.\n"); - exit(EXIT_FAILURE); - } - fdo = fdDup(STDOUT_FILENO); - - { rpmts ts = rpmtsCreate(); - rpmVSFlags vsflags = 0; - - /* XXX retain the ageless behavior of rpm2cpio */ - vsflags |= RPMVSF_MASK_NODIGESTS; - vsflags |= RPMVSF_MASK_NOSIGNATURES; - vsflags |= RPMVSF_NOHDRCHK; - (void) rpmtsSetVSFlags(ts, vsflags); - - rc = rpmReadPackageFile(ts, fdi, "rpm2cpio", &h); - - ts = rpmtsFree(ts); - } - - switch (rc) { - case RPMRC_OK: - case RPMRC_NOKEY: - case RPMRC_NOTTRUSTED: - break; - case RPMRC_NOTFOUND: - fprintf(stderr, _("argument is not an RPM package\n")); - exit(EXIT_FAILURE); - break; - case RPMRC_FAIL: - default: - fprintf(stderr, _("error reading header from package\n")); - exit(EXIT_FAILURE); - break; - } - - if (headerIsEntry(h, RPMTAG_LONGFILESIZES)) { - fprintf(stderr, _("files over 4GB not supported by cpio, use rpm2archive instead\n")); - exit(EXIT_FAILURE); - } - - /* Retrieve payload size and compression type. */ - { const char *compr = headerGetString(h, RPMTAG_PAYLOADCOMPRESSOR); - rpmio_flags = rstrscat(NULL, "r.", compr ? compr : "gzip", NULL); - payload_size = headerGetNumber(h, RPMTAG_LONGARCHIVESIZE); - } - - 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); - } - - rc = (ufdCopy(gzdi, fdo) == payload_size) ? EXIT_SUCCESS : EXIT_FAILURE; - - headerFree(h); - Fclose(fdo); - Fclose(gzdi); /* XXX gzdi == fdi */ - - return rc; -}