poldek: poldek/pkgu.c, poldek/lib_init.c, poldek/cli/dbcache.c - c...

mis mis at pld-linux.org
Fri Jun 22 00:32:39 CEST 2007


Author: mis                          Date: Thu Jun 21 22:32:39 2007 GMT
Module: poldek                        Tag: HEAD
---- Log message:
- comments, killed warnings, etc

---- Files affected:
poldek/poldek:
   pkgu.c (1.31 -> 1.32) , lib_init.c (1.79 -> 1.80) 
poldek/poldek/cli:
   dbcache.c (1.32 -> 1.33) 

---- Diffs:

================================================================
Index: poldek/poldek/pkgu.c
diff -u poldek/poldek/pkgu.c:1.31 poldek/poldek/pkgu.c:1.32
--- poldek/poldek/pkgu.c:1.31	Sat Jan  7 02:11:58 2006
+++ poldek/poldek/pkgu.c	Fri Jun 22 00:32:34 2007
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2000 - 2005 Pawel A. Gajda <mis at pld.org.pl>
+  Copyright (C) 2000 - 2007 Pawel A. Gajda <mis at pld-linux.org>
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License, version 2 as
@@ -57,8 +57,6 @@
     char              _buf[0];
 };
 
-static Header make_pkguinf_hdr(struct pkguinf *pkgu, int *langs_cnt);
-
 static
 struct pkguinf_i18n *pkguinf_i18n_new(tn_alloc *na, const char *summary,
                                       const char *description)
@@ -148,95 +146,6 @@
     return pkgu;
 }
 
-
-int pkguinf_store_rpmhdr(struct pkguinf *pkgu, tn_buf *nbuf) 
-{
-    Header   hdr = NULL;
-    void     *rawhdr;
-    int      rawhdr_size;
-    
-    int rc;
-
-
-    hdr = make_pkguinf_hdr(pkgu, NULL);
-    rawhdr_size = headerSizeof(hdr, HEADER_MAGIC_NO);
-    rawhdr = headerUnload(hdr);
-
-#if 0    
-    printf("> %ld\t%d\n", ftell(stream), headerSizeof(pkgu->_hdr, HEADER_MAGIC_NO));
-    headerDump(pkgu->_hdr, stdout, HEADER_DUMP_INLINE, rpmTagTable);
-#endif     
-
-	n_buf_write_int16(nbuf, n_hash_size(pkgu->_ht));
-    n_buf_write_int16(nbuf, rawhdr_size);
-
-    
-    rc = (n_buf_write(nbuf, rawhdr, rawhdr_size) == rawhdr_size);
-    
-    free(rawhdr);
-    headerFree(hdr);
-    
-    return rc;
-}
-
-struct pkguinf *pkguinf_restore_rpmhdr_st(tn_alloc *na,
-                                          tn_stream *st, off_t offset)
-{
-    uint16_t nsize, nlangs;
-    struct pkguinf *pkgu = NULL;
-    void *rawhdr;
-    Header hdr;
-
-    if (offset > 0)
-        if (n_stream_seek(st, offset, SEEK_SET) != 0) {
-            logn(LOGERR, "pkguinf_restore: fseek %ld: %m", (long int)offset);
-            return NULL;
-        }
-
-    
-    if (!n_stream_read_uint16(st, &nlangs)) {
-        logn(LOGERR, "pkguinf_restore: read error nlangs (%m) at %ld %p",
-             n_stream_tell(st), st);
-        return NULL;
-    }
-    
-    if (!n_stream_read_uint16(st, &nsize)) {
-        logn(LOGERR, "pkguinf_restore: read error nsize (%m) at %ld",
-             n_stream_tell(st));
-        return NULL;
-    }
-    
-    rawhdr = alloca(nsize);
-    
-    if (n_stream_read(st, rawhdr, nsize) != nsize) {
-        logn(LOGERR, "pkguinf_restore: read %d error at %ld", nsize,
-             n_stream_tell(st));
-        return NULL;
-    }
-    
-    if ((hdr = headerLoad(rawhdr)) != NULL) {
-        pkgu = pkguinf_ldrpmhdr(na, hdr);
-        headerFree(hdr); //rpm's memleak
-    }
-
-    return pkgu;
-}
-
-
-int pkguinf_skip_rpmhdr(tn_stream *st) 
-{
-    uint16_t nsize, nlangs;
-
-    n_stream_seek(st, sizeof(nlangs), SEEK_CUR);
-    
-    if (!n_stream_read_uint16(st, &nsize))
-        nsize = 0;
-	else
-        n_stream_seek(st, nsize, SEEK_CUR);
-    
-    return nsize;
-}
-
 static inline
 void set_member(struct pkguinf *pkgu, char **m, const char *v, int len)
 {
@@ -345,56 +254,6 @@
     return pkgu;
 }
 
