]> git.saurik.com Git - apt.git/commitdiff
CDROMs are unmounted
authorArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:54:53 +0000 (16:54 +0000)
committerArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:54:53 +0000 (16:54 +0000)
Author: jgg
Date: 1999-10-18 00:37:35 GMT
CDROMs are unmounted

apt-pkg/acquire-method.cc
apt-pkg/acquire-method.h
apt-pkg/acquire-worker.cc
apt-pkg/acquire-worker.h
apt-pkg/acquire.cc
apt-pkg/acquire.h
cmdline/apt-get.cc
debian/changelog
doc/method.sgml
methods/cdrom.cc

index 13b11c8dbc0d61bc28aba25b0be00ee0b42b0019..5b7251a5fe0aefebfc2a3ce2978f474e9de81802 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-method.cc,v 1.20 1999/08/04 02:39:13 jgg Exp $
+// $Id: acquire-method.cc,v 1.21 1999/10/18 00:37:35 jgg Exp $
 /* ######################################################################
 
    Acquire Method
@@ -49,6 +49,9 @@ pkgAcqMethod::pkgAcqMethod(const char *Ver,unsigned long Flags)
 
    if ((Flags & LocalOnly) == LocalOnly)
       strcat(End,"Local-Only: true\n");
+
+   if ((Flags & NeedsCleanup) == NeedsCleanup)
+      strcat(End,"Needs-Cleanup: true\n");
    strcat(End,"\n");
 
    if (write(STDOUT_FILENO,S,strlen(S)) != (signed)strlen(S))
@@ -309,10 +312,9 @@ int pkgAcqMethod::Run(bool Single)
       {
         if (Single == false)
            if (WaitFd(STDIN_FILENO) == false)
-              return 0;
-      
+              break;
         if (ReadMessages(STDIN_FILENO,Messages) == false)
-           return 0;
+           break;
       }
             
       // Single mode exits if the message queue is empty
@@ -332,7 +334,7 @@ int pkgAcqMethod::Run(bool Single)
       }
 
       switch (Number)
-      {
+      {         
         case 601:
         if (Configuration(Message) == false)
            return 100;
@@ -365,6 +367,7 @@ int pkgAcqMethod::Run(bool Single)
       }      
    }
 
+   Exit();
    return 0;
 }
                                                                        /*}}}*/
index 225ec15a8d584e17df4e07650997aacc0ca7968b..ca03dd1d1a559738d0ebceafc87e678a473fccb3 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-method.h,v 1.11 1999/07/20 05:53:33 jgg Exp $
+// $Id: acquire-method.h,v 1.12 1999/10/18 00:37:35 jgg Exp $
 /* ######################################################################
 
    Acquire Method - Method helper class + functions
@@ -61,12 +61,13 @@ class pkgAcqMethod
    void URIStart(FetchResult &Res);
    void URIDone(FetchResult &Res,FetchResult *Alt = 0);
    bool MediaFail(string Required,string Drive);
-   
+   void Exit() {};
+
    public:
 
    enum CnfFlags {SingleInstance = (1<<0),
                   Pipeline = (1<<1), SendConfig = (1<<2),
-                  LocalOnly = (1<<3)};
+                  LocalOnly = (1<<3), NeedsCleanup = (1<<4)};
 
    void Log(const char *Format,...);
    void Status(const char *Format,...);
index 972ab2455027de38afa06f40dad1f11fcaa3ac02..f6b14da3c4b19a6a943ad4677d1931e41fd22882 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-worker.cc,v 1.27 1999/08/28 01:49:56 jgg Exp $
+// $Id: acquire-worker.cc,v 1.28 1999/10/18 00:37:35 jgg Exp $
 /* ######################################################################
 
    Acquire Worker 
@@ -86,7 +86,10 @@ pkgAcquire::Worker::~Worker()
    
    if (Process > 0)
    {
-      kill(Process,SIGINT);
+      /* Closing of stdin is the signal to exit and die when the process
+         indicates it needs cleanup */
+      if (Config->NeedsCleanup == false)
+        kill(Process,SIGINT);
       ExecWait(Process,Access.c_str(),true);
    }   
 }
@@ -323,6 +326,7 @@ bool pkgAcquire::Worker::Capabilities(string Message)
    Config->Pipeline = StringToBool(LookupTag(Message,"Pipeline"),false);
    Config->SendConfig = StringToBool(LookupTag(Message,"Send-Config"),false);
    Config->LocalOnly = StringToBool(LookupTag(Message,"Local-Only"),false);
