summaryrefslogtreecommitdiff
path: root/apt-pkg/edsp/edspindexfile.cc
blob: 058cef63689ba80356187fa9e90b69a7b9a4f358 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// -*- mode: cpp; mode: fold -*-
// Description								/*{{{*/
/* ######################################################################
   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
   ##################################################################### */
									/*}}}*/
// Include Files							/*{{{*/
#include <config.h>

#include <apt-pkg/edspindexfile.h>
#include <apt-pkg/edsplistparser.h>
#include <apt-pkg/sourcelist.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/progress.h>
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/acquire-item.h>

#include <sys/stat.h>
									/*}}}*/

// 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;
   if (File != "stdin")
      Pkg.Open(File, FileFd::ReadOnly);
   else
      Pkg.OpenDescriptor(STDIN_FILENO, FileFd::ReadOnly);
   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("edsp::scenario");

   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 = "EDSP scenario file";};
};
static edspIFType _apt_Universe;

const pkgIndexFile::Type *edspIndex::GetType() const
{
   return &_apt_Universe;
}
									/*}}}*/