]> git.saurik.com Git - apt.git/commitdiff
Working acquire code
authorArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:51:20 +0000 (16:51 +0000)
committerArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:51:20 +0000 (16:51 +0000)
Author: jgg
Date: 1998-11-05 07:21:35 GMT
Working acquire code

14 files changed:
apt-pkg/acquire-item.cc
apt-pkg/acquire-item.h
apt-pkg/acquire-method.cc
apt-pkg/acquire-worker.cc
apt-pkg/acquire.cc
apt-pkg/acquire.h
apt-pkg/contrib/configuration.cc
apt-pkg/contrib/strutl.cc
apt-pkg/init.cc
buildlib/configure.mak
doc/examples/apt.conf
methods/gzip.cc
methods/http.cc
test/scratch.cc

index f8cc7a0de5c4a9666afdee1365cd7004d7c7a1aa..9f9d082fed52a48d62f6b31ebce776b67b9903c9 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-item.cc,v 1.6 1998/10/30 07:53:34 jgg Exp $
+// $Id: acquire-item.cc,v 1.7 1998/11/05 07:21:35 jgg Exp $
 /* ######################################################################
 
    Acquire Item - Item to acquire
@@ -94,6 +94,7 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,const pkgSourceList::Item *Location)
              Item(Owner), Location(Location)
 {
    Decompression = false;
+   Erase = false;
    
    DestFile = _config->FindDir("Dir::State::lists") + "partial/";
    DestFile += URItoFileName(Location->PackagesURI());
@@ -136,9 +137,19 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5)
       string FinalFile = _config->FindDir("Dir::State::lists");
       FinalFile += URItoFileName(Location->PackagesURI());
       Rename(DestFile,FinalFile);
+      
+      // Remove the compressed version.
+      if (Erase == true)
+      {
+        DestFile = _config->FindDir("Dir::State::lists") + "partial/";
+        DestFile += URItoFileName(Location->PackagesURI());
+        unlink(DestFile.c_str());
+      }      
       return;
    }
-      
+
+   Erase = false;
+   
    // Handle the unzipd case
    string FileName = LookupTag(Message,"Alt-Filename");
    if (FileName.empty() == false)
@@ -163,6 +174,9 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5)
    // The files timestamp matches
    if (StringToBool(LookupTag(Message,"IMS-Hit"),false) == true)
       return;
+
+   if (FileName == DestFile)
+      Erase = true;
    
    Decompression = true;
    DestFile += ".decomp";
index bdd4d35811c2212306948eef683ab0a49d83a045..9ead29c9a6575b250af4b104138bcc4eaca21fc6 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-item.h,v 1.4 1998/10/26 07:11:44 jgg Exp $
+// $Id: acquire-item.h,v 1.5 1998/11/05 07:21:36 jgg Exp $
 /* ######################################################################
 
    Acquire Item - Item to acquire
@@ -63,6 +63,7 @@ class pkgAcqIndex : public pkgAcquire::Item
    
    const pkgSourceList::Item *Location;
    bool Decompression;
+   bool Erase;
    
    public:
    
index 8d26537fa4e64d28e8b1b5fea1a552ccbe8575fd..681015910da72ad57c6c945af7e6cbe7e0ad517b 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-method.cc,v 1.3 1998/11/01 08:07:11 jgg Exp $
+// $Id: acquire-method.cc,v 1.4 1998/11/05 07:21:38 jgg Exp $
 /* ######################################################################
 
    Acquire Method
@@ -263,10 +263,11 @@ int pkgAcqMethod::Run(bool Single)
            FetchItem **I = &Queue;
            for (; *I != 0; I = &(*I)->Next);
            *I = Tmp;
-           cout << "GOT " << Tmp->Uri << endl;
-           
+
+           // Notify that this item is to be fetched.
            if (Fetch(Tmp) == false)
               Fail();
+           
            break;                                           
         }   
       }      
index a02c6bc0414b77467210cb51be04ea104cdcc18c..2cbab7720464a8c0fe3bad9c389f3139f6ab13a2 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-worker.cc,v 1.9 1998/11/01 05:27:33 jgg Exp $
+// $Id: acquire-worker.cc,v 1.10 1998/11/05 07:21:39 jgg Exp $
 /* ######################################################################
 
    Acquire Worker 
@@ -192,7 +192,7 @@ bool pkgAcquire::Worker::RunMessages()
       pkgAcquire::Queue::QItem *Itm = 0;
       if (URI.empty() == false)
         Itm = OwnerQ->FindItem(URI,this);
-        
+      
       // Determine the message number and dispatch
       switch (Number)
       {
@@ -237,8 +237,9 @@ bool pkgAcquire::Worker::RunMessages()
               break;
            }
 
+           pkgAcquire::Item *Owner = Itm->Owner;
            OwnerQ->ItemDone(Itm);
-           Itm->Owner->Done(Message,atoi(LookupTag(Message,"Size","0").c_str()),
+           Owner->Done(Message,atoi(LookupTag(Message,"Size","0").c_str()),
                                          LookupTag(Message,"MD5-Hash"));
            break;
         }       
@@ -252,8 +253,9 @@ bool pkgAcquire::Worker::RunMessages()
               break;
            }
 
+           pkgAcquire::Item *Owner = Itm->Owner;
            OwnerQ->ItemDone(Itm);
-           Itm->Owner->Failed(Message);
+           Owner->Failed(Message);
            break;
         }       
         
index 91b2a7590e1fd77e041772797abe610ff1c19197..16adf3ae22bbfbc02acfc2dba9d2eb45d7d725da 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire.cc,v 1.7 1998/11/01 05:27:34 jgg Exp $
+// $Id: acquire.cc,v 1.8 1998/11/05 07:21:40 jgg Exp $
 /* ######################################################################
 
    Acquire - File Acquiration
@@ -143,6 +143,8 @@ void pkgAcquire::Enqueue(Item *Itm,string URI,string Description)
       if (Running == true)
         I->Startup();
    }
+
+   Itm->Status = Item::StatIdle;
    
    // Queue it into the named queue
    I->Enqueue(Itm,URI,Description);
@@ -164,12 +166,14 @@ void pkgAcquire::Enqueue(Item *Itm,string URI,string Description)
 void pkgAcquire::Dequeue(Item *Itm)
 {
    Queue *I = Queues;
+   bool Res = false;
    for (; I != 0; I = I->Next)
-      I->Dequeue(Itm);
+      Res |= I->Dequeue(Itm);
    
    if (Debug == true)
       clog << "Dequeuing " << Itm->DestFile << endl;
-   ToFetch--;
+   if (Res == true)
+      ToFetch--;
 }
                                                                        /*}}}*/
 // Acquire::QueueName - Return the name of the queue for this URI      /*{{{*/
