Просмотр исходного кода

Move pkgadmindir() and pkgadminfile() to the filesdb module

These functions are not really part of the modstatdb module, and by
moving them out they get detangled and will make it possible to extend
them w/o pulling additional code into binaries not using the functions.
Guillem Jover лет назад: 15
Родитель
Сommit
557765dbed
6 измененных файлов с 44 добавлено и 21 удалено
  1. 0 16
      lib/dpkg/dbmodify.c
  2. 0 3
      lib/dpkg/dpkg-db.h
  3. 0 2
      lib/dpkg/libdpkg.Versions
  4. 40 0
      src/filesdb.c
  5. 3 0
      src/filesdb.h
  6. 1 0
      src/infodb.c

+ 0 - 16
lib/dpkg/dbmodify.c

@@ -425,19 +425,3 @@ modstatdb_note_ifwrite(struct pkginfo *pkg)
     modstatdb_note(pkg);
 }
 
-const char *
-pkgadmindir(void)
-{
-  return infodir;
-}
-
-const char *pkgadminfile(struct pkginfo *pkg, const char *whichfile) {
-  static struct varbuf vb;
-  varbuf_reset(&vb);
-  varbuf_add_str(&vb, infodir);
-  varbuf_add_str(&vb, pkg->name);
-  varbuf_add_char(&vb, '.');
-  varbuf_add_str(&vb, whichfile);
-  varbuf_end_str(&vb);
-  return vb.buf;
-}

+ 0 - 3
lib/dpkg/dpkg-db.h

@@ -240,9 +240,6 @@ void modstatdb_note_ifwrite(struct pkginfo *pkg);
 void modstatdb_checkpoint(void);
 void modstatdb_shutdown(void);
 
-const char *pkgadmindir(void);
-const char *pkgadminfile(struct pkginfo *pkg, const char *whichfile);
-
 /*** from database.c ***/
 
 void pkg_blank(struct pkginfo *pp);

+ 0 - 2
lib/dpkg/libdpkg.Versions

@@ -217,8 +217,6 @@ LIBDPKG_PRIVATE {
 	varbufdependency;
 	varbufrecord;
 	writerecord;
-	pkgadmindir;
-	pkgadminfile;
 	parsedb;
 	writedb;
 

+ 40 - 0
src/filesdb.c

@@ -51,6 +51,44 @@
 #include "filesdb.h"
 #include "main.h"
 
+/*** Package control information database directory routines. ***/
+
+/*
+ * XXX: Strictly speaking these functions do not exactly belong here, and
+ * they should be eventually moved back to a unified on-disk database
+ * handling module in libdpkg. For now this is good enough, as it avoids
+ * pulling unneeded code into the resulting binaries, because all its
+ * users require filesdb anyway.
+ */
+
+static char *infodir;
+
+static void
+pkgadmindir_init(void)
+{
+  infodir = dpkg_db_get_path(INFODIR);
+}
+
+const char *
+pkgadmindir(void)
+{
+  return infodir;
+}
+
+const char *
+pkgadminfile(struct pkginfo *pkg, const char *filetype)
+{
+  static struct varbuf vb;
+
+  varbuf_reset(&vb);
+  varbuf_add_str(&vb, infodir);
+  varbuf_add_str(&vb, pkg->name);
+  varbuf_add_char(&vb, '.');
+  varbuf_add_str(&vb, filetype);
+  varbuf_end_str(&vb);
+
+  return vb.buf;
+}
 
 /*** filepackages support for tracking packages owning a file. ***/
 
@@ -584,6 +622,8 @@ void filesdbinit(void) {
   struct filenamenode *fnn;
   int i;
 
+  pkgadmindir_init();
+
   for (i=0; i<BINS; i++)
     for (fnn= bins[i]; fnn; fnn= fnn->next) {
       fnn->flags= 0;

+ 3 - 0
src/filesdb.h

@@ -132,6 +132,9 @@ struct diversion {
   struct diversion *next;
 };
 
+const char *pkgadmindir(void);
+const char *pkgadminfile(struct pkginfo *pkg, const char *filetype);
+
 struct filepackages_iterator;
 struct filepackages_iterator *filepackages_iter_new(struct filenamenode *fnn);
 struct pkginfo *filepackages_iter_next(struct filepackages_iterator *i);

+ 1 - 0
src/infodb.c

@@ -34,6 +34,7 @@
 #include <dpkg/dpkg-db.h>
 #include <dpkg/debug.h>
 
+#include "filesdb.h"
 #include "infodb.h"
 
 bool