]> git.saurik.com Git - apt.git/commitdiff
guard ABI changes for SourcePkg/Ver in pkgCache
authorDavid Kalnischkies <david@kalnischkies.de>
Fri, 7 Nov 2014 15:45:18 +0000 (16:45 +0100)
committerDavid Kalnischkies <david@kalnischkies.de>
Sat, 8 Nov 2014 13:28:28 +0000 (14:28 +0100)
Git-Dch: Ignore

apt-pkg/cacheiterators.h
apt-pkg/deb/deblistparser.cc
apt-pkg/deb/dpkgpm.cc
apt-pkg/edsp.cc
apt-pkg/pkgcache.h
cmdline/apt-cache.cc
cmdline/apt-get.cc

index b0c02d4a20f591e261101d9ce5978e73e3941052..f8f4c05ce9d5dd63213790fd45fecdc11158d806 100644 (file)
@@ -215,12 +215,14 @@ class pkgCache::VerIterator : public Iterator<Version, VerIterator> {
        // Accessors
        inline const char *VerStr() const {return S->VerStr == 0?0:Owner->StrP + S->VerStr;}
        inline const char *Section() const {return S->Section == 0?0:Owner->StrP + S->Section;}
+#if APT_PKG_ABI >= 413
        /** \brief source package name this version comes from
           Always contains the name, even if it is the same as the binary name */
        inline const char *SourcePkgName() const {return Owner->StrP + S->SourcePkgName;}
        /** \brief source version this version comes from
           Always contains the version string, even if it is the same as the binary version */
        inline const char *SourceVerStr() const {return Owner->StrP + S->SourceVerStr;}
+#endif
        inline const char *Arch() const {
                if ((S->MultiArch & pkgCache::Version::All) == pkgCache::Version::All)
                        return "all";
index 42db341b33b8e00b5c41af140a38698728a83383..462818a039d7c24d354ab2669f5a70b5a3e335cd 100644 (file)
@@ -141,6 +141,7 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
       map_stringitem_t const idx = StoreString(pkgCacheGenerator::SECTION, Start, Stop - Start);
       Ver->Section = idx;
    }
+#if APT_PKG_ABI >= 413
    // Parse the source package name
    pkgCache::GrpIterator const G = Ver.ParentPkg().Group();
    Ver->SourcePkgName = G->Name;
@@ -192,6 +193,7 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
         }
       }
    }
+#endif
 
    Ver->MultiArch = ParseMultiArch(true);
    // Archive Size
index 0cded32e1f9e5bd93c73657eb589b5d6f98b4301..3f6039e0db849e5f1a3c35b7876baadeefcc59e6 100644 (file)
@@ -1684,7 +1684,7 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
    if (apportPkg.end() == true || apportPkg->CurrentVer == 0)
       return;
 
-   string pkgname, reportfile, srcpkgname, pkgver, arch;
+   string pkgname, reportfile, pkgver, arch;
    string::size_type pos;
    FILE *report;
 
@@ -1823,7 +1823,16 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
    time_t now = time(NULL);
    fprintf(report, "Date: %s" , ctime(&now));
    fprintf(report, "Package: %s %s\n", pkgname.c_str(), pkgver.c_str());
+#if APT_PKG_ABI >= 413
    fprintf(report, "SourcePackage: %s\n", Ver.SourcePkgName());
+#else
+   pkgRecords Recs(Cache);
+   pkgRecords::Parser &Parse = Recs.Lookup(Ver.FileList());
+   std::string srcpkgname = Parse.SourcePkg();
+   if(srcpkgname.empty())
+      srcpkgname = pkgname;
+   fprintf(report, "SourcePackage: %s\n", srcpkgname.c_str());
+#endif
    fprintf(report, "ErrorMessage:\n %s\n", errormsg);
 
    // ensure that the log is flushed