@@ -371,9 +375,11 @@ void pkgAcquire::Queue::Enqueue(Item *Owner,string URI,string Description)
                                                                        /*}}}*/
 // Queue::Dequeue - Remove an item from the queue                      /*{{{*/
 // ---------------------------------------------------------------------
-/* */
-void pkgAcquire::Queue::Dequeue(Item *Owner)
+/* We return true if we hit something*/
+bool pkgAcquire::Queue::Dequeue(Item *Owner)
 {
+   bool Res = false;
+   
    QItem **I = &Items;
    for (; *I != 0;)
    {
@@ -383,10 +389,13 @@ void pkgAcquire::Queue::Dequeue(Item *Owner)
         *I = (*I)->Next;
         Owner->QueueCounter--;
         delete Jnk;
+        Res = true;
       }
       else
         I = &(*I)->Next;
    }
+   
+   return Res;
 }
                                                                        /*}}}*/
 // Queue::Startup - Start the worker processes                         /*{{{*/
@@ -463,6 +472,8 @@ bool pkgAcquire::Queue::Cycle()
    if (Items == 0 || Workers == 0)
       return true;
 
+   cout << "Cylce for " << Name << endl;
+
    // Look for a queable item
    QItem *I = Items;
    for (; I != 0; I = I->Next)
@@ -475,6 +486,7 @@ bool pkgAcquire::Queue::Cycle()
    
    I->Worker = Workers;
    I->Owner->Status = pkgAcquire::Item::StatFetching;
+   cout << "Item has been queued!" << endl;
    return Workers->QueueItem(I);
 }
                                                                        /*}}}*/
