poldek: poldek/conf.h, poldek/configure.in, poldek/fileindex.c, po...

mis mis at pld-linux.org
Sun Aug 20 20:15:03 CEST 2006


Author: mis                          Date: Sun Aug 20 18:15:03 2006 GMT
Module: poldek                        Tag: HEAD
---- Log message:
- support for rpm 4.4.6 auto directory-based dependencies
- install/ subsys is default dependency engine now
- code cleanups 

---- Files affected:
poldek/poldek:
   conf.h (1.16 -> 1.17) , configure.in (1.123 -> 1.124) , fileindex.c (1.28 -> 1.29) , fileindex.h (1.11 -> 1.12) , lib_init.c (1.74 -> 1.75) , lib_pkgset.c (1.20 -> 1.21) , libpoldek.sym (1.24 -> 1.25) , misc.c (1.54 -> 1.55) , pkg.c (1.109 -> 1.110) , pkg.h (1.75 -> 1.76) , pkgfl.c (1.40 -> 1.41) , pkgfl.h (1.22 -> 1.23) , pkgset-install.c (1.149 -> 1.150) , pkgset-order.c (1.30 -> 1.31) , pkgset-req.c (1.42 -> 1.43) , pkgset.c (1.87 -> 1.88) , pkgset.h (1.58 -> 1.59) , poldek.h (1.33 -> 1.34) , poldek_intern.h (1.8 -> 1.9) , poldek_ts.c (1.56 -> 1.57) , poldek_ts.h (1.33 -> 1.34) , poldek_util.h (1.6 -> 1.7) , split.c (1.23 -> 1.24) , uninstall.c (1.40 -> 1.41) 
poldek/poldek/cli:
   dbcache.c (1.30 -> 1.31) 
poldek/poldek/install:
   ictx.h (1.3 -> 1.4) 
poldek/poldek/pkgdir:
   pkgdir_dirindex.c (NONE -> 1.1)  (NEW), pkgdir_dirindex.h (NONE -> 1.1)  (NEW), Makefile.am (1.9 -> 1.10) , pkgdir.c (1.44 -> 1.45) , pkgdir.h (1.32 -> 1.33) 
poldek/poldek/pkgdir/dir:
   dir.c (1.25 -> 1.26) 
poldek/poldek/pkgdir/metadata:
   metadata.c (1.5 -> 1.6) 
poldek/poldek/pkgdir/yum:
   yum.c (1.17 -> 1.18) 
poldek/poldek/pm:
   mod.h (1.11 -> 1.12) , pkgdb.c (1.22 -> 1.23) , pm.h (1.15 -> 1.16) 
poldek/poldek/pm/pset:
   pm_pset.h (1.8 -> 1.9) , pset.c (1.20 -> 1.21) 
poldek/poldek/pm/rpm:
   pm_rpm.h (1.13 -> 1.14) , rpm.c (1.14 -> 1.15) 

---- Diffs:

================================================================
Index: poldek/poldek/conf.h
diff -u poldek/poldek/conf.h:1.16 poldek/poldek/conf.h:1.17
--- poldek/poldek/conf.h:1.16	Sun Apr  2 21:10:36 2006
+++ poldek/poldek/conf.h	Sun Aug 20 20:14:58 2006
@@ -16,10 +16,9 @@
 
 
 /*
-  Adds to htconf parameters discovered from lines. If htconf is NULL
-  then it is created. Caution: parameters from lines overwrite
-  previously discovered ones, i.e. if lines = [ 'foo = a', 'foo = b' ]
-  then 'foo' value will be 'b'
+  Adds to htconf parameters discovered from lines; htconf is created if NULL.
+  Caution: parameters from lines overwrite previously discovered ones, i.e.
+  if lines = [ 'foo = a', 'foo = b' ] then 'foo' value will be 'b'
 */
 tn_hash *poldek_conf_addlines(tn_hash *htconf, const char *sectnam,
                               tn_array *lines);

