Browse Source

More CD fixes
Author: jgg
Date: 2000-01-17 07:11:49 GMT
More CD fixes

Arch Librarian 22 years ago
parent
commit
459681d3b8

+ 17 - 11
apt-pkg/acquire-item.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: acquire-item.cc,v 1.40 1999/10/31 06:32:27 jgg Exp $
+// $Id: acquire-item.cc,v 1.41 2000/01/17 07:11:49 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire Item - Item to acquire
    Acquire Item - Item to acquire
@@ -88,7 +88,8 @@ void pkgAcquire::Item::Start(string /*Message*/,unsigned long Size)
 // Acquire::Item::Done - Item downloaded OK				/*{{{*/
 // Acquire::Item::Done - Item downloaded OK				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-void pkgAcquire::Item::Done(string Message,unsigned long Size,string)
+void pkgAcquire::Item::Done(string Message,unsigned long Size,string,
+			    pkgAcquire::MethodConfig *Cnf)
 {
 {
    // We just downloaded something..
    // We just downloaded something..
    string FileName = LookupTag(Message,"Filename");
    string FileName = LookupTag(Message,"Filename");
@@ -175,9 +176,10 @@ string pkgAcqIndex::Custom600Headers()
    to the uncompressed version of the file. If this is so the file
    to the uncompressed version of the file. If this is so the file
    is copied into the partial directory. In all other cases the file
    is copied into the partial directory. In all other cases the file
    is decompressed with a gzip uri. */
    is decompressed with a gzip uri. */
-void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5)
+void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5,
+		       pkgAcquire::MethodConfig *Cfg)
 {
 {
-   Item::Done(Message,Size,MD5);
+   Item::Done(Message,Size,MD5,Cfg);
 
 
    if (Decompression == true)
    if (Decompression == true)
    {
    {
@@ -285,9 +287,10 @@ string pkgAcqIndexRel::Custom600Headers()
 /* The release file was not placed into the download directory then
 /* The release file was not placed into the download directory then
    a copy URI is generated and it is copied there otherwise the file
    a copy URI is generated and it is copied there otherwise the file
    in the partial directory is moved into .. and the URI is finished. */
    in the partial directory is moved into .. and the URI is finished. */
-void pkgAcqIndexRel::Done(string Message,unsigned long Size,string MD5)
+void pkgAcqIndexRel::Done(string Message,unsigned long Size,string MD5,
+			  pkgAcquire::MethodConfig *Cfg)
 {
 {
-   Item::Done(Message,Size,MD5);
+   Item::Done(Message,Size,MD5,Cfg);
 
 
    string FileName = LookupTag(Message,"Filename");
    string FileName = LookupTag(Message,"Filename");
    if (FileName.empty() == true)
    if (FileName.empty() == true)
@@ -472,9 +475,10 @@ bool pkgAcqArchive::QueueNext()
 // AcqArchive::Done - Finished fetching					/*{{{*/
 // AcqArchive::Done - Finished fetching					/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-void pkgAcqArchive::Done(string Message,unsigned long Size,string Md5Hash)
+void pkgAcqArchive::Done(string Message,unsigned long Size,string Md5Hash,
+			 pkgAcquire::MethodConfig *Cfg)
 {
 {
-   Item::Done(Message,Size,Md5Hash);
+   Item::Done(Message,Size,Md5Hash,Cfg);
    
    
    // Check the size
    // Check the size
    if (Size != Version->Size)
    if (Size != Version->Size)
@@ -597,7 +601,8 @@ pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string MD5,
 // AcqFile::Done - Item downloaded OK					/*{{{*/
 // AcqFile::Done - Item downloaded OK					/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-void pkgAcqFile::Done(string Message,unsigned long Size,string MD5)
+void pkgAcqFile::Done(string Message,unsigned long Size,string MD5,
+		      pkgAcquire::MethodConfig *Cnf)
 {
 {
    // Check the md5
    // Check the md5
    if (Md5Hash.empty() == false && MD5.empty() == false)
    if (Md5Hash.empty() == false && MD5.empty() == false)
@@ -611,7 +616,7 @@ void pkgAcqFile::Done(string Message,unsigned long Size,string MD5)
       }
       }
    }
    }
    
    
-   Item::Done(Message,Size,MD5);
+   Item::Done(Message,Size,MD5,Cnf);
 
 
    string FileName = LookupTag(Message,"Filename");
    string FileName = LookupTag(Message,"Filename");
    if (FileName.empty() == true)
    if (FileName.empty() == true)
@@ -631,7 +636,8 @@ void pkgAcqFile::Done(string Message,unsigned long Size,string MD5)
    if (FileName != DestFile)
    if (FileName != DestFile)
    {
    {
       Local = true;
       Local = true;
-      if (_config->FindB("Acquire::Source-Symlinks",true) == false)
+      if (_config->FindB("Acquire::Source-Symlinks",true) == false ||
+	  Cnf->Removable == true)
       {
       {
 	 Desc.URI = "copy:" + FileName;
 	 Desc.URI = "copy:" + FileName;
 	 QueueURI(Desc);
 	 QueueURI(Desc);

+ 11 - 6
apt-pkg/acquire-item.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: acquire-item.h,v 1.22 1999/10/17 20:58:36 jgg Exp $
+// $Id: acquire-item.h,v 1.23 2000/01/17 07:11:49 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire Item - Item to acquire
    Acquire Item - Item to acquire
@@ -62,7 +62,8 @@ class pkgAcquire::Item
 
 
    // Action members invoked by the worker
    // Action members invoked by the worker
    virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
    virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
-   virtual void Done(string Message,unsigned long Size,string Md5Hash);
+   virtual void Done(string Message,unsigned long Size,string Md5Hash,
+		     pkgAcquire::MethodConfig *Cnf);
    virtual void Start(string Message,unsigned long Size);
    virtual void Start(string Message,unsigned long Size);
    virtual string Custom600Headers() {return string();};
    virtual string Custom600Headers() {return string();};
    virtual string DescURI() = 0;
    virtual string DescURI() = 0;
@@ -88,7 +89,8 @@ class pkgAcqIndex : public pkgAcquire::Item
    public:
    public:
    
    
    // Specialized action members
    // Specialized action members
-   virtual void Done(string Message,unsigned long Size,string Md5Hash);   
+   virtual void Done(string Message,unsigned long Size,string Md5Hash,
+		     pkgAcquire::MethodConfig *Cnf);
    virtual string Custom600Headers();
    virtual string Custom600Headers();
    virtual string DescURI() {return Location->PackagesURI();};
    virtual string DescURI() {return Location->PackagesURI();};
 
 
@@ -107,7 +109,8 @@ class pkgAcqIndexRel : public pkgAcquire::Item
    
    
    // Specialized action members
    // Specialized action members
    virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
    virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
-   virtual void Done(string Message,unsigned long Size,string Md5Hash);   
+   virtual void Done(string Message,unsigned long Size,string Md5Hash,
+		     pkgAcquire::MethodConfig *Cnf);   
    virtual string Custom600Headers();
    virtual string Custom600Headers();
    virtual string DescURI() {return Location->ReleaseURI();};
    virtual string DescURI() {return Location->ReleaseURI();};
    
    
@@ -136,7 +139,8 @@ class pkgAcqArchive : public pkgAcquire::Item
    
    
    // Specialized action members
    // Specialized action members
    virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
    virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
-   virtual void Done(string Message,unsigned long Size,string Md5Hash);
+   virtual void Done(string Message,unsigned long Size,string Md5Hash,
+		     pkgAcquire::MethodConfig *Cnf);
    virtual string MD5Sum() {return MD5;};
    virtual string MD5Sum() {return MD5;};
    virtual string DescURI() {return Desc.URI;};
    virtual string DescURI() {return Desc.URI;};
    virtual void Finished();
    virtual void Finished();
@@ -157,7 +161,8 @@ class pkgAcqFile : public pkgAcquire::Item
    
    
    // Specialized action members
    // Specialized action members
    virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
    virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
-   virtual void Done(string Message,unsigned long Size,string Md5Hash);
+   virtual void Done(string Message,unsigned long Size,string Md5Hash,
+		     pkgAcquire::MethodConfig *Cnf);
    virtual string MD5Sum() {return Md5Hash;};
    virtual string MD5Sum() {return Md5Hash;};
    virtual string DescURI() {return Desc.URI;};
    virtual string DescURI() {return Desc.URI;};
    
    

+ 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.23 1999/12/09 21:18:01 jgg Exp $
+// $Id: acquire-method.cc,v 1.24 2000/01/17 07:11:49 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire Method
    Acquire Method
@@ -53,6 +53,9 @@ pkgAcqMethod::pkgAcqMethod(const char *Ver,unsigned long Flags)
 
 
    if ((Flags & NeedsCleanup) == NeedsCleanup)
    if ((Flags & NeedsCleanup) == NeedsCleanup)
       strcat(End,"Needs-Cleanup: true\n");
       strcat(End,"Needs-Cleanup: true\n");
+
+   if ((Flags & Removable) == Removable)
+      strcat(End,"Removable: 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))

+ 4 - 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.12 1999/10/18 00:37:35 jgg Exp $
+// $Id: acquire-method.h,v 1.13 2000/01/17 07:11:49 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire Method - Method helper class + functions
    Acquire Method - Method helper class + functions
@@ -61,13 +61,14 @@ class pkgAcqMethod
    void URIStart(FetchResult &Res);
    void URIStart(FetchResult &Res);
    void URIDone(FetchResult &Res,FetchResult *Alt = 0);
    void URIDone(FetchResult &Res,FetchResult *Alt = 0);
    bool MediaFail(string Required,string Drive);
    bool MediaFail(string Required,string Drive);
-   void Exit() {};
+   virtual void Exit() {};
 
 
    public:
    public:
 
 
    enum CnfFlags {SingleInstance = (1<<0),
    enum CnfFlags {SingleInstance = (1<<0),
                   Pipeline = (1<<1), SendConfig = (1<<2),
                   Pipeline = (1<<1), SendConfig = (1<<2),
-                  LocalOnly = (1<<3), NeedsCleanup = (1<<4)};
+                  LocalOnly = (1<<3), NeedsCleanup = (1<<4), 
+                  Removable = (1<<5)};
 
 
    void Log(const char *Format,...);
    void Log(const char *Format,...);
    void Status(const char *Format,...);
    void Status(const char *Format,...);

+ 10 - 6
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.28 1999/10/18 00:37:35 jgg Exp $
+// $Id: acquire-worker.cc,v 1.29 2000/01/17 07:11:49 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire Worker 
    Acquire Worker 
@@ -257,7 +257,7 @@ bool pkgAcquire::Worker::RunMessages()
 			       LookupTag(Message,"Size","0").c_str(),TotalSize);
 			       LookupTag(Message,"Size","0").c_str(),TotalSize);
 
 
 	    Owner->Done(Message,atoi(LookupTag(Message,"Size","0").c_str()),
 	    Owner->Done(Message,atoi(LookupTag(Message,"Size","0").c_str()),
-			LookupTag(Message,"MD5-Hash"));
+			LookupTag(Message,"MD5-Hash"),Config);
 	    ItemDone();
 	    ItemDone();
 	    
 	    
 	    // Log that we are done
 	    // Log that we are done
@@ -327,15 +327,19 @@ bool pkgAcquire::Worker::Capabilities(string Message)
    Config->SendConfig = StringToBool(LookupTag(Message,"Send-Config"),false);
    Config->SendConfig = StringToBool(LookupTag(Message,"Send-Config"),false);
    Config->LocalOnly = StringToBool(LookupTag(Message,"Local-Only"),false);
    Config->LocalOnly = StringToBool(LookupTag(Message,"Local-Only"),false);
    Config->NeedsCleanup = StringToBool(LookupTag(Message,"Needs-Cleanup"),false);
    Config->NeedsCleanup = StringToBool(LookupTag(Message,"Needs-Cleanup"),false);
+   Config->Removable = StringToBool(LookupTag(Message,"Removable"),false);
 
 
    // Some debug text
    // Some debug text
    if (Debug == true)
    if (Debug == true)
    {
    {
       clog << "Configured access method " << Config->Access << endl;
       clog << "Configured access method " << Config->Access << endl;
-      clog << "Version:" << Config->Version << " SingleInstance:" <<
-	 Config->SingleInstance << 
-	 " Pipeline:" << Config->Pipeline << " SendConfig:" << 
-	 Config->SendConfig << endl;
+      clog << "Version:" << Config->Version <<
+	      " SingleInstance:" << Config->SingleInstance <<
+	      " Pipeline:" << Config->Pipeline << 
+	      " SendConfig:" << Config->SendConfig << 
+	      " LocalOnly: " << Config->LocalOnly << 
+	      " NeedsCleanup: " << Config->NeedsCleanup << 
+	      " Removable: " << Config->Removable << endl;
    }
    }
    
    
    return true;
    return true;

+ 4 - 3
apt-pkg/acquire.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: acquire.cc,v 1.44 1999/12/09 05:22:33 jgg Exp $
+// $Id: acquire.cc,v 1.45 2000/01/17 07:11:49 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire - File Acquiration
    Acquire - File Acquiration
@@ -65,14 +65,14 @@ pkgAcquire::pkgAcquire(pkgAcquireStatus *Log) : Log(Log)
 /* Free our memory, clean up the queues (destroy the workers) */
 /* Free our memory, clean up the queues (destroy the workers) */
 pkgAcquire::~pkgAcquire()
 pkgAcquire::~pkgAcquire()
 {
 {
+   Shutdown();
+   
    while (Configs != 0)
    while (Configs != 0)
    {
    {
       MethodConfig *Jnk = Configs;
       MethodConfig *Jnk = Configs;
       Configs = Configs->Next;
       Configs = Configs->Next;
       delete Jnk;
       delete Jnk;
    }   
    }   
-   
-   Shutdown();
 }
 }
 									/*}}}*/
 									/*}}}*/
 // Acquire::Shutdown - Clean out the acquire object			/*{{{*/
 // Acquire::Shutdown - Clean out the acquire object			/*{{{*/
@@ -493,6 +493,7 @@ pkgAcquire::MethodConfig::MethodConfig()
    Pipeline = false;
    Pipeline = false;
    SendConfig = false;
    SendConfig = false;
    LocalOnly = false;
    LocalOnly = false;
+   Removable = false;
    Next = 0;
    Next = 0;
 }
 }
 									/*}}}*/
 									/*}}}*/

+ 2 - 1
apt-pkg/acquire.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: acquire.h,v 1.25 1999/10/18 00:37:35 jgg Exp $
+// $Id: acquire.h,v 1.26 2000/01/17 07:11:49 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Acquire - File Acquiration
    Acquire - File Acquiration
@@ -230,6 +230,7 @@ struct pkgAcquire::MethodConfig
    bool SendConfig;
    bool SendConfig;
    bool LocalOnly;
    bool LocalOnly;
    bool NeedsCleanup;
    bool NeedsCleanup;
+   bool Removable;
    
    
    MethodConfig();
    MethodConfig();
 };
 };

+ 2 - 2
apt-pkg/contrib/fileutl.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: fileutl.cc,v 1.33 1999/12/10 23:40:29 jgg Exp $
+// $Id: fileutl.cc,v 1.34 2000/01/17 07:11:49 jgg Exp $
 /* ######################################################################
 /* ######################################################################
    
    
    File Utilities
    File Utilities
@@ -347,7 +347,7 @@ bool FileFd::Open(string FileName,OpenMode Mode, unsigned long Perms)
       case WriteEmpty:
       case WriteEmpty:
       {
       {
 	 struct stat Buf;
 	 struct stat Buf;
-	 if (stat(FileName.c_str(),&Buf) == 0 && S_ISLNK(Buf.st_mode))
+	 if (lstat(FileName.c_str(),&Buf) == 0 && S_ISLNK(Buf.st_mode))
 	    unlink(FileName.c_str());
 	    unlink(FileName.c_str());
 	 iFd = open(FileName.c_str(),O_RDWR | O_CREAT | O_TRUNC,Perms);
 	 iFd = open(FileName.c_str(),O_RDWR | O_CREAT | O_TRUNC,Perms);
 	 break;
 	 break;

+ 3 - 3
cmdline/apt-cdrom.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: apt-cdrom.cc,v 1.33 2000/01/16 05:36:17 jgg Exp $
+// $Id: apt-cdrom.cc,v 1.34 2000/01/17 07:11:49 jgg Exp $
 /* ######################################################################
 /* ######################################################################
    
    
    APT CDROM - Tool for handling APT's CDROM database.
    APT CDROM - Tool for handling APT's CDROM database.
@@ -589,8 +589,8 @@ bool DoAdd(CommandLine &)
 	    Name = PromptLine("");
 	    Name = PromptLine("");
 	    if (Name.empty() == false &&
 	    if (Name.empty() == false &&
 		Name.find('"') == string::npos &&
 		Name.find('"') == string::npos &&
-		Name.find(':') == string::npos &&
-		Name.find('/') == string::npos)
+		Name.find('[') == string::npos &&
+		Name.find(']') == string::npos)
 	       break;
 	       break;
 	    cout << "That is not a valid name, try again " << endl;
 	    cout << "That is not a valid name, try again " << endl;
 	 }	 
 	 }	 

+ 4 - 4
methods/cdrom.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: cdrom.cc,v 1.16 1999/10/18 00:37:36 jgg Exp $
+// $Id: cdrom.cc,v 1.17 2000/01/17 07:11:49 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    CDROM URI method for APT
    CDROM URI method for APT
@@ -38,8 +38,9 @@ class CDROMMethod : public pkgAcqMethod
 // CDROMMethod::CDROMethod - Constructor				/*{{{*/
 // CDROMMethod::CDROMethod - Constructor				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-CDROMMethod::CDROMMethod() : pkgAcqMethod("1.0",SingleInstance | LocalOnly | 
-					  SendConfig | NeedsCleanup), 
+CDROMMethod::CDROMMethod() : pkgAcqMethod("1.0",SingleInstance | LocalOnly |
+					  SendConfig | NeedsCleanup |
+					  Removable), 
                                           DatabaseLoaded(false), 
                                           DatabaseLoaded(false), 
                                           Mounted(false)
                                           Mounted(false)
 {
 {
@@ -175,7 +176,6 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
    if (NewID.empty() == false)
    if (NewID.empty() == false)
       CurrentID = NewID;
       CurrentID = NewID;
    Res.LastModified = Buf.st_mtime;
    Res.LastModified = Buf.st_mtime;
-   Res.IMSHit = true;
    Res.Size = Buf.st_size;
    Res.Size = Buf.st_size;
    URIDone(Res);
    URIDone(Res);
    return true;
    return true;