int rpm2cpio_main(int argc UNUSED_PARAM, char **argv) { struct rpm_lead lead; unsigned pos; if (argv[1]) { xmove_fd(xopen(argv[1], O_RDONLY), rpm_fd); } xread(rpm_fd, &lead, sizeof(lead)); /* Just check the magic, the rest is irrelevant */ if (lead.magic != htonl(RPM_LEAD_MAGIC)) { bb_error_msg_and_die("invalid RPM magic"); } /* Skip the signature header, align to 8 bytes */ pos = skip_header(); seek_by_jump(rpm_fd, (-(int)pos) & 7); /* Skip the main header */ skip_header(); //if (SEAMLESS_COMPRESSION) // /* We need to know whether child (gzip/bzip/etc) exits abnormally */ // signal(SIGCHLD, check_errors_in_children); /* This works, but doesn't report uncompress errors (they happen in child) */ setup_unzip_on_fd(rpm_fd, /*fail_if_not_compressed:*/ 1); if (bb_copyfd_eof(rpm_fd, STDOUT_FILENO) < 0) bb_error_msg_and_die("error unpacking"); if (ENABLE_FEATURE_CLEAN_UP) { close(rpm_fd); } if (SEAMLESS_COMPRESSION) { check_errors_in_children(0); return bb_got_signal; } return EXIT_SUCCESS; }
int rpm2cpio_main(int argc UNUSED_PARAM, char **argv) { const char *str; int rpm_fd; INIT_G(); G.pagesize = getpagesize(); rpm_fd = rpm_gettags(argv[1]); //if (SEAMLESS_COMPRESSION) - we do this at the end instead. // /* We need to know whether child (gzip/bzip/etc) exits abnormally */ // signal(SIGCHLD, check_errors_in_children); if (ENABLE_FEATURE_SEAMLESS_LZMA && (str = rpm_getstr0(TAG_PAYLOADCOMPRESSOR)) != NULL && strcmp(str, "lzma") == 0 ) { // lzma compression can't be detected // set up decompressor without detection setup_lzma_on_fd(rpm_fd); } else { setup_unzip_on_fd(rpm_fd, /*fail_if_not_compressed:*/ 1); } if (bb_copyfd_eof(rpm_fd, STDOUT_FILENO) < 0) bb_error_msg_and_die("error unpacking"); if (ENABLE_FEATURE_CLEAN_UP) { close(rpm_fd); } if (SEAMLESS_COMPRESSION) { check_errors_in_children(0); return bb_got_signal; } return EXIT_SUCCESS; }