summaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
authorRob Landley2005-10-15 03:06:21 +0000
committerRob Landley2005-10-15 03:06:21 +0000
commit3ee6c24ea29c073e67f9aaf04ccd6436aeb99e1f (patch)
treee7357032f4a1205f8c609aba4b2ca4e2b7bfc292 /archival
parentf704b27b5bb8bd5acaed9464714db34ccef06cc8 (diff)
downloadbusybox-3ee6c24ea29c073e67f9aaf04ccd6436aeb99e1f.zip
busybox-3ee6c24ea29c073e67f9aaf04ccd6436aeb99e1f.tar.gz
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. :)
Diffstat (limited to 'archival')
-rw-r--r--archival/tar.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/archival/tar.c b/archival/tar.c
index 7cfb495..81edc3f 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -59,12 +59,12 @@
# define TAR_MAGIC "ustar" /* ustar and a null */
# define TAR_VERSION " " /* Be compatable with GNU tar format */
-static const int TAR_BLOCK_SIZE = 512;
-static const int TAR_MAGIC_LEN = 6;
-static const int TAR_VERSION_LEN = 2;
+#define TAR_BLOCK_SIZE 512
+#define TAR_MAGIC_LEN 6
+#define TAR_VERSION_LEN 2
/* POSIX tar Header Block, from POSIX 1003.1-1990 */
-enum { NAME_SIZE = 100 }; /* because gcc won't let me use 'static const int' */
+#define NAME_SIZE 100
struct TarHeader { /* byte offset */
char name[NAME_SIZE]; /* 0-99 */
char mode[8]; /* 100-107 */
@@ -670,6 +670,7 @@ static const struct option tar_long_options[] = {
# ifdef CONFIG_FEATURE_TAR_FROM
{ "files-from", 1, NULL, 'T' },
{ "exclude-from", 1, NULL, 'X' },
+ { "exclude", 1, NULL, '\n' },
# endif
# ifdef CONFIG_FEATURE_TAR_GZIP
{ "gzip", 0, NULL, 'z' },
@@ -688,7 +689,7 @@ int tar_main(int argc, char **argv)
char *base_dir = NULL;
const char *tar_filename = "-";
unsigned long opt;
- unsigned long ctx_flag = 0;
+ llist_t *excludes;
/* Initialise default values */
@@ -697,9 +698,9 @@ int tar_main(int argc, char **argv)
/* Prepend '-' to the first argument if required */
#ifdef CONFIG_FEATURE_TAR_CREATE
- bb_opt_complementally = "--:-1:X::T::c:t:x:?:c--tx:t--cx:x--ct";
+ bb_opt_complementally = "--:-1:X::T::\n::c:t:x:?:c--tx:t--cx:x--ct";
#else
- bb_opt_complementally = "--:-1:X::T::t:x:?:t--x:x--t";
+ bb_opt_complementally = "--:-1:X::T::\n::t:x:?:t--x:x--t";
#endif
#ifdef CONFIG_FEATURE_TAR_LONG_OPTIONS
bb_applet_long_options = tar_long_options;
@@ -709,12 +710,12 @@ int tar_main(int argc, char **argv)
&tar_filename /* archive filename */
#ifdef CONFIG_FEATURE_TAR_FROM
, &(tar_handle->accept),
- &(tar_handle->reject)
+ &(tar_handle->reject),
+ &excludes
#endif
);
-
- ctx_flag = opt & (CTX_CREATE | CTX_TEST | CTX_EXTRACT);
- if(ctx_flag & CTX_TEST) {
+
+ if(opt & CTX_TEST) {
if ((tar_handle->action_header == header_list) ||
(tar_handle->action_header == header_verbose_list)) {
tar_handle->action_header = header_verbose_list;
@@ -722,10 +723,10 @@ int tar_main(int argc, char **argv)
tar_handle->action_header = header_list;
}
}
- if(ctx_flag & CTX_EXTRACT) {
+ if(opt & CTX_EXTRACT) {
if (tar_handle->action_data != data_extract_to_stdout)
tar_handle->action_data = data_extract_all;
- }
+ }
if(opt & TAR_OPT_2STDOUT) {
/* To stdout */
tar_handle->action_data = data_extract_to_stdout;
@@ -734,7 +735,7 @@ int tar_main(int argc, char **argv)
if ((tar_handle->action_header == header_list) ||
(tar_handle->action_header == header_verbose_list))
{
- tar_handle->action_header = header_verbose_list;
+ tar_handle->action_header = header_verbose_list;
} else {
tar_handle->action_header = header_list;
}
@@ -759,12 +760,15 @@ int tar_main(int argc, char **argv)
}
#endif
#ifdef CONFIG_FEATURE_TAR_FROM
- if(opt & TAR_OPT_EXCLUDE_FROM) {
- tar_handle->reject = append_file_list_to_list(tar_handle->reject);
- }
- if(opt & TAR_OPT_INCLUDE_FROM) {
- tar_handle->accept = append_file_list_to_list(tar_handle->accept);
- }
+ tar_handle->reject = append_file_list_to_list(tar_handle->reject);
+ /* Append excludes to reject */
+ while(excludes) {
+ llist_t *temp = excludes->link;
+ excludes->link = tar_handle->reject;
+ tar_handle->reject = excludes;
+ excludes = temp;
+ }
+ tar_handle->accept = append_file_list_to_list(tar_handle->accept);
#endif
/* Check if we are reading from stdin */