- make multilib arch-stuff runtime configurable
authorPanu Matilainen <pmatilai@turre.koti.laiskiainen.org>
Thu, 26 Apr 2007 15:54:09 +0000 (18:54 +0300)
committerPanu Matilainen <pmatilai@turre.koti.laiskiainen.org>
Thu, 26 Apr 2007 15:54:09 +0000 (18:54 +0300)
- realize that preferred arch is not always same as basearch (eg ppc64 and
  sparc64), support it
- add etc/ directory for "factory default" configs
- add basic multilib config, installed automatically to apt.conf.d
- move example rpmpriorities to etc/

Makefile.am
Makefile.in
apt-pkg/rpm/rpmlistparser.cc
apt-pkg/rpm/rpmpackagedata.cc
apt-pkg/rpm/rpmpackagedata.h
etc/multilib.conf [new file with mode: 0644]
etc/rpmpriorities [moved from rpmpriorities with 100% similarity]

index 62c67e2..3a9a9b9 100644 (file)
@@ -7,7 +7,7 @@ ACLOCAL_AMFLAGS = -I m4 -I buildlib
 EXTRA_DIST = \
                AUTHORS.RPM \
                COPYING.GPL \
-               rpmpriorities \
+               etc/rpmpriorities \
                python/apt.i \
                python/apt.py \
                python/apt_wrap.cxx \
@@ -88,7 +88,7 @@ aptsources_list_ddir = $(aptconfigdir)/sources.list.d
 aptsources_list_d_DATA =
 
 aptconf_ddir = $(aptconfigdir)/apt.conf.d
-aptconf_d_DATA =
+aptconf_d_DATA = etc/multilib.conf
 
 aptvendors_list_ddir = $(aptconfigdir)/vendors.list.d
 aptvendors_list_d_DATA =
index c08624c..8591f55 100644 (file)
@@ -259,7 +259,7 @@ sysconfdir = @sysconfdir@
 target_alias = @target_alias@
 SUBDIRS = lua apt-pkg methods cmdline tools doc po test
 ACLOCAL_AMFLAGS = -I m4 -I buildlib
-EXTRA_DIST = AUTHORS.RPM COPYING.GPL rpmpriorities python/apt.i \
+EXTRA_DIST = AUTHORS.RPM COPYING.GPL etc/rpmpriorities python/apt.i \
        python/apt.py python/apt_wrap.cxx python/Makefile \
        python/swig-1.3.16-cxx.patch contrib/gpg-check/README \
        contrib/gpg-check/gpg-check.conf \
@@ -303,7 +303,7 @@ aptconfigdir = ${sysconfdir}/apt
 aptsources_list_ddir = $(aptconfigdir)/sources.list.d
 aptsources_list_d_DATA = 
 aptconf_ddir = $(aptconfigdir)/apt.conf.d
-aptconf_d_DATA = 
+aptconf_d_DATA = etc/multilib.conf
 aptvendors_list_ddir = $(aptconfigdir)/vendors.list.d
 aptvendors_list_d_DATA = 
 aptcachedir = $(localstatedir)/cache/apt
@@ -716,7 +716,7 @@ distclean-tags:
 distdir: $(DISTFILES)
        $(am__remove_distdir)
        mkdir $(distdir)
-       $(mkdir_p) $(distdir)/apt-pkg $(distdir)/buildlib $(distdir)/contrib/allow-duplicated $(distdir)/contrib/apt-cron $(distdir)/contrib/apt-files $(distdir)/contrib/apt-groupinstall $(distdir)/contrib/apt-wrapper $(distdir)/contrib/gpg-check $(distdir)/contrib/guess $(distdir)/contrib/install-devel $(distdir)/contrib/list-extras $(distdir)/contrib/list-nodeps $(distdir)/contrib/log $(distdir)/contrib/preserve-conf $(distdir)/contrib/proxypasswd $(distdir)/m4 $(distdir)/po $(distdir)/python
+       $(mkdir_p) $(distdir)/apt-pkg $(distdir)/buildlib $(distdir)/contrib/allow-duplicated $(distdir)/contrib/apt-cron $(distdir)/contrib/apt-files $(distdir)/contrib/apt-groupinstall $(distdir)/contrib/apt-wrapper $(distdir)/contrib/gpg-check $(distdir)/contrib/guess $(distdir)/contrib/install-devel $(distdir)/contrib/list-extras $(distdir)/contrib/list-nodeps $(distdir)/contrib/log $(distdir)/contrib/preserve-conf $(distdir)/contrib/proxypasswd $(distdir)/etc $(distdir)/m4 $(distdir)/po $(distdir)/python
        @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
        topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
        list='$(DISTFILES)'; for file in $$list; do \
index df6d5a8..ab58a16 100644 (file)
@@ -92,7 +92,7 @@ string rpmListParser::Package()
    bool IsDup = false;
 
    if (RpmData->IsMultilibSys() && RpmData->IsCompatArch(Architecture())) {
-        Name += ".32bit";       
+        Name += RpmData->GetCompatArchSuffix();
         CurrentName = Name;
    }
 
