Quellcode durchsuchen

* apt-pkg/cdrom.cc:
- only unmount if APT::CDROM::NoMount is false
* methods/cdrom.cc:
- only umount if it was mounted by the method before

Michael Vogt vor 19 Jahren
Ursprung
Commit
e29dfa9ebf
5 geänderte Dateien mit 23 neuen und 12 gelöschten Zeilen
  1. 8 4
      apt-pkg/cdrom.cc
  2. 2 1
      apt-pkg/contrib/cdromutl.h
  3. 1 1
      configure.in
  4. 5 1
      debian/changelog
  5. 7 5
      methods/cdrom.cc

+ 8 - 4
apt-pkg/cdrom.cc

@@ -679,7 +679,8 @@ bool pkgCdrom::Add(pkgCdromStatus *log)
 
    if (List.size() == 0 && SourceList.size() == 0) 
    {
-      UnmountCdrom(CDROM);
+      if (_config->FindB("APT::CDROM::NoMount",false) == false) 
+	 UnmountCdrom(CDROM);
       return _error->Error("Unable to locate any package files, perhaps this is not a Debian Disc");
    }
 
@@ -718,7 +719,8 @@ bool pkgCdrom::Add(pkgCdromStatus *log)
       {
 	 if(!log) 
          {
-	    UnmountCdrom(CDROM);
+	    if (_config->FindB("APT::CDROM::NoMount",false) == false) 
+	       UnmountCdrom(CDROM);
 	    return _error->Error("No disc name found and no way to ask for it");
 	 }
 
@@ -796,7 +798,8 @@ bool pkgCdrom::Add(pkgCdromStatus *log)
       string::size_type Space = (*I).find(' ');
       if (Space == string::npos)
       {
-	 UnmountCdrom(CDROM);
+	 if (_config->FindB("APT::CDROM::NoMount",false) == false) 
+	    UnmountCdrom(CDROM);
 	 return _error->Error("Internal error");
       }
 
@@ -813,7 +816,8 @@ bool pkgCdrom::Add(pkgCdromStatus *log)
       string::size_type Space = (*I).find(' ');
       if (Space == string::npos)
       {
-	 UnmountCdrom(CDROM);
+	 if (_config->FindB("APT::CDROM::NoMount",false) == false) 
+	    UnmountCdrom(CDROM);
 	 return _error->Error("Internal error");
       }
 

+ 2 - 1
apt-pkg/contrib/cdromutl.h

@@ -8,7 +8,7 @@
    ##################################################################### */
 									/*}}}*/
 #ifndef PKGLIB_CDROMUTL_H
-#define PKGLIB_ACQUIRE_METHOD_H
+#define PKGLIB_CDROMUTL_H
 
 #include <string>
 
@@ -21,5 +21,6 @@ using std::string;
 bool MountCdrom(string Path);
 bool UnmountCdrom(string Path);
 bool IdentCdrom(string CD,string &Res,unsigned int Version = 2);
+bool IsMounted(string &Path);
 
 #endif

+ 1 - 1
configure.in

@@ -18,7 +18,7 @@ AC_CONFIG_AUX_DIR(buildlib)
 AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in)
 
 dnl -- SET THIS TO THE RELEASE VERSION --
-AC_DEFINE_UNQUOTED(VERSION,"0.6.46.4ubuntu8")
+AC_DEFINE_UNQUOTED(VERSION,"0.6.46.4ubuntu9")
 PACKAGE="apt"
 AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
 AC_SUBST(PACKAGE)

+ 5 - 1
debian/changelog

@@ -3,8 +3,12 @@ apt (0.6.46.4ubuntu9) feisty; urgency=low
   * debian/control:
     - set XS-Vcs-Bzr header
     - Set Ubuntu maintainer address
+  * apt-pkg/cdrom.cc:
+    - only unmount if APT::CDROM::NoMount is false
+  * methods/cdrom.cc:  
+    - only umount if it was mounted by the method before
 
- --
+ -- Michael Vogt <michael.vogt@ubuntu.com>  Wed,  7 Mar 2007 12:51:17 +0100
 
 apt (0.6.46.4ubuntu8) feisty; urgency=low
 

+ 7 - 5
methods/cdrom.cc

@@ -30,7 +30,7 @@ class CDROMMethod : public pkgAcqMethod
    ::Configuration Database;
    string CurrentID;
    string CDROM;
-   bool Mounted;
+   bool MountedByApt;
    
    virtual bool Fetch(FetchItem *Itm);
    string GetID(string Name);
@@ -48,7 +48,7 @@ CDROMMethod::CDROMMethod() : pkgAcqMethod("1.0",SingleInstance | LocalOnly |
 					  SendConfig | NeedsCleanup |
 					  Removable), 
                                           DatabaseLoaded(false), 
-                                          Mounted(false)
+                                          MountedByApt(false)
 {
 };
 									/*}}}*/
@@ -57,7 +57,7 @@ CDROMMethod::CDROMMethod() : pkgAcqMethod("1.0",SingleInstance | LocalOnly |
 /* */
 void CDROMMethod::Exit()
 {
-   if (Mounted == true)
+   if (MountedByApt == true)
       UnmountCdrom(CDROM);
 }
 									/*}}}*/
@@ -139,7 +139,8 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
    while (CurrentID.empty() == true)
    {
       bool Hit = false;
-      Mounted = MountCdrom(CDROM);
+      if(!IsMounted(CDROM))
+	 MountedByApt = MountCdrom(CDROM);
       for (unsigned int Version = 2; Version != 0; Version--)
       {
 	 if (IdentCdrom(CDROM,NewID,Version) == false)
@@ -160,7 +161,8 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
 	 break;
 	 
       // I suppose this should prompt somehow?
-      if (UnmountCdrom(CDROM) == false)
+      if (_config->FindB("APT::CDROM::NoMount",false) == false &&
+	  UnmountCdrom(CDROM) == false)
 	 return _error->Error(_("Unable to unmount the CD-ROM in %s, it may still be in use."),
 			      CDROM.c_str());
       if (MediaFail(Get.Host,CDROM) == false)