+   Config->NeedsCleanup = StringToBool(LookupTag(Message,"Needs-Cleanup"),false);
 
    // Some debug text
    if (Debug == true)
index 4c3a666ae2c7b052237bb6a304c41e84f8e70f41..797ea3f7cb00387bdb36c60f80383f8c6c4cac48 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-worker.h,v 1.10 1999/05/23 06:47:43 jgg Exp $
+// $Id: acquire-worker.h,v 1.11 1999/10/18 00:37:35 jgg Exp $
 /* ######################################################################
 
    Acquire Worker - Worker process manager
@@ -79,6 +79,7 @@ class pkgAcquire::Worker
    bool QueueItem(pkgAcquire::Queue::QItem *Item);
    bool Start();
    void Pulse();
+   inline const MethodConfig *GetConf() const {return Config;};
    
    Worker(Queue *OwnerQ,MethodConfig *Config,pkgAcquireStatus *Log);
    Worker(MethodConfig *Config);
index 99dacf5be097f163acfec1171a103d6379d5e266..7a93fbd8e180d191c89d508be863060b30e2d733 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire.cc,v 1.39 1999/10/16 19:53:18 jgg Exp $
+// $Id: acquire.cc,v 1.40 1999/10/18 00:37:35 jgg Exp $
 /* ######################################################################
 
    Acquire - File Acquiration
@@ -63,7 +63,7 @@ pkgAcquire::~pkgAcquire()
    Shutdown();
 }
                                                                        /*}}}*/
-// pkgAcquire::Shutdown - Clean out the acquire object                 /*{{{*/
+// Acquire::Shutdown - Clean out the acquire object                    /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 void pkgAcquire::Shutdown()
@@ -345,11 +345,11 @@ pkgAcquire::RunResult pkgAcquire::Run()
    // Shut down the acquire bits
    Running = false;
    for (Queue *I = Queues; I != 0; I = I->Next)
-      I->Shutdown();
+      I->Shutdown(false);
 
    // Shut down the items
    for (Item **I = Items.begin(); I != Items.end(); I++)
-      (*I)->Finished();
+      (*I)->Finished(); 
    
    if (_error->PendingError())
       return Failed;
@@ -453,7 +453,7 @@ unsigned long pkgAcquire::PartialPresent()
    return Total;
 }
                                                                        /*}}}*/
-// pkgAcquire::UriBegin - Start iterator for the uri list              /*{{{*/
+// Acquire::UriBegin - Start iterator for the uri list                 /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 pkgAcquire::UriIterator pkgAcquire::UriBegin()
@@ -461,7 +461,7 @@ pkgAcquire::UriIterator pkgAcquire::UriBegin()
    return UriIterator(Queues);
 }
                                                                        /*}}}*/