-
-static Header make_pkguinf_hdr(struct pkguinf *pkgu, int *langs_cnt) 
-{
-    int                i, nlangs = 0;
-    Header             hdr = NULL;
-    unsigned           hdr_size;
-    tn_array           *langs;
-    
-
-    hdr = headerNew();
-    if ((langs = pkgu->_langs_rpmhdr) == NULL)
-        langs = pkguinf_langs(pkgu);
-    
-    for (i=0; i < n_array_size(langs); i++) {
-        const char *lang = n_array_nth(langs, i);
-        struct pkguinf_i18n *inf = n_hash_get(pkgu->_ht, lang);
-        
-        headerAddI18NString(hdr, RPMTAG_SUMMARY, inf->summary, lang);
-        headerAddI18NString(hdr, RPMTAG_DESCRIPTION, inf->description, lang);
-    }
-
-    if (pkgu->vendor)
-        headerAddEntry(hdr, RPMTAG_VENDOR, RPM_STRING_TYPE, pkgu->vendor, 1);
-    
-    if (pkgu->license)
-        headerAddEntry(hdr, PM_RPMTAG_LICENSE, RPM_STRING_TYPE, pkgu->license, 1);
-    
-    if (pkgu->url)
-        headerAddEntry(hdr, RPMTAG_URL, RPM_STRING_TYPE, pkgu->url, 1);
-    
-    if (pkgu->distro)
-        headerAddEntry(hdr, RPMTAG_DISTRIBUTION, RPM_STRING_TYPE, pkgu->distro, 1);
-    
-    if (pkgu->buildhost)
-        headerAddEntry(hdr, RPMTAG_BUILDHOST, RPM_STRING_TYPE, pkgu->buildhost, 1);
-
-    hdr_size = headerSizeof(hdr, HEADER_MAGIC_NO);
-    
-    if (hdr_size > UINT16_MAX) {
-        logn(LOGERR, "internal: header size too large: %d", hdr_size);
-        headerFree(hdr);
-        hdr = NULL;
-    }
-
-    if (langs_cnt)
-        *langs_cnt = nlangs;
-
-    return hdr;
-}
-
 tn_array *pkguinf_langs(struct pkguinf *pkgu)
 {
     if (pkgu->_langs == NULL) 
@@ -498,8 +357,6 @@
     return nbuf;
 }
 
-
-
 struct pkguinf *pkguinf_restore(tn_alloc *na, tn_buf_it *it, const char *lang)
 {
     struct pkguinf *pkgu;
@@ -550,7 +407,6 @@
     return pkgu;
 }
 
-
 int pkguinf_restore_i18n(struct pkguinf *pkgu, tn_buf_it *it, const char *lang)
 {
     struct pkguinf_i18n *inf;
@@ -584,7 +440,6 @@
     return 1;
 }
 
