Archive acquire code
authorArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:51:27 +0000 (16:51 +0000)
committerArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:51:27 +0000 (16:51 +0000)
Author: jgg
Date: 1998-11-13 04:23:26 GMT
Archive acquire code

16 files changed:
apt-pkg/acquire-item.cc
apt-pkg/acquire-item.h
apt-pkg/deb/debrecords.cc
apt-pkg/deb/debrecords.h
apt-pkg/deb/dpkgpm.cc [new file with mode: 0644]
apt-pkg/deb/dpkgpm.h [new file with mode: 0644]
apt-pkg/makefile
apt-pkg/packagemanager.cc
apt-pkg/packagemanager.h
apt-pkg/pkgcache.cc
apt-pkg/pkgcachegen.cc
apt-pkg/pkgrecords.cc
apt-pkg/pkgrecords.h
apt-pkg/tagfile.cc
cmdline/apt-cache.cc
cmdline/apt-get.cc

index 7cd43f4..ef58636 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-item.cc,v 1.10 1998/11/12 04:10:52 jgg Exp $
+// $Id: acquire-item.cc,v 1.11 1998/11/13 04:23:26 jgg Exp $
 /* ######################################################################
 
    Acquire Item - Item to acquire
@@ -18,6 +18,7 @@
 #endif
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/configuration.h>
+#include <apt-pkg/error.h>
 #include <strutl.h>
 
 #include <sys/stat.h>
@@ -300,3 +301,97 @@ void pkgAcqIndexRel::Done(string Message,unsigned long Size,string MD5)
    Rename(DestFile,FinalFile);
 }
                                                                        /*}}}*/
+
+// AcqArchive::AcqArchive - Constructor                                        /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
+                            pkgRecords *Recs,pkgCache::VerIterator const &Version) :
+               Item(Owner), Version(Version), Sources(Sources), Recs(Recs)
+{
+   // Select a source
+   pkgCache::VerFileIterator Vf = Version.FileList();
+   for (; Vf.end() == false; Vf++)
+   {
+      // Ignore not source sources
+      if ((Vf.File()->Flags & pkgCache::Flag::NotSource) != 0)
+        continue;
+
+      // Try to cross match against the source list
+      string PkgFile = flNotDir(Vf.File().FileName());
+      pkgSourceList::const_iterator Location;
+      for (Location = Sources->begin(); Location != Sources->end(); Location++)
+        if (PkgFile == URItoFileName(Location->PackagesURI()))
+           break;
+
+      if (Location == Sources->end())
+        continue;
+      
+      // Grab the text package record
+      pkgRecords::Parser &Parse = Recs->Lookup(Vf);
+      if (_error->PendingError() == true)
+        return;
+      
+      PkgFile = Parse.FileName();
+      MD5 = Parse.MD5Hash();
+      if (PkgFile.empty() == true)
+      {
+        _error->Error("Unable to locate a file name for package %s, "
+                      "perhaps the package files are corrupted.",
+                      Version.ParentPkg().Name());
+        return;
+      }
+      
+      // Create the item
+      Desc.URI = Location->ArchiveURI(PkgFile);
+      Desc.Description = Location->ArchiveInfo(Version);
+      Desc.Owner = this;
+      Desc.ShortDesc = Version.ParentPkg().Name();
+      QueueURI(Desc);
+      
+      DestFile = _config->FindDir("Dir::Cache::Archives") + "partial/" + flNotDir(PkgFile);
+      return;
+   }
+   
+  _error->Error("I wasn't able to locate file for the %s package. "
+               "This probably means you need to rerun update.",
+               Version.ParentPkg().Name());
+}
+                                                                       /*}}}*/
+// AcqArchive::Done - Finished fetching                                        /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void pkgAcqArchive::Done(string Message,unsigned long Size,string Md5Hash)
+{
+   Item::Done(Message,Size,MD5);
+   
+   // Check the size
+   if (Size != Version->Size)
+   {
+      _error->Error("Size mismatch for package %s",Version.ParentPkg().Name());
+      return;
+   }
+   
+   // Check the md5
+   if (Md5Hash.empty() == false && MD5.empty() == false)
+   {
+      if (Md5Hash != MD5)
+      {
+        _error->Error("MD5Sum mismatch for package %s",Version.ParentPkg().Name());
+        return;
+      }
+   }
+   
+   // Store the destination filename
+   string FileName = LookupTag(Message,"Filename");
+   if (FileName.empty() == true)
+   {
+      Status = StatError;
+      ErrorText = "Method gave a blank filename";
+      return;
+   }
+   
+   DestFile = FileName;
+   Complete = true;
+}
+                                                                       /*}}}*/
index da650a6..2de1e40 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-item.h,v 1.7 1998/11/11 06:54:14 jgg Exp $
+// $Id: acquire-item.h,v 1.8 1998/11/13 04:23:28 jgg Exp $
 /* ######################################################################
 
    Acquire Item - Item to acquire
@@ -19,6 +19,7 @@
 
 #include <apt-pkg/acquire.h>
 #include <apt-pkg/sourcelist.h>
+#include <apt-pkg/pkgrecords.h>
 
 #ifdef __GNUG__
 #pragma interface "apt-pkg/acquire-item.h"
@@ -95,4 +96,23 @@ class pkgAcqIndexRel : public pkgAcquire::Item
    pkgAcqIndexRel(pkgAcquire *Owner,const pkgSourceList::Item *Location);
 };
 
+// Item class for archive files
+class pkgAcqArchive : public pkgAcquire::Item
+{
+   protected:
+   
+   pkgCache::VerIterator Version;
+   pkgAcquire::ItemDesc Desc;
+   pkgSourceList *Sources;
+   pkgRecords *Recs;
+   string MD5;
+   
+   public:
+   
+   virtual void Done(string Message,unsigned long Size,string Md5Hash);
+   
+   pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
+                pkgRecords *Recs,pkgCache::VerIterator const &Version);
+};
+
 #endif
index c28e11a..c4019b4 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: debrecords.cc,v 1.2 1998/10/08 04:55:02 jgg Exp $
+// $Id: debrecords.cc,v 1.3 1998/11/13 04:23:37 jgg Exp $
 /* ######################################################################
    
    Debian Package Records - Parser for debian package records
@@ -25,7 +25,7 @@ debRecordParser::debRecordParser(FileFd &File) : Tags(File,4*1024)
 // RecordParser::Jump - Jump to a specific record                      /*{{{*/
 // ---------------------------------------------------------------------
 /* */
