Browse Source

Local file fixes
Author: jgg
Date: 1998-11-14 01:39:41 GMT
Local file fixes

Arch Librarian 22 years ago
parent
commit
e331f6edcb

+ 4 - 1
apt-pkg/acquire-method.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: acquire-method.cc,v 1.7 1998/11/11 07:30:54 jgg Exp $
+// $Id: acquire-method.cc,v 1.8 1998/11/14 01:39:41 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire Method
    Acquire Method
@@ -41,6 +41,9 @@ pkgAcqMethod::pkgAcqMethod(const char *Ver,unsigned long Flags)
    
    
    if ((Flags & SendConfig) == SendConfig)
    if ((Flags & SendConfig) == SendConfig)
       strcat(End,"Send-Config: true\n");
       strcat(End,"Send-Config: true\n");
+
+   if ((Flags & LocalOnly) == LocalOnly)
+      strcat(End,"Local-Only: true\n");
    strcat(End,"\n");
    strcat(End,"\n");
 
 
    if (write(STDOUT_FILENO,S,strlen(S)) != (signed)strlen(S))
    if (write(STDOUT_FILENO,S,strlen(S)) != (signed)strlen(S))

+ 3 - 3
apt-pkg/acquire-method.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: acquire-method.h,v 1.2 1998/11/01 05:27:32 jgg Exp $
+// $Id: acquire-method.h,v 1.3 1998/11/14 01:39:43 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire Method - Method helper class + functions
    Acquire Method - Method helper class + functions
@@ -33,7 +33,6 @@ class pkgAcqMethod
       time_t LastModified;
       time_t LastModified;
    };
    };
    
    
-   
    struct FetchResult
    struct FetchResult
    {
    {
       string MD5Sum;
       string MD5Sum;
@@ -62,7 +61,8 @@ class pkgAcqMethod
    public:
    public:
    
    
    enum CnfFlags {SingleInstance = (1<<0), PreScan = (1<<1), 
    enum CnfFlags {SingleInstance = (1<<0), PreScan = (1<<1), 
-                  Pipeline = (1<<2), SendConfig = (1<<3)};
+                  Pipeline = (1<<2), SendConfig = (1<<3), 
+                  LocalOnly = (1<<4)};
 
 
    void Log(const char *Format,...);
    void Log(const char *Format,...);
    void Status(const char *Format,...);
    void Status(const char *Format,...);

+ 2 - 1
apt-pkg/acquire-worker.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: acquire-worker.cc,v 1.11 1998/11/09 01:09:23 jgg Exp $
+// $Id: acquire-worker.cc,v 1.12 1998/11/14 01:39:44 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire Worker 
    Acquire Worker 
@@ -307,6 +307,7 @@ bool pkgAcquire::Worker::Capabilities(string Message)
    Config->PreScan = StringToBool(LookupTag(Message,"Pre-Scan"),false);
    Config->PreScan = StringToBool(LookupTag(Message,"Pre-Scan"),false);
    Config->Pipeline = StringToBool(LookupTag(Message,"Pipeline"),false);
    Config->Pipeline = StringToBool(LookupTag(Message,"Pipeline"),false);
    Config->SendConfig = StringToBool(LookupTag(Message,"Send-Config"),false);
    Config->SendConfig = StringToBool(LookupTag(Message,"Send-Config"),false);
+   Config->LocalOnly = StringToBool(LookupTag(Message,"Local-Only"),false);
 
 
    // Some debug text
    // Some debug text
    if (Debug == true)
    if (Debug == true)

+ 32 - 20
apt-pkg/acquire.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: acquire.cc,v 1.15 1998/11/13 07:08:54 jgg Exp $
+// $Id: acquire.cc,v 1.16 1998/11/14 01:39:45 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire - File Acquiration
    Acquire - File Acquiration
@@ -130,7 +130,8 @@ void pkgAcquire::Remove(Worker *Work)
 void pkgAcquire::Enqueue(ItemDesc &Item)
 void pkgAcquire::Enqueue(ItemDesc &Item)
 {
 {
    // Determine which queue to put the item in
    // Determine which queue to put the item in
-   string Name = QueueName(Item.URI);
+   const MethodConfig *Config;
+   string Name = QueueName(Item.URI,Config);
    if (Name.empty() == true)
    if (Name.empty() == true)
       return;
       return;
 
 
@@ -147,6 +148,9 @@ void pkgAcquire::Enqueue(ItemDesc &Item)
 	 I->Startup();
 	 I->Startup();
    }
    }
 
 
+   // See if this is a local only URI
+   if (Config->LocalOnly == true && Item.Owner->Complete == false)
+      Item.Owner->Local = true;
    Item.Owner->Status = Item::StatIdle;
    Item.Owner->Status = Item::StatIdle;
    
    
    // Queue it into the named queue
    // Queue it into the named queue
@@ -158,7 +162,7 @@ void pkgAcquire::Enqueue(ItemDesc &Item)
    {
    {
       clog << "Fetching " << Item.URI << endl;
       clog << "Fetching " << Item.URI << endl;
       clog << " to " << Item.Owner->DestFile << endl;
       clog << " to " << Item.Owner->DestFile << endl;
-      clog << " Queue is: " << QueueName(Item.URI) << endl;
+      clog << " Queue is: " << Name << endl;
    }
    }
 }
 }
 									/*}}}*/
 									/*}}}*/