index 25fe4b7613e93b4a260a70f8fc19b26e4fadede7..a4ea45bff3e6c6c45706c6c5df5a611fc12213d1 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire.h,v 1.7 1998/11/01 05:27:35 jgg Exp $
+// $Id: acquire.h,v 1.8 1998/11/05 07:21:41 jgg Exp $
 /* ######################################################################
 
    Acquire - File Acquiration
@@ -124,7 +124,7 @@ class pkgAcquire::Queue
    
    // Put an item into this queue
    void Enqueue(Item *Owner,string URI,string Description);
-   void Dequeue(Item *Owner);
+   bool Dequeue(Item *Owner);
 
    // Find a Queued item
    QItem *FindItem(string URI,pkgAcquire::Worker *Owner);
index 27299ec6a6936742d7f589e37588730c7a302a83..da026f0f62a59fb4f7f701930d89d98667c2e8bc 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: configuration.cc,v 1.9 1998/10/30 07:53:42 jgg Exp $
+// $Id: configuration.cc,v 1.10 1998/11/05 07:21:43 jgg Exp $
 /* ######################################################################
 
    Configuration Class
@@ -292,8 +292,14 @@ bool ReadConfigFile(Configuration &Conf,string FName)
       }
       
       // Discard single line comments
+      bool InQuote = false;
       for (char *I = Buffer; *I != 0; I++)
       {
+        if (*I == '"')
+           InQuote = !InQuote;
+        if (InQuote == true)
+           continue;
+        
         if (*I == '/' && I[1] == '/')
          {
            *I = 0;
@@ -304,6 +310,11 @@ bool ReadConfigFile(Configuration &Conf,string FName)
       // Look for multi line comments
       for (char *I = Buffer; *I != 0; I++)
       {
+        if (*I == '"')
+           InQuote = !InQuote;
+        if (InQuote == true)
+           continue;
+        
         if (*I == '/' && I[1] == '*')
          {
            InComment = true;
@@ -398,7 +409,7 @@ bool ReadConfigFile(Configuration &Conf,string FName)
            string Word;
            if (ParseCWord(LineBuffer.c_str()+Pos,Word) == false)
               return _error->Error("Syntax error %s:%u: Malformed value",FName.c_str(),CurLine);
-              
+           
            // Generate the item name
            string Item;
            if (ParentTag.empty() == true)
index c99f88c3fc930e33dab905024f6125920cb857ae..d5f765dd466d507ab78ec7e3a38fd26e2ebc1647 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: strutl.cc,v 1.12 1998/11/04 07:11:13 jgg Exp $
+// $Id: strutl.cc,v 1.13 1998/11/05 07:21:44 jgg Exp $
 /* ######################################################################
 
    String Util - Some usefull string functions.
@@ -623,23 +623,14 @@ void URI::CopyFrom(string U)
    for (; I < U.end() && *I != ':' ; I++);
    string::const_iterator FirstColon = I;
 
-   // Determine if this is a host type URI with a leading double //
+   /* Determine if this is a host type URI with a leading double //
+      and then search for the first single / */
    string::const_iterator SingleSlash = I;
    if (I + 3 < U.end() && I[1] == '/' && I[2] == '/')
-   {
-      // Locate the single / that starts the path
-      for (; I < U.end(); I++)
-      {
-        if (*I == '/' && I+1 < U.end() && I[1] == '/')
-           I += 2;
-        else 
-           if (*I == '/')
-              break;
-      }
-      if (I > U.end())
-        I = U.end();
-      SingleSlash = I;      
-   }
+      SingleSlash += 3;
+   for (; SingleSlash < U.end() && *SingleSlash != '/'; SingleSlash++);
+   if (SingleSlash > U.end())
+        SingleSlash = U.end();
 
    // We can now write the access and path specifiers
    Access = string(U,0,FirstColon - U.begin());