-bool debRecordParser::Jump(pkgCache::VerFileIterator &Ver)
+bool debRecordParser::Jump(pkgCache::VerFileIterator const &Ver)
 {
    return Tags.Jump(Section,Ver->Offset);
 }
index 6255d79..68fe0f6 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: debrecords.h,v 1.2 1998/10/08 04:55:04 jgg Exp $
+// $Id: debrecords.h,v 1.3 1998/11/13 04:23:38 jgg Exp $
 /* ######################################################################
    
    Debian Package Records - Parser for debian package records
@@ -31,7 +31,7 @@ class debRecordParser : public pkgRecords::Parser
 
    protected:
    
-   virtual bool Jump(pkgCache::VerFileIterator &Ver);
+   virtual bool Jump(pkgCache::VerFileIterator const &Ver);
    
    public:
 
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
new file mode 100644 (file)
index 0000000..75a5c77
--- /dev/null
@@ -0,0 +1,197 @@
+// -*- mode: cpp; mode: fold -*-
+// Description                                                         /*{{{*/
+// $Id: dpkgpm.cc,v 1.1 1998/11/13 04:23:39 jgg Exp $
+/* ######################################################################
+
+   DPKG Package Manager - Provide an interface to dpkg
+   
+   ##################################################################### */
+                                                                       /*}}}*/
+// Includes                                                            /*{{{*/
+#ifdef __GNUG__
+#pragma implementation "apt-pkg/dpkgpm.h"
+#endif
+#include <apt-pkg/dpkgpm.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/configuration.h>
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <signal.h>
+#include <errno.h>
+                                                                       /*}}}*/
+
+// DPkgPM::pkgDPkgPM - Constructor                                     /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+pkgDPkgPM::pkgDPkgPM(pkgDepCache &Cache) : pkgPackageManager(Cache)
+{
+}
+                                                                       /*}}}*/
+// DPkgPM::pkgDPkgPM - Destructor                                      /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+pkgDPkgPM::~pkgDPkgPM()
+{
+}
+                                                                       /*}}}*/
+// DPkgPM::Install - Install a package                                 /*{{{*/
+// ---------------------------------------------------------------------
+/* Add an install operation to the sequence list */
+bool pkgDPkgPM::Install(PkgIterator Pkg,string File)
+{
+   if (File.empty() == true || Pkg.end() == true)
+      return _error->Error("Internal Error, No file name for %s",Pkg.Name());
+
+   List.push_back(Item(Item::Install,Pkg,File));
+   return true;
+}
+                                                                       /*}}}*/
+// DPkgPM::Configure - Configure a package                             /*{{{*/
+// ---------------------------------------------------------------------
+/* Add a configure operation to the sequence list */
+bool pkgDPkgPM::Configure(PkgIterator Pkg)
+{
+   if (Pkg.end() == true)
+      return false;
+   
+   List.push_back(Item(Item::Configure,Pkg));
+   return true;
+}
+                                                                       /*}}}*/
+// DPkgPM::Remove - Remove a package                                   /*{{{*/
+// ---------------------------------------------------------------------
+/* Add a remove operation to the sequence list */
+bool pkgDPkgPM::Remove(PkgIterator Pkg)
+{
+   if (Pkg.end() == true)
+      return false;
+   
+   List.push_back(Item(Item::Remove,Pkg));
+   return true;
+}
+                                                                       /*}}}*/
+// DPkgPM::Go - Run the sequence                                       /*{{{*/
+// ---------------------------------------------------------------------
+/* This globs the operations and calls dpkg */
+bool pkgDPkgPM::Go()
+{
+   for (vector<Item>::iterator I = List.begin(); I != List.end();)
+   {
+      vector<Item>::iterator J = I;
+      for (; J != List.end() && J->Op == I->Op; J++);
+      
+      // Generate the argument list
+      const char *Args[400];
+      if (J - I > 350)
+        J = I + 350;
+      
+      int n= 0;
+      Args[n++] = "dpkg";
+      
+      switch (I->Op)
+      {
+        case Item::Remove:
+        Args[n++] = "--force-depends";
+        Args[n++] = "--force-remove-essential";
+        Args[n++] = "--remove";
+        break;
+        
+        case Item::Configure:
+        Args[n++] = "--configure";
+        break;
+        
+        case Item::Install:
+        Args[n++] = "--unpack";
+        break;
+      }
+      
+      // Write in the file or package names
+      if (I->Op == Item::Install)
+        for (;I != J; I++)
+           Args[n++] = I->File.c_str();
+      else
+        for (;I != J; I++)
+           Args[n++] = I->Pkg.Name();
+      Args[n] = 0;
+      
+/*      for (int k = 0; k != n; k++)
+        cout << Args[k] << ' ';
+      cout << endl;*/
+
+      cout << flush;
+      clog << flush;
+      cerr << flush;
+
+      /* Mask off sig int/quit. We do this because dpkg also does when 
+         it forks scripts. What happens is that when you hit ctrl-c it sends
+        it to all processes in the group. Since dpkg ignores the signal 
+        it doesn't die but we do! So we must also ignore it */
+      signal(SIGQUIT,SIG_IGN);
+      signal(SIGINT,SIG_IGN);
+            
+      // Fork dpkg
+      pid_t Child = fork();
+      if (Child < 0)
+        return _error->Errno("fork","Could't fork");
+      
+      // This is the child
+      if (Child == 0)
+      {
+        signal(SIGQUIT,SIG_DFL);
+        signal(SIGINT,SIG_DFL);
+        signal(SIGWINCH,SIG_DFL);
+        signal(SIGCONT,SIG_DFL);
+        signal(SIGTSTP,SIG_DFL);
+
+        if (chdir(_config->FindDir("Dir::Cache::Archives").c_str()) != 0)
+           exit(100);
+        
+        // Close all of our FDs - just in case
+        for (int K = 3; K != 40; K++)
+           fcntl(K,F_SETFD,FD_CLOEXEC);
+
+        int Flags,dummy;
+        if ((Flags = fcntl(STDIN_FILENO,F_GETFL,dummy)) < 0)
+           exit(100);
+        
+        // Discard everything in stdin before forking dpkg
+        if (fcntl(STDIN_FILENO,F_SETFL,Flags | O_NONBLOCK) < 0)
+           exit(100);
+        
+        while (read(STDIN_FILENO,&dummy,1) == 1);
+        
+        if (fcntl(STDIN_FILENO,F_SETFL,Flags & (~(long)O_NONBLOCK)) < 0)
+           exit(100);
+
+        /* No Job Control Stop Env is a magic dpkg var that prevents it
+           from using sigstop */
+        setenv("DPKG_NO_TSTP","yes",1);
+        execvp("dpkg",(char **)Args);
+        cerr << "Could not exec dpkg!" << endl;
+        exit(100);
+      }      
+
+      // Wait for dpkg
+      int Status = 0;
+      while (waitpid(Child,&Status,0) != Child)
+      {
+        if (errno == EINTR)
+           continue;
+        return _error->Errno("waitpid","Couldn't wait for subprocess");
+      }
+      
+      // Check for an error code.
+      if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0)
+        return _error->Error("Sub-process returned an error code");
+
+      // Restore sig int/quit
+      signal(SIGQUIT,SIG_DFL);
+      signal(SIGINT,SIG_DFL);
+   }
+   return true;
+}
+                                                                       /*}}}*/
diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h
new file mode 100644 (file)
index 0000000..b5f08ea
--- /dev/null
@@ -0,0 +1,49 @@
+// -*- mode: cpp; mode: fold -*-
+// Description                                                         /*{{{*/
+// $Id: dpkgpm.h,v 1.1 1998/11/13 04:23:39 jgg Exp $
+/* ######################################################################
+
+   DPKG Package Manager - Provide an interface to dpkg
+   
+   ##################################################################### */
+                                                                       /*}}}*/
+// Header section: pkglib
+#ifndef PKGLIB_DPKGPM_H
+#define PKGLIB_DPKGPM_H
+
+#ifdef __GNUG__
+#pragma interface "apt-pkg/dpkgpm.h"
+#endif
+
+#include <apt-pkg/packagemanager.h>
+#include <vector>
+
+class pkgDPkgPM : public pkgPackageManager
+{
+   protected:
+   
+   struct Item
+   {
+      enum Ops {Install, Configure, Remove} Op;
+      string File;
+      PkgIterator Pkg;
+      Item(Ops Op,PkgIterator Pkg,string File = "") : Op(Op), 
+            File(File), Pkg(Pkg) {};
+      Item() {};
+      
+   };
+   vector<Item> List;
+      
+   // The Actuall installation implementation
+   virtual bool Install(PkgIterator Pkg,string File);
+   virtual bool Configure(PkgIterator Pkg);
+   virtual bool Remove(PkgIterator Pkg);
+   virtual bool Go();
+   
+   public:
+
+   pkgDPkgPM(pkgDepCache &Cache);
+   virtual ~pkgDPkgPM();
+};
+
+#endif
index 285d012..f981a88 100644 (file)
@@ -27,14 +27,15 @@ SOURCE+= pkgcache.cc version.cc fileutl.cc pkgcachegen.cc depcache.cc \
         acquire-worker.cc acquire-method.cc init.cc templates.cc
 
 # Source code for the debian specific components        
