|
|
@@ -104,8 +104,8 @@ read_line(int fd, char *buf, size_t min_size, size_t max_size)
|
|
|
}
|
|
|
|
|
|
void
|
|
|
-extracthalf(const char *debar, const char *dir, const char *taroption,
|
|
|
- int admininfo)
|
|
|
+extracthalf(const char *debar, const char *dir,
|
|
|
+ enum dpkg_tar_options taroption, int admininfo)
|
|
|
{
|
|
|
struct dpkg_error err;
|
|
|
const char *errstr;
|
|
|
@@ -302,7 +302,19 @@ extracthalf(const char *debar, const char *dir, const char *taroption,
|
|
|
command_init(&cmd, TAR, "tar");
|
|
|
command_add_arg(&cmd, "tar");
|
|
|
|
|
|
- command_add_arg(&cmd, taroption);
|
|
|
+ if ((taroption & DPKG_TAR_LIST) && (taroption & DPKG_TAR_EXTRACT))
|
|
|
+ command_add_arg(&cmd, "-xv");
|
|
|
+ else if (taroption & DPKG_TAR_EXTRACT)
|
|
|
+ command_add_arg(&cmd, "-x");
|
|
|
+ else if (taroption & DPKG_TAR_LIST)
|
|
|
+ command_add_arg(&cmd, "-tv");
|
|
|
+ else
|
|
|
+ internerr("unknown or missing tar action '%d'", taroption);
|
|
|
+
|
|
|
+ if (taroption & DPKG_TAR_PERMS)
|
|
|
+ command_add_arg(&cmd, "-p");
|
|
|
+ if (taroption & DPKG_TAR_NOMTIME)
|
|
|
+ command_add_arg(&cmd, "-m");
|
|
|
|
|
|
command_add_arg(&cmd, "-f");
|
|
|
command_add_arg(&cmd, "-");
|
|
|
@@ -349,7 +361,7 @@ extracthalf(const char *debar, const char *dir, const char *taroption,
|
|
|
}
|
|
|
|
|
|
static int
|
|
|
-controlextractvextract(int admin, const char *taroptions,
|
|
|
+controlextractvextract(int admin, enum dpkg_tar_options taroptions,
|
|
|
const char *const *argv)
|
|
|
{
|
|
|
const char *debar, *dir;
|
|
|
@@ -379,7 +391,7 @@ do_fsystarfile(const char *const *argv)
|
|
|
badusage(_("--%s needs a .deb filename argument"),cipaction->olong);
|
|
|
if (*argv)
|
|
|
badusage(_("--%s takes only one argument (.deb filename)"),cipaction->olong);
|
|
|
- extracthalf(debar, NULL, NULL, 0);
|
|
|
+ extracthalf(debar, NULL, DPKG_TAR_PASSTHROUGH, 0);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -387,16 +399,18 @@ do_fsystarfile(const char *const *argv)
|
|
|
int
|
|
|
do_control(const char *const *argv)
|
|
|
{
|
|
|
- return controlextractvextract(1, "x", argv);
|
|
|
+ return controlextractvextract(1, DPKG_TAR_EXTRACT, argv);
|
|
|
}
|
|
|
|
|
|
int
|
|
|
do_extract(const char *const *argv)
|
|
|
{
|
|
|
+ enum dpkg_tar_options options = DPKG_TAR_EXTRACT | DPKG_TAR_PERMS;
|
|
|
+
|
|
|
if (opt_verbose)
|
|
|
- return controlextractvextract(0, "xpv", argv);
|
|
|
- else
|
|
|
- return controlextractvextract(0, "xp", argv);
|
|
|
+ options |= DPKG_TAR_LIST;
|
|
|
+
|
|
|
+ return controlextractvextract(0, options, argv);
|
|
|
}
|
|
|
|
|
|
int
|
|
|
@@ -410,6 +424,7 @@ do_vextract(const char *const *argv)
|
|
|
int
|
|
|
do_raw_extract(const char *const *argv)
|
|
|
{
|
|
|
+ enum dpkg_tar_options data_options;
|
|
|
const char *debar, *dir;
|
|
|
char *control_dir;
|
|
|
|
|
|
@@ -428,11 +443,12 @@ do_raw_extract(const char *const *argv)
|
|
|
|
|
|
m_asprintf(&control_dir, "%s/%s", dir, EXTRACTCONTROLDIR);
|
|
|
|
|
|
+ data_options = DPKG_TAR_EXTRACT | DPKG_TAR_PERMS;
|
|
|
if (opt_verbose)
|
|
|
- extracthalf(debar, dir, "xpv", 0);
|
|
|
- else
|
|
|
- extracthalf(debar, dir, "xp", 0);
|
|
|
- extracthalf(debar, control_dir, "x", 1);
|
|
|
+ data_options |= DPKG_TAR_LIST;
|
|
|
+
|
|
|
+ extracthalf(debar, dir, data_options, 0);
|
|
|
+ extracthalf(debar, control_dir, DPKG_TAR_EXTRACT, 1);
|
|
|
|
|
|
free(control_dir);
|
|
|
|