diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2001-04-12 11:48:02 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2001-04-12 11:48:02 +0000 |
commit | 6785b51280d6b0c00e964e1e9b24ff05d92f5bcc (patch) | |
tree | c9fbaf8bd615cb7871e16a5525f3223543fe69f5 | |
parent | 359c1068719c295b25b2d8b81a6aded5aeb6e23d (diff) | |
download | busybox-w32-6785b51280d6b0c00e964e1e9b24ff05d92f5bcc.tar.gz busybox-w32-6785b51280d6b0c00e964e1e9b24ff05d92f5bcc.tar.bz2 busybox-w32-6785b51280d6b0c00e964e1e9b24ff05d92f5bcc.zip |
dpkg-deb -c works now
-rw-r--r-- | archival/dpkg_deb.c | 15 | ||||
-rw-r--r-- | dpkg_deb.c | 15 | ||||
-rw-r--r-- | libbb/untar.c | 40 |
3 files changed, 36 insertions, 34 deletions
diff --git a/archival/dpkg_deb.c b/archival/dpkg_deb.c index fbdb14e26..6653f2a7c 100644 --- a/archival/dpkg_deb.c +++ b/archival/dpkg_deb.c | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | extern int dpkg_deb_main(int argc, char **argv) | 21 | extern int dpkg_deb_main(int argc, char **argv) |
22 | { | 22 | { |
23 | char *target_dir = NULL; | 23 | char *target_dir; |
24 | int opt = 0; | 24 | int opt = 0; |
25 | int optflag = 0; | 25 | int optflag = 0; |
26 | 26 | ||
@@ -50,9 +50,10 @@ extern int dpkg_deb_main(int argc, char **argv) | |||
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
53 | if (((optind + 1 ) > argc) || (optflag == 0)) { | 53 | if (optind == argc) { |
54 | show_usage(); | 54 | show_usage(); |
55 | } | 55 | } |
56 | |||
56 | switch (optflag) { | 57 | switch (optflag) { |
57 | case (extract_control): | 58 | case (extract_control): |
58 | case (extract_extract): | 59 | case (extract_extract): |
@@ -60,13 +61,15 @@ extern int dpkg_deb_main(int argc, char **argv) | |||
60 | if ( (optind + 1) == argc ) { | 61 | if ( (optind + 1) == argc ) { |
61 | target_dir = (char *) xmalloc(7); | 62 | target_dir = (char *) xmalloc(7); |
62 | strcpy(target_dir, "DEBIAN"); | 63 | strcpy(target_dir, "DEBIAN"); |
64 | } else { | ||
65 | target_dir = (char *) xmalloc(strlen(argv[optind + 1]) + 1); | ||
66 | strcpy(target_dir, argv[optind + 1]); | ||
63 | } | 67 | } |
64 | break; | 68 | break; |
65 | default: { | 69 | default: |
66 | target_dir = (char *) xmalloc(strlen(argv[optind + 1])); | 70 | target_dir = NULL; |
67 | strcpy(target_dir, argv[optind + 1]); | ||
68 | } | ||
69 | } | 71 | } |
72 | |||
70 | deb_extract(argv[optind], optflag, target_dir); | 73 | deb_extract(argv[optind], optflag, target_dir); |
71 | /* else if (optflag & dpkg_deb_info) { | 74 | /* else if (optflag & dpkg_deb_info) { |
72 | extract_flag = TRUE; | 75 | extract_flag = TRUE; |
diff --git a/dpkg_deb.c b/dpkg_deb.c index fbdb14e26..6653f2a7c 100644 --- a/dpkg_deb.c +++ b/dpkg_deb.c | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | extern int dpkg_deb_main(int argc, char **argv) | 21 | extern int dpkg_deb_main(int argc, char **argv) |
22 | { | 22 | { |
23 | char *target_dir = NULL; | 23 | char *target_dir; |
24 | int opt = 0; | 24 | int opt = 0; |
25 | int optflag = 0; | 25 | int optflag = 0; |
26 | 26 | ||
@@ -50,9 +50,10 @@ extern int dpkg_deb_main(int argc, char **argv) | |||
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
53 | if (((optind + 1 ) > argc) || (optflag == 0)) { | 53 | if (optind == argc) { |
54 | show_usage(); | 54 | show_usage(); |
55 | } | 55 | } |
56 | |||
56 | switch (optflag) { | 57 | switch (optflag) { |
57 | case (extract_control): | 58 | case (extract_control): |
58 | case (extract_extract): | 59 | case (extract_extract): |
@@ -60,13 +61,15 @@ extern int dpkg_deb_main(int argc, char **argv) | |||
60 | if ( (optind + 1) == argc ) { | 61 | if ( (optind + 1) == argc ) { |
61 | target_dir = (char *) xmalloc(7); | 62 | target_dir = (char *) xmalloc(7); |
62 | strcpy(target_dir, "DEBIAN"); | 63 | strcpy(target_dir, "DEBIAN"); |
64 | } else { | ||
65 | target_dir = (char *) xmalloc(strlen(argv[optind + 1]) + 1); | ||
66 | strcpy(target_dir, argv[optind + 1]); | ||
63 | } | 67 | } |
64 | break; | 68 | break; |
65 | default: { | 69 | default: |
66 | target_dir = (char *) xmalloc(strlen(argv[optind + 1])); | 70 | target_dir = NULL; |
67 | strcpy(target_dir, argv[optind + 1]); | ||
68 | } | ||
69 | } | 71 | } |
72 | |||
70 | deb_extract(argv[optind], optflag, target_dir); | 73 | deb_extract(argv[optind], optflag, target_dir); |
71 | /* else if (optflag & dpkg_deb_info) { | 74 | /* else if (optflag & dpkg_deb_info) { |
72 | extract_flag = TRUE; | 75 | extract_flag = TRUE; |
diff --git a/libbb/untar.c b/libbb/untar.c index cb312d597..9f7bd303c 100644 --- a/libbb/untar.c +++ b/libbb/untar.c | |||
@@ -52,18 +52,16 @@ extern int untar(FILE *src_tar_file, int untar_function, char *base_path) | |||
52 | size_t size; | 52 | size_t size; |
53 | mode_t mode; | 53 | mode_t mode; |
54 | 54 | ||
55 | // signal(SIGCHLD, child_died); | ||
56 | |||
57 | while (fread((char *) &raw_tar_header, 1, 512, src_tar_file) == 512) { | 55 | while (fread((char *) &raw_tar_header, 1, 512, src_tar_file) == 512) { |
58 | long sum = 0; | 56 | long sum = 0; |
59 | char *dir; | 57 | char *dir = NULL; |
60 | 58 | ||
61 | uncompressed_count += 512; | 59 | uncompressed_count += 512; |
62 | 60 | ||
63 | /* Check header has valid magic */ | 61 | /* Check header has valid magic */ |
64 | if (strncmp(raw_tar_header.magic, "ustar", 5) != 0) { | 62 | if (strncmp(raw_tar_header.magic, "ustar", 5) != 0) { |
65 | /* Put this pack after TODO (check child still alive) is done */ | 63 | /* Put this pack after TODO (check child still alive) is done */ |
66 | // error_msg("Invalid tar magic"); | 64 | error_msg("Invalid tar magic"); |
67 | break; | 65 | break; |
68 | } | 66 | } |
69 | 67 | ||
@@ -111,11 +109,16 @@ extern int untar(FILE *src_tar_file, int untar_function, char *base_path) | |||
111 | 109 | ||
112 | } | 110 | } |
113 | */ | 111 | */ |
114 | /* extract files */ | 112 | if (untar_function & (extract_verbose_extract | extract_contents)) { |
115 | dir = xmalloc(strlen(raw_tar_header.name) + strlen(base_path) + 2); | 113 | printf("%s\n", raw_tar_header.name); |
114 | } | ||
116 | 115 | ||
117 | sprintf(dir, "%s/%s", base_path, raw_tar_header.name); | 116 | /* extract files */ |
118 | create_path(dir, 0777); | 117 | if (base_path != NULL) { |
118 | dir = xmalloc(strlen(raw_tar_header.name) + strlen(base_path) + 2); | ||
119 | sprintf(dir, "%s/%s", base_path, raw_tar_header.name); | ||
120 | create_path(dir, 0777); | ||
121 | } | ||
119 | switch (raw_tar_header.typeflag ) { | 122 | switch (raw_tar_header.typeflag ) { |
120 | case '0': | 123 | case '0': |
121 | case '\0': | 124 | case '\0': |
@@ -124,8 +127,6 @@ extern int untar(FILE *src_tar_file, int untar_function, char *base_path) | |||
124 | */ | 127 | */ |
125 | if (raw_tar_header.name[strlen(raw_tar_header.name)-1] != '/') { | 128 | if (raw_tar_header.name[strlen(raw_tar_header.name)-1] != '/') { |
126 | switch (untar_function) { | 129 | switch (untar_function) { |
127 | case (extract_verbose_extract): | ||
128 | printf("%s\n", raw_tar_header.name); | ||
129 | case (extract_extract): { | 130 | case (extract_extract): { |
130 | FILE *dst_file = wfopen(dir, "w"); | 131 | FILE *dst_file = wfopen(dir, "w"); |
131 | copy_file_chunk(src_tar_file, dst_file, size); | 132 | copy_file_chunk(src_tar_file, dst_file, size); |
@@ -143,17 +144,12 @@ extern int untar(FILE *src_tar_file, int untar_function, char *base_path) | |||
143 | break; | 144 | break; |
144 | } | 145 | } |
145 | case '5': | 146 | case '5': |
146 | switch (untar_function) { | 147 | if (untar_function & (extract_extract | extract_verbose_extract)) { |
147 | case (extract_verbose_extract): | 148 | if (create_path(dir, mode) != TRUE) { |
148 | printf("%s\n", raw_tar_header.name); | 149 | free(dir); |
149 | case (extract_extract): | 150 | perror_msg("%s: Cannot mkdir", raw_tar_header.name); |
150 | if (create_path(dir, mode) != TRUE) { | 151 | return(EXIT_FAILURE); |
151 | free(dir); | 152 | } |
152 | perror_msg("%s: Cannot mkdir", raw_tar_header.name); | ||
153 | return(EXIT_FAILURE); | ||
154 | } | ||
155 | break; | ||
156 | default: | ||
157 | } | 153 | } |
158 | break; | 154 | break; |
159 | case '1': | 155 | case '1': |
@@ -185,7 +181,7 @@ extern int untar(FILE *src_tar_file, int untar_function, char *base_path) | |||
185 | free(dir); | 181 | free(dir); |
186 | return(EXIT_FAILURE); | 182 | return(EXIT_FAILURE); |
187 | } | 183 | } |
188 | free(dir); | 184 | // free(dir); |
189 | } | 185 | } |
190 | return(EXIT_SUCCESS); | 186 | return(EXIT_SUCCESS); |
191 | } | 187 | } |