-SOURCE+= deb/deblistparser.cc deb/debrecords.cc
+SOURCE+= deb/deblistparser.cc deb/debrecords.cc deb/dpkgpm.cc
 
 # Public apt-pkg header files
 HEADERS = algorithms.h depcache.h mmap.h pkgcachegen.h cacheiterators.h \
           error.h orderlist.h sourcelist.h configuration.h fileutl.h \
           packagemanager.h tagfile.h deblistparser.h init.h pkgcache.h \
           version.h progress.h pkgrecords.h debrecords.h cmndline.h \
-         acquire.h acquire-worker.h acquire-item.h acquire-method.h md5.h
+         acquire.h acquire-worker.h acquire-item.h acquire-method.h md5.h \
+         dpkgpm.h
 
 HEADERS := $(addprefix apt-pkg/,$(HEADERS))
 
index 1780dff..2b47d42 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: packagemanager.cc,v 1.4 1998/07/12 23:58:30 jgg Exp $
+// $Id: packagemanager.cc,v 1.5 1998/11/13 04:23:30 jgg Exp $
 /* ######################################################################
 
    Package Manager - Abstacts the package manager
@@ -21,6 +21,7 @@
 #include <apt-pkg/depcache.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/version.h>
+#include <apt-pkg/acquire-item.h>
                                                                        /*}}}*/
 
 // PM::PackageManager - Constructor                                    /*{{{*/
@@ -41,6 +42,26 @@ pkgPackageManager::~pkgPackageManager()
    delete [] FileNames;
 }
                                                                        /*}}}*/
+// PM::GetArchives - Queue the archives for download                   /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool pkgPackageManager::GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
+                                   pkgRecords *Recs)
+{
+   pkgCache::PkgIterator I = Cache.PkgBegin();
+   for (;I.end() != true; I++)
+   {      
+      // Not interesting
+      if ((Cache[I].InstallVer == (pkgCache::Version *)I.CurrentVer() &&
+          I.State() != pkgCache::PkgIterator::NeedsUnpack) ||
+         Cache[I].Delete() == true)
+        continue;
+      
+      new pkgAcqArchive(Owner,Sources,Recs,Cache[I].InstVerIter(Cache));
+   }
+   return true;
+}
+                                                                       /*}}}*/
 // PM::FixMissing - Keep all missing packages                          /*{{{*/
 // ---------------------------------------------------------------------
 /* This is called to correct the installation when packages could not
index 7fd01cb..c6ab82d 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: packagemanager.h,v 1.4 1998/07/19 21:24:13 jgg Exp $
+// $Id: packagemanager.h,v 1.5 1998/11/13 04:23:31 jgg Exp $
 /* ######################################################################
 
    Package Manager - Abstacts the package manager
 #include <string>
 #include <apt-pkg/pkgcache.h>
 
-class pkgAquire;
+class pkgAcquire;
 class pkgDepCache;
 class pkgSourceList;
 class pkgOrderList;
+class pkgRecords;
 class pkgPackageManager
 {
    protected:
@@ -68,11 +69,13 @@ class pkgPackageManager
    virtual bool Install(PkgIterator /*Pkg*/,string /*File*/) {return false;};
    virtual bool Configure(PkgIterator /*Pkg*/) {return false;};
    virtual bool Remove(PkgIterator /*Pkg*/) {return false;};
