[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] change in location of conffiles db.



previously the pattern was:

	<admindir>/<conffiles>/<pkg>[_ext]/<path>

and now it's:

	<admindir>/<conffiles>[-ext]/<pkg>/<path>

which is slightly less hackish and works like most of the other "databases".
---
 lib/dpkg.h      |    2 +-
 src/conffiles.c |   35 ++++++++++++++---------------------
 2 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/lib/dpkg.h b/lib/dpkg.h
index a450716..de46930 100644
--- a/lib/dpkg.h
+++ b/lib/dpkg.h
@@ -93,7 +93,7 @@
 #define UPDATESDIR        "updates/"
 #define INFODIR           "info/"
 #define PARTSDIR          "parts/"
-#define CONFFILESDIR      "conffiles/"
+#define CONFFILESDIR      "conffiles"
 #define CONTROLDIRTMP     "tmp.ci/"
 #define IMPORTANTTMP      "tmp.i"
 #define REASSEMBLETMP     "reassemble" DEBEXT
diff --git a/src/conffiles.c b/src/conffiles.c
index a520717..db55538 100644
--- a/src/conffiles.c
+++ b/src/conffiles.c
@@ -20,21 +20,23 @@
  */
 static char* conff_db_path(const char *pkg, const char *path, conff_flag f){
   char *p = NULL;
-  const char *ext = NULL;
-  size_t ext_sz = 0, cfgdb_root_sz = 0, p_sz = 0, path_sz = 0;
+  const char *ext = "";
+  size_t cfgdb_root_sz = 0, p_sz = 0, path_sz = 0;
   
-  cfgdb_root_sz = strlen(admindir)+1+strlen(CONFFILESDIR)+strlen(pkg);
+  /* <admindir>/<conffiles[-ext]>/<pkg> + '\0' */
+  cfgdb_root_sz = strlen(admindir)+1+strlen(CONFFILESDIR)+1+strlen(pkg)+1;
 
   if(path!=NULL) path_sz = strlen(path);
 
+  /* in the case of new/old, we add extra space for the [-ext] */
   switch(f){
   case conff_db_new:
-    ext=DPKGNEWEXT;
-    ext_sz=strlen(DPKGNEWEXT);
+    ext=NEWDBEXT;
+    cfgdb_root_sz+=strlen(NEWDBEXT);
     break;
   case conff_db_old:
-    ext=DPKGOLDEXT;
-    ext_sz=strlen(DPKGOLDEXT);
+    ext=OLDDBEXT;
+    cfgdb_root_sz+=strlen(OLDDBEXT);
     break;
   case conff_db_cur:
     break;
@@ -43,22 +45,13 @@ static char* conff_db_path(const char *pkg, const char *path, conff_flag f){
     break;
   }
 
-  p_sz = cfgdb_root_sz + ext_sz + path_sz + 1;
-  p = m_malloc(p_sz);
+  /* add add the path's length, if appropriate */
+  if(path!=NULL) path_sz = strlen(path);
+
+  p = m_malloc(cfgdb_root_sz + path_sz);
 
   /* this is the path to the conffile db root for pkg */
-  snprintf(p, p_sz, "%s/%s%s", admindir, CONFFILESDIR, pkg);
-
-  /* append the extension if relevant */
-  if(ext_sz) {
-    strncat(p, ext, ext_sz);
-    /* replace '.' with '_' to avoid namespace conflicts.  a better 
-     * approach would be to have seperate dirs for new/old, or use a flat 
-     * hash-based approach with an index.  none of which would require 
-     * extensive changes from what's done here, though 
-     */
-    p[p_sz-(p_sz-cfgdb_root_sz)] = '_';
-  }
+  snprintf(p, cfgdb_root_sz, "%s/%s%s/%s", admindir, CONFFILESDIR, ext, pkg);
 
   /* append the pathname if relevant */
   if(path_sz) strncat(p, path, path_sz);
-- 
1.5.4.3


Reply to: