瀏覽代碼

Move pkg_infodb_get_dir() and pkg_infodb_get_file() to infodb-format.c

These functions have never belonged in the filesdb module, but were put
there temporarily for convenience.
Guillem Jover 14 年之前
父節點
當前提交
58d868951d
共有 6 個文件被更改,包括 37 次插入45 次删除
  1. 0 41
      src/filesdb.c
  2. 0 4
      src/filesdb.h
  3. 1 0
      src/help.c
  4. 32 0
      src/infodb-format.c
  5. 3 0
      src/infodb.h
  6. 1 0
      src/trigproc.c

+ 0 - 41
src/filesdb.c

@@ -53,47 +53,6 @@
 #include "infodb.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;
-
-const char *
-pkg_infodb_get_dir(void)
-{
-  if (infodir == NULL)
-    infodir = dpkg_db_get_path(INFODIR);
-
-  return infodir;
-}
-
-const char *
-pkg_infodb_get_file(struct pkginfo *pkg, struct pkgbin *pkgbin,
-                    const char *filetype)
-{
-  static struct varbuf vb;
-
-  varbuf_reset(&vb);
-  varbuf_add_str(&vb, pkgadmindir());
-  varbuf_add_char(&vb, '/');
-  varbuf_add_str(&vb, pkg->set->name);
-  if (pkgbin->multiarch == multiarch_same &&
-      pkg_infodb_get_format() == pkg_infodb_format_multiarch)
-    varbuf_add_archqual(&vb, pkgbin->arch);
-  varbuf_add_char(&vb, '.');
-  varbuf_add_str(&vb, filetype);
-  varbuf_end_str(&vb);
-
-  return vb.buf;
-}
-
 /*** filepackages support for tracking packages owning a file. ***/
 
 #define PERFILEPACKAGESLUMP 10

+ 0 - 4
src/filesdb.h

@@ -137,10 +137,6 @@ struct diversion {
   struct diversion *next;
 };
 
-const char *pkg_infodb_get_dir(void);
-const char *pkg_infodb_get_file(struct pkginfo *pkg, struct pkgbin *pkgbin,
-                                const char *filetype);
-
 struct filepackages_iterator;
 struct filepackages_iterator *filepackages_iter_new(struct filenamenode *fnn);
 struct pkginfo *filepackages_iter_next(struct filepackages_iterator *iter);

+ 1 - 0
src/help.c

@@ -44,6 +44,7 @@
 #include <dpkg/triglib.h>
 
 #include "filesdb.h"
+#include "infodb.h"
 #include "main.h"
 
 const char *const statusstrings[]= {

+ 32 - 0
src/infodb-format.c

@@ -31,6 +31,7 @@
 #include <dpkg/i18n.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg-db.h>
+#include <dpkg/varbuf.h>
 
 #include "infodb.h"
 
@@ -109,3 +110,34 @@ pkg_infodb_is_upgrading(void)
 
 	return db_upgrading;
 }
+
+const char *
+pkg_infodb_get_dir(void)
+{
+	static char *infodir;
+
+	if (infodir == NULL)
+		infodir = dpkg_db_get_path(INFODIR);
+
+	return infodir;
+}
+
+const char *
+pkg_infodb_get_file(struct pkginfo *pkg, struct pkgbin *pkgbin,
+                    const char *filetype)
+{
+	static struct varbuf vb;
+
+	varbuf_reset(&vb);
+	varbuf_add_str(&vb, pkg_infodb_get_dir());
+	varbuf_add_char(&vb, '/');
+	varbuf_add_str(&vb, pkg->set->name);
+	if (pkgbin->multiarch == multiarch_same &&
+		pkg_infodb_get_format() == pkg_infodb_format_multiarch)
+	varbuf_add_archqual(&vb, pkgbin->arch);
+	varbuf_add_char(&vb, '.');
+	varbuf_add_str(&vb, filetype);
+	varbuf_end_str(&vb);
+
+	return vb.buf;
+}

+ 3 - 0
src/infodb.h

@@ -36,6 +36,9 @@ void pkg_infodb_set_format(enum pkg_infodb_format format);
 bool pkg_infodb_is_upgrading(void);
 void pkg_infodb_upgrade(void);
 
+const char *pkg_infodb_get_dir(void);
+const char *pkg_infodb_get_file(struct pkginfo *pkg, struct pkgbin *pkgbin,
+                                const char *filetype);
 bool pkg_infodb_has_file(struct pkginfo *pkg, struct pkgbin *pkgbin,
                          const char *name);
 

+ 1 - 0
src/trigproc.c

@@ -38,6 +38,7 @@
 
 #include "main.h"
 #include "filesdb.h"
+#include "infodb.h"
 
 /*
  * Trigger processing algorithms: