X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/51b2a0fc603c8e4fe667bf7a278bd1ce151e38a3..fce9f472046344d15d4f4df281a003d837cf4177:/apt-pkg/cdrom.cc?ds=sidebyside

diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc
index 50c204371..a5668a50a 100644
--- a/apt-pkg/cdrom.cc
+++ b/apt-pkg/cdrom.cc
@@ -269,6 +269,29 @@ bool pkgCdrom::DropBinaryArch(vector<string> &List)
       --I; // the next entry is at the same index after the erase
    }
    
+   return true;
+}
+									/*}}}*/
+// DropTranslation - Dump unwanted Translation-<lang> files		/*{{{*/
+// ---------------------------------------------------------------------
+/* Here we drop everything that is not configured in Acquire::Languages */
+bool pkgCdrom::DropTranslation(vector<string> &List)
+{
+   for (unsigned int I = 0; I < List.size(); I++)
+   {
+      const char *Start;
+      if ((Start = strstr(List[I].c_str(), "/Translation-")) == NULL)
+	 continue;
+      Start += strlen("/Translation-");
+
+      if (APT::Configuration::checkLanguage(Start, true) == true)
+	 continue;
+
+      // not accepted -> Erase it
+      List.erase(List.begin() + I);
+      --I; // the next entry is at the same index after the erase
+   }
+
    return true;
 }
 									/*}}}*/
@@ -363,6 +386,7 @@ void pkgCdrom::ReduceSourcelist(string CD,vector<string> &List)
 
       string Word1 = string(*I,Space,SSpace-Space);
       string Prefix = string(*I,0,Space);
+      string Component = string(*I,SSpace);
       for (vector<string>::iterator J = List.begin(); J != I; ++J)
       {
 	 // Find a space..
@@ -377,9 +401,11 @@ void pkgCdrom::ReduceSourcelist(string CD,vector<string> &List)
 	    continue;
 	 if (string(*J,Space2,SSpace2-Space2) != Word1)
 	    continue;
-	 
-	 *J += string(*I,SSpace);
-	 *I = string();
+
+	 string Component2 = string(*J, SSpace2) + " ";
+	 if (Component2.find(Component + " ") == std::string::npos)
+	    *J += Component;
+	 I->clear();
       }
    }   
 
@@ -409,29 +435,12 @@ bool pkgCdrom::WriteDatabase(Configuration &Cnf)
    
    /* Write out all of the configuration directives by walking the
       configuration tree */
-   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;
-   }   
+   Cnf.Dump(Out, NULL, "%f \"%v\";\n", false);
 
    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 (FileExists(DFile) == true)
+      rename(DFile.c_str(), string(DFile + '~').c_str());
    if (rename(NewFile.c_str(),DFile.c_str()) != 0)
       return _error->Errno("rename","Failed to rename %s.new to %s",
 			   DFile.c_str(),DFile.c_str());
@@ -728,6 +737,8 @@ bool pkgCdrom::Add(pkgCdromStatus *log)					/*{{{*/
    DropRepeats(SigList,"InRelease");
    _error->RevertToStack();
    DropRepeats(TransList,"");
+   if (_config->FindB("APT::CDROM::DropTranslation", true) == true)
+      DropTranslation(TransList);
    if(log != NULL) {
       msg.str("");
       ioprintf(msg, _("Found %zu package indexes, %zu source indexes, "
@@ -818,6 +829,14 @@ bool pkgCdrom::Add(pkgCdromStatus *log)					/*{{{*/
       log->Update(msg.str());
       log->Update(_("Copying package lists..."), STEP_COPY);
    }
+
+   // check for existence and possibly create state directory for copying
+   string const listDir = _config->FindDir("Dir::State::lists");
+   string const partialListDir = listDir + "partial/";
+   if (CreateAPTDirectoryIfNeeded(_config->FindDir("Dir::State"), partialListDir) == false &&
+       CreateAPTDirectoryIfNeeded(listDir, partialListDir) == false)
+      return _error->Errno("cdrom", _("List directory %spartial is missing."), listDir.c_str());
+
    // take care of the signatures and copy them if they are ok
    // (we do this before PackageCopy as it modifies "List" and "SourceList")
    SigVerify SignVerify;