]> git.saurik.com Git - apt.git/blobdiff - methods/cdrom.cc
Fixed up the example sources.list. Closes: #63676
[apt.git] / methods / cdrom.cc
index c53c3ddebd37c0e7e33dbe1e4ddfe12be98fc031..c367c99a1de435f78aac5bbddcc5e5a276dd1f64 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: cdrom.cc,v 1.14 1999/08/08 03:34:08 jgg Exp $
+// $Id: cdrom.cc,v 1.17 2000/01/17 07:11:49 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:
    
@@ -35,11 +38,23 @@ class CDROMMethod : public pkgAcqMethod
 // CDROMMethod::CDROMethod - Constructor                               /*{{{*/
 // ---------------------------------------------------------------------
 /* */
-CDROMMethod::CDROMMethod() : pkgAcqMethod("1.0",SingleInstance | LocalOnly | 
-                                         SendConfig), DatabaseLoaded(false)
+CDROMMethod::CDROMMethod() : pkgAcqMethod("1.0",SingleInstance | LocalOnly |
+                                         SendConfig | NeedsCleanup |
+                                         Removable), 
+                                          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      /*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -77,6 +92,7 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
    {
       Res.LastModified = Itm->LastModified;
       Res.IMSHit = true;
+      Res.Filename = File;
       URIDone(Res);
       return true;
    }
@@ -110,7 +126,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;
@@ -148,6 +164,7 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
       }
       
       MountCdrom(CDROM);
+      Mounted = true;
    }
    
    // Found a CD
@@ -159,7 +176,6 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
    if (NewID.empty() == false)
       CurrentID = NewID;
    Res.LastModified = Buf.st_mtime;
-   Res.IMSHit = true;
    Res.Size = Buf.st_size;
    URIDone(Res);
    return true;