- snprintf(fn, sizeof(fn), "%s/%s.%u%d", _config->Find("APT::ExtractTemplates::TempDir", TMPDIR).c_str(), prefix, getpid(), i++);
+
+ std::string tempdir = GetTempDir();
+ snprintf(fn, sizeof(fn), "%s/%s.%s.%u%d",
+ _config->Find("APT::ExtractTemplates::TempDir",
+ tempdir.c_str()).c_str(),
+ package, prefix, getpid(), i++);