index de9b742..7dbac3a 100644 (file)
@@ -24,22 +24,24 @@ RPMPackageData::RPMPackageData()
    , ArchScores(31)
 #endif
 {
+   const Configuration::Item *Top = NULL;
    BaseArch = _config->Find("APT::Architecture");
-   if (BaseArch == "x86_64" || BaseArch == "ia64" ||
-       BaseArch == "ppc64" || BaseArch == "sparc64")
-      MultilibSys = true;
-   else
-      MultilibSys = false;
+
+   // Figure out multilib stuff..
+   string MLBase = "RPM::Multilib::" + BaseArch;
+   MultilibSys = _config->Exists(MLBase.c_str());
 
    if (MultilibSys) {
-      CompatArch["x86_64"].push_back("i386");
-      CompatArch["x86_64"].push_back("i486");
-      CompatArch["x86_64"].push_back("i586");
-      CompatArch["x86_64"].push_back("i686");
-      CompatArch["x86_64"].push_back("athlon");
-      CompatArch["ia64"] = CompatArch["x86_64"];
-      CompatArch["ppc64"].push_back("ppc");
-      CompatArch["sparc64"].push_back("sparc");
+      string CA = MLBase + "::CompatArchs";
+      Top = _config->Tree(CA.c_str());
+      for (Top = Top->Child; Top != 0; Top = Top->Next) {
+        CompatArch[Top->Value] = true;
+      }
+
+      string PA = MLBase + "::PreferredArch";
+      PreferredArch = _config->Find(PA.c_str(), BaseArch.c_str());
+      string CAS = MLBase + "::CompatArchSuffix";
+      CompatArchSuffix = _config->Find(CAS.c_str(), ".32bit");
    }
 
    // Populate priorities
@@ -100,7 +102,7 @@ RPMPackageData::RPMPackageData()
    }
 
    // Populate holding packages
-   const Configuration::Item *Top = _config->Tree("RPM::Hold");
+   Top = _config->Tree("RPM::Hold");
    for (Top = (Top == 0?0:Top->Child); Top != 0; Top = Top->Next)
    {
       regex_t *ptrn = new regex_t;
@@ -303,15 +305,9 @@ int RPMPackageData::RpmArchScore(const char *Arch)
 
 bool RPMPackageData::IsCompatArch(string Arch)
 {
-   for (vector<string>::iterator I = CompatArch[BaseArch].begin();
-        I != CompatArch[BaseArch].end(); I++) {
-      if (Arch == *I)
-         return true;
-   }
-   return false;
+   return CompatArch.find(Arch) != CompatArch.end();
 }
 
-
 bool RPMPackageData::IsDupPackage(const string &Name)
 {
    if (DuplicatedPackages.find(Name) != DuplicatedPackages.end())
index ac2d8fd..d6d33e3 100644 (file)
@@ -28,7 +28,7 @@ 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,vector<string>,hash_string> CompatArch;
+   hash_map<string,bool,hash_string> CompatArch;
    typedef map<string,pkgCache::VerIterator> VerMapValueType;
    typedef hash_map<unsigned long,VerMapValueType> VerMapType;
    typedef hash_map<const char*,int,
@@ -39,7 +39,7 @@ class RPMPackageData
    map<string,vector<string>*> FakeProvides;
    map<string,int> IgnorePackages;
    map<string,int> DuplicatedPackages;
-   map<string,vector<string> > CompatArch;
+   map<string,bool> > CompatArch;
    typedef map<string,pkgCache::VerIterator> VerMapValueType;
    typedef map<unsigned long,VerMapValueType> VerMapType;
    typedef map<const char*,int,cstr_lt_pred> ArchScoresType;
@@ -68,6 +68,8 @@ class RPMPackageData
    int RpmArchScore(const char *Arch);
 
    string BaseArch;
+   string PreferredArch;
+   string CompatArchSuffix;
    bool MultilibSys;
 
    public:
@@ -115,6 +117,7 @@ class RPMPackageData
 
    bool IsCompatArch(string Arch);
    bool IsMultilibSys() { return MultilibSys; };
+   string GetCompatArchSuffix() { return CompatArchSuffix; };
 
    void SetDupPackage(const string &Name)
        {DuplicatedPackages[Name] = 1;};
diff --git a/etc/multilib.conf b/etc/multilib.conf
new file mode 100644 (file)
index 0000000..3006aa4
--- /dev/null
@@ -0,0 +1,25 @@
+// Not to be edited lightly...
+RPM {
+    Multilib { 
+        x86_64 {
+            PreferredArch "x86_64";
+            CompatArchs { "i386"; "i486"; "i586"; "i686"; "athlon";}
+            CompatArchSuffix ".32bit";
+        };
+        ia64 {
+            PreferredArch "ia64";
+            CompatArchs { "i386"; "i486"; "i586"; "i686"; "athlon";}
+            CompatArchSuffix ".32bit";
+        };
+        ppc64 {
+            PreferredArch "ppc";
+            CompatArchs { "ppc64";}
+            CompatArchSuffix ".64bit";
+        };
+        sparc64 {
+            PreferredArch "sparc";
+            CompatArchs { "sparc64";}
+            CompatArchSuffix ".64bit";
+        };
+    };
+};
similarity index 100%
rename from rpmpriorities
rename to etc/rpmpriorities