diff options
author | Rob Landley <rob@landley.net> | 2005-10-15 03:06:21 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2005-10-15 03:06:21 +0000 |
commit | 3ee6c24ea29c073e67f9aaf04ccd6436aeb99e1f (patch) | |
tree | e7357032f4a1205f8c609aba4b2ca4e2b7bfc292 | |
parent | f704b27b5bb8bd5acaed9464714db34ccef06cc8 (diff) | |
download | busybox-w32-3ee6c24ea29c073e67f9aaf04ccd6436aeb99e1f.tar.gz busybox-w32-3ee6c24ea29c073e67f9aaf04ccd6436aeb99e1f.tar.bz2 busybox-w32-3ee6c24ea29c073e67f9aaf04ccd6436aeb99e1f.zip |
Add --exclude option (to make uClibc-0.9.28 headers install using busybox tar).
I have no idea how to apply bb_getopt_complementally to a --longopt that
has no short option. The documentation from vodz has a bad case of
babelfish poisoning, and I can't understand it. It sort of seems to
suggest there is a way, but what it is I have no idea. So I used \n as
the short option, which is fairly unlikely to be used for something else. :)
-rw-r--r-- | archival/tar.c | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/archival/tar.c b/archival/tar.c index 7cfb495e5..81edc3fc3 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -59,12 +59,12 @@ | |||
59 | # define TAR_MAGIC "ustar" /* ustar and a null */ | 59 | # define TAR_MAGIC "ustar" /* ustar and a null */ |
60 | # define TAR_VERSION " " /* Be compatable with GNU tar format */ | 60 | # define TAR_VERSION " " /* Be compatable with GNU tar format */ |
61 | 61 | ||
62 | static const int TAR_BLOCK_SIZE = 512; | 62 | #define TAR_BLOCK_SIZE 512 |
63 | static const int TAR_MAGIC_LEN = 6; | 63 | #define TAR_MAGIC_LEN 6 |
64 | static const int TAR_VERSION_LEN = 2; | 64 | #define TAR_VERSION_LEN 2 |
65 | 65 | ||
66 | /* POSIX tar Header Block, from POSIX 1003.1-1990 */ | 66 | /* POSIX tar Header Block, from POSIX 1003.1-1990 */ |
67 | enum { NAME_SIZE = 100 }; /* because gcc won't let me use 'static const int' */ | 67 | #define NAME_SIZE 100 |
68 | struct TarHeader { /* byte offset */ | 68 | struct TarHeader { /* byte offset */ |
69 | char name[NAME_SIZE]; /* 0-99 */ | 69 | char name[NAME_SIZE]; /* 0-99 */ |
70 | char mode[8]; /* 100-107 */ | 70 | char mode[8]; /* 100-107 */ |
@@ -670,6 +670,7 @@ static const struct option tar_long_options[] = { | |||
670 | # ifdef CONFIG_FEATURE_TAR_FROM | 670 | # ifdef CONFIG_FEATURE_TAR_FROM |
671 | { "files-from", 1, NULL, 'T' }, | 671 | { "files-from", 1, NULL, 'T' }, |
672 | { "exclude-from", 1, NULL, 'X' }, | 672 | { "exclude-from", 1, NULL, 'X' }, |
673 | { "exclude", 1, NULL, '\n' }, | ||
673 | # endif | 674 | # endif |
674 | # ifdef CONFIG_FEATURE_TAR_GZIP | 675 | # ifdef CONFIG_FEATURE_TAR_GZIP |
675 | { "gzip", 0, NULL, 'z' }, | 676 | { "gzip", 0, NULL, 'z' }, |
@@ -688,7 +689,7 @@ int tar_main(int argc, char **argv) | |||
688 | char *base_dir = NULL; | 689 | char *base_dir = NULL; |
689 | const char *tar_filename = "-"; | 690 | const char *tar_filename = "-"; |
690 | unsigned long opt; | 691 | unsigned long opt; |
691 | unsigned long ctx_flag = 0; | 692 | llist_t *excludes; |
692 | 693 | ||
693 | 694 | ||
694 | /* Initialise default values */ | 695 | /* Initialise default values */ |
@@ -697,9 +698,9 @@ int tar_main(int argc, char **argv) | |||
697 | 698 | ||
698 | /* Prepend '-' to the first argument if required */ | 699 | /* Prepend '-' to the first argument if required */ |
699 | #ifdef CONFIG_FEATURE_TAR_CREATE | 700 | #ifdef CONFIG_FEATURE_TAR_CREATE |
700 | bb_opt_complementally = "--:-1:X::T::c:t:x:?:c--tx:t--cx:x--ct"; | 701 | bb_opt_complementally = "--:-1:X::T::\n::c:t:x:?:c--tx:t--cx:x--ct"; |
701 | #else | 702 | #else |
702 | bb_opt_complementally = "--:-1:X::T::t:x:?:t--x:x--t"; | 703 | bb_opt_complementally = "--:-1:X::T::\n::t:x:?:t--x:x--t"; |
703 | #endif | 704 | #endif |
704 | #ifdef CONFIG_FEATURE_TAR_LONG_OPTIONS | 705 | #ifdef CONFIG_FEATURE_TAR_LONG_OPTIONS |
705 | bb_applet_long_options = tar_long_options; | 706 | bb_applet_long_options = tar_long_options; |
@@ -709,12 +710,12 @@ int tar_main(int argc, char **argv) | |||
709 | &tar_filename /* archive filename */ | 710 | &tar_filename /* archive filename */ |
710 | #ifdef CONFIG_FEATURE_TAR_FROM | 711 | #ifdef CONFIG_FEATURE_TAR_FROM |
711 | , &(tar_handle->accept), | 712 | , &(tar_handle->accept), |
712 | &(tar_handle->reject) | 713 | &(tar_handle->reject), |
714 | &excludes | ||
713 | #endif | 715 | #endif |
714 | ); | 716 | ); |
715 | 717 | ||
716 | ctx_flag = opt & (CTX_CREATE | CTX_TEST | CTX_EXTRACT); | 718 | if(opt & CTX_TEST) { |
717 | if(ctx_flag & CTX_TEST) { | ||
718 | if ((tar_handle->action_header == header_list) || | 719 | if ((tar_handle->action_header == header_list) || |
719 | (tar_handle->action_header == header_verbose_list)) { | 720 | (tar_handle->action_header == header_verbose_list)) { |
720 | tar_handle->action_header = header_verbose_list; | 721 | tar_handle->action_header = header_verbose_list; |
@@ -722,10 +723,10 @@ int tar_main(int argc, char **argv) | |||
722 | tar_handle->action_header = header_list; | 723 | tar_handle->action_header = header_list; |
723 | } | 724 | } |
724 | } | 725 | } |
725 | if(ctx_flag & CTX_EXTRACT) { | 726 | if(opt & CTX_EXTRACT) { |
726 | if (tar_handle->action_data != data_extract_to_stdout) | 727 | if (tar_handle->action_data != data_extract_to_stdout) |
727 | tar_handle->action_data = data_extract_all; | 728 | tar_handle->action_data = data_extract_all; |
728 | } | 729 | } |
729 | if(opt & TAR_OPT_2STDOUT) { | 730 | if(opt & TAR_OPT_2STDOUT) { |
730 | /* To stdout */ | 731 | /* To stdout */ |
731 | tar_handle->action_data = data_extract_to_stdout; | 732 | tar_handle->action_data = data_extract_to_stdout; |
@@ -734,7 +735,7 @@ int tar_main(int argc, char **argv) | |||
734 | if ((tar_handle->action_header == header_list) || | 735 | if ((tar_handle->action_header == header_list) || |
735 | (tar_handle->action_header == header_verbose_list)) | 736 | (tar_handle->action_header == header_verbose_list)) |
736 | { | 737 | { |
737 | tar_handle->action_header = header_verbose_list; | 738 | tar_handle->action_header = header_verbose_list; |
738 | } else { | 739 | } else { |
739 | tar_handle->action_header = header_list; | 740 | tar_handle->action_header = header_list; |
740 | } | 741 | } |
@@ -759,12 +760,15 @@ int tar_main(int argc, char **argv) | |||
759 | } | 760 | } |
760 | #endif | 761 | #endif |
761 | #ifdef CONFIG_FEATURE_TAR_FROM | 762 | #ifdef CONFIG_FEATURE_TAR_FROM |
762 | if(opt & TAR_OPT_EXCLUDE_FROM) { | 763 | tar_handle->reject = append_file_list_to_list(tar_handle->reject); |
763 | tar_handle->reject = append_file_list_to_list(tar_handle->reject); | 764 | /* Append excludes to reject */ |
764 | } | 765 | while(excludes) { |
765 | if(opt & TAR_OPT_INCLUDE_FROM) { | 766 | llist_t *temp = excludes->link; |
766 | tar_handle->accept = append_file_list_to_list(tar_handle->accept); | 767 | excludes->link = tar_handle->reject; |
767 | } | 768 | tar_handle->reject = excludes; |
769 | excludes = temp; | ||
770 | } | ||
771 | tar_handle->accept = append_file_list_to_list(tar_handle->accept); | ||
768 | #endif | 772 | #endif |
769 | 773 | ||
770 | /* Check if we are reading from stdin */ | 774 | /* Check if we are reading from stdin */ |