@@ -184,11 +188,11 @@ void pkgAcquire::Dequeue(Item *Itm)
 /* The string returned depends on the configuration settings and the
 /* The string returned depends on the configuration settings and the
    method parameters. Given something like http://foo.org/bar it can
    method parameters. Given something like http://foo.org/bar it can
    return http://foo.org or http */
    return http://foo.org or http */
-string pkgAcquire::QueueName(string Uri)
+string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config)
 {
 {
    URI U(Uri);
    URI U(Uri);
    
    
-   const MethodConfig *Config = GetConfig(U.Access);
+   Config = GetConfig(U.Access);
    if (Config == 0)
    if (Config == 0)
       return string();
       return string();
    
    
@@ -386,18 +390,6 @@ bool pkgAcquire::Clean(string Dir)
    return true;   
    return true;   
 }
 }
 									/*}}}*/
 									/*}}}*/
-// Acquire::MethodConfig::MethodConfig - Constructor			/*{{{*/
-// ---------------------------------------------------------------------
-/* */
-pkgAcquire::MethodConfig::MethodConfig()
-{
-   SingleInstance = false;
-   PreScan = false;
-   Pipeline = false;
-   SendConfig = false;
-   Next = 0;
-}
-									/*}}}*/
 // Acquire::TotalNeeded - Number of bytes to fetch			/*{{{*/
 // Acquire::TotalNeeded - Number of bytes to fetch			/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This is the total number of bytes needed */
 /* This is the total number of bytes needed */
@@ -422,6 +414,20 @@ unsigned long pkgAcquire::FetchNeeded()
 }
 }
 									/*}}}*/
 									/*}}}*/
 
 
+// Acquire::MethodConfig::MethodConfig - Constructor			/*{{{*/
+// ---------------------------------------------------------------------
+/* */
+pkgAcquire::MethodConfig::MethodConfig()
+{
+   SingleInstance = false;
+   PreScan = false;
+   Pipeline = false;
+   SendConfig = false;
+   LocalOnly = false;
+   Next = 0;
+}
+									/*}}}*/
+
 // Queue::Queue - Constructor						/*{{{*/
 // Queue::Queue - Constructor						/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
@@ -653,7 +659,10 @@ void pkgAcquireStatus::Pulse(pkgAcquire *Owner)
       }
       }
             
             
       // Compute the CPS value
       // Compute the CPS value
-      CurrentCPS = (CurrentBytes - LastBytes)/(sdiff + usdiff/1000000.0);
+      if (sdiff == 0 && usdiff == 0)
+	 CurrentCPS = 0;
+      else
+	 CurrentCPS = (CurrentBytes - LastBytes)/(sdiff + usdiff/1000000.0);
       LastBytes = CurrentBytes;
       LastBytes = CurrentBytes;
       ElapsedTime = NewTime.tv_sec - StartTime.tv_sec;
       ElapsedTime = NewTime.tv_sec - StartTime.tv_sec;
       Time = NewTime;
       Time = NewTime;
@@ -694,9 +703,12 @@ void pkgAcquireStatus::Stop()
       usdiff += 1000000;
       usdiff += 1000000;
       sdiff--;
       sdiff--;
    }
    }