================================================================
Index: poldek/poldek/configure.in
diff -u poldek/poldek/configure.in:1.123 poldek/poldek/configure.in:1.124
--- poldek/poldek/configure.in:1.123	Sun Jul  9 23:24:56 2006
+++ poldek/poldek/configure.in	Sun Aug 20 20:14:58 2006
@@ -1,12 +1,12 @@
 dnl Process this file with autoconf to produce a configure script.
 dnl $Id$
 
-AC_INIT(poldek,0.20)
+AC_INIT(poldek,0.20.1)
 AC_CONFIG_SRCDIR([capreq.c])
 
-PACKAGE_BUGREPORT="mis at pld.org.pl"
+PACKAGE_BUGREPORT="mis at pld-linux.pl"
 VERSION_STATUS="beta"
-VERSION=0.20
+VERSION=0.20.1
 VERSION_TAG=$(echo $VERSION | sed 's/\./_/g')
 VERSION_CVSTAG="v$VERSION_TAG"
 PACKAGE_VERSION_SERIES="2"

================================================================
Index: poldek/poldek/fileindex.c
diff -u poldek/poldek/fileindex.c:1.28 poldek/poldek/fileindex.c:1.29
--- poldek/poldek/fileindex.c:1.28	Thu Oct 27 00:49:40 2005
+++ poldek/poldek/fileindex.c	Sun Aug 20 20:14:58 2006
@@ -119,28 +119,34 @@
 }
 
 
-int file_index_init(struct file_index *fi, int nelem)  
+struct file_index *file_index_new(int nelem)  
 {
+    tn_alloc *na;
+    struct file_index *fi;
+
+    na = n_alloc_new(32, TN_ALLOC_OBSTACK);
+
+    fi = na->na_malloc(na, sizeof(*fi));
     memset(fi, 0, sizeof(*fi));
     
-    fi->dirs = n_hash_new_na(NULL, nelem, (tn_fn_free)n_array_free);
-    if (fi->dirs == NULL)
-       return 0;
-    fi->cnflh = NULL;
+    fi->dirs = n_hash_new_na(na, nelem, (tn_fn_free)n_array_free);
     n_hash_ctl(fi->dirs, TN_HASH_NOCPKEY);
-    fi->na = n_alloc_new(128, TN_ALLOC_OBSTACK);
+    
+    fi->cnflh = NULL;
+    fi->na = na;
     fi->_last_files = NULL;
     fi->_last_dirname = NULL;
-    return 1;
+    return fi;
 }
 
 
-void file_index_destroy(struct file_index *fi) 
+void file_index_free(struct file_index *fi) 
 {
     n_hash_free(fi->dirs);
     fi->dirs = NULL;
+    if (fi->cnflh)
+        n_hash_free(fi->cnflh);
     n_alloc_free(fi->na);
-    memset(fi, 0, sizeof(*fi));
 }
 
 
@@ -206,6 +212,8 @@
     tn_array *files;
     struct file_ent *entp;
     int i = 1, n;
+
+    n_assert(size > 0);
     
     if ((files = n_hash_get(fi->dirs, dirname)) == NULL) {
         DBGF("%s: directory not found\n", dirname);

================================================================
Index: poldek/poldek/fileindex.h
diff -u poldek/poldek/fileindex.h:1.11 poldek/poldek/fileindex.h:1.12
--- poldek/poldek/fileindex.h:1.11	Wed Oct 19 18:27:09 2005
+++ poldek/poldek/fileindex.h	Sun Aug 20 20:14:58 2006
@@ -23,8 +23,8 @@
     const char *_last_dirname;
 };
 
-int  file_index_init(struct file_index *fi, int nelem);
-void file_index_destroy(struct file_index *fi);
+struct file_index *file_index_new(int nelem);
+void file_index_free(struct file_index *fi);
 
 void file_index_setup(struct file_index *fi); 
 

================================================================
Index: poldek/poldek/lib_init.c
diff -u poldek/poldek/lib_init.c:1.74 poldek/poldek/lib_init.c:1.75
--- poldek/poldek/lib_init.c:1.74	Sun Apr  2 21:10:36 2006
+++ poldek/poldek/lib_init.c	Sun Aug 20 20:14:58 2006
@@ -53,10 +53,10 @@
 #define SOURCES_LOADED      (1 << 3)
 #define SETUP_DONE          (1 << 4)  
 
