poldek: poldek/pm/rpm/misc.c, poldek/pm/rpm/rpm_pkg_ld.c - compare...

mis mis at pld-linux.org
Tue Jun 19 16:01:48 CEST 2007


Author: mis                          Date: Tue Jun 19 14:01:48 2007 GMT
Module: poldek                        Tag: HEAD
---- Log message:
- compare OSes manually if PlatformScore says no
- cache os,cpu and vendor rpm's macros 
- more pkg_id()'s

---- Files affected:
poldek/poldek/pm/rpm:
   misc.c (1.12 -> 1.13) , rpm_pkg_ld.c (1.11 -> 1.12) 

---- Diffs:

================================================================
Index: poldek/poldek/pm/rpm/misc.c
diff -u poldek/poldek/pm/rpm/misc.c:1.12 poldek/poldek/pm/rpm/misc.c:1.13
--- poldek/poldek/pm/rpm/misc.c:1.12	Sat Jun 16 22:16:40 2007
+++ poldek/poldek/pm/rpm/misc.c	Tue Jun 19 16:01:43 2007
@@ -189,15 +189,37 @@
     return caps;
 }
 
+static void get_host_cpu_vendor_os(char **acpu, char **avendor, char **aos) 
+{
+    static char *cpu = NULL, *vendor = NULL, *os = NULL; /* XXX static variable */
+    
+    if (cpu == NULL) {
+        cpu = rpmExpand("%{_host_cpu}", NULL);
+        vendor = rpmExpand("%{_host_vendor}", NULL);
+        os = rpmExpand("%{_host_os}", NULL);
+    }
+    
+    if (acpu)
+        *acpu = cpu;
+
+    if (avendor)
+        *avendor = vendor;
+
+    if (aos)
+        *aos = os;
+}
+
+
+            
+
+
 #ifdef HAVE_RPMPLATFORMSCORE    /* rpm 4.4.9 */
 static int machine_score(int tag, const char *val) {
-    char *cpu, *vendor, *os;
+    char *cpu = NULL, *vendor = NULL, *os = NULL; /* XXX static variable */
     int rc;
 
-    cpu = rpmExpand("%{_host_cpu}", NULL);
-    vendor = rpmExpand("%{_host_vendor}", NULL);
-    os = rpmExpand("%{_host_os}", NULL);
-
+    get_host_cpu_vendor_os(&cpu, &vendor, &os);
+    
     if (! (cpu && vendor && os) ) {
         rc = rpmPlatformScore(val, platpat, nplatpat);
         
@@ -207,22 +229,30 @@
 	    switch (tag) {
 		    case PMMSTAG_ARCH:
 			    n_snprintf(p, size, "%s-%s-%s", val, vendor, os);
+                DBGF("ARCH %s\n", p);
 			    break;
+                
 		    case PMMSTAG_OS:
-			    n_snprintf(p, size, "%s-%s-%s", cpu, vendor, val);
+                n_snprintf(p, size, "%s-%s-%s", cpu, vendor, val);
+                DBGF("OS %s\n", p);
 			    break;
+                
 		    default:
-			    n_snprintf(p, size, "%s", val);
+                n_assert(0);
 			    break;
 	    }
-
+        
         rc = rpmPlatformScore(p, platpat, nplatpat);
+
+        /* do not trust PlatformScore() to much and just strcmp -> OS never used
+           for scoring */
+        if (rc == 0 && tag == PMMSTAG_OS) {
+            rc = (strcasecmp(os, val) == 0); 
+            DBGF("cmp %s, %s => %d\n", os, val, rc);
+        }
+        
     }
     
-    n_cfree(&cpu);
-    n_cfree(&vendor);
-    n_cfree(&os);
-    
     return rc;
 }
 
@@ -260,14 +290,12 @@
             break;
             
         case PMMSTAG_OS: {
-            char *host_val = rpmExpand("%{_host_os}", NULL);
+            const char *host_os;
+            get_host_cpu_vendor_os(NULL, NULL, &host_os);
 
             rc = 9;
-            if (host_val) {
-                if (strcasecmp(host_val, val) == 0)
-                    rc = 1;                 /* exact fit */
-                free(host_val);
-            }
+            if (host_os && strcasecmp(host_val, val) == 0)
+                rc = 1;                 /* exact fit */
             break;
 
         default:
@@ -289,7 +317,6 @@
 /* XXX: function used directly in pkg.c */
 int pm_rpm_arch_score(const char *arch)
 {
-    char *host_arch;
     int rc;
     
     if (arch == NULL)
@@ -305,7 +332,7 @@
         rc = 1;
         
     } else {
-        host_arch = rpmExpand("%{_host_cpu}", NULL);
+        host_arch = get_host_cpu_vendor_os(&cpu, NULL, NULL);
         if (host_arch) {
             if (strcasecmp(host_arch, arch) == 0)
                 rc = 1;                 /* exact fit */

================================================================
Index: poldek/poldek/pm/rpm/rpm_pkg_ld.c
diff -u poldek/poldek/pm/rpm/rpm_pkg_ld.c:1.11 poldek/poldek/pm/rpm/rpm_pkg_ld.c:1.12
--- poldek/poldek/pm/rpm/rpm_pkg_ld.c:1.11	Thu Oct 20 17:44:43 2005
+++ poldek/poldek/pm/rpm/rpm_pkg_ld.c	Tue Jun 19 16:01:43 2007
@@ -202,7 +202,7 @@
 
         if ((cr = capreq_new_evr(name, evr, cr_relflags, cr_flags)) == NULL) {
             logn(LOGERR, "%s: '%s %s%s%s %s': invalid capability",
-                 pkg ? pkg_snprintf_s(pkg) : "(null)", name, 
+                 pkg ? pkg_id(pkg) : "(null)", name, 
                  (cr_relflags & REL_LT) ? "<" : "",
                  (cr_relflags & REL_GT) ? ">" : "",
                  (cr_relflags & REL_EQ) ? "=":"", evr);
@@ -502,7 +502,7 @@
     pkg->color = hGetColor(h);
 #endif
 
-    msg(4, "ld %s\n", pkg_snprintf_s(pkg));
+    msg(4, "ld %s\n", pkg_id(pkg));
     
     if (ldflags & PKG_LDCAPS) {
         pkg->caps = capreq_arr_new(0);
@@ -549,8 +549,7 @@
         else
             flldflags = PKGFL_DEPDIRS;
         
-        if (pm_rpm_ldhdr_fl(na, &pkg->fl, h, flldflags,
-                            pkg_snprintf_s(pkg)) == -1) {
+        if (pm_rpm_ldhdr_fl(na, &pkg->fl, h, flldflags, pkg_id(pkg)) == -1) {
             pkg_free(pkg);
             pkg = NULL;
         
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/poldek/poldek/pm/rpm/misc.c?r1=1.12&r2=1.13&f=u
    http://cvs.pld-linux.org/poldek/poldek/pm/rpm/rpm_pkg_ld.c?r1=1.11&r2=1.12&f=u



More information about the pld-cvs-commit mailing list