X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/259ca5969a2efbb1a541c7a9e9391531689cd865..e7c82918f3abfb49d794bbe697f8721f25333b77:/cmdline/apt-extracttemplates.cc diff --git a/cmdline/apt-extracttemplates.cc b/cmdline/apt-extracttemplates.cc index 9261f6805..8fe15fdf9 100644 --- a/cmdline/apt-extracttemplates.cc +++ b/cmdline/apt-extracttemplates.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: apt-extracttemplates.cc,v 1.12 2002/11/09 22:41:55 doogie Exp $ +// $Id: apt-extracttemplates.cc,v 1.15 2003/07/26 00:00:11 mdz Exp $ /* ###################################################################### APT Extract Templates - Program to extract debconf config and template @@ -13,6 +13,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -28,19 +30,23 @@ #include #include #include - +#include + #include #include #include #include +#include + #include -#include -#include -#include #include "apt-extracttemplates.h" + +#include /*}}}*/ +using namespace std; + #define TMPDIR "/tmp" pkgCache *DebFile::Cache = 0; @@ -49,8 +55,8 @@ pkgCache *DebFile::Cache = 0; // --------------------------------------------------------------------- /* */ DebFile::DebFile(const char *debfile) - : File(debfile, FileFd::ReadOnly), Control(0), DepOp(0), - PreDepOp(0), Config(0), Template(0), Which(None) + : File(debfile, FileFd::ReadOnly), Size(0), Control(NULL), ControlLen(0), + DepOp(0), PreDepOp(0), Config(0), Template(0), Which(None) { } /*}}}*/ @@ -97,7 +103,7 @@ bool DebFile::Go() if (File.Seek(Member->Start) == false) return false; - ExtractTar Tar(File, Member->Size); + ExtractTar Tar(File, Member->Size,"gzip"); return Tar.Go(*this); } /*}}}*/ @@ -220,8 +226,8 @@ bool DebFile::ParseInfo() /* */ int ShowHelp(void) { - ioprintf(cout,_("%s %s for %s %s compiled on %s %s\n"),PACKAGE,VERSION, - COMMON_OS,COMMON_CPU,__DATE__,__TIME__); + ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, + COMMON_ARCH,__DATE__,__TIME__); if (_config->FindB("version") == true) return 0; @@ -236,7 +242,7 @@ int ShowHelp(void) " -h This help text\n" " -t Set the temp dir\n" " -c=? Read this configuration file\n" - " -o=? Set an arbitary configuration option, eg -o dir::cache=/tmp\n"); + " -o=? Set an arbitrary configuration option, eg -o dir::cache=/tmp\n"); return 0; } /*}}}*/ @@ -247,7 +253,15 @@ string WriteFile(const char *package, const char *prefix, const char *data) { char fn[512]; static int i; - snprintf(fn, sizeof(fn), "%s/%s.%s.%u%d", _config->Find("APT::ExtractTemplates::TempDir", TMPDIR).c_str(), package, prefix, getpid(), i++); + const char *tempdir = NULL; + + tempdir = getenv("TMPDIR"); + if (tempdir == NULL) + tempdir = TMPDIR; + + snprintf(fn, sizeof(fn), "%s/%s.%s.%u%d", + _config->Find("APT::ExtractTemplates::TempDir", tempdir).c_str(), + package, prefix, getpid(), i++); FileFd f; if (data == NULL) data = ""; @@ -268,8 +282,8 @@ string WriteFile(const char *package, const char *prefix, const char *data) /* */ void WriteConfig(const DebFile &file) { - string templatefile = WriteFile(file.package, "template", file.Template); - string configscript = WriteFile(file.package, "config", file.Config); + string templatefile = WriteFile(file.Package.c_str(), "template", file.Template); + string configscript = WriteFile(file.Package.c_str(), "config", file.Config); if (templatefile.empty() == true || configscript.empty() == true) return; @@ -286,8 +300,7 @@ bool Go(CommandLine &CmdL) MMap *Map = 0; pkgSourceList List; List.ReadMainList(); - OpProgress Prog; - pkgMakeStatusCache(List,Prog,&Map,true); + pkgCacheGenerator::MakeStatusCache(List,NULL,&Map,true); if (Map == 0) return false; DebFile::Cache = new pkgCache(Map); @@ -338,8 +351,7 @@ bool Go(CommandLine &CmdL) return !_error->PendingError(); } /*}}}*/ - -int main(int argc, const char **argv) +int main(int argc, const char **argv) /*{{{*/ { CommandLine::Args Args[] = { {'h',"help","help",0}, @@ -381,3 +393,4 @@ int main(int argc, const char **argv) return 0; } + /*}}}*/