poldek: poldek/install3/misc.c, poldek/lib_init.c, poldek/tests/sh/07-depso...

mis mis at pld-linux.org
Sun May 11 23:02:46 CEST 2008


Author: mis                          Date: Sun May 11 21:02:46 2008 GMT
Module: poldek                        Tag: HEAD
---- Log message:
- use machine arch score if multilib mode and marker is noarch (#127)

---- Files affected:
poldek/poldek/install3:
   misc.c (1.6 -> 1.7) 
poldek/poldek:
   lib_init.c (1.94 -> 1.95) 
poldek/poldek/tests/sh:
   07-depsolver (1.4 -> 1.5) 

---- Diffs:

================================================================
Index: poldek/poldek/install3/misc.c
diff -u poldek/poldek/install3/misc.c:1.6 poldek/poldek/install3/misc.c:1.7
--- poldek/poldek/install3/misc.c:1.6	Sun Feb 24 23:10:41 2008
+++ poldek/poldek/install3/misc.c	Sun May 11 23:02:41 2008
@@ -145,11 +145,34 @@
     return 0;
 }
 
+static void prepare_arch_scores(int *scores, const tn_array *pkgs)
+{
+    int i, min_score = INT_MAX;
+    
+    for (i=0; i < n_array_size(pkgs); i++) {
+        struct pkg *pkg = n_array_nth(pkgs, i);
+        
+        scores[i] = pkg_arch_score(pkg);
+        if (min_score > scores[i])
+            min_score = scores[i];
+    }
+
+    for (i=0; i < n_array_size(pkgs); i++) {
+        if (scores[i] == min_score)
+            scores[i] = 1;      /* 1 point for best fit */
+        else
+            scores[i] = 0;
+        DBGF("%s %d\n", pkg_id(n_array_nth(pkgs, i)), scores[i]);
+    }
+}
+
+    
+
 static int do_select_best_pkg(int indent, struct i3ctx *ictx,
                               const struct pkg *marker, tn_array *candidates)
 {
-    int *conflicts, min_nconflicts, j, i_best, *scores, max_score, i;
-    int npkgs, same_packages_different_arch = 0;
+    int *conflicts, min_nconflicts, j, i_best, *scores, *arch_scores = NULL;
+    int i, max_score, npkgs, same_packages_different_arch = 0;
 
     npkgs = n_array_size(candidates);
     tracef(indent, "marker is %s, ncandidates=%d",
@@ -162,8 +185,14 @@
     scores = alloca(npkgs * sizeof(*scores));
     conflicts = alloca(npkgs * sizeof(*conflicts));
     min_nconflicts = 0;
-    i_best = -1;
-    
+
+    /* marker noarch -> suggests architecture not */
+    if (poldek_conf_MULTILIB && marker && n_str_eq(pkg_arch(marker), "noarch")) {
+        arch_scores = alloca(npkgs * sizeof(*arch_scores));
+        prepare_arch_scores(arch_scores, candidates);
+    }
+
+    i_best = -1;    
     for (i=0; i < n_array_size(candidates); i++) {
         struct pkg *pkg = n_array_nth(candidates, i);
         int cmprc = 0;
@@ -174,7 +203,6 @@
         trace(indent, "- %d. %s (marked=%d)", i, pkg_id(pkg),
               i3_is_marked(ictx, pkg));
 
-        
         if (pkg_isset_mf(ictx->processed, pkg, PKGMARK_BLACK))
             scores[i] = -999;
 
@@ -195,8 +223,11 @@
                 scores[i] += 2;
             else if (pkg_cmp_arch(pkg, marker) == 0)
                 scores[i] += 1;
+            else if (arch_scores)
+                scores[i] += arch_scores[i];
         }
 
+        //DBGF_F("xxx %s %d %d\n", pkg_id(pkg), pkg_arch_score(pkg), arch_scores[i]);
         scores[i] += satisfiability_score(marker, pkg);
         
         if (i > 0) {

================================================================
Index: poldek/poldek/lib_init.c
diff -u poldek/poldek/lib_init.c:1.94 poldek/poldek/lib_init.c:1.95
--- poldek/poldek/lib_init.c:1.94	Mon Feb 25 00:04:02 2008
+++ poldek/poldek/lib_init.c	Sun May 11 23:02:41 2008
@@ -1577,6 +1577,9 @@
         __setup_multilib(ctx);
         
     } else if (strcmp(pm, "pset") == 0) {
+        if (poldek__is_in_testing_mode()) /* need rpm_machine_score for testing */
+            pm_new("rpm");
+        
         n_array_sort_ex(ctx->dest_sources, (tn_fn_cmp)source_cmp_no);
         if (n_array_size(ctx->dest_sources) == 0) {
             logn(LOGERR, "%s: missing destination source", pm);

================================================================
Index: poldek/poldek/tests/sh/07-depsolver
diff -u poldek/poldek/tests/sh/07-depsolver:1.4 poldek/poldek/tests/sh/07-depsolver:1.5
--- poldek/poldek/tests/sh/07-depsolver:1.4	Wed Jan 30 16:05:53 2008
+++ poldek/poldek/tests/sh/07-depsolver	Sun May 11 23:02:41 2008
@@ -335,6 +335,22 @@
 
 }
 
+# alternatives suggested by noarch packages should be scored by rpmArchScore
+# https://bugs.pld-linux.org/show_bug.cgi?id=127
+testMultilibSuggestedByNoarchShouldUseArchScore() {
+    ORIG_POLDEK_INSTALL="$POLDEK_INSTALL"
+    POLDEK_INSTALL="$POLDEK_INSTALL -Omultilib=1"
 
+    msgn "Preparing repositories..."
+    build n 1-1 -a "noarch" -s "a"
+    for i in i686 x86-64; do 
+        build a 1-1 -a $i -f "/hello.$i"
+    done    
+    POLDEK_TESTING_WITH_SUGGESTS="all" # choose all suggested packages
+    export POLDEK_TESTING_WITH_SUGGESTS
+    try_install n "n-1-1.noarch,a-1-1.i686"
+    POLDEK_INSTALL="$ORIG_POLDEK_INSTALL"
+    POLDEK_TESTING_WITH_SUGGESTS=""
+}
 
 . ./sh/lib/shunit2
\ No newline at end of file
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/poldek/poldek/install3/misc.c?r1=1.6&r2=1.7&f=u
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/poldek/poldek/lib_init.c?r1=1.94&r2=1.95&f=u
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/poldek/poldek/tests/sh/07-depsolver?r1=1.4&r2=1.5&f=u



More information about the pld-cvs-commit mailing list