Witam 

Kolejna latka tym razem dodaje wsparcie dla blokowania lub ignorowania arch.
Prosze o testy i raporty na launchapad.

This patch adds ability to block also arch.
Please test it and report on launchpad.

hold = *-smp-* foo-* *!i686 bar!* home:gcc*


http://starowa.one.pl/~uzi/pld/poldek-add_arch_match_to_ignore_and_hold.patch
https://bugs.launchpad.net/poldek/+bug/408036
diff --git a/pkgscore.c b/pkgscore.c
index f2a527c..fc8f0c3 100644
--- a/pkgscore.c
+++ b/pkgscore.c
@@ -113,24 +113,47 @@ void pkgscore_match_init(struct pkgscore_s *psc, struct pkg *pkg)
         n += n_snprintf(psc->pkgbuf, sizeof(psc->pkgbuf),
                         "%s:", pkg->pkgdir->name);
 
-    psc->pkgname_off = n;
-    
+    // pkgname_off - size of pkgdir_name
+     psc->pkgname_off = n;
+    // pkgbuf - "pkgdir_name:name-ver-rel"
+
     pkg_snprintf(&psc->pkgbuf[n], sizeof(psc->pkgbuf) - n, pkg);
     psc->pkg = pkg;
 }
 
     
 
+// return 0 if arch,name,version,rev,pkgdir_name not match
 int pkgscore_match(struct pkgscore_s *psc, const char *mask)
 {
-    if (fnmatch(mask, psc->pkg->name, 0) == 0)
-        return 1;
-
-    if (psc->pkgname_off &&
-        fnmatch(mask, &psc->pkgbuf[psc->pkgname_off], 0) == 0)
-        return 1;
-    
-    return fnmatch(mask, psc->pkgbuf, 0) == 0;
+    const char *arch, *used_mask;
+    static char str[256];
+
+    // if "!" in mask => compare arch first
+    if ((arch = strchr(mask, '!')) != NULL)
+    {
+       arch++;
+
+       // arch string not "" and not same archs
+       if ((*arch != 0) && (fnmatch(arch, pkg_arch(psc->pkg), 0) != 0))
+               return 0;
+
+       strncpy(str, mask, arch - mask - 1);
+       used_mask = &str;
+    } else
+       used_mask = mask;
+
+    // match name
+    if (fnmatch(used_mask, psc->pkg->name, 0) == 0)
+         return 1;
+
+    // match name+version+arch as string
+     if (psc->pkgname_off &&
+        fnmatch(used_mask, &psc->pkgbuf[psc->pkgname_off], 0) == 0)
+         return 1;
+
+    // match pkgdir_name:name+version
+    return (fnmatch(used_mask, psc->pkgbuf, 0) == 0);
 }
 
     
_______________________________________________
pld-devel-pl mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-devel-pl

Odpowiedź listem elektroniczym