]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/pkgcachegen.cc
* apt-pkg/cdrom.{cc,h}:
[apt.git] / apt-pkg / pkgcachegen.cc
index c9a9a753ca1aad96558d89daac58e2feaae2cc52..70dcd9de999959a8b2cea135bd201a5256076fa0 100644 (file)
@@ -98,6 +98,7 @@ pkgCacheGenerator::~pkgCacheGenerator()
       return;
    
    Cache.HeaderP->Dirty = false;
+   Cache.HeaderP->CacheFileSize = Map.Size();
    Map.Sync(0,sizeof(pkgCache::Header));
 }
                                                                        /*}}}*/
@@ -178,23 +179,12 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
       if (PackageName.empty() == true)
         return false;
 
-      /* As we handle Arch all packages as architecture bounded
-         we add all information to every (simulated) arch package */
-      std::vector<string> genArch;
-      if (List.ArchitectureAll() == true) {
-        genArch = APT::Configuration::getArchitectures();
-        if (genArch.size() != 1)
-           genArch.push_back("all");
-      } else
-        genArch.push_back(List.Architecture());
-
-      for (std::vector<string>::const_iterator arch = genArch.begin();
-          arch != genArch.end(); ++arch)
-      {
+      string const Arch = List.Architecture();
       // Get a pointer to the package structure
       pkgCache::PkgIterator Pkg;
       Dynamic<pkgCache::PkgIterator> DynPkg(Pkg);
-      if (NewPackage(Pkg, PackageName, *arch) == false)
+      if (NewPackage(Pkg, PackageName, Arch) == false)
         return _error->Error(_("Error occurred while processing %s (NewPackage)"),PackageName.c_str());
       Counter++;
       if (Counter % 100 == 0 && Progress != 0)
@@ -351,7 +341,6 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
 
       if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false)
         return _error->Error(_("Error occurred while processing %s (NewFileDesc2)"),PackageName.c_str());
-      }
    }
 
    FoundFileDeps |= List.HasFileDeps();
@@ -491,7 +480,8 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const string &Name
    // Set the name, arch and the ID
    Pkg->Name = Grp->Name;
    Pkg->Group = Grp.Index();
-   map_ptrloc const idxArch = WriteUniqString(Arch.c_str());
+   // all is mapped to the native architecture
+   map_ptrloc const idxArch = (Arch == "all") ? Cache.HeaderP->Architecture : WriteUniqString(Arch.c_str());
    if (unlikely(idxArch == 0))
       return false;
    Pkg->Arch = idxArch;
@@ -638,27 +628,22 @@ bool pkgCacheGenerator::FinishCache(OpProgress *Progress)
         Dynamic<pkgCache::PkgIterator> DynP(P);
         for (; P.end() != true; P = G.NextPkg(P))
         {
-           if (strcmp(P.Arch(),"all") == 0)
-              continue;
            pkgCache::PkgIterator allPkg;
            Dynamic<pkgCache::PkgIterator> DynallPkg(allPkg);
            pkgCache::VerIterator V = P.VersionList();
            Dynamic<pkgCache::VerIterator> DynV(V);
            for (; V.end() != true; V++)
            {
-              string const Arch = V.Arch(true);
+              char const * const Arch = P.Arch();
               map_ptrloc *OldDepLast = NULL;
               /* MultiArch handling introduces a lot of implicit Dependencies:
                - MultiArch: same → Co-Installable if they have the same version
                - Architecture: all → Need to be Co-Installable for internal reasons
                - All others conflict with all other group members */
-              bool const coInstall = (V->MultiArch == pkgCache::Version::All ||
-                                       V->MultiArch == pkgCache::Version::Same);
-              if (V->MultiArch == pkgCache::Version::All && allPkg.end() == true)
-                 allPkg = G.FindPkg("all");
+              bool const coInstall = ((V->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same);
               for (vector<string>::const_iterator A = archs.begin(); A != archs.end(); ++A)
               {
-                 if (*A == Arch)
+                 if (Arch == 0 || *A == Arch)
                     continue;
                  /* We allow only one installed arch at the time
                     per group, therefore each group member conflicts
@@ -677,13 +662,6 @@ bool pkgCacheGenerator::FinishCache(OpProgress *Progress)
                     NewDepends(D, V, V.VerStr(),
                                pkgCache::Dep::NotEquals, pkgCache::Dep::DpkgBreaks,
                                OldDepLast);
-                    if (V->MultiArch == pkgCache::Version::All)
-                    {
-                       // Depend on ${self}:all which does depend on nothing
-                       NewDepends(allPkg, V, V.VerStr(),
-                                  pkgCache::Dep::Equals, pkgCache::Dep::Depends,
-                                  OldDepLast);
-                    }
                  } else {
                        // Conflicts: ${self}:other
                        NewDepends(D, V, "",
@@ -806,7 +784,8 @@ bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator &Ver,
    pkgCache &Cache = Owner->Cache;
 
    // We do not add self referencing provides
-   if (Ver.ParentPkg().Name() == PkgName && PkgArch == Ver.Arch(true))
+   if (Ver.ParentPkg().Name() == PkgName && (PkgArch == Ver.ParentPkg().Arch() ||
+       (PkgArch == "all" && strcmp((Cache.StrP + Cache.HeaderP->Architecture), Ver.ParentPkg().Arch()) == 0)))
       return true;
    
    // Get a structure
@@ -1191,16 +1170,32 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
    SPtr<DynamicMMap> Map;
    if (Writeable == true && CacheFile.empty() == false)
    {
+      _error->PushToStack();
       unlink(CacheFile.c_str());
-      CacheF = new FileFd(CacheFile,FileFd::WriteEmpty);
+      CacheF = new FileFd(CacheFile,FileFd::WriteAtomic);
       fchmod(CacheF->Fd(),0644);
       Map = CreateDynamicMMap(CacheF, MMap::Public);
       if (_error->PendingError() == true)
-        return false;
-      if (Debug == true)
+      {
+        delete CacheF.UnGuard();
+        delete Map.UnGuard();
+        if (Debug == true)
+           std::clog << "Open filebased MMap FAILED" << std::endl;
+        Writeable = false;
+        if (AllowMem == false)
+        {
+           _error->MergeWithStack();
+           return false;
+        }
+        _error->RevertToStack();
+      }
+      else if (Debug == true)
+      {
+        _error->MergeWithStack();
         std::clog << "Open filebased MMap" << std::endl;
+      }
    }
-   else
+   if (Writeable == false || CacheFile.empty() == true)
    {
       // Just build it in memory..
       Map = CreateDynamicMMap(NULL);
@@ -1254,7 +1249,7 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
       // Write it back
       if (Writeable == true && SrcCacheFile.empty() == false)
       {
-        FileFd SCacheF(SrcCacheFile,FileFd::WriteEmpty);
+        FileFd SCacheF(SrcCacheFile,FileFd::WriteAtomic);
         if (_error->PendingError() == true)
            return false;