-   virtual bool Go() {return false;};
+   virtual bool Go() {return true;};
    
    public:
 
    // Main action members
+   bool GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
+                   pkgRecords *Recs);
    bool DoInstall();
    bool FixMissing();
    
index aef6541..9e0d5db 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: pkgcache.cc,v 1.14 1998/11/08 23:29:19 jgg Exp $
+// $Id: pkgcache.cc,v 1.15 1998/11/13 04:23:32 jgg Exp $
 /* ######################################################################
    
    Package Cache - Accessor code for the cache
@@ -44,7 +44,7 @@ pkgCache::Header::Header()
    /* Whenever the structures change the major version should be bumped,
       whenever the generator changes the minor version should be bumped. */
    MajorVersion = 2;
-   MinorVersion = 1;
+   MinorVersion = 2;
    Dirty = true;
    
    HeaderSz = sizeof(pkgCache::Header);
index 0bec88f..bbf245b 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: pkgcachegen.cc,v 1.22 1998/11/12 03:28:31 jgg Exp $
+// $Id: pkgcachegen.cc,v 1.23 1998/11/13 04:23:33 jgg Exp $
 /* ######################################################################
    
    Package Cache Generator - Generator for the cache structure.
@@ -176,8 +176,14 @@ bool pkgCacheGenerator::NewFileVer(pkgCache::VerIterator &Ver,
    
    pkgCache::VerFileIterator VF(Cache,Cache.VerFileP + VerFile);
    VF->File = CurrentFile - Cache.PkgFileP;
-   VF->NextFile = Ver->FileList;
-   Ver->FileList = VF.Index();
+   
+   // Link it to the end of the list
+   __apt_ptrloc *Last = &Ver->FileList;
+   for (pkgCache::VerFileIterator V = Ver.FileList(); V.end() == false; V++)
+      Last = &V->NextFile;
+   VF->NextFile = *Last;
+   *Last = VF.Index();
+   
    VF->Offset = List.Offset();
    VF->Size = List.Size();
    if (Cache.HeaderP->MaxVerFileSize < VF->Size)
index 59bc2a1..5d982ca 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: pkgrecords.cc,v 1.3 1998/10/20 02:39:23 jgg Exp $
+// $Id: pkgrecords.cc,v 1.4 1998/11/13 04:23:34 jgg Exp $
 /* ######################################################################
    
    Package Records - Allows access to complete package description records
@@ -23,9 +23,7 @@
 /* This will create the necessary structures to access the status files */
 pkgRecords::pkgRecords(pkgCache &Cache) : Cache(Cache), Files(0)
 {
-   string ListDir = _config->FindFile("Dir::State::lists");
-   
-   Files = new PkgFile[Cache.HeaderP->PackageFileCount];   
+   Files = new PkgFile[Cache.HeaderP->PackageFileCount];
    for (pkgCache::PkgFileIterator I = Cache.FileBegin(); 
        I.end() == false; I++)
    {
@@ -37,7 +35,7 @@ pkgRecords::pkgRecords(pkgCache &Cache) : Cache(Cache), Files(0)
       }
    
       // Create the file
-      Files[I->ID].File = new FileFd(ListDir + I.FileName(),FileFd::ReadOnly);
+      Files[I->ID].File = new FileFd(I.FileName(),FileFd::ReadOnly);
       if (_error->PendingError() == true)
         return;
       
@@ -59,8 +57,8 @@ pkgRecords::~pkgRecords()
 // Records::Lookup - Get a parser for the package version file         /*{{{*/
 // ---------------------------------------------------------------------
 /* */
-pkgRecords::Parser &pkgRecords::Lookup(pkgCache::VerFileIterator &Ver)
-{   
+pkgRecords::Parser &pkgRecords::Lookup(pkgCache::VerFileIterator const &Ver)
+{
    PkgFile &File = Files[Ver.File()->ID];
    File.Parse->Jump(Ver);
 
index 28cb728..9fc30ac 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: pkgrecords.h,v 1.2 1998/10/08 04:55:00 jgg Exp $
+// $Id: pkgrecords.h,v 1.3 1998/11/13 04:23:35 jgg Exp $
 /* ######################################################################
    
    Package Records - Allows access to complete package description records
@@ -48,8 +48,8 @@ class pkgRecords
    public:
 
    // Lookup function
-   Parser &Lookup(pkgCache::VerFileIterator &Ver);
-   
+   Parser &Lookup(pkgCache::VerFileIterator const &Ver);
+
    // Construct destruct
    pkgRecords(pkgCache &Cache);
    ~pkgRecords();
@@ -59,7 +59,7 @@ class pkgRecords::Parser
 {
    protected:
    
-   virtual bool Jump(pkgCache::VerFileIterator &Ver) = 0;
+   virtual bool Jump(pkgCache::VerFileIterator const &Ver) = 0;
    
    public:
    friend pkgRecords;
index 91653f6..1d6d10d 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: tagfile.cc,v 1.13 1998/10/30 07:53:41 jgg Exp $
+// $Id: tagfile.cc,v 1.14 1998/11/13 04:23:36 jgg Exp $
 /* ######################################################################
 
    Fast scanner for RFC-822 type header information
@@ -94,7 +94,8 @@ bool pkgTagFile::Fill()
                                                                        /*}}}*/
 // TagFile::Jump - Jump to a pre-recorded location in the file         /*{{{*/
 // ---------------------------------------------------------------------
-/* This jumps to a pre-recorded file location and */
+/* This jumps to a pre-recorded file location and reads the record
+   that is there */
 bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long Offset)
 {
    iOffset = Offset;
index 5317445..c629991 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: apt-cache.cc,v 1.10 1998/10/19 23:45:35 jgg Exp $
+// $Id: apt-cache.cc,v 1.11 1998/11/13 04:24:01 jgg Exp $
 /* ######################################################################
    
    apt-cache - Manages the cache files
@@ -44,7 +44,13 @@ bool DumpPackage(pkgCache &Cache,CommandLine &CmdL)
       cout << "Package: " << Pkg.Name() << endl;
       cout << "Versions: ";
       for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; Cur++)
-        cout << Cur.VerStr() << ',';
+      {
+        cout << Cur.VerStr();
+        for (pkgCache::VerFileIterator Vf = Cur.FileList(); Vf.end() == false; Vf++)
+           cout << "(" << Vf.File().FileName() << ")";
+        cout << ',';
+      }
+      
       cout << endl;
       
       cout << "Reverse Depends: " << endl;
@@ -72,6 +78,7 @@ bool DumpPackage(pkgCache &Cache,CommandLine &CmdL)
       for (pkgCache::PrvIterator Prv = Pkg.ProvidesList(); Prv.end() != true; Prv++)
         cout << Prv.OwnerPkg().Name() << " " << Prv.OwnerVer().VerStr();
       cout << endl;
+            
    }
 
    return true;
index 8daaf05..85373d8 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: apt-get.cc,v 1.8 1998/11/12 05:30:10 jgg Exp $
+// $Id: apt-get.cc,v 1.9 1998/11/13 04:24:03 jgg Exp $
 /* ######################################################################
    
    apt-get - Cover for dpkg
@@ -33,6 +33,7 @@
 #include <apt-pkg/pkgcachegen.h>
 #include <apt-pkg/algorithms.h>
 #include <apt-pkg/acquire-item.h>
+#include <apt-pkg/dpkgpm.h>
 
 #include <config.h>
 
@@ -421,7 +422,7 @@ bool CacheFile::Open()
 // ---------------------------------------------------------------------
 /* This displays the informative messages describing what is going to 
    happen and then calls the download routines */
-bool InstallPackages(pkgDepCache &Cache,bool ShwKept)
+bool InstallPackages(pkgDepCache &Cache,bool ShwKept,bool Ask = true)
 {
    ShowDel(c1out,Cache);
    ShowNew(c1out,Cache);
@@ -443,7 +444,35 @@ bool InstallPackages(pkgDepCache &Cache,bool ShwKept)
    if (Cache.DelCount() == 0 && Cache.InstCount() == 0 && 
        Cache.BadCount() == 0)
       return true;   
-      
+
+   // Run the simulator ..
+   if (_config->FindB("APT::Get::Simulate") == true)
+   {
+      pkgSimulate PM(Cache);
+      return PM.DoInstall();
+   }
+   
+   // Create the text record parser
+   pkgRecords Recs(Cache);
+   
+   // Create the download object
+   AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0));   
+   pkgAcquire Fetcher(&Stat);
+
+   // Read the source list
+   pkgSourceList List;
+   if (List.ReadMainList() == false)
+      return _error->Error("The list of sources could not be read.");
+   
+   // Create the package manager and prepare to download
+   pkgPackageManager PM(Cache);
+   if (PM.GetArchives(&Fetcher,&List,&Recs) == false)
+      return false;
+
+   // Run it
+   if (Fetcher.Run() == false)
+      return false;
+   
    return true;
 }
                                                                        /*}}}*/
@@ -654,7 +683,10 @@ bool DoInstall(CommandLine &CmdL)
       ShowList(c1out,"The following extra packages will be installed:",List);
    }
 
-   return InstallPackages(Cache,false);
+   // See if we need to prompt
+   if (Cache->InstCount() != ExpectedInst || Cache->DelCount() != 0)
+      return InstallPackages(Cache,false,true);
+   return InstallPackages(Cache,false);   
 }
                                                                        /*}}}*/
 // DoDistUpgrade - Automatic smart upgrader                            /*{{{*/