poldek: poldek/pkgdir/pdir/pdir_pkg_store.c, poldek/pkgdir/source....

mis mis at pld-linux.org
Fri May 12 01:47:43 CEST 2006


Author: mis                          Date: Thu May 11 23:47:43 2006 GMT
Module: poldek                        Tag: HEAD
---- Log message:
- finished --mo <opts> to pass pkgdir's specific options to index creation
- with --mo v018x created pdir does not contain files timestamps -
  index is backward compat with versions < 0.18.9
- code cleanups

---- Files affected:
poldek/poldek/pkgdir/pdir:
   pdir_pkg_store.c (1.11 -> 1.12) 
poldek/poldek/pkgdir:
   source.h (1.20 -> 1.21) , source.c (1.39 -> 1.40) 
poldek/poldek/cli:
   op_makeidx.c (1.26 -> 1.27) 

---- Diffs:

================================================================
Index: poldek/poldek/pkgdir/pdir/pdir_pkg_store.c
diff -u poldek/poldek/pkgdir/pdir/pdir_pkg_store.c:1.11 poldek/poldek/pkgdir/pdir/pdir_pkg_store.c:1.12
--- poldek/poldek/pkgdir/pdir/pdir_pkg_store.c:1.11	Thu Oct 13 17:39:26 2005
+++ poldek/poldek/pkgdir/pdir/pdir_pkg_store.c	Fri May 12 01:47:38 2006
@@ -132,7 +132,7 @@
     if (pkg->fn)
         n_buf_printf(nbuf, "n: %s\n", pkg->fn);
 
-    if (pkg->fmtime)
+    if (pkg->fmtime && (flags & PKGSTORE_NOTIMESTAMP) == 0)
         n_buf_printf(nbuf, "t: %u\n", pkg->fmtime);
     
     n_buf_printf(nbuf, "F:\n");

================================================================
Index: poldek/poldek/pkgdir/source.h
diff -u poldek/poldek/pkgdir/source.h:1.20 poldek/poldek/pkgdir/source.h:1.21
--- poldek/poldek/pkgdir/source.h:1.20	Thu May  5 18:34:57 2005
+++ poldek/poldek/pkgdir/source.h	Fri May 12 01:47:38 2006
@@ -96,10 +96,7 @@
 
 int sources_clean(tn_array *sources, unsigned flags);
 
-#define PKGSOURCE_MKIDX_NODIFF         (1 << 0)
-#define PKGSOURCE_MKIDX_COMPRESSED_GZ  (1 << 1)
-#define PKGSOURCE_MKIDX_COMPRESSED_BZ2 (1 << 2)
-
+/* flags = PKGDIR_CREAT_* */
 int source_make_idx(struct source *src, const char *stype, 
                     const char *dtype, const char *idxpath,
                     unsigned flags, tn_hash *kw);

================================================================
Index: poldek/poldek/pkgdir/source.c
diff -u poldek/poldek/pkgdir/source.c:1.39 poldek/poldek/pkgdir/source.c:1.40
--- poldek/poldek/pkgdir/source.c:1.39	Thu Oct 27 00:59:33 2005
+++ poldek/poldek/pkgdir/source.c	Fri May 12 01:47:38 2006
@@ -1034,6 +1034,10 @@
     rc = 0;
     if (pkgdir_load(pkgdir, NULL, ldflags)) {
         n_assert((pkgdir->_ldflags & PKGDIR_LD_DOIGNORE) == 0);
+        
+        if (kw && n_hash_exists(kw, "v018x"))
+            cr_flags |= PKGDIR_CREAT_v018x;
+        
         rc = pkgdir_save_as(pkgdir, type, idxpath, cr_flags);
     }
     

================================================================
Index: poldek/poldek/cli/op_makeidx.c
diff -u poldek/poldek/cli/op_makeidx.c:1.26 poldek/poldek/cli/op_makeidx.c:1.27
--- poldek/poldek/cli/op_makeidx.c:1.26	Sun Oct  9 23:47:57 2005
+++ poldek/poldek/cli/op_makeidx.c	Fri May 12 01:47:38 2006
@@ -74,9 +74,6 @@
 {"nocompress", OPT_NOCOMPR, NULL, 0, 
  N_("Create uncompressed index"), OPT_GID },
 
-{"compress", OPT_COMPR, "type", OPTION_HIDDEN, /* not finished yet */
- N_("Sets compression type (none, bz2, gz)"), OPT_GID },
-
 {"mo", OPT_MOPT, "OPTION[,OPTION]", OPTION_HIDDEN, /* not finished yet */
      N_("index type specific options"), OPT_GID },
 { 0, 0, 0, 0, 0, 0 },