-const char poldek_BUG_MAILADDR[] = "<mis at pld.org.pl>";
+const char poldek_BUG_MAILADDR[] = "<mis at pld-linux.org>";
 const char poldek_VERSION_BANNER[] = PACKAGE " " VERSION " (" VERSION_STATUS ")";
 const char poldek_BANNER[] = PACKAGE " " VERSION " (" VERSION_STATUS ")\n"
-"Copyright (C) 2000-2005 Pawel A. Gajda <mis at pld.org.pl>\n"
+"Copyright (C) 2000-2006 Pawel A. Gajda <mis at pld-linux.org>\n"
 "This program may be freely redistributed under the terms of the GNU GPL v2";
 
 static const char *poldek_logprefix = "poldek";
@@ -1283,8 +1283,16 @@
                 case POLDEK_OP_MULTILIB: /* do not touch, will
                                             be determined later */
                     break;
+
+                case POLDEK_OP_AUTODIRDEP:
+                    v = 0;
+#ifdef HAVE_RPMDSUNAME          /* rpmdsUname - rpm 4.4.6  */
+                    v = 1;
+#endif
+                    break;
                     
                 default:
+                    logn(LOGERR, "unhandled %s", ent->name);
                     n_assert(0);
             }
             DBGF("auto %s  = %d\n",  ent->name,  v);
@@ -1509,6 +1517,14 @@
         rc = 0;
 
     vfile_setup();
+
+    ctx->_depengine = 2; /* XXX: should be extracted from conf_sections.c */
+    if (ctx->htconf) {
+        tn_hash *htcnf = poldek_conf_get_section_ht(ctx->htconf, "global");
+        ctx->_depengine = poldek_conf_get_int(htcnf, "dependency engine version",
+                                              ctx->_depengine);
+    }
+
     ctx->_iflags |= SETUP_DONE;
     return rc;
 }
@@ -1534,9 +1550,10 @@
     return rc;
 }
 
-struct pkgdir *poldek_load_destination_pkgdir(struct poldek_ctx *ctx)
+struct pkgdir *poldek_load_destination_pkgdir(struct poldek_ctx *ctx,
+                                              unsigned ldflags)
 {
-    return pkgdb_to_pkgdir(ctx->pmctx, ctx->ts->rootdir, NULL, NULL);
+    return pkgdb_to_pkgdir(ctx->pmctx, ctx->ts->rootdir, NULL, ldflags, NULL);
 }
 
 int poldek_is_interactive_on(const struct poldek_ctx *ctx)

================================================================
Index: poldek/poldek/lib_pkgset.c
diff -u poldek/poldek/lib_pkgset.c:1.20 poldek/poldek/lib_pkgset.c:1.21
--- poldek/poldek/lib_pkgset.c:1.20	Fri Oct 21 01:10:51 2005
+++ poldek/poldek/lib_pkgset.c	Sun Aug 20 20:14:58 2006
@@ -66,6 +66,9 @@
 
     if (strcmp(pm_get_name(ctx->pmctx), "pset") == 0)
         ldflags |= PKGDIR_LD_FULLFLIST;
+
+    if (ctx->ts->getop(ctx->ts, POLDEK_OP_AUTODIRDEP))
+        ldflags |= PKGDIR_LD_DIRINDEX;
     
     if (!pkgset_load(ps, ldflags, ctx->sources))
         logn(LOGWARN, _("no packages loaded"));

================================================================
Index: poldek/poldek/libpoldek.sym
diff -u poldek/poldek/libpoldek.sym:1.24 poldek/poldek/libpoldek.sym:1.25
--- poldek/poldek/libpoldek.sym:1.24	Sat Nov  5 18:47:55 2005
+++ poldek/poldek/libpoldek.sym	Sun Aug 20 20:14:58 2006
@@ -89,6 +89,7 @@
 pkg_path_s
 pkg_pkgdirpath
 pkg_printf
