From 6d38011bb93451dd9da3294614d821c77ac91687 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 30 Mar 2011 17:23:43 +0200 Subject: add a first round of stuff needed for talking between APT and solvers based on a very early draft for EDSP by Stefano APT can now write a scenario as well as load most stuff from it. --- apt-pkg/edsp/edspindexfile.cc | 74 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 apt-pkg/edsp/edspindexfile.cc (limited to 'apt-pkg/edsp/edspindexfile.cc') diff --git a/apt-pkg/edsp/edspindexfile.cc b/apt-pkg/edsp/edspindexfile.cc new file mode 100644 index 000000000..5a9d5aacd --- /dev/null +++ b/apt-pkg/edsp/edspindexfile.cc @@ -0,0 +1,74 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +/* ###################################################################### + The universe file is designed to work as an intermediate file between + APT and the resolver. Its on propose very similar to a dpkg status file + ##################################################################### */ + /*}}}*/ +// Include Files /*{{{*/ +#include +#include +#include +#include +#include +#include +#include +#include + +#include + /*}}}*/ + +// edspIndex::edspIndex - Constructor /*{{{*/ +// --------------------------------------------------------------------- +/* */ +edspIndex::edspIndex(string File) : debStatusIndex(File) +{ +} + /*}}}*/ +// StatusIndex::Merge - Load the index file into a cache /*{{{*/ +bool edspIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const +{ + FileFd Pkg(File,FileFd::ReadOnlyGzip); + if (_error->PendingError() == true) + return false; + edspListParser Parser(&Pkg); + if (_error->PendingError() == true) + return false; + + if (Prog != NULL) + Prog->SubProgress(0,File); + if (Gen.SelectFile(File,string(),*this) == false) + return _error->Error("Problem with SelectFile %s",File.c_str()); + + // Store the IMS information + pkgCache::PkgFileIterator CFile = Gen.GetCurFile(); + struct stat St; + if (fstat(Pkg.Fd(),&St) != 0) + return _error->Errno("fstat","Failed to stat"); + CFile->Size = St.st_size; + CFile->mtime = St.st_mtime; + CFile->Archive = Gen.WriteUniqString("universe"); + + if (Gen.MergeList(Parser) == false) + return _error->Error("Problem with MergeList %s",File.c_str()); + return true; +} + /*}}}*/ +// Index File types for APT /*{{{*/ +class edspIFType: public pkgIndexFile::Type +{ + public: + virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const + { + // we don't have a record parser for this type as the file is not presistent + return NULL; + }; + edspIFType() {Label = "APT universe file";}; +}; +static edspIFType _apt_Universe; + +const pkgIndexFile::Type *edspIndex::GetType() const +{ + return &_apt_Universe; +} + /*}}}*/ -- cgit v1.2.3 From 41ceaf02483a826d5797cf0bd61bd7b6013733a8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 31 Mar 2011 11:47:01 +0200 Subject: add a special scenario filename for using stdin --- apt-pkg/edsp/edspindexfile.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'apt-pkg/edsp/edspindexfile.cc') diff --git a/apt-pkg/edsp/edspindexfile.cc b/apt-pkg/edsp/edspindexfile.cc index 5a9d5aacd..366325d0f 100644 --- a/apt-pkg/edsp/edspindexfile.cc +++ b/apt-pkg/edsp/edspindexfile.cc @@ -28,7 +28,11 @@ edspIndex::edspIndex(string File) : debStatusIndex(File) // StatusIndex::Merge - Load the index file into a cache /*{{{*/ bool edspIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const { - FileFd Pkg(File,FileFd::ReadOnlyGzip); + FileFd Pkg; + if (File != "stdin") + Pkg.Open(File, FileFd::ReadOnly); + else + Pkg.OpenDescriptor(STDIN_FILENO, FileFd::ReadOnly); if (_error->PendingError() == true) return false; edspListParser Parser(&Pkg); -- cgit v1.2.3 From e0a78caad639a3fa8d50edf3374a06805ab86315 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 31 Mar 2011 11:58:24 +0200 Subject: rename the 'universe' to 'scenario' to reflect the naming in the draft --- apt-pkg/edsp/edspindexfile.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'apt-pkg/edsp/edspindexfile.cc') diff --git a/apt-pkg/edsp/edspindexfile.cc b/apt-pkg/edsp/edspindexfile.cc index 366325d0f..f5881e663 100644 --- a/apt-pkg/edsp/edspindexfile.cc +++ b/apt-pkg/edsp/edspindexfile.cc @@ -1,7 +1,7 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ /* ###################################################################### - The universe file is designed to work as an intermediate file between + The scenario file is designed to work as an intermediate file between APT and the resolver. Its on propose very similar to a dpkg status file ##################################################################### */ /*}}}*/ @@ -51,7 +51,7 @@ bool edspIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const return _error->Errno("fstat","Failed to stat"); CFile->Size = St.st_size; CFile->mtime = St.st_mtime; - CFile->Archive = Gen.WriteUniqString("universe"); + CFile->Archive = Gen.WriteUniqString("edsp::scenario"); if (Gen.MergeList(Parser) == false) return _error->Error("Problem with MergeList %s",File.c_str()); @@ -67,7 +67,7 @@ class edspIFType: public pkgIndexFile::Type // we don't have a record parser for this type as the file is not presistent return NULL; }; - edspIFType() {Label = "APT universe file";}; + edspIFType() {Label = "EDSP scenario file";}; }; static edspIFType _apt_Universe; -- cgit v1.2.3