aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2001-04-12 13:49:09 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2001-04-12 13:49:09 +0000
commit3e2ab88ee2e488df1b674655f0038729a635aa52 (patch)
tree40aecd08a39f0f1ad7074f2a1003ace79bb4c641
parentc9cac5be236475e91af1865a2dae2c2af5f19fd6 (diff)
downloadbusybox-w32-3e2ab88ee2e488df1b674655f0038729a635aa52.tar.gz
busybox-w32-3e2ab88ee2e488df1b674655f0038729a635aa52.tar.bz2
busybox-w32-3e2ab88ee2e488df1b674655f0038729a635aa52.zip
New dpkg-deb function -t, stands for --fsys-tarfile
-rw-r--r--applets/usage.h6
-rw-r--r--archival/dpkg_deb.c5
-rw-r--r--dpkg_deb.c5
-rw-r--r--include/usage.h6
-rw-r--r--libbb/deb_extract.c16
-rw-r--r--libbb/untar.c21
-rw-r--r--usage.h6
7 files changed, 41 insertions, 24 deletions
diff --git a/applets/usage.h b/applets/usage.h
index 5712c4413..31c749e2f 100644
--- a/applets/usage.h
+++ b/applets/usage.h
@@ -265,13 +265,13 @@
265 "WORK IN PROGRESS, only usefull for debian-installer" 265 "WORK IN PROGRESS, only usefull for debian-installer"
266 266
267#define dpkg_deb_trivial_usage \ 267#define dpkg_deb_trivial_usage \
268 "[-cexX] file directory" 268 "[-cefxX] file directory"
269#define dpkg_deb_full_usage \ 269#define dpkg_deb_full_usage \
270 "Perform actions on debian packages (.debs)\n\n" \ 270 "Perform actions on debian packages (.debs)\n\n" \
271 "Options:\n" \ 271 "Options:\n" \
272 "\t-c\tList contents of filesystem tree (verbose)\n" \ 272 "\t-c\tList contents of filesystem tree\n" \
273 "\t-l\tList contents of filesystem tree (.list format)\n" \
274 "\t-e\tExtract control files to directory\n" \ 273 "\t-e\tExtract control files to directory\n" \
274 "\t-f\tExtract filesystem tree to stdout in tar format\n" \
275 "\t-x\tExctract packages filesystem tree to directory\n" \ 275 "\t-x\tExctract packages filesystem tree to directory\n" \
276 "\t-X\tVerbose extract" 276 "\t-X\tVerbose extract"
277#define dpkg_deb_example_usage \ 277#define dpkg_deb_example_usage \
diff --git a/archival/dpkg_deb.c b/archival/dpkg_deb.c
index 6653f2a7c..3bec8cfc7 100644
--- a/archival/dpkg_deb.c
+++ b/archival/dpkg_deb.c
@@ -24,7 +24,7 @@ extern int dpkg_deb_main(int argc, char **argv)
24 int opt = 0; 24 int opt = 0;
25 int optflag = 0; 25 int optflag = 0;
26 26
27 while ((opt = getopt(argc, argv, "cexXl")) != -1) { 27 while ((opt = getopt(argc, argv, "cetXxl")) != -1) {
28 switch (opt) { 28 switch (opt) {
29 case 'c': 29 case 'c':
30 optflag |= extract_contents; 30 optflag |= extract_contents;
@@ -32,6 +32,9 @@ extern int dpkg_deb_main(int argc, char **argv)
32 case 'e': 32 case 'e':
33 optflag |= extract_control; 33 optflag |= extract_control;
34 break; 34 break;
35 case 't':
36 optflag |= extract_fsys_tarfile;
37 break;
35 case 'X': 38 case 'X':
36 optflag |= extract_verbose_extract; 39 optflag |= extract_verbose_extract;
37 break; 40 break;
diff --git a/dpkg_deb.c b/dpkg_deb.c
index 6653f2a7c..3bec8cfc7 100644
--- a/dpkg_deb.c
+++ b/dpkg_deb.c
@@ -24,7 +24,7 @@ extern int dpkg_deb_main(int argc, char **argv)
24 int opt = 0; 24 int opt = 0;
25 int optflag = 0; 25 int optflag = 0;
26 26
27 while ((opt = getopt(argc, argv, "cexXl")) != -1) { 27 while ((opt = getopt(argc, argv, "cetXxl")) != -1) {
28 switch (opt) { 28 switch (opt) {
29 case 'c': 29 case 'c':
30 optflag |= extract_contents; 30 optflag |= extract_contents;
@@ -32,6 +32,9 @@ extern int dpkg_deb_main(int argc, char **argv)
32 case 'e': 32 case 'e':
33 optflag |= extract_control; 33 optflag |= extract_control;
34 break; 34 break;
35 case 't':
36 optflag |= extract_fsys_tarfile;
37 break;
35 case 'X': 38 case 'X':
36 optflag |= extract_verbose_extract; 39 optflag |= extract_verbose_extract;
37 break; 40 break;
diff --git a/include/usage.h b/include/usage.h
index 5712c4413..31c749e2f 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -265,13 +265,13 @@
265 "WORK IN PROGRESS, only usefull for debian-installer" 265 "WORK IN PROGRESS, only usefull for debian-installer"
266 266
267#define dpkg_deb_trivial_usage \ 267#define dpkg_deb_trivial_usage \
268 "[-cexX] file directory" 268 "[-cefxX] file directory"
269#define dpkg_deb_full_usage \ 269#define dpkg_deb_full_usage \
270 "Perform actions on debian packages (.debs)\n\n" \ 270 "Perform actions on debian packages (.debs)\n\n" \
271 "Options:\n" \ 271 "Options:\n" \
272 "\t-c\tList contents of filesystem tree (verbose)\n" \ 272 "\t-c\tList contents of filesystem tree\n" \
273 "\t-l\tList contents of filesystem tree (.list format)\n" \
274 "\t-e\tExtract control files to directory\n" \ 273 "\t-e\tExtract control files to directory\n" \
274 "\t-f\tExtract filesystem tree to stdout in tar format\n" \
275 "\t-x\tExctract packages filesystem tree to directory\n" \ 275 "\t-x\tExctract packages filesystem tree to directory\n" \
276 "\t-X\tVerbose extract" 276 "\t-X\tVerbose extract"
277#define dpkg_deb_example_usage \ 277#define dpkg_deb_example_usage \
diff --git a/libbb/deb_extract.c b/libbb/deb_extract.c
index e982c14bb..d3e615305 100644
--- a/libbb/deb_extract.c
+++ b/libbb/deb_extract.c
@@ -26,6 +26,7 @@
26#include <fcntl.h> 26#include <fcntl.h>
27#include <unistd.h> 27#include <unistd.h>
28#include <stdlib.h> 28#include <stdlib.h>
29#include <string.h>
29#include <signal.h> 30#include <signal.h>
30#include "libbb.h" 31#include "libbb.h"
31 32
@@ -42,14 +43,9 @@ extern int deb_extract(const char *package_filename, int function, char *target_
42 case (extract_control): 43 case (extract_control):
43 ared_file = xstrdup("control.tar.gz"); 44 ared_file = xstrdup("control.tar.gz");
44 break; 45 break;
45 case (extract_contents): 46 default:
46 case (extract_extract):
47 case (extract_verbose_extract):
48 case (extract_list):
49 ared_file = xstrdup("data.tar.gz"); 47 ared_file = xstrdup("data.tar.gz");
50 break; 48 break;
51 default:
52 error_msg("Unknown extraction function");
53 } 49 }
54 50
55 /* open the debian package to be worked on */ 51 /* open the debian package to be worked on */
@@ -71,9 +67,11 @@ extern int deb_extract(const char *package_filename, int function, char *target_
71 /* open a stream of decompressed data */ 67 /* open a stream of decompressed data */
72 uncompressed_file = fdopen(gz_open(deb_file, &gunzip_pid), "r"); 68 uncompressed_file = fdopen(gz_open(deb_file, &gunzip_pid), "r");
73 69
74 /* get a list of all tar headers inside the .gz file */ 70 if (function & extract_fsys_tarfile) {
75 untar(uncompressed_file, function, target_dir); 71 copy_file_chunk(uncompressed_file, stdout, -1);
76 72 } else {
73 untar(uncompressed_file, function, target_dir);
74 }
77 /* we are deliberately terminating the child so we can safely ignore this */ 75 /* we are deliberately terminating the child so we can safely ignore this */
78 gz_close(gunzip_pid); 76 gz_close(gunzip_pid);
79 77
diff --git a/libbb/untar.c b/libbb/untar.c
index 9f7bd303c..11c55df7c 100644
--- a/libbb/untar.c
+++ b/libbb/untar.c
@@ -55,13 +55,26 @@ extern int untar(FILE *src_tar_file, int untar_function, char *base_path)
55 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) {
56 long sum = 0; 56 long sum = 0;
57 char *dir = NULL; 57 char *dir = NULL;
58
59 if (ferror(src_tar_file) || feof(src_tar_file)) {
60 break;
61 }
58 62
59 uncompressed_count += 512; 63 uncompressed_count += 512;
60 64
61 /* Check header has valid magic */ 65 /* Check header has valid magic */
62 if (strncmp(raw_tar_header.magic, "ustar", 5) != 0) { 66 if (strncmp(raw_tar_header.magic, "ustar", 5) != 0) {
63 /* Put this pack after TODO (check child still alive) is done */ 67/*
64 error_msg("Invalid tar magic"); 68 * FIXME, Need HELP with this
69 *
70 * This has to fail silently or it incorrectly reports errors when called from
71 * deb_extract.
72 * The problem is deb_extract decompresses the .gz file in a child process and
73 * untar reads from the child proccess. The child process finishes and exits,
74 * but fread reads 0's from the src_tar_file even though the child
75 * closed its handle.
76 */
77// error_msg("Invalid tar magic");
65 break; 78 break;
66 } 79 }
67 80
@@ -109,7 +122,7 @@ extern int untar(FILE *src_tar_file, int untar_function, char *base_path)
109 122
110 } 123 }
111*/ 124*/
112 if (untar_function & (extract_verbose_extract | extract_contents)) { 125 if (untar_function & (extract_contents | extract_verbose_extract)) {
113 printf("%s\n", raw_tar_header.name); 126 printf("%s\n", raw_tar_header.name);
114 } 127 }
115 128
@@ -144,7 +157,7 @@ extern int untar(FILE *src_tar_file, int untar_function, char *base_path)
144 break; 157 break;
145 } 158 }
146 case '5': 159 case '5':
147 if (untar_function & (extract_extract | extract_verbose_extract)) { 160 if (untar_function & extract_extract) {
148 if (create_path(dir, mode) != TRUE) { 161 if (create_path(dir, mode) != TRUE) {
149 free(dir); 162 free(dir);
150 perror_msg("%s: Cannot mkdir", raw_tar_header.name); 163 perror_msg("%s: Cannot mkdir", raw_tar_header.name);
diff --git a/usage.h b/usage.h
index 5712c4413..31c749e2f 100644
--- a/usage.h
+++ b/usage.h
@@ -265,13 +265,13 @@
265 "WORK IN PROGRESS, only usefull for debian-installer" 265 "WORK IN PROGRESS, only usefull for debian-installer"
266 266
267#define dpkg_deb_trivial_usage \ 267#define dpkg_deb_trivial_usage \
268 "[-cexX] file directory" 268 "[-cefxX] file directory"
269#define dpkg_deb_full_usage \ 269#define dpkg_deb_full_usage \
270 "Perform actions on debian packages (.debs)\n\n" \ 270 "Perform actions on debian packages (.debs)\n\n" \
271 "Options:\n" \ 271 "Options:\n" \
272 "\t-c\tList contents of filesystem tree (verbose)\n" \ 272 "\t-c\tList contents of filesystem tree\n" \
273 "\t-l\tList contents of filesystem tree (.list format)\n" \
274 "\t-e\tExtract control files to directory\n" \ 273 "\t-e\tExtract control files to directory\n" \
274 "\t-f\tExtract filesystem tree to stdout in tar format\n" \
275 "\t-x\tExctract packages filesystem tree to directory\n" \ 275 "\t-x\tExctract packages filesystem tree to directory\n" \
276 "\t-X\tVerbose extract" 276 "\t-X\tVerbose extract"
277#define dpkg_deb_example_usage \ 277#define dpkg_deb_example_usage \