[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#674100: apt: apt-cdrom add generates broken cdroms.list



tags 674100 patch
thanks


The 'apt-cdrom add generates broken /var/lib/apt/cdroms.list' issue was introduced in apt version 0.9.3 with a change that replaced generation of proper cdroms.list with a config dump. This made it impossible to use cd/dvd repository and broke debian installation from cd/dvd media.

Reverting the change and recompiling the package brings apt-cdrom add functionality back.

Patch reverting the puzzling change is attached.


  * apt-pkg/cdrom.cc:
    - Revert "use Dump() to generate the configuration output" change
      introduced in release 0.9.3. (Closes: #674100)

--- ../apt-0.9.5.1/apt-pkg/cdrom.cc	2012-05-11 10:15:50.000000000 -0400
+++ apt-pkg/cdrom.cc	2012-06-05 15:05:48.240446258 -0400
@@ -409,10 +409,27 @@
    
    /* Write out all of the configuration directives by walking the
       configuration tree */
-   _config->Dump(Out, NULL, "%f \"%v\";\n", false);
+   const Configuration::Item *Top = Cnf.Tree(0);
+   for (; Top != 0;)
+   {
+      // Print the config entry
+      if (Top->Value.empty() == false)
+	 Out <<  Top->FullTag() + " \"" << Top->Value << "\";" << endl;
+      
+      if (Top->Child != 0)
+      {
+	 Top = Top->Child;
+	 continue;
+      }
+      
+      while (Top != 0 && Top->Next == 0)
+	 Top = Top->Parent;
+      if (Top != 0)
+	 Top = Top->Next;
+   }   
 
    Out.close();
-
+   
    if (FileExists(DFile) == true && link(DFile.c_str(),string(DFile + '~').c_str()) != 0)
       return _error->Errno("link", "Failed to link %s to %s~", DFile.c_str(), DFile.c_str());
    if (rename(NewFile.c_str(),DFile.c_str()) != 0)

Reply to: