- basic implementation of runtime access() dependencies
[apt.git] / apt-pkg / rpm / rpmlistparser.cc
index 381006b..34dee2e 100644 (file)
@@ -35,6 +35,8 @@
 
 #define WITH_VERSION_CACHING 1
 
+string MultilibArchs[] = {"x86_64", "ia64", "ppc64", "sparc64"};
+
 // ListParser::rpmListParser - Constructor                             /*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -120,7 +122,7 @@ string rpmListParser::Package()
    bool IsDup = false;
    string Name = str;
 
-   if (IsCompatArch(Architecture()) == true) {
+   if (RpmData->IsMultilibSys() && RpmData->IsCompatArch(Architecture())) {
         Name += ".32bit";       
         CurrentName = Name;
    }
@@ -165,21 +167,6 @@ string rpmListParser::Package()
    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                   /*{{{*/
 // ---------------------------------------------------------------------
@@ -426,20 +413,85 @@ bool rpmListParser::ParseDepends(pkgCache::VerIterator Ver,
       }
 
 #if RPM_VERSION >= 0x040404
-      if (namel[i][0] == 'g' && strncmp(namel[i], "getconf", 7) == 0)
+      // uhhuh, any of these changing would require full cache rebuild...
+      if (strncmp(namel[i], "getconf(", sizeof("getconf(")-1) == 0)
       {
         rpmds getconfProv = NULL;
         rpmds ds = rpmdsSingle(RPMTAG_PROVIDENAME,
                                namel[i], verl?verl[i]:NULL, flagl[i]);
         rpmdsGetconf(&getconfProv, NULL);
-        int res = rpmdsSearch(getconfProv, ds) >= 0;
+        int res = rpmdsSearch(getconfProv, ds);
         rpmdsFree(ds);
         rpmdsFree(getconfProv);
         if (res) continue;
       }
+
+      if (strncmp(namel[i], "cpuinfo(", sizeof("cpuinfo(")-1) == 0)
+      {
+        rpmds cpuinfoProv = NULL;
+        rpmds ds = rpmdsSingle(RPMTAG_PROVIDENAME,
+                               namel[i], verl?verl[i]:NULL, flagl[i]);
+        rpmdsCpuinfo(&cpuinfoProv, NULL);
+        int res = rpmdsSearch(cpuinfoProv, ds);
+        rpmdsFree(ds);
+        rpmdsFree(cpuinfoProv);
+        if (res) continue;
+      }
+
+      if (strncmp(namel[i], "sysinfo(", sizeof("sysinfo(")-1) == 0)
+      {
+        rpmds sysinfoProv = NULL;
+        rpmds ds = rpmdsSingle(RPMTAG_PROVIDENAME,
+                               namel[i], verl?verl[i]:NULL, flagl[i]);
+        rpmdsCpuinfo(&sysinfoProv, NULL);
+        int res = rpmdsSearch(sysinfoProv, ds);
+        rpmdsFree(ds);
+        rpmdsFree(sysinfoProv);
+        if (res) continue;
+      }
+
+      if (strncmp(namel[i], "uname(", sizeof("uname(")-1) == 0)
+      {
+        rpmds unameProv = NULL;
+        rpmds ds = rpmdsSingle(RPMTAG_PROVIDENAME,
+                               namel[i], verl?verl[i]:NULL, flagl[i]);
+        rpmdsUname(&unameProv, NULL);
+        int res = rpmdsSearch(unameProv, ds);
+        rpmdsFree(ds);
+        rpmdsFree(unameProv);
+        if (res) continue;
+      }
+
+      if (strlen(namel[i]) > 5 && namel[i][strlen(namel[i])-1] == ')' &&
+         ((strchr("Rr_", namel[i][0]) != NULL &&
+           strchr("Ww_", namel[i][1]) != NULL &&
+           strchr("Xx_", namel[i][2]) != NULL &&
+           namel[i][3] == '(') ||
+           strncmp(namel[i], "exists(", sizeof("exists(")-1) == 0 ||
+           strncmp(namel[i], "executable(", sizeof("executable(")-1) == 0 ||
+           strncmp(namel[i], "readable(", sizeof("readable(")-1) == 0 ||
+           strncmp(namel[i], "writable(", sizeof("writable(")-1)== 0 ))
+      {
+        int res = rpmioAccess(namel[i], NULL, X_OK);
+        if (res == 0)
+           continue;
+      }
+
+      /* TODO
+       * - /etc/rpm/sysinfo provides
+       * - macro probe provides 
+       * - actually implement soname() and access() dependencies
+       */
+      if (strncmp(namel[i], "soname(", sizeof("soname(")-1) == 0)
+      {
+        cout << "FIXME, ignoring soname() dependency: " << namel[i] << endl;
+        continue;
+      }
+      
+
 #endif
       
-      if (namel[i][0] == 'r' && strncmp(namel[i], "rpmlib", 6) == 0)
+      if (strncmp(namel[i], "rpmlib(", sizeof("rpmlib(")-1) == 0)
       {
 #if RPM_VERSION >= 0x040404
         rpmds rpmlibProv = NULL;