- much simpler multilib handling by renaming only non-native packages
authorpmatilai <pmatilai>
Tue, 31 Jan 2006 16:25:36 +0000 (16:25 +0000)
committerpmatilai <pmatilai>
Tue, 31 Jan 2006 16:25:36 +0000 (16:25 +0000)
apt-pkg/rpm/rpmlistparser.cc
apt-pkg/rpm/rpmlistparser.h
apt-pkg/rpm/rpmpackagedata.cc
apt-pkg/rpm/rpmpackagedata.h

index 25715e3..4b54936 100644 (file)
@@ -47,16 +47,13 @@ rpmListParser::rpmListParser(RPMHandler *Handler)
    {
 #ifdef WITH_HASH_MAP
       SeenPackages = new SeenPackagesType(517);
-      SeenMultiPackages = new SeenMultiPackagesType(517);
 #else
       SeenPackages = new SeenPackagesType;
-      SeenMultiPackages = new SeenMultiPackagesType;
 #endif
    }
    else
    {
       SeenPackages = NULL;
-      SeenMultiPackages = NULL;
    }
    RpmData = RPMPackageData::Singleton();
 }
@@ -65,7 +62,6 @@ rpmListParser::rpmListParser(RPMHandler *Handler)
 rpmListParser::~rpmListParser()
 {
    delete SeenPackages;
-   delete SeenMultiPackages;
 }
 
 // ListParser::UniqFindTagWrite - Find the tag and write a unq string  /*{{{*/
@@ -93,6 +89,7 @@ unsigned long rpmListParser::UniqFindTagWrite(int Tag)
    
    return WriteUniqString(Start,Stop - Start);
 }
+
                                                                         /*}}}*/
 // ListParser::Package - Return the package name                       /*{{{*/
 // ---------------------------------------------------------------------
@@ -121,26 +118,11 @@ string rpmListParser::Package()
    } 
 
    bool IsDup = false;
-   bool IsMulti = false;
    string Name = str;
-   string BaseArch = _config->Find("APT::Architecture");
 
-   if (RpmData->IsMultiArchPackage(Name) == true)
-      IsMulti = true;
-   else if (SeenMultiPackages != NULL) {
-      if (SeenMultiPackages->find(Name.c_str()) != SeenMultiPackages->end())
-      {
-        RpmData->SetMultiArchPackage(Name);
-        MultiArchPackage(Name);
-        IsMulti = true;
-      }
-   }
-   if (IsMulti == true)
-   {
-      Name += "@" + Architecture();     
-      CurrentName = Name;
-      Multilib = true;
-      return Name;
+   if (IsCompatArch(Architecture()) == true) {
+        Name += ".32bit";       
+        CurrentName = Name;
    }
 
    
@@ -182,6 +164,22 @@ string rpmListParser::Package()
    CurrentName = Name;
    return Name;
 }
+
+bool rpmListParser::IsCompatArch(string Architecture)
+{
+   bool compat = false;
+   string BaseArch = _config->Find("APT::Architecture");
+   // ugh, gpg-pubkey doesn't have arch set
+   if (Architecture == "") {
+      return false;
+   }
+   // TODO: arch vs basearch isn't enough, should handle eg x86_64 vs ia32e
+   // and other fun..
+   if (Architecture != BaseArch && Architecture != "noarch") {
+      compat = true;
+   }
+   return compat;
+}
                                                                         /*}}}*/
 // ListParser::Arch - Return the architecture string                   /*{{{*/
 // ---------------------------------------------------------------------