@@ -85,6 +82,20 @@
 { 0, 0, 0, 0, 0, 0 },    
 };
 
+struct mopt {
+    char *name;
+    unsigned flag;
+};
+
+static struct mopt valid_mopts[] = {
+    { "nodesc", PKGDIR_CREAT_NODESC },
+    { "nodiff", PKGDIR_CREAT_NOPATCH },
+    { "v018x", PKGDIR_CREAT_v018x },  /* pdir without pkg files timestamps */
+    { "nocompress", 0 },
+    { "compress", 0 }, /* compress=[gz,bz2,none] - a compression type, NFY */
+    { NULL, 0 },
+};
+
 struct arg_s {
     unsigned            cnflags;
     unsigned            crflags;
@@ -95,6 +106,9 @@
 };
 #define DO_MAKEIDX (1 << 0)
 
+
+static int parse_mopts(struct arg_s *arg_s, char *opstr);
+
 static
 error_t parse_opt(int key, char *arg, struct argp_state *state);
 
@@ -171,29 +185,103 @@
             break;
             
         case OPT_NODESC:
-            arg_s->crflags |= PKGDIR_CREAT_NODESC;
+            parse_mopts(arg_s, "nodesc");
             /* XXX hack, no way to pass option between argps (?)*/
             poclidek_op_source_nodesc = 1;
             break;
 
         case OPT_NODIFF:
-            arg_s->crflags |= PKGDIR_CREAT_NOPATCH;
+            parse_mopts(arg_s, "nodiff");
             break;
             
-        case OPT_COMPR:
-            n_hash_replace(arg_s->opts, "compress", n_strdup(arg));
+        case OPT_COMPR: {
+            char tmp[128];
+            n_snprintf(tmp, sizeof(tmp), "compress=%s", arg);
+            parse_mopts(arg_s, tmp);
             break;
+        }
 
         case OPT_NOCOMPR:
-            n_hash_replace(arg_s->opts, "compress", n_strdup("none"));
+            parse_mopts(arg_s, "nocompress");
+            break;
+
+        case OPT_MOPT:
+            parse_mopts(arg_s, arg);
             break;
-           
+            
         default:
             return ARGP_ERR_UNKNOWN;
     }
     
     return 0;
 }
+
+
+static int parse_mopt(struct arg_s *arg_s, const char *opstr)
+{
+    char *p, *tmp;
+    int i, valid;
+    
+    n_strdupap(opstr, &tmp);
+    
+    if ((p = strchr(tmp, '='))) {
+        *p = 0;
+        p++;
+        p = n_str_strip_ws(p);
+        tmp = n_str_strip_ws(tmp);
+    }
+
+    n_hash_replace(arg_s->opts, tmp, p ? n_strdup(p) : NULL);
+    
+    i = 0;
+    valid = 0;
+    while (valid_mopts[i].name) {
+        if (n_str_eq(tmp, valid_mopts[i].name)) {
+            arg_s->crflags |= valid_mopts[i].flag;
+            valid = 1;
+            break;
+        }
+        i++;
+    }
+    
+    if (!valid) {
+        logn(LOGERR, _("%s: unknown option"), tmp);
+    
+    } else {
+        if (n_str_eq(tmp, "nocompress"))
+            n_hash_replace(arg_s->opts, "compress", n_strdup("none"));
+        else 
+            n_hash_replace(arg_s->opts, tmp, p ? n_strdup(p) : NULL);
+    }
+    
+    return valid;
+}
+
+
+static int parse_mopts(struct arg_s *arg_s, char *opstr) 
+{
+    opstr = n_str_strip_ws(opstr);
+
+    if (opstr == NULL || *opstr == '\0')
+        return 1;
+    
+    if (strchr(opstr, ',') == NULL) {
+        parse_mopt(arg_s, opstr);
+        
+    } else {
+        const char **tl_save, **tl;
+        
+        tl = tl_save = n_str_tokl(opstr, ",");
+        while (*tl) {
+            parse_mopt(arg_s, *tl);
+            tl++;
+        }
+        n_str_tokl_free(tl_save);
+    }
+    
+    return 1;
+}
+
 
 static tn_array *parse_types(const char *type) 
 {
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/poldek/poldek/pkgdir/pdir/pdir_pkg_store.c?r1=1.11&r2=1.12&f=u
    http://cvs.pld-linux.org/poldek/poldek/pkgdir/source.h?r1=1.20&r2=1.21&f=u
    http://cvs.pld-linux.org/poldek/poldek/pkgdir/source.c?r1=1.39&r2=1.40&f=u
    http://cvs.pld-linux.org/poldek/poldek/cli/op_makeidx.c?r1=1.26&r2=1.27&f=u



More information about the pld-cvs-commit mailing list