Bug#191656: Support TMPDIR in apt-extracttemplates
On Fri, 2 May 2003, Wichert Akkerman wrote:
> diff -wur org/apt-0.5.4/cmdline/apt-extracttemplates.cc apt-0.5.4/cmdline/apt-extracttemplates.cc
> --- org/apt-0.5.4/cmdline/apt-extracttemplates.cc 2001-04-29 07:40:36.000000000 +0200
> +++ apt-0.5.4/cmdline/apt-extracttemplates.cc 2003-05-02 17:31:08.000000000 +0200
> @@ -40,8 +40,6 @@
> #include "apt-extracttemplates.h"
> /*}}}*/
>
> -#define TMPDIR "/tmp"
> -
> pkgCache *DebFile::Cache = 0;
>
> // DebFile::DebFile - Construct the DebFile object /*{{{*/
> @@ -245,8 +243,12 @@
> string WriteFile(const char *prefix, const char *data)
> {
> char fn[512];
> + const char* defaultdir;
> static int i;
> - snprintf(fn, sizeof(fn), "%s/%s.%u%d", _config->Find("APT::ExtractTemplates::TempDir", TMPDIR).c_str(), prefix, getpid(), i++);
> +
> + if ((defaultdir=getenv("TMPDIR"))==NULL)
> + defaultdir="/tmp";
> + snprintf(fn, sizeof(fn), "%s/%s.%u%d", _config->Find("APT::ExtractTemplates::TempDir", defaultdir).c_str(), prefix, getpid(), i++);
> FileFd f;
> if (data == NULL)
> data = "";
Patch is fine, but you should still define TMPDIR "/tmp", instead of
harc-coding it. And then maybe fall back to APT:TempDir then TempDir.
Reply to: