Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/archival/dpkg_deb.c

    r1765 r2725  
    33 * dpkg-deb packs, unpacks and provides information about Debian archives.
    44 *
    5  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
     5 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    66 */
    77#include "libbb.h"
    8 #include "unarchive.h"
     8#include "archive.h"
    99
    10 #define DPKG_DEB_OPT_CONTENTS   1
    11 #define DPKG_DEB_OPT_CONTROL    2
    12 #define DPKG_DEB_OPT_FIELD  4
    13 #define DPKG_DEB_OPT_EXTRACT    8
    14 #define DPKG_DEB_OPT_EXTRACT_VERBOSE    16
     10#define DPKG_DEB_OPT_CONTENTS         1
     11#define DPKG_DEB_OPT_CONTROL          2
     12#define DPKG_DEB_OPT_FIELD            4
     13#define DPKG_DEB_OPT_EXTRACT          8
     14#define DPKG_DEB_OPT_EXTRACT_VERBOSE 16
    1515
    16 int dpkg_deb_main(int argc, char **argv);
     16int dpkg_deb_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
    1717int dpkg_deb_main(int argc, char **argv)
    1818{
     
    2121    llist_t *control_tar_llist = NULL;
    2222    unsigned opt;
    23     const char *extract_dir = NULL;
    24     short argcount = 1;
     23    const char *extract_dir;
     24    int need_args;
    2525
    2626    /* Setup the tar archive handle */
     
    2929    /* Setup an ar archive handle that refers to the gzip sub archive */
    3030    ar_archive = init_handle();
    31     ar_archive->sub_archive = tar_archive;
     31    ar_archive->dpkg__sub_archive = tar_archive;
    3232    ar_archive->filter = filter_accept_list_reassign;
    3333
    34 #if ENABLE_FEATURE_DEB_TAR_GZ
    35     llist_add_to(&(ar_archive->accept), (char*)"data.tar.gz");
     34#if ENABLE_FEATURE_SEAMLESS_GZ
     35    llist_add_to(&ar_archive->accept, (char*)"data.tar.gz");
    3636    llist_add_to(&control_tar_llist, (char*)"control.tar.gz");
    3737#endif
    38 
    39 #if ENABLE_FEATURE_DEB_TAR_BZ2
    40     llist_add_to(&(ar_archive->accept), (char*)"data.tar.bz2");
     38#if ENABLE_FEATURE_SEAMLESS_BZ2
     39    llist_add_to(&ar_archive->accept, (char*)"data.tar.bz2");
    4140    llist_add_to(&control_tar_llist, (char*)"control.tar.bz2");
    4241#endif
     42#if ENABLE_FEATURE_SEAMLESS_LZMA
     43    llist_add_to(&ar_archive->accept, (char*)"data.tar.lzma");
     44    llist_add_to(&control_tar_llist, (char*)"control.tar.lzma");
     45#endif
    4346
    44     opt_complementary = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
     47    opt_complementary = "c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
    4548    opt = getopt32(argv, "cefXx");
     49    argv += optind;
     50    argc -= optind;
    4651
    4752    if (opt & DPKG_DEB_OPT_CONTENTS) {
    4853        tar_archive->action_header = header_verbose_list;
    4954    }
     55    extract_dir = NULL;
     56    need_args = 1;
    5057    if (opt & DPKG_DEB_OPT_CONTROL) {
    5158        ar_archive->accept = control_tar_llist;
    5259        tar_archive->action_data = data_extract_all;
    53         if (optind + 1 == argc) {
     60        if (1 == argc) {
    5461            extract_dir = "./DEBIAN";
    5562        } else {
    56             argcount++;
     63            need_args++;
    5764        }
    5865    }
     
    7178    if (opt & (DPKG_DEB_OPT_EXTRACT_VERBOSE | DPKG_DEB_OPT_EXTRACT)) {
    7279        tar_archive->action_data = data_extract_all;
    73         argcount = 2;
     80        need_args = 2;
    7481    }
    7582
    76     if ((optind + argcount) != argc) {
     83    if (need_args != argc) {
    7784        bb_show_usage();
    7885    }
    7986
    80     tar_archive->src_fd = ar_archive->src_fd = xopen(argv[optind++], O_RDONLY);
     87    tar_archive->src_fd = ar_archive->src_fd = xopen(argv[0], O_RDONLY);
    8188
    82     /* Workout where to extract the files */
     89    /* Work out where to extract the files */
    8390    /* 2nd argument is a dir name */
    84     if (argv[optind]) {
    85         extract_dir = argv[optind];
     91    if (argv[1]) {
     92        extract_dir = argv[1];
    8693    }
    8794    if (extract_dir) {
     
    8996        xchdir(extract_dir);
    9097    }
     98
     99    /* Do it */
    91100    unpack_ar_archive(ar_archive);
    92101
    93102    /* Cleanup */
    94     close(ar_archive->src_fd);
     103    if (ENABLE_FEATURE_CLEAN_UP)
     104        close(ar_archive->src_fd);
    95105
    96106    return EXIT_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.