index 2ba914b16ee8e14d7655de1d644c74da2c2aca3c..3c6a7e30f903131412a414ff6449096a99ec3cc4 100644 (file)
@@ -96,7 +96,14 @@ void EDSP::WriteScenarioVersion(pkgDepCache &Cache, FILE* output, pkgCache::PkgI
                                pkgCache::VerIterator const &Ver)
 {
    fprintf(output, "Package: %s\n", Pkg.Name());
+#if APT_PKG_ABI >= 413
    fprintf(output, "Source: %s\n", Ver.SourcePkgName());
+#else
+   pkgRecords Recs(Cache);
+   pkgRecords::Parser &rec = Recs.Lookup(Ver.FileList());
+   string srcpkg = rec.SourcePkg().empty() ? Pkg.Name() : rec.SourcePkg();
+   fprintf(output, "Source: %s\n", srcpkg.c_str());
+#endif
    fprintf(output, "Architecture: %s\n", Ver.Arch());
    fprintf(output, "Version: %s\n", Ver.VerStr());
    if (Pkg.CurrentVer() == Ver)
index 4f856820509d6f0c0532a42492f27e1ed942e232..a7b7fa539ae8536b2391cc8177c766ef2ff666be 100644 (file)
@@ -510,12 +510,14 @@ struct pkgCache::Version
    map_stringitem_t VerStr;
    /** \brief section this version is filled in */
    map_stringitem_t Section;
+#if APT_PKG_ABI >= 413
    /** \brief source package name this version comes from
       Always contains the name, even if it is the same as the binary name */
    map_stringitem_t SourcePkgName;
    /** \brief source version this version comes from
       Always contains the version string, even if it is the same as the binary version */
    map_stringitem_t SourceVerStr;
+#endif
 
    /** \brief Multi-Arch capabilities of a package version */
    enum VerMultiArch { None = 0, /*!< is the default and doesn't trigger special behaviour */
index 0f4f7e1ce1e9ef30a9ce9bd716e9c46bd5263988..1bd75dfba1565f065337cdb76fe05b57b1a63974 100644 (file)
@@ -389,8 +389,10 @@ static bool Stats(CommandLine &)
            stritems.insert(V->VerStr);
         if (V->Section != 0)
            stritems.insert(V->Section);
+#if APT_PKG_ABI >= 413
         stritems.insert(V->SourcePkgName);
         stritems.insert(V->SourceVerStr);
+#endif
         for (pkgCache::DepIterator D = V.DependsList(); D.end() == false; ++D)
         {
            if (D->Version != 0)
index e9e38debc91b0f933cfdf25203af30b3952b3adf..eca4a723b28f35e3d806a4ef0677c58a3c03a5fc 100644 (file)
@@ -170,7 +170,11 @@ static std::string GetReleaseForSourceRecord(pkgSourceList *SrcList,
 // FindSrc - Find a source record                                      /*{{{*/
 // ---------------------------------------------------------------------
 /* */
+#if APT_PKG_ABI >= 413
 static pkgSrcRecords::Parser *FindSrc(const char *Name,
+#else
+static pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
+#endif
                               pkgSrcRecords &SrcRecs,string &Src,
                               CacheFile &CacheFile)
 {
@@ -278,10 +282,21 @@ static pkgSrcRecords::Parser *FindSrc(const char *Name,
                  (VF.File().Archive() != 0 && VF.File().Archive() == RelTag) ||
                  (VF.File().Codename() != 0 && VF.File().Codename() == RelTag)) 
               {
-                 Src = Ver.SourcePkgName();
                  // the Version we have is possibly fuzzy or includes binUploads,
-                 // so we use the Version of the SourcePkg
+                 // so we use the Version of the SourcePkg (empty if same as package)
+#if APT_PKG_ABI >= 413
+                 Src = Ver.SourcePkgName();
                  VerTag = Ver.SourceVerStr();
+#else
+                 pkgRecords::Parser &Parse = Recs.Lookup(VF);
+                 Src = Parse.SourcePkg();
+                 // no SourcePkg name, so it is the "binary" name
+                 if (Src.empty() == true)
+                    Src = TmpSrc;
+                 VerTag = Parse.SourceVer();
+                 if (VerTag.empty() == true)
+                    VerTag = Ver.VerStr();
+#endif
                  break;
               }
            }
@@ -312,10 +327,17 @@ static pkgSrcRecords::Parser *FindSrc(const char *Name,
         pkgCache::VerIterator Ver = Cache->GetCandidateVer(Pkg);
         if (Ver.end() == false) 
         {
+#if APT_PKG_ABI >= 413
            if (strcmp(Ver.SourcePkgName(),Ver.ParentPkg().Name()) != 0)
               Src = Ver.SourcePkgName();
            if (VerTag.empty() == true && strcmp(Ver.SourceVerStr(),Ver.VerStr()) != 0)
               VerTag = Ver.SourceVerStr();
+#else
+           pkgRecords::Parser &Parse = Recs.Lookup(Ver.FileList());
+           Src = Parse.SourcePkg();
+           if (VerTag.empty() == true)
+              VerTag = Parse.SourceVer();
+#endif
         }
       }
    }
@@ -717,6 +739,9 @@ static bool DoSource(CommandLine &CmdL)
    pkgSourceList *List = Cache.GetSourceList();
    
    // Create the text record parsers
+#if APT_PKG_ABI < 413
+   pkgRecords Recs(Cache);
+#endif
    pkgSrcRecords SrcRecs(*List);
    if (_error->PendingError() == true)
       return false;
@@ -744,8 +769,11 @@ static bool DoSource(CommandLine &CmdL)
    for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++)
    {
       string Src;
+#if APT_PKG_ABI >= 413
       pkgSrcRecords::Parser *Last = FindSrc(*I,SrcRecs,Src,Cache);
-      
+#else
+      pkgSrcRecords::Parser *Last = FindSrc(*I,Recs,SrcRecs,Src,Cache);
+#endif
       if (Last == 0) {
         return _error->Error(_("Unable to find a source package for %s"),Src.c_str());
       }
@@ -1004,6 +1032,9 @@ static bool DoBuildDep(CommandLine &CmdL)
    pkgSourceList *List = Cache.GetSourceList();
    
    // Create the text record parsers
+#if APT_PKG_ABI < 413
+   pkgRecords Recs(Cache);
+#endif
    pkgSrcRecords SrcRecs(*List);
    if (_error->PendingError() == true)
       return false;
@@ -1050,7 +1081,11 @@ static bool DoBuildDep(CommandLine &CmdL)
             Last = Type->CreateSrcPkgParser(*I);
       } else {
          // normal case, search the cache for the source file
-         Last = FindSrc(*I,SrcRecs,Src,Cache);
+#if APT_PKG_ABI >= 413
+        Last = FindSrc(*I,SrcRecs,Src,Cache);
+#else
+        Last = FindSrc(*I,Recs,SrcRecs,Src,Cache);
+#endif
       }
 
       if (Last == 0)
@@ -1407,9 +1442,18 @@ static string GetChangelogPath(CacheFile &Cache,
    pkgRecords Recs(Cache);
    pkgRecords::Parser &rec=Recs.Lookup(Ver.FileList());
    string path = flNotFile(rec.FileName());
+#if APT_PKG_ABI >= 413
    path.append(Ver.SourcePkgName());
    path.append("_");
    path.append(StripEpoch(Ver.SourceVerStr()));
+#else
+   string srcpkg = rec.SourcePkg().empty() ? Ver.ParentPkg().Name() : rec.SourcePkg();
+   string ver = Ver.VerStr();
+   // if there is a source version it always wins
+   if (rec.SourceVer() != "")
+      ver = rec.SourceVer();
+   path += srcpkg + "_" + StripEpoch(ver);
+#endif
    return path;
 }
                                                                        /*}}}*/