-
 const char *pkguinf_get(const struct pkguinf *pkgu, int tag)
 {
     switch (tag) {
@@ -680,4 +535,145 @@
     }
     
     return 1;
+}
+
+/*
+ * DEPRECIATED, LEGACY 
+ * pkguinf store/restore as rpm header; functions used by old-poor pdir index
+ * format
+ */
+static Header make_pkguinf_hdr(struct pkguinf *pkgu, int *langs_cnt) 
+{
+    int                i, nlangs = 0;
+    Header             hdr = NULL;
+    unsigned           hdr_size;
+    tn_array           *langs;
+    
+
+    hdr = headerNew();
+    if ((langs = pkgu->_langs_rpmhdr) == NULL)
+        langs = pkguinf_langs(pkgu);
+    
+    for (i=0; i < n_array_size(langs); i++) {
+        const char *lang = n_array_nth(langs, i);
+        struct pkguinf_i18n *inf = n_hash_get(pkgu->_ht, lang);
+        
+        headerAddI18NString(hdr, RPMTAG_SUMMARY, inf->summary, lang);
+        headerAddI18NString(hdr, RPMTAG_DESCRIPTION, inf->description, lang);
+    }
+
+    if (pkgu->vendor)
+        headerAddEntry(hdr, RPMTAG_VENDOR, RPM_STRING_TYPE, pkgu->vendor, 1);
+    
+    if (pkgu->license)
+        headerAddEntry(hdr, PM_RPMTAG_LICENSE, RPM_STRING_TYPE, pkgu->license, 1);
+    
+    if (pkgu->url)
+        headerAddEntry(hdr, RPMTAG_URL, RPM_STRING_TYPE, pkgu->url, 1);
+    
+    if (pkgu->distro)
+        headerAddEntry(hdr, RPMTAG_DISTRIBUTION, RPM_STRING_TYPE, pkgu->distro, 1);
+    
+    if (pkgu->buildhost)
+        headerAddEntry(hdr, RPMTAG_BUILDHOST, RPM_STRING_TYPE, pkgu->buildhost, 1);
+
+    hdr_size = headerSizeof(hdr, HEADER_MAGIC_NO);
+    
+    if (hdr_size > UINT16_MAX) {
+        logn(LOGERR, "internal: header size too large: %d", hdr_size);
+        headerFree(hdr);
+        hdr = NULL;
+    }
+
+    if (langs_cnt)
+        *langs_cnt = nlangs;
+
+    return hdr;
+}
+
+int pkguinf_store_rpmhdr(struct pkguinf *pkgu, tn_buf *nbuf) 
+{
+    Header   hdr = NULL;
+    void     *rawhdr;
+    int      rawhdr_size;
+    
+    int rc;
+
+
+    hdr = make_pkguinf_hdr(pkgu, NULL);
+    rawhdr_size = headerSizeof(hdr, HEADER_MAGIC_NO);
+    rawhdr = headerUnload(hdr);
+
+#if 0    
+    printf("> %ld\t%d\n", ftell(stream), headerSizeof(pkgu->_hdr, HEADER_MAGIC_NO));
+    headerDump(pkgu->_hdr, stdout, HEADER_DUMP_INLINE, rpmTagTable);
+#endif     
+
+	n_buf_write_int16(nbuf, n_hash_size(pkgu->_ht));
+    n_buf_write_int16(nbuf, rawhdr_size);
+
+    
+    rc = (n_buf_write(nbuf, rawhdr, rawhdr_size) == rawhdr_size);
+    
+    free(rawhdr);
+    headerFree(hdr);
+    
+    return rc;
+}
+
+struct pkguinf *pkguinf_restore_rpmhdr_st(tn_alloc *na,
+                                          tn_stream *st, off_t offset)
+{
+    uint16_t nsize, nlangs;
+    struct pkguinf *pkgu = NULL;
+    void *rawhdr;
+    Header hdr;
+
+    if (offset > 0)
+        if (n_stream_seek(st, offset, SEEK_SET) != 0) {
+            logn(LOGERR, "pkguinf_restore: fseek %ld: %m", (long int)offset);
+            return NULL;
+        }
+
+    
+    if (!n_stream_read_uint16(st, &nlangs)) {
+        logn(LOGERR, "pkguinf_restore: read error nlangs (%m) at %ld %p",
+             n_stream_tell(st), st);
+        return NULL;
+    }
+    
+    if (!n_stream_read_uint16(st, &nsize)) {
+        logn(LOGERR, "pkguinf_restore: read error nsize (%m) at %ld",
+             n_stream_tell(st));
+        return NULL;
+    }
+    
+    rawhdr = alloca(nsize);
+    
+    if (n_stream_read(st, rawhdr, nsize) != nsize) {
+        logn(LOGERR, "pkguinf_restore: read %d error at %ld", nsize,
+             n_stream_tell(st));
+        return NULL;
+    }
+    
+    if ((hdr = headerLoad(rawhdr)) != NULL) {
+        pkgu = pkguinf_ldrpmhdr(na, hdr);
+        headerFree(hdr); //rpm's memleak
+    }
+
+    return pkgu;
+}
+
+int pkguinf_skip_rpmhdr(tn_stream *st) 
+{
+    uint16_t nsize, nlangs;
+
+    n_stream_seek(st, sizeof(nlangs), SEEK_CUR);
+    
+    if (!n_stream_read_uint16(st, &nsize))
+        nsize = 0;
+	else
+        n_stream_seek(st, nsize, SEEK_CUR);
+    
+    return nsize;
 }