-// pkgAcquire::UriEnd - End iterator for the uri list                  /*{{{*/
+// Acquire::UriEnd - End iterator for the uri list                     /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 pkgAcquire::UriIterator pkgAcquire::UriEnd()
@@ -501,7 +501,7 @@ pkgAcquire::Queue::Queue(string Name,pkgAcquire *Owner) : Name(Name),
 /* */
 pkgAcquire::Queue::~Queue()
 {
-   Shutdown();
+   Shutdown(true);
    
    while (Items != 0)
    {
@@ -560,44 +560,53 @@ bool pkgAcquire::Queue::Dequeue(Item *Owner)
                                                                        /*}}}*/
 // Queue::Startup - Start the worker processes                         /*{{{*/
 // ---------------------------------------------------------------------
-/* */
+/* It is possible for this to be called with a pre-existing set of
+   workers. */
 bool pkgAcquire::Queue::Startup()
 {
-   Shutdown();
-   
-   URI U(Name);
-   pkgAcquire::MethodConfig *Cnf = Owner->GetConfig(U.Access);
-   if (Cnf == 0)
-      return false;
-   
-   Workers = new Worker(this,Cnf,Owner->Log);
-   Owner->Add(Workers);
-   if (Workers->Start() == false)
-      return false;
-   
-   /* When pipelining we commit 10 items. This needs to change when we
-      added other source retry to have cycle maintain a pipeline depth
-      on its own. */
-   if (Cnf->Pipeline == true)
-      MaxPipeDepth = 10;
-   else
-      MaxPipeDepth = 1;
+   if (Workers == 0)
+   {
+      URI U(Name);
+      pkgAcquire::MethodConfig *Cnf = Owner->GetConfig(U.Access);
+      if (Cnf == 0)
+        return false;
+      
+      Workers = new Worker(this,Cnf,Owner->Log);
+      Owner->Add(Workers);
+      if (Workers->Start() == false)
+        return false;
+      
+      /* When pipelining we commit 10 items. This needs to change when we
+         added other source retry to have cycle maintain a pipeline depth
+         on its own. */
+      if (Cnf->Pipeline == true)
+        MaxPipeDepth = 10;
+      else
+        MaxPipeDepth = 1;
+   }
    
    return Cycle();
 }
                                                                        /*}}}*/
 // Queue::Shutdown - Shutdown the worker processes                     /*{{{*/
 // ---------------------------------------------------------------------
-/* */
-bool pkgAcquire::Queue::Shutdown()
+/* If final is true then all workers are eliminated, otherwise only workers
+   that do not need cleanup are removed */
+bool pkgAcquire::Queue::Shutdown(bool Final)
 {
    // Delete all of the workers
-   while (Workers != 0)
+   pkgAcquire::Worker **Cur = &Workers;
+   while (*Cur != 0)
    {
-      pkgAcquire::Worker *Jnk = Workers;
-      Workers = Workers->NextQueue;
-      Owner->Remove(Jnk);
-      delete Jnk;
+      pkgAcquire::Worker *Jnk = *Cur;
+      if (Final == true || Jnk->GetConf()->NeedsCleanup == false)
+      {
+        *Cur = Jnk->NextQueue;
+        Owner->Remove(Jnk);
+        delete Jnk;
+      }
+      else
+        Cur = &(*Cur)->NextQueue;      
    }
    
    return true;
index 0d12b554fef2683850d5a0b4174c945dec00d85e..e05ab3adc686968e9c83ebf73e71b205d33c01c6 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire.h,v 1.24 1999/07/20 05:53:33 jgg Exp $
+// $Id: acquire.h,v 1.25 1999/10/18 00:37:35 jgg Exp $
 /* ######################################################################
 
    Acquire - File Acquiration
@@ -175,7 +175,7 @@ class pkgAcquire::Queue
    bool ItemDone(QItem *Itm);
    
    bool Startup();
-   bool Shutdown();
+   bool Shutdown(bool Final);
    bool Cycle();
    void Bump();
    
@@ -229,7 +229,8 @@ struct pkgAcquire::MethodConfig
    bool Pipeline;
    bool SendConfig;
    bool LocalOnly;
-      
+   bool NeedsCleanup;
+   
    MethodConfig();
 };
 
index aeb01485f9d924e00f5dba8ec28078fc97aaa118..06422ada51e36f810d5bb6d9a1beb384dbdc8e31 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: apt-get.cc,v 1.79 1999/10/17 07:49:41 jgg Exp $
+// $Id: apt-get.cc,v 1.80 1999/10/18 00:37:35 jgg Exp $
 /* ######################################################################
    
    apt-get - Cover for dpkg
@@ -660,7 +660,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,bool Saftey =
    while (1)
    {
       if (_config->FindB("APT::Get::No-Download",false) == false)
-        ifFetcher.Run() == pkgAcquire::Failed)
+        if (Fetcher.Run() == pkgAcquire::Failed)
            return false;
       
       // Print out errors
@@ -672,8 +672,6 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,bool Saftey =
             (*I)->Complete == true)
            continue;
         
-        (*I)->Finished();
-        
         if ((*I)->Status == pkgAcquire::Item::StatIdle)
         {
            Transient = true;
index b4e5991b2783a1654c17a0693a46f29c3e6da929..070ce3af707b4dbe596a0d5c53be7925ba52939b 100644 (file)
@@ -2,7 +2,7 @@ apt (0.3.13.1) unstable; urgency=low
 
   * Fix Perl or group pre-depends thing Closes: #46091, #46096, #46233, #45901
   * Fix handling of dpkg's conversions from < -> <= Closes: #46094, #47088
-  * Make unparsable priorities non-fatal Closes: #46266, #46267, #46293, #46298  
+  * Make unparsable priorities non-fatal Closes: #46266, #46267, #46293, #46298
   * Fix handling of '/' for the dist name. Closes: #43830, #45640, #45692
   * Fixed 'Method gave a blank filename' error from IMS queries onto CDs.
     Closes: #45034, #45695, #46537
@@ -16,6 +16,7 @@ apt (0.3.13.1) unstable; urgency=low
   * Tweaked Dselect 'update' script to re-gen the avail file even in the
     event of a failure Closes: #47112
   * Retries for source archives too Closes: #47529
+  * Unmounts CDROMs iff it mounted them Closes: #45299
   
  -- Jason Gunthorpe <jgg@debian.org>  Fri,  3 Sep 1999 09:04:28 -0700
  
index ae4b713f14f1d75285ce229c0c02ea785678b5b5..95fb8a52bdfefc0435c54656e313d5e7fd89b339 100644 (file)
@@ -4,7 +4,7 @@
 <title>APT Method Interface </title>
 
 <author>Jason Gunthorpe <email>jgg@debian.org</email></author>
-<version>$Id: method.sgml,v 1.6 1998/12/14 04:00:34 jgg Exp $</version>
+<version>$Id: method.sgml,v 1.7 1999/10/18 00:37:36 jgg Exp $</version>
 
 <abstract>
 This document describes the interface that APT uses to the archive
@@ -219,6 +219,9 @@ the ones it wants.
 <tag>Pipeline<item>The method is capable of pipelining.
 <tag>Local<item>The method only returns Filename: feilds.
 <tag>Send-Config<item>Send configuration to the method.
+<tag>Needs-Cleanup<item>The process is kept around while the files it returned
+are being used. This is primarily intended for CDROM and File URIs that need
+to unmount filesystems.
 <tag>Version<item>Version string for the method
 </taglist>
 
@@ -229,7 +232,8 @@ This is a list of which headers each status code can use
 Displays the capabilities of the method. Methods should set the
 pipeline bit if their underlying protocol supports pipeling. The
 only known method that does support pipelining is http.
-Fields: Version, Single-Instance, Pre-Scan, Pipeline, Send-Config
+Fields: Version, Single-Instance, Pre-Scan, Pipeline, Send-Config, 
+Needs-Cleanup
 
 <tag>101 Log<item>
 A log message may be printed to the screen if debugging is enabled. This
index befd531a657e6529f9a5ac6275d7f2769f0808aa..e2eddf19e6b56334c889941aaa1b9fc38bfbf3f9 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: cdrom.cc,v 1.15 1999/10/02 04:14:54 jgg Exp $
+// $Id: cdrom.cc,v 1.16 1999/10/18 00:37:36 jgg Exp $
 /* ######################################################################
 
    CDROM URI method for APT
@@ -23,9 +23,12 @@ class CDROMMethod : public pkgAcqMethod
    bool DatabaseLoaded;
    ::Configuration Database;
    string CurrentID;
+   string CDROM;
+   bool Mounted;
    
    virtual bool Fetch(FetchItem *Itm);
    string GetID(string Name);
+   virtual void Exit();
    
    public:
    
@@ -36,10 +39,21 @@ class CDROMMethod : public pkgAcqMethod
 // ---------------------------------------------------------------------
 /* */
 CDROMMethod::CDROMMethod() : pkgAcqMethod("1.0",SingleInstance | LocalOnly | 
-                                         SendConfig), DatabaseLoaded(false)
+                                         SendConfig | NeedsCleanup), 
+                                          DatabaseLoaded(false), 
+                                          Mounted(false)
 {
 };
                                                                        /*}}}*/
+// CDROMMethod::Exit - Unmount the disc if necessary                   /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void CDROMMethod::Exit()
+{
+   if (Mounted == true)
+      UnmountCdrom(CDROM);
+}
+                                                                       /*}}}*/
 // CDROMMethod::GetID - Search the database for a matching string      /*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -111,7 +125,7 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
       return true;
    }
    
-   string CDROM = _config->FindDir("Acquire::cdrom::mount","/cdrom/");
+   CDROM = _config->FindDir("Acquire::cdrom::mount","/cdrom/");
    if (CDROM[0] == '.')
       CDROM= SafeGetCWD() + '/' + CDROM;
    string NewID;
@@ -149,6 +163,7 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
       }
       
       MountCdrom(CDROM);
+      Mounted = true;
    }
    
    // Found a CD