@@ -296,8 +294,6 @@ bool rpmListParser::UsePackage(pkgCache::PkgIterator Pkg,
 {
    if (SeenPackages != NULL)
       (*SeenPackages)[Pkg.Name()] = true;
-   if (SeenMultiPackages != NULL)
-      (*SeenMultiPackages)[Pkg.Name()] = true;
    if (Pkg->Section == 0)
       Pkg->Section = UniqFindTagWrite(RPMTAG_GROUP);
    if (_error->PendingError()) 
@@ -706,8 +702,6 @@ bool rpmListParser::Step()
       
       string RealName = Package();
 
-      if (Multilib == true)
-        RealName = RealName.substr(0,RealName.find('@'));
       if (Duplicated == true)
         RealName = RealName.substr(0,RealName.find('#'));
       if (RpmData->IgnorePackage(RealName) == true)
@@ -849,7 +843,7 @@ void rpmListParser::VirtualizePackage(string Name)
    FromPkgI->CurrentState = 0;
 }
 
-void rpmListParser::MultiArchPackage(string Name)
+void rpmListParser::CompatArchPackage(string Name)
 {
    pkgCache::PkgIterator FromPkgI = Owner->GetCache().FindPkg(Name);
 
@@ -859,7 +853,7 @@ void rpmListParser::MultiArchPackage(string Name)
 
    pkgCache::VerIterator FromVerI = FromPkgI.VersionList();
    while (FromVerI.end() == false) {
-      string MangledName = Name+"@"+string(FromVerI.Arch());
+      string MangledName = Name+".32bit";
 
       // Get the new package.
       pkgCache::PkgIterator ToPkgI = Owner->GetCache().FindPkg(MangledName);
index 09c3492..4aa6cd8 100644 (file)
@@ -38,17 +38,12 @@ class rpmListParser : public pkgCacheGenerator::ListParser
 #ifdef WITH_HASH_MAP
    typedef hash_map<const char*,bool,
                    hash<const char*>,cstr_eq_pred> SeenPackagesType;
-   typedef hash_map<const char*,bool,
-                   hash<const char*>,cstr_eq_pred> SeenMultiPackagesType;
 #else
    typedef map<const char*,bool,cstr_lt_pred> SeenPackagesType;
-   typedef map<const char*,bool,cstr_lt_pred> SeenMultiPackagesType;
 #endif
    SeenPackagesType *SeenPackages;
-   SeenMultiPackagesType *SeenMultiPackages;
    
    bool Duplicated;
-   bool Multilib;
    
    unsigned long UniqFindTagWrite(int Tag);
    bool ParseStatus(pkgCache::PkgIterator Pkg,pkgCache::VerIterator Ver);
@@ -68,6 +63,7 @@ class rpmListParser : public pkgCacheGenerator::ListParser
    virtual string Package();
    virtual string Version();
    virtual string Architecture();
+   virtual bool IsCompatArch(string Architecture);
    virtual bool NewVersion(pkgCache::VerIterator Ver);
    virtual unsigned short VersionHash();
    virtual bool UsePackage(pkgCache::PkgIterator Pkg,
@@ -89,7 +85,7 @@ class rpmListParser : public pkgCacheGenerator::ListParser
    bool LoadReleaseInfo(pkgCache::PkgFileIterator FileI,FileFd &File);
 
    void VirtualizePackage(string Name);
-   void MultiArchPackage(string Name);
+   void CompatArchPackage(string Name);
    
    rpmListParser(RPMHandler *Handler);
    ~rpmListParser();
index 3c400bf..489bd96 100644 (file)
@@ -112,21 +112,6 @@ RPMPackageData::RPMPackageData()
          DuplicatedPatterns.push_back(ptrn);
    }
 
-   // Populate MultiArch packages.
-   Top = _config->Tree("RPM::MultiArch");
-   for (Top = (Top == 0?0:Top->Child); Top != 0; Top = Top->Next)
-   {
-      regex_t *ptrn = new regex_t;
-      if (regcomp(ptrn,Top->Value.c_str(),REG_EXTENDED|REG_ICASE|REG_NOSUB) != 0)
-      {
-        _error->Warning(_("Bad regular expression '%s' in option RPM::MultiArch."),
-                        Top->Value.c_str());
-        delete ptrn;
-      }
-      else
-         MultiArchPatterns.push_back(ptrn);
-   }
-
    // Populate fake provides
    Top = _config->Tree("RPM::Fake-Provides");
    for (Top = (Top == 0?0:Top->Child); Top != 0; Top = Top->Next)
@@ -306,20 +291,6 @@ bool RPMPackageData::IsDupPackage(const string &Name)
    return false;
 }
 
-bool RPMPackageData::IsMultiArchPackage(const string &Name)
-{
-   if (MultiArchPackages.find(Name) != MultiArchPackages.end())
-      return true;
-   const char *name = Name.c_str();
-   for (vector<regex_t*>::iterator I = MultiArchPatterns.begin();
-       I != MultiArchPatterns.end(); I++) {
-      if (regexec(*I,name,0,0,0) == 0) {
-        SetMultiArchPackage(Name);
-        return true;
-      }
-   }
-   return false;
-}
 RPMPackageData *RPMPackageData::Singleton()
 {
    static RPMPackageData *data = NULL;
index cb68dbc..106ecf8 100644 (file)
@@ -27,7 +27,6 @@ class RPMPackageData
    hash_map<string,vector<string>*,hash_string> FakeProvides;
    hash_map<string,int,hash_string> IgnorePackages;
    hash_map<string,int,hash_string> DuplicatedPackages;
-   hash_map<string,int,hash_string> MultiArchPackages;
    typedef map<string,pkgCache::VerIterator> VerMapValueType;
    typedef hash_map<unsigned long,VerMapValueType> VerMapType;
    typedef hash_map<const char*,int,
@@ -38,7 +37,6 @@ class RPMPackageData
    map<string,vector<string>*> FakeProvides;
    map<string,int> IgnorePackages;
    map<string,int> DuplicatedPackages;
-   map<string,int> MultiArchPackages;
    typedef map<string,pkgCache::VerIterator> VerMapValueType;
    typedef map<unsigned long,VerMapValueType> VerMapType;
    typedef map<const char*,int,cstr_lt_pred> ArchScoresType;
@@ -46,7 +44,6 @@ class RPMPackageData
 
    vector<regex_t*> HoldPackages;   
    vector<regex_t*> DuplicatedPatterns;
-   vector<regex_t*> MultiArchPatterns;
 
    struct Translate {
           regex_t Pattern;
@@ -113,9 +110,6 @@ class RPMPackageData
    void SetDupPackage(const string &Name)
        {DuplicatedPackages[Name] = 1;};
    bool IsDupPackage(const string &Name);
-   void SetMultiArchPackage(const string &Name)
-        {MultiArchPackages[Name] = 1;};
-   bool IsMultiArchPackage(const string &Name);
 
    static RPMPackageData *Singleton();