-   
+
    // Compute the CPS value
    // Compute the CPS value
-   CurrentCPS = FetchedBytes/(sdiff + usdiff/1000000.0);
+   if (sdiff == 0 && usdiff == 0)
+      CurrentCPS = 0;
+   else
+      CurrentCPS = FetchedBytes/(sdiff + usdiff/1000000.0);
    LastBytes = CurrentBytes;
    LastBytes = CurrentBytes;
    ElapsedTime = sdiff;
    ElapsedTime = sdiff;
 }
 }

+ 4 - 3
apt-pkg/acquire.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: acquire.h,v 1.12 1998/11/13 07:08:55 jgg Exp $
+// $Id: acquire.h,v 1.13 1998/11/14 01:39:46 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire - File Acquiration
    Acquire - File Acquiration
@@ -79,7 +79,7 @@ class pkgAcquire
    
    
    void Enqueue(ItemDesc &Item);
    void Enqueue(ItemDesc &Item);
    void Dequeue(Item *Item);
    void Dequeue(Item *Item);
-   string QueueName(string URI);
+   string QueueName(string URI,MethodConfig const *&Config);
 
 
    // FDSET managers for derived classes
    // FDSET managers for derived classes
    void SetFds(int &Fd,fd_set *RSet,fd_set *WSet);
    void SetFds(int &Fd,fd_set *RSet,fd_set *WSet);
@@ -182,7 +182,8 @@ struct pkgAcquire::MethodConfig
    bool PreScan;
    bool PreScan;
    bool Pipeline;
    bool Pipeline;
    bool SendConfig;
    bool SendConfig;
-   
+   bool LocalOnly;
+      
    MethodConfig();
    MethodConfig();
 };
 };
 
 

+ 2 - 1
apt-pkg/depcache.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: depcache.h,v 1.6 1998/11/13 07:08:58 jgg Exp $
+// $Id: depcache.h,v 1.7 1998/11/14 01:39:47 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    DepCache - Dependency Extension data for the cache
    DepCache - Dependency Extension data for the cache
@@ -168,6 +168,7 @@ class pkgDepCache : public pkgCache
    // This is for debuging
    // This is for debuging
    void Update(OpProgress *Prog = 0);
    void Update(OpProgress *Prog = 0);
 
 
+   
    // Size queries
    // Size queries
    inline signed long UsrSize() {return iUsrSize;};
    inline signed long UsrSize() {return iUsrSize;};
    inline unsigned long DebSize() {return iDownloadSize;};
    inline unsigned long DebSize() {return iDownloadSize;};

+ 2 - 3
cmdline/apt-get.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: apt-get.cc,v 1.10 1998/11/13 07:09:02 jgg Exp $
+// $Id: apt-get.cc,v 1.11 1998/11/14 01:39:48 jgg Exp $
 /* ######################################################################
 /* ######################################################################
    
    
    apt-get - Cover for dpkg
    apt-get - Cover for dpkg
@@ -514,8 +514,7 @@ bool InstallPackages(pkgDepCache &Cache,bool ShwKept,bool Ask = true)
       return false;
       return false;
 
 
    if (Ask == true)
    if (Ask == true)
-   {
-      
+   {      
       if (_config->FindI("quiet",0) < 2 || 
       if (_config->FindI("quiet",0) < 2 || 
 	  _config->FindB("APT::Get::Assume-Yes",false) == false)
 	  _config->FindB("APT::Get::Assume-Yes",false) == false)
       c2out << "Do you want to continue? [Y/n] " << flush;
       c2out << "Do you want to continue? [Y/n] " << flush;

+ 2 - 2
methods/file.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: file.cc,v 1.5 1998/11/01 05:27:41 jgg Exp $
+// $Id: file.cc,v 1.6 1998/11/14 01:39:49 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    File URI method for APT
    File URI method for APT
@@ -26,7 +26,7 @@ class FileMethod : public pkgAcqMethod
    
    
    public:
    public:
    
    
-   FileMethod() : pkgAcqMethod("1.0",SingleInstance) {};
+   FileMethod() : pkgAcqMethod("1.0",SingleInstance | LocalOnly) {};
 };
 };
 
 
 // FileMethod::Fetch - Fetch a file					/*{{{*/
 // FileMethod::Fetch - Fetch a file					/*{{{*/