================================================================
Index: poldek/poldek/lib_init.c
diff -u poldek/poldek/lib_init.c:1.79 poldek/poldek/lib_init.c:1.80
--- poldek/poldek/lib_init.c:1.79	Thu Jun 21 18:47:45 2007
+++ poldek/poldek/lib_init.c	Fri Jun 22 00:32:34 2007
@@ -1215,14 +1215,14 @@
     vfile_configure(VFILE_CONF_VERBOSE, &poldek_VERBOSE);
     vfile_configure(VFILE_CONF_LOGCB, poldek_vf_vlog_cb);
 
-    /* Kind of egg and chicken problem with cachedir;
+    /* Kind of egg and chicken problem (remote configs) with cachedir;
        on start set it to $TMPDIR. */
-
     path = setup_cachedir(NULL);
     n_assert(path);
     vfile_configure(VFILE_CONF_CACHEDIR, path);
     free(path);
 
+    /* add libdir/poldek to PATH */
 #ifdef PKGLIBDIR
     {
         char *path, buf[PATH_MAX];
@@ -1230,16 +1230,16 @@
             path = "/bin:/usr/bin:/usr/local/bin";
         
         n_snprintf(buf, sizeof(buf), "%s:%s", path, PKGLIBDIR);
-#ifdef HAVE_SETENV        
+# ifdef HAVE_SETENV        
         setenv("PATH", buf, 1);
-#else
+# else
         {
             int len = strlen("PATH") + strlen(path) + 3;
             char *tmp = n_malloc(len);
             n_snprintf(tmp, len, "%s=%s", PATH, path);
             putenv(tmp);
         }
-#endif  /* HAVE_SETENV */
+# endif  /* HAVE_SETENV */
     }
 #endif  /* PKGLIBDIR */
     return 1;

================================================================
Index: poldek/poldek/cli/dbcache.c
diff -u poldek/poldek/cli/dbcache.c:1.32 poldek/poldek/cli/dbcache.c:1.33
--- poldek/poldek/cli/dbcache.c:1.32	Wed Jun 20 19:15:45 2007
+++ poldek/poldek/cli/dbcache.c	Fri Jun 22 00:32:34 2007
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2000 - 2005 Pawel A. Gajda <mis at k2.net.pl>
+  Copyright (C) 2000 - 2007 Pawel A. Gajda <mis at pld-linux.org>
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License, version 2 as
@@ -207,7 +207,6 @@
     char         rpmdb_path[PATH_MAX], dbcache_path[PATH_MAX], dbpath[PATH_MAX];
     const char   *path;
     struct poldek_ts *ts = cctx->ctx->ts; /* for short */
-    int          i;
 
     if (!pm_dbpath(cctx->ctx->pmctx, dbpath, sizeof(dbpath)))
         return 1;
@@ -239,8 +238,7 @@
          mtime_rpmdb, pkgdir->ts, mtime_dbcache);
     n_assert(*path != '\0');
     n_assert(strlen(path) > 10);
-    DBGF("%s %s, %d %d\n", ts->cachedir, path,
-         mtime_rpmdb, cctx->ts_dbpkgdir);
+    DBGF("%s %s, %d %d\n", ts->cachedir, path, mtime_rpmdb, cctx->ts_dbpkgdir);
 
     return pkgdir_save_as(pkgdir, RPMDBCACHE_PDIRTYPE, path,
                           PKGDIR_CREAT_NOPATCH | PKGDIR_CREAT_NOUNIQ |
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/poldek/poldek/pkgu.c?r1=1.31&r2=1.32&f=u
    http://cvs.pld-linux.org/poldek/poldek/lib_init.c?r1=1.79&r2=1.80&f=u
    http://cvs.pld-linux.org/poldek/poldek/cli/dbcache.c?r1=1.32&r2=1.33&f=u



More information about the pld-cvs-commit mailing list