index da11e3b408232cf8891d348dde36ec7149fcf698..f79668c543617e32ce939f1ec7daa5e125de19d7 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: init.cc,v 1.9 1998/10/30 07:53:39 jgg Exp $
+// $Id: init.cc,v 1.10 1998/11/05 07:21:42 jgg Exp $
 /* ######################################################################
 
    Init - Initialize the package library
@@ -46,7 +46,7 @@ bool pkgInitialize(Configuration &Cnf)
    Cnf.Set("Dir::Etc","/etc/apt/");
    Cnf.Set("Dir::Etc::sourcelist","sources.list");
    Cnf.Set("Dir::Etc::main","apt.conf");
-   Cnf.Set("Dir::Bin::methods","/usr/lib/apt/metods");
+   Cnf.Set("Dir::Bin::methods","/usr/lib/apt/methods");
    
    // Read the main config file
    string FName = Cnf.FindFile("Dir::Etc::main");
@@ -57,7 +57,9 @@ bool pkgInitialize(Configuration &Cnf)
    // Read an alternate config file
    const char *Cfg = getenv("APT_CONFIG");
    
-   if (ReadConfigFile(Cnf,FName) != true || ReadConfigFile(Cnf,Cfg) != true)
+   // Read both config files, either existing will be OK
+   if ((ReadConfigFile(Cnf,FName) != true) |
+       (ReadConfigFile(Cnf,Cfg) != true))
       return false;
    
    if (Cnf.FindB("Debug::pkgInitialize",false) == true)
index 64c3179d1af117fa8f12ec309bd6fd70cf406d1d..70578a56518dab22d7cb93bb775677cd11618a27 100644 (file)
@@ -24,12 +24,3 @@ $(BUILD)/config.status: configure
        (HERE=`pwd`; cd $(BUILD) && $$HERE/configure)
 $(CONVERTED): $(BUILD)/config.status
        (cd $(BUILD) && ./config.status)
-
-# We include the environment if it exists and re-export it to configure. This
-# allows someone to edit it and not have their changes blown away.
-Env = $(wildcard $(BUILD)/environment.mak)
-ifneq ($(words $(Env)),0)
-include $(Env)
-export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS PICFLAGS
-endif
-
index 2fd962c7fa467a7fd0991e63ecdcd324aa816c34..4371c2b56d1c417cdd260f93148054915bb07487 100644 (file)
@@ -1,4 +1,4 @@
-// $Id: apt.conf,v 1.8 1998/11/04 23:22:24 jgg Exp $
+// $Id: apt.conf,v 1.9 1998/11/05 07:21:46 jgg Exp $
 /* This file is an index of all APT configuration directives. It should
    NOT actually be used as a real config file, though it is a completely
    valid file.
@@ -37,10 +37,10 @@ Acquire
 {
   Queue-Mode "access";       // host|access
   
-  http 
+/*  http 
   {
     Proxy "http://127.0.0.1:3128";
-  };
+  };*/
 };
 
 // Directory layout
index be4f82e6f9670362e34fccb699d55cfccffcd016..a78fcb3ee8cd84bc2a4ee0fe6038d84d90ccba8d 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: gzip.cc,v 1.4 1998/11/01 05:27:43 jgg Exp $
+// $Id: gzip.cc,v 1.5 1998/11/05 07:21:47 jgg Exp $
 /* ######################################################################
 
    GZip method - Take a file URI in and decompress it into the target 
@@ -36,7 +36,7 @@ class GzipMethod : public pkgAcqMethod
 bool GzipMethod::Fetch(FetchItem *Itm)
 {
    URI Get = Itm->Uri;
-   
+
    // Open the source and destintation files
    FileFd From(Get.Path,FileFd::ReadOnly);
    FileFd To(Itm->DestFile,FileFd::WriteEmpty);   
index 4c773b064a1af8f8bee835fe70b80da7d16ee13f..b97d1dbc9c5e821d078f6172c55750bbcfeef16d 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: http.cc,v 1.3 1998/11/04 07:10:49 jgg Exp $
+// $Id: http.cc,v 1.4 1998/11/05 07:21:48 jgg Exp $
 /* ######################################################################
 
    HTTP Aquire Method - This is the HTTP aquire method for APT.
@@ -951,6 +951,7 @@ int HttpMethod::Loop()
       
       // Decide what to do.
       FetchResult Res;
+      Res.Filename = Queue->DestFile;
       switch (DealWithHeaders(Res,Server))
       {
         // Ok, the file is Open
index 502b31db06580ca291d5b5cae024cd2061381475..53681db16e030e668f758ea72df999defcff1d60 100644 (file)
@@ -8,7 +8,7 @@ int main(int argc,char *argv[])
 {
    signal(SIGPIPE,SIG_IGN);
 
-   URI Foo(argv[1]);
+/*   URI Foo(argv[1]);
    cout << Foo.Access << '\'' << endl;
    cout << Foo.Host << '\'' << endl;
    cout << Foo.Path << '\'' << endl;
@@ -16,7 +16,7 @@ int main(int argc,char *argv[])
    cout << Foo.Password << '\'' << endl;
    cout << Foo.Port << endl;
    
-   return 0;
+   return 0;*/
 
    pkgInitialize(*_config);