diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-22 15:33:04 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-22 15:33:04 +0200 |
| commit | efcc89b21b08effa2490a405bb0c3e7963dc46be (patch) | |
| tree | 817268de41c95f9bfdfc2f045dcd9e6c14f6254f | |
| parent | 7d834c9bb436edd594ebacc48d2b9ea7d3364dbd (diff) | |
| download | busybox-w32-efcc89b21b08effa2490a405bb0c3e7963dc46be.tar.gz busybox-w32-efcc89b21b08effa2490a405bb0c3e7963dc46be.tar.bz2 busybox-w32-efcc89b21b08effa2490a405bb0c3e7963dc46be.zip | |
rpm,rpm2cpio: do not compile not-configurred parts of rpm.c
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | archival/rpm.c | 88 |
1 files changed, 48 insertions, 40 deletions
diff --git a/archival/rpm.c b/archival/rpm.c index c24cfdf41..790eeb59d 100644 --- a/archival/rpm.c +++ b/archival/rpm.c | |||
| @@ -88,37 +88,6 @@ struct globals { | |||
| 88 | #define G (*(struct globals*)bb_common_bufsiz1) | 88 | #define G (*(struct globals*)bb_common_bufsiz1) |
| 89 | #define INIT_G() do { setup_common_bufsiz(); } while (0) | 89 | #define INIT_G() do { setup_common_bufsiz(); } while (0) |
| 90 | 90 | ||
| 91 | static void extract_cpio(int fd, const char *source_rpm) | ||
| 92 | { | ||
| 93 | archive_handle_t *archive_handle; | ||
| 94 | |||
| 95 | if (source_rpm != NULL) { | ||
| 96 | /* Binary rpm (it was built from some SRPM), install to root */ | ||
| 97 | xchdir("/"); | ||
| 98 | } /* else: SRPM, install to current dir */ | ||
| 99 | |||
| 100 | /* Initialize */ | ||
| 101 | archive_handle = init_handle(); | ||
| 102 | archive_handle->seek = seek_by_read; | ||
| 103 | archive_handle->action_data = data_extract_all; | ||
| 104 | #if 0 /* For testing (rpm -i only lists the files in internal cpio): */ | ||
| 105 | archive_handle->action_header = header_list; | ||
| 106 | archive_handle->action_data = data_skip; | ||
| 107 | #endif | ||
| 108 | archive_handle->ah_flags = ARCHIVE_RESTORE_DATE | ARCHIVE_CREATE_LEADING_DIRS | ||
| 109 | /* compat: overwrite existing files. | ||
| 110 | * try "rpm -i foo.src.rpm" few times in a row - | ||
| 111 | * standard rpm will not complain. | ||
| 112 | */ | ||
| 113 | | ARCHIVE_REPLACE_VIA_RENAME; | ||
| 114 | archive_handle->src_fd = fd; | ||
| 115 | /*archive_handle->offset = 0; - init_handle() did it */ | ||
| 116 | |||
| 117 | setup_unzip_on_fd(archive_handle->src_fd, /*fail_if_not_compressed:*/ 1); | ||
| 118 | while (get_header_cpio(archive_handle) == EXIT_SUCCESS) | ||
| 119 | continue; | ||
| 120 | } | ||
| 121 | |||
| 122 | static int rpm_gettags(const char *filename) | 91 | static int rpm_gettags(const char *filename) |
| 123 | { | 92 | { |
| 124 | rpm_index *tags; | 93 | rpm_index *tags; |
| @@ -190,15 +159,6 @@ static int bsearch_rpmtag(const void *key, const void *item) | |||
| 190 | return (*tag - tmp->tag); | 159 | return (*tag - tmp->tag); |
| 191 | } | 160 | } |
| 192 | 161 | ||
| 193 | static int rpm_getcount(int tag) | ||
| 194 | { | ||
| 195 | rpm_index *found; | ||
| 196 | found = bsearch(&tag, G.mytags, G.tagcount, sizeof(G.mytags[0]), bsearch_rpmtag); | ||
| 197 | if (!found) | ||
| 198 | return 0; | ||
| 199 | return found->count; | ||
| 200 | } | ||
| 201 | |||
| 202 | static char *rpm_getstr(int tag, int itemindex) | 162 | static char *rpm_getstr(int tag, int itemindex) |
| 203 | { | 163 | { |
| 204 | rpm_index *found; | 164 | rpm_index *found; |
| @@ -222,6 +182,8 @@ static char *rpm_getstr0(int tag) | |||
| 222 | return rpm_getstr(tag, 0); | 182 | return rpm_getstr(tag, 0); |
| 223 | } | 183 | } |
| 224 | 184 | ||
| 185 | #if ENABLE_RPM | ||
| 186 | |||
| 225 | static int rpm_getint(int tag, int itemindex) | 187 | static int rpm_getint(int tag, int itemindex) |
| 226 | { | 188 | { |
| 227 | rpm_index *found; | 189 | rpm_index *found; |
| @@ -249,6 +211,15 @@ static int rpm_getint(int tag, int itemindex) | |||
| 249 | return -1; | 211 | return -1; |
| 250 | } | 212 | } |
| 251 | 213 | ||
| 214 | static int rpm_getcount(int tag) | ||
| 215 | { | ||
| 216 | rpm_index *found; | ||
| 217 | found = bsearch(&tag, G.mytags, G.tagcount, sizeof(G.mytags[0]), bsearch_rpmtag); | ||
| 218 | if (!found) | ||
| 219 | return 0; | ||
| 220 | return found->count; | ||
| 221 | } | ||
| 222 | |||
| 252 | static void fileaction_dobackup(char *filename, int fileref) | 223 | static void fileaction_dobackup(char *filename, int fileref) |
| 253 | { | 224 | { |
| 254 | struct stat oldfile; | 225 | struct stat oldfile; |
| @@ -317,6 +288,37 @@ static void print_all_tags(void) | |||
| 317 | #define print_all_tags() ((void)0) | 288 | #define print_all_tags() ((void)0) |
| 318 | #endif | 289 | #endif |
| 319 | 290 | ||
| 291 | static void extract_cpio(int fd, const char *source_rpm) | ||
| 292 | { | ||
| 293 | archive_handle_t *archive_handle; | ||
| 294 | |||
| 295 | if (source_rpm != NULL) { | ||
| 296 | /* Binary rpm (it was built from some SRPM), install to root */ | ||
| 297 | xchdir("/"); | ||
| 298 | } /* else: SRPM, install to current dir */ | ||
| 299 | |||
| 300 | /* Initialize */ | ||
| 301 | archive_handle = init_handle(); | ||
| 302 | archive_handle->seek = seek_by_read; | ||
| 303 | archive_handle->action_data = data_extract_all; | ||
| 304 | #if 0 /* For testing (rpm -i only lists the files in internal cpio): */ | ||
| 305 | archive_handle->action_header = header_list; | ||
| 306 | archive_handle->action_data = data_skip; | ||
| 307 | #endif | ||
| 308 | archive_handle->ah_flags = ARCHIVE_RESTORE_DATE | ARCHIVE_CREATE_LEADING_DIRS | ||
| 309 | /* compat: overwrite existing files. | ||
| 310 | * try "rpm -i foo.src.rpm" few times in a row - | ||
| 311 | * standard rpm will not complain. | ||
| 312 | */ | ||
| 313 | | ARCHIVE_REPLACE_VIA_RENAME; | ||
| 314 | archive_handle->src_fd = fd; | ||
| 315 | /*archive_handle->offset = 0; - init_handle() did it */ | ||
| 316 | |||
| 317 | setup_unzip_on_fd(archive_handle->src_fd, /*fail_if_not_compressed:*/ 1); | ||
| 318 | while (get_header_cpio(archive_handle) == EXIT_SUCCESS) | ||
| 319 | continue; | ||
| 320 | } | ||
| 321 | |||
| 320 | //usage:#define rpm_trivial_usage | 322 | //usage:#define rpm_trivial_usage |
| 321 | //usage: "-i PACKAGE.rpm; rpm -qp[ildc] PACKAGE.rpm" | 323 | //usage: "-i PACKAGE.rpm; rpm -qp[ildc] PACKAGE.rpm" |
| 322 | //usage:#define rpm_full_usage "\n\n" | 324 | //usage:#define rpm_full_usage "\n\n" |
| @@ -487,6 +489,8 @@ int rpm_main(int argc, char **argv) | |||
| 487 | return 0; | 489 | return 0; |
| 488 | } | 490 | } |
| 489 | 491 | ||
| 492 | #endif /* RPM */ | ||
| 493 | |||
| 490 | /* | 494 | /* |
| 491 | * Mini rpm2cpio implementation for busybox | 495 | * Mini rpm2cpio implementation for busybox |
| 492 | * | 496 | * |
| @@ -509,6 +513,8 @@ int rpm_main(int argc, char **argv) | |||
| 509 | //usage:#define rpm2cpio_full_usage "\n\n" | 513 | //usage:#define rpm2cpio_full_usage "\n\n" |
| 510 | //usage: "Output a cpio archive of the rpm file" | 514 | //usage: "Output a cpio archive of the rpm file" |
| 511 | 515 | ||
| 516 | #if ENABLE_RPM2CPIO | ||
| 517 | |||
| 512 | /* No getopt required */ | 518 | /* No getopt required */ |
| 513 | int rpm2cpio_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 519 | int rpm2cpio_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
| 514 | int rpm2cpio_main(int argc UNUSED_PARAM, char **argv) | 520 | int rpm2cpio_main(int argc UNUSED_PARAM, char **argv) |
| @@ -549,3 +555,5 @@ int rpm2cpio_main(int argc UNUSED_PARAM, char **argv) | |||
| 549 | } | 555 | } |
| 550 | return EXIT_SUCCESS; | 556 | return EXIT_SUCCESS; |
| 551 | } | 557 | } |
| 558 | |||
| 559 | #endif /* RPM2CPIO */ | ||