+pkg_required_dirs
 pkg_requires_versioned_cap
 pkg_satisfies_req
 pkg_set_arch

================================================================
Index: poldek/poldek/misc.c
diff -u poldek/poldek/misc.c:1.54 poldek/poldek/misc.c:1.55
--- poldek/poldek/misc.c:1.54	Sun Nov  6 20:28:39 2005
+++ poldek/poldek/misc.c	Sun Aug 20 20:14:58 2006
@@ -669,7 +669,15 @@
     return dest;
 }
 
+time_t poldek_util_mtime(const char *path)
+{
+    struct stat st;
+    
+    if (stat(path, &st) != 0)
+        return 0;
 
+    return st.st_mtime;
+}
 
 const char *poldek_util_expand_env_vars(char *dest, int size, const char *str)
 {

================================================================
Index: poldek/poldek/pkg.c
diff -u poldek/poldek/pkg.c:1.109 poldek/poldek/pkg.c:1.110
--- poldek/poldek/pkg.c:1.109	Sun Apr  2 21:10:36 2006
+++ poldek/poldek/pkg.c	Sun Aug 20 20:14:58 2006
@@ -949,6 +949,12 @@
     return pkgu;
 }
 
+tn_array *pkg_required_dirs(const struct pkg *pkg) 
+{
+    if (pkg->pkgdir && pkg->pkgdir->dirindex)
+        return pkgdir_dirindex_get_reqdirs(pkg->pkgdir->dirindex, pkg);
+    return NULL;
+}
 
 static
 tn_tuple *do_pkg_other_fl(tn_alloc *na, const struct pkg *pkg) 

================================================================
Index: poldek/poldek/pkg.h
diff -u poldek/poldek/pkg.h:1.75 poldek/poldek/pkg.h:1.76
--- poldek/poldek/pkg.h:1.75	Thu Oct 20 17:44:43 2005
+++ poldek/poldek/pkg.h	Sun Aug 20 20:14:58 2006
@@ -220,6 +220,9 @@
 struct pkguinf *pkg_uinf(const struct pkg *pkg);
 struct pkguinf *pkg_xuinf(const struct pkg *pkg, tn_array *langs);
 
+/* directories required by package */
+tn_array *pkg_required_dirs(const struct pkg *pkg);
+
 struct pkgflist {
     tn_tuple *fl;
     tn_alloc *_na;

================================================================
Index: poldek/poldek/pkgfl.c
diff -u poldek/poldek/pkgfl.c:1.40 poldek/poldek/pkgfl.c:1.41
--- poldek/poldek/pkgfl.c:1.40	Mon Jul 10 00:16:44 2006
+++ poldek/poldek/pkgfl.c	Sun Aug 20 20:14:58 2006
@@ -636,65 +636,65 @@
     return path;
 }
 
-/* returns list of directories not belong to filelist itself */
 int pkgfl_owned_and_required_dirs(tn_tuple *fl, tn_array **owned,
                                   tn_array **required)
 {
-    const char *dn = NULL;
-    int i, dnlen, r;
+    int i, j, n;
     tn_array *od = NULL, *rd = NULL;
+    tn_hash *oh = n_hash_new(n_tuple_size(fl), free);
 
-    if (owned)
-        od = n_array_new(n_tuple_size(fl), NULL, (tn_fn_cmp)strcmp);
-    
-    if (required)
-        rd = n_array_new(n_tuple_size(fl), NULL, (tn_fn_cmp)strcmp);
+    n_assert(owned);
     
     for (i=0; i < n_tuple_size(fl); i++) {
         struct pkgfl_ent *flent = n_tuple_nth(fl, i);
 
-        if (dn && strncmp(dn, flent->dirname, dnlen) == 0) {
-            if (od)
-                n_array_push(od, flent->dirname);
-            continue;
+        for (j=0; j < flent->items; j++) {
+            struct flfile     *f = flent->files[j];
+            char              dir[PATH_MAX];
+            
+            if (S_ISDIR(f->mode)) {
+                n_snprintf(dir, sizeof(dir), "%s/%s", flent->dirname, f->basename);
+                n_hash_insert(oh, dir, NULL);
+            }
         }
+    }
+    
+    n = 0;
+    od = n_hash_keys_cp(oh);
+    
+    if (required) {
+        rd = n_array_clone(od);
         
-        dn = flent->dirname;
-        if (*dn == '/' && *(dn + 1) == '\0') {
-            dn = "";
-            dnlen = 0;
-            continue;
+        for (i=0; i < n_tuple_size(fl); i++) {
+            struct pkgfl_ent *flent = n_tuple_nth(fl, i);
+            if (!n_hash_exists(oh, flent->dirname))
+                n_array_push(rd, n_strdup(flent->dirname));
         }
         
-        dnlen = strlen(dn);
-        if (rd)
-            n_array_push(rd, dn);
+        if (n_array_size(rd) == 0)
+            n_array_cfree(&rd);
+        else
+            n += n_array_size(rd);
+        
+        *required = rd;
     }
+    n_hash_free(oh);
+
+    if (n_array_size(od) == 0)
+        n_array_cfree(&od);
+    else
+        n += n_array_size(od);
 
-    r = 0;
+    
     if (od) {
-        *owned = od;
-        for (i = 0; i < n_array_size(od); i++)            
-            printf("O %s\n", n_array_nth(od, i));
-        r += i;
+        //for (i = 0; i < n_array_size(od); i++)            
+        //    printf("O %s\n", n_array_nth(od, i));
     }
     
     if (rd) {
-        *required = rd;
-        for (i = 0; i < n_array_size(rd); i++)            
-            printf("R %s\n", n_array_nth(rd, i));
-        r += i;
+        //for (i = 0; i < n_array_size(rd); i++)            
+        //    printf("R %s\n", n_array_nth(rd, i));
     }
-    return r;
-}
-
-tn_array *pkgfl_required_directories(tn_tuple *fl) 
-{
-    tn_array *required = NULL;
-
-    pkgfl_owned_and_required_dirs(fl, NULL, &required);
-
-    return required;
+    return n;
 }
 
-                             

================================================================
Index: poldek/poldek/pkgfl.h
diff -u poldek/poldek/pkgfl.h:1.22 poldek/poldek/pkgfl.h:1.23
--- poldek/poldek/pkgfl.h:1.22	Wed Oct 12 21:25:55 2005
+++ poldek/poldek/pkgfl.h	Sun Aug 20 20:14:58 2006
@@ -83,6 +83,10 @@
 const char *pkgfl_it_get_rawargs(struct pkgfl_it *it, uint32_t *size, uint16_t *mode,
                                  const char **basename);
 
+/* extract owned and required directories */
+int pkgfl_owned_and_required_dirs(tn_tuple *fl, tn_array **owned,
+                                  tn_array **required);
+
 #endif /* POLDEK_PKGFL_H */
 
 

================================================================
Index: poldek/poldek/pkgset-install.c
diff -u poldek/poldek/pkgset-install.c:1.149 poldek/poldek/pkgset-install.c:1.150
--- poldek/poldek/pkgset-install.c:1.149	Thu Nov  3 01:21:00 2005
+++ poldek/poldek/pkgset-install.c	Sun Aug 20 20:14:58 2006
@@ -63,7 +63,7 @@
 #include "poldek.h"
 #include "poldek_intern.h"
 #include "pm/pm.h"
-
+#include "pkgfl.h"
 
 #define DBPKG_ORPHANS_PROCESSED   (1 << 15) /* is its orphan processed ?*/
 #define DBPKG_DEPS_PROCESSED      (1 << 16) /* is its deps processed? */

================================================================
Index: poldek/poldek/pkgset-order.c
diff -u poldek/poldek/pkgset-order.c:1.30 poldek/poldek/pkgset-order.c:1.31
--- poldek/poldek/pkgset-order.c:1.30	Tue Jul  5 23:10:06 2005
+++ poldek/poldek/pkgset-order.c	Sun Aug 20 20:14:58 2006
@@ -18,6 +18,7 @@
 #include <trurl/nassert.h>
 #include <trurl/narray.h>
 #include <trurl/nhash.h>
+#include <trurl/n_snprintf.h>
 
 #include "i18n.h"
 #include "log.h"

================================================================
Index: poldek/poldek/pkgset-req.c
diff -u poldek/poldek/pkgset-req.c:1.42 poldek/poldek/pkgset-req.c:1.43
--- poldek/poldek/pkgset-req.c:1.42	Sun Jul  9 23:24:56 2006
+++ poldek/poldek/pkgset-req.c	Sun Aug 20 20:14:58 2006
@@ -29,8 +29,11 @@
 #include "pkgmisc.h"
 #include "capreq.h"
 #include "pkgset-req.h"
+#include "fileindex.h"
 
 extern int poldek_conf_MULTILIB;
+extern tn_array *pkgset_search_reqdir(struct pkgset *ps, tn_array *pkgs,
+                                      const char *dir);
 
 void *pkg_na_malloc(struct pkg *pkg, size_t size);
 
@@ -304,10 +307,10 @@
 {
     const struct capreq_idx_ent *ent;
     char *reqname;
-    int matched;
-
+    int matched, pkgsbuf_size;
 
     reqname = capreq_name(req);
+    pkgsbuf_size = *npkgs;
     *npkgs = 0;
     matched = 0;
 
@@ -316,14 +319,30 @@
         *npkgs = ent->items;
         matched = 1;
         
-    } else if (*reqname == '/') {
+    } else if (capreq_is_file(req)) {
         int n;
         
-        n = file_index_lookup(&ps->file_idx, reqname, 0, pkgsbuf, *npkgs);
-        if (n > 0) {
+        n = file_index_lookup(ps->file_idx, reqname, 0, pkgsbuf, pkgsbuf_size);
+        n_assert(n >= 0);
+        if (n) {
             *npkgs = n;
             matched = 1;
             *suspkgs = pkgsbuf;
+            
+        } else {                /* n is 0 */
+            tn_array *pkgs;
+            if ((pkgs = pkgset_search_reqdir(ps, NULL, reqname))) {
+                while (n_array_size(pkgs)) {
+                    pkgsbuf[n++] = n_array_shift(pkgs);
+                    if (n == pkgsbuf_size)
+                        break;
+                }
+                
+                *npkgs = n;
+                matched = 1;
+                *suspkgs = pkgsbuf;
+                n_array_free(pkgs);
+            }
         }
     }
 

================================================================
Index: poldek/poldek/pkgset.c
diff -u poldek/poldek/pkgset.c:1.87 poldek/poldek/pkgset.c:1.88
--- poldek/poldek/pkgset.c:1.87	Sun Jul  9 23:24:56 2006
+++ poldek/poldek/pkgset.c	Sun Aug 20 20:14:58 2006
@@ -39,6 +39,7 @@
 #include "poldek_term.h"
 #include "pm/pm.h"
 #include "pkgdir/pkgdir.h"
+#include "fileindex.h"
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -92,7 +93,7 @@
         capreq_idx_destroy(&ps->req_idx);
         capreq_idx_destroy(&ps->obs_idx);
         capreq_idx_destroy(&ps->cnfl_idx);
-        file_index_destroy(&ps->file_idx);
+        file_index_free(ps->file_idx);
         ps->flags &= (unsigned)~_PKGSET_INDEXES_INIT;
     }
     
@@ -214,7 +215,7 @@
     capreq_idx_init(&ps->req_idx,  CAPREQ_IDX_REQ, 4 * n_array_size(ps->pkgs));
     capreq_idx_init(&ps->obs_idx,  CAPREQ_IDX_REQ, n_array_size(ps->pkgs)/5 + 4);
     capreq_idx_init(&ps->cnfl_idx, CAPREQ_IDX_REQ, n_array_size(ps->pkgs)/5 + 4);
-    file_index_init(&ps->file_idx, 512);
+    ps->file_idx = file_index_new(512);
     ps->flags |= _PKGSET_INDEXES_INIT;
 
     for (i=0; i < n_array_size(ps->pkgs); i++) {
@@ -232,7 +233,7 @@
     capreq_idx_stats("req", &ps->req_idx);
     capreq_idx_stats("obs", &ps->obs_idx);
 #endif    
-    file_index_setup(&ps->file_idx);
+    file_index_setup(ps->file_idx);
     msg(3, " ..%d done\n", i);
     
     return 0;
@@ -295,7 +296,7 @@
     MEMINF("after index");
     v = poldek_VERBOSE;
     poldek_VERBOSE = -1;
-    file_index_find_conflicts(&ps->file_idx, strict);
+    file_index_find_conflicts(ps->file_idx, strict);
     poldek_VERBOSE = v;
  
     pkgset_verify_deps(ps, strict);
@@ -353,7 +354,7 @@
                 capreq_idx_add(&ps->cnfl_idx, capreq_name(cnfl), pkg);
         }
     
-    pkgfl2fidx(pkg, &ps->file_idx, rt);
+    pkgfl2fidx(pkg, ps->file_idx, rt);
     return 1;
 }
 
@@ -399,7 +400,7 @@
             struct pkgfl_ent *flent = n_tuple_nth(pkg->fl, i);
             
             for (j=0; j < flent->items; j++)
-                file_index_remove(&ps->file_idx, flent->dirname,
+                file_index_remove(ps->file_idx, flent->dirname,
                                   flent->files[j]->basename, pkg);
         }
 
@@ -527,6 +528,35 @@
     return pkgs;
 }
 
+tn_array *pkgset_search_reqdir(struct pkgset *ps, tn_array *pkgs,
+                               const char *dir)
+{
+    tn_array *tmp = pkgs_array_new(32);
+    int i;
+    
+        
+    for (i=0; i < n_array_size(ps->pkgdirs); i++) {
+        struct pkgdir *pkgdir = n_array_nth(ps->pkgdirs, i);
+        
+        if (pkgdir->dirindex == NULL)
+            continue;
+
+        pkgdir_dirindex_get(pkgdir->dirindex, tmp, dir);
+    }
+
+    if (pkgs == NULL)
+        pkgs = n_array_clone(tmp);
+
+    for (i=0; i < n_array_size(tmp); i++) {
+        struct pkg *pkg = n_array_nth(tmp, i);
+        if (n_array_bsearch(ps->pkgs, pkg))
+            n_array_push(pkgs, pkg_link(pkg));
+    }
+    n_array_free(tmp);
+    return pkgs;
+}
+
+
 tn_array *pkgset_search(struct pkgset *ps, enum pkgset_search_tag tag,
                         const char *value)
 {
@@ -571,10 +601,15 @@
             else {
                 struct pkg *buf[1024];
                 int i, n;
-                n = file_index_lookup(&ps->file_idx, value, 0, buf, 1024);
-                if (n > 0) {
+                n = file_index_lookup(ps->file_idx, value, 0, buf, 1024);
+                n_assert(n >= 0);
+                
+                if (n) {
                     for (i=0; i < n; i++)
                         n_array_push(pkgs, pkg_link(buf[i]));
+
+                } else {
+                    pkgset_search_reqdir(ps, pkgs, value);
                 }
             }
<<Diff was trimmed, longer than 597 lines>>

---- CVS-web:
    http://cvs.pld-linux.org/poldek/poldek/conf.h?r1=1.16&r2=1.17&f=u
    http://cvs.pld-linux.org/poldek/poldek/configure.in?r1=1.123&r2=1.124&f=u
    http://cvs.pld-linux.org/poldek/poldek/fileindex.c?r1=1.28&r2=1.29&f=u
    http://cvs.pld-linux.org/poldek/poldek/fileindex.h?r1=1.11&r2=1.12&f=u
    http://cvs.pld-linux.org/poldek/poldek/lib_init.c?r1=1.74&r2=1.75&f=u
    http://cvs.pld-linux.org/poldek/poldek/lib_pkgset.c?r1=1.20&r2=1.21&f=u
    http://cvs.pld-linux.org/poldek/poldek/libpoldek.sym?r1=1.24&r2=1.25&f=u
    http://cvs.pld-linux.org/poldek/poldek/misc.c?r1=1.54&r2=1.55&f=u
    http://cvs.pld-linux.org/poldek/poldek/pkg.c?r1=1.109&r2=1.110&f=u
    http://cvs.pld-linux.org/poldek/poldek/pkg.h?r1=1.75&r2=1.76&f=u
    http://cvs.pld-linux.org/poldek/poldek/pkgfl.c?r1=1.40&r2=1.41&f=u
    http://cvs.pld-linux.org/poldek/poldek/pkgfl.h?r1=1.22&r2=1.23&f=u
    http://cvs.pld-linux.org/poldek/poldek/pkgset-install.c?r1=1.149&r2=1.150&f=u
    http://cvs.pld-linux.org/poldek/poldek/pkgset-order.c?r1=1.30&r2=1.31&f=u
    http://cvs.pld-linux.org/poldek/poldek/pkgset-req.c?r1=1.42&r2=1.43&f=u
    http://cvs.pld-linux.org/poldek/poldek/pkgset.c?r1=1.87&r2=1.88&f=u
    http://cvs.pld-linux.org/poldek/poldek/pkgset.h?r1=1.58&r2=1.59&f=u
    http://cvs.pld-linux.org/poldek/poldek/poldek.h?r1=1.33&r2=1.34&f=u
    http://cvs.pld-linux.org/poldek/poldek/poldek_intern.h?r1=1.8&r2=1.9&f=u
    http://cvs.pld-linux.org/poldek/poldek/poldek_ts.c?r1=1.56&r2=1.57&f=u
    http://cvs.pld-linux.org/poldek/poldek/poldek_ts.h?r1=1.33&r2=1.34&f=u
    http://cvs.pld-linux.org/poldek/poldek/poldek_util.h?r1=1.6&r2=1.7&f=u
    http://cvs.pld-linux.org/poldek/poldek/split.c?r1=1.23&r2=1.24&f=u
    http://cvs.pld-linux.org/poldek/poldek/uninstall.c?r1=1.40&r2=1.41&f=u
    http://cvs.pld-linux.org/poldek/poldek/cli/dbcache.c?r1=1.30&r2=1.31&f=u
    http://cvs.pld-linux.org/poldek/poldek/install/ictx.h?r1=1.3&r2=1.4&f=u
    http://cvs.pld-linux.org/poldek/poldek/pkgdir/Makefile.am?r1=1.9&r2=1.10&f=u
    http://cvs.pld-linux.org/poldek/poldek/pkgdir/pkgdir.c?r1=1.44&r2=1.45&f=u
    http://cvs.pld-linux.org/poldek/poldek/pkgdir/pkgdir.h?r1=1.32&r2=1.33&f=u
    http://cvs.pld-linux.org/poldek/poldek/pkgdir/dir/dir.c?r1=1.25&r2=1.26&f=u
    http://cvs.pld-linux.org/poldek/poldek/pkgdir/metadata/metadata.c?r1=1.5&r2=1.6&f=u
    http://cvs.pld-linux.org/poldek/poldek/pkgdir/yum/yum.c?r1=1.17&r2=1.18&f=u
    http://cvs.pld-linux.org/poldek/poldek/pm/mod.h?r1=1.11&r2=1.12&f=u
    http://cvs.pld-linux.org/poldek/poldek/pm/pkgdb.c?r1=1.22&r2=1.23&f=u
    http://cvs.pld-linux.org/poldek/poldek/pm/pm.h?r1=1.15&r2=1.16&f=u
    http://cvs.pld-linux.org/poldek/poldek/pm/pset/pm_pset.h?r1=1.8&r2=1.9&f=u
    http://cvs.pld-linux.org/poldek/poldek/pm/pset/pset.c?r1=1.20&r2=1.21&f=u
    http://cvs.pld-linux.org/poldek/poldek/pm/rpm/pm_rpm.h?r1=1.13&r2=1.14&f=u
    http://cvs.pld-linux.org/poldek/poldek/pm/rpm/rpm.c?r1=1.14&r2=1.15&f=u



More information about the pld-cvs-commit mailing list