This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=5a678bf493de3630cb2dd58e8d124a86c74568ab

commit 5a678bf493de3630cb2dd58e8d124a86c74568ab
Author: Guillem Jover <[email protected]>
AuthorDate: Tue Aug 14 06:08:56 2018 +0200

    libdpkg: Factor out package files handling into its own module
    
    We need these functions from the list and mtree implementations. Move
    them out so that they can be shared. In addition this is pure in-core
    handling so it makes sense to split out from the db-fsys modules.
---
 debian/changelog                     |  1 +
 lib/dpkg/Makefile.am                 |  2 +
 lib/dpkg/db-fsys-files.c             | 67 +------------------------
 lib/dpkg/pkg-files.c                 | 95 ++++++++++++++++++++++++++++++++++++
 lib/dpkg/{pkg-list.h => pkg-files.h} | 25 +++++-----
 po/POTFILES.in                       |  1 +
 6 files changed, 112 insertions(+), 79 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 9ed4a732c..4fa07bb48 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -186,6 +186,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium
     - libdpkg: Rename pkg-db module to pkg-hash.
     - libdpkg: Simplify pkg_files_blank() by using a pointer to pointer to
       track the previous entry.
+    - libdpkg: Factor out package files handling into its own module.
   * Build system:
     - Set distribution tarball format to ustar, instead of default v7 format.
     - Mark PO4A and POD2MAN as precious variables.
diff --git a/lib/dpkg/Makefile.am b/lib/dpkg/Makefile.am
index fae6e8ca7..7ecf6639f 100644
--- a/lib/dpkg/Makefile.am
+++ b/lib/dpkg/Makefile.am
@@ -86,6 +86,7 @@ libdpkg_la_SOURCES = \
        path-remove.c \
        pkg.c \
        pkg-array.c \
+       pkg-files.c \
        pkg-format.c \
        pkg-hash.c \
        pkg-list.c \
@@ -141,6 +142,7 @@ pkginclude_HEADERS = \
        path.h \
        pkg.h \
        pkg-array.h \
+       pkg-files.h \
        pkg-format.h \
        pkg-list.h \
        pkg-queue.h \
diff --git a/lib/dpkg/db-fsys-files.c b/lib/dpkg/db-fsys-files.c
index 085cb143d..bfc2ccbe6 100644
--- a/lib/dpkg/db-fsys-files.c
+++ b/lib/dpkg/db-fsys-files.c
@@ -48,7 +48,7 @@
 #include <dpkg/dir.h>
 #include <dpkg/fdio.h>
 #include <dpkg/pkg-array.h>
-#include <dpkg/pkg-list.h>
+#include <dpkg/pkg-files.h>
 #include <dpkg/progress.h>
 #include <dpkg/db-ctrl.h>
 #include <dpkg/db-fsys.h>
@@ -71,71 +71,6 @@ enum pkg_filesdb_load_status {
 static enum pkg_filesdb_load_status saidread = PKG_FILESDB_LOAD_NONE;
 
 /**
- * Erase the files saved in pkg.
- */
-static void
-pkg_files_blank(struct pkginfo *pkg)
-{
-  struct fileinlist *current;
-
-  for (current = pkg->files;
-       current;
-       current= current->next) {
-    struct pkg_list *pkg_node, **pkg_prev = &current->namenode->packages;
-
-    /* For each file that used to be in the package,
-     * go through looking for this package's entry in the list
-     * of packages containing this file, and blank it out. */
-    for (pkg_node = current->namenode->packages;
-         pkg_node;
-         pkg_node = pkg_node->next) {
-      if (pkg_node->pkg == pkg) {
-        *pkg_prev = pkg_node->next;
-
-        /* The actual filelist links were allocated using nfmalloc, so
-         * we shouldn't free them. */
-        break;
-      }
-
-      pkg_prev = &pkg_node->next;
-    }
-  }
-  pkg->files = NULL;
-}
-
-static struct fileinlist **
-pkg_files_add_file(struct pkginfo *pkg, struct filenamenode *namenode,
-                   struct fileinlist **file_tail)
-{
-  struct fileinlist *newent;
-  struct pkg_list *pkg_node;
-
-  if (file_tail == NULL)
-    file_tail = &pkg->files;
-
-  /* Make sure we're at the end. */
-  while ((*file_tail) != NULL) {
-    file_tail = &((*file_tail)->next);
-  }
-
-  /* Create a new node. */
-  newent = nfmalloc(sizeof(struct fileinlist));
-  newent->namenode = namenode;
-  newent->next = NULL;
-  *file_tail = newent;
-  file_tail = &newent->next;
-
-  /* Add pkg to newent's package list. */
-  pkg_node = nfmalloc(sizeof(*pkg_node));
-  pkg_node->pkg = pkg;
-  pkg_node->next = newent->namenode->packages;
-  newent->namenode->packages = pkg_node;
-
-  /* Return the position for the next guy. */
-  return file_tail;
-}
-
-/**
  * Load the list of files in this package into memory, or update the
  * list if it is there but stale.
  */
diff --git a/lib/dpkg/pkg-files.c b/lib/dpkg/pkg-files.c
new file mode 100644
index 000000000..e60134a32
--- /dev/null
+++ b/lib/dpkg/pkg-files.c
@@ -0,0 +1,95 @@
+/*
+ * libdpkg - Debian packaging suite library routines
+ * pkg-files.c - handle list of filesystem files per package
+ *
+ * Copyright © 1995 Ian Jackson <[email protected]>
+ * Copyright © 2000,2001 Wichert Akkerman <[email protected]>
+ * Copyright © 2008-2014 Guillem Jover <[email protected]>
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <compat.h>
+
+#include <dpkg/i18n.h>
+#include <dpkg/dpkg.h>
+#include <dpkg/dpkg-db.h>
+#include <dpkg/pkg-list.h>
+#include <dpkg/pkg-files.h>
+
+/**
+ * Erase the files saved in pkg.
+ */
+void
+pkg_files_blank(struct pkginfo *pkg)
+{
+       struct fileinlist *current;
+
+       for (current = pkg->files;
+            current;
+            current = current->next) {
+               struct pkg_list **pkg_prev = &current->namenode->packages;
+               struct pkg_list *pkg_node;
+
+               /* For each file that used to be in the package, go through
+                * looking for this package's entry in the list of packages
+                * containing this file, and blank it out. */
+               for (pkg_node = current->namenode->packages;
+                    pkg_node;
+                    pkg_node = pkg_node->next) {
+                       if (pkg_node->pkg == pkg) {
+                               *pkg_prev = pkg_node->next;
+
+                               /* The actual filelist links were allocated
+                                * w/ nfmalloc, so we should not free them. */
+                               break;
+                       }
+
+                       pkg_prev = &pkg_node->next;
+               }
+       }
+       pkg->files = NULL;
+}
+
+struct fileinlist **
+pkg_files_add_file(struct pkginfo *pkg, struct filenamenode *namenode,
+                   struct fileinlist **file_tail)
+{
+       struct fileinlist *newent;
+       struct pkg_list *pkg_node;
+
+       if (file_tail == NULL)
+               file_tail = &pkg->files;
+
+       /* Make sure we're at the end. */
+       while ((*file_tail) != NULL)
+               file_tail = &((*file_tail)->next);
+
+       /* Create a new node. */
+       newent = nfmalloc(sizeof(struct fileinlist));
+       newent->namenode = namenode;
+       newent->next = NULL;
+       *file_tail = newent;
+       file_tail = &newent->next;
+
+       /* Add pkg to newent's package list. */
+       pkg_node = nfmalloc(sizeof(*pkg_node));
+       pkg_node->pkg = pkg;
+       pkg_node->next = newent->namenode->packages;
+       newent->namenode->packages = pkg_node;
+
+       /* Return the position for the next guy. */
+       return file_tail;
+}
diff --git a/lib/dpkg/pkg-list.h b/lib/dpkg/pkg-files.h
similarity index 62%
copy from lib/dpkg/pkg-list.h
copy to lib/dpkg/pkg-files.h
index 6a34755cc..73770b7dc 100644
--- a/lib/dpkg/pkg-list.h
+++ b/lib/dpkg/pkg-files.h
@@ -1,8 +1,8 @@
 /*
  * libdpkg - Debian packaging suite library routines
- * pkg-list.h - primitives for pkg linked list handling
+ * pkg-files.h - primitives for pkg files handling
  *
- * Copyright © 2009 Guillem Jover <[email protected]>
+ * Copyright © 2018 Guillem Jover <[email protected]>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -18,30 +18,29 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#ifndef LIBDPKG_PKG_LIST_H
-#define LIBDPKG_PKG_LIST_H
+#ifndef LIBDPKG_PKG_FILES_H
+#define LIBDPKG_PKG_FILES_H
 
 #include <dpkg/dpkg-db.h>
+#include <dpkg/fsys.h>
 
 DPKG_BEGIN_DECLS
 
 /**
- * @defgroup pkg-list Package linked lists
+ * @defgroup pkg-files Package files handling
  * @ingroup dpkg-public
  * @{
  */
 
-struct pkg_list {
-       struct pkg_list *next;
-       struct pkginfo *pkg;
-};
+void
+pkg_files_blank(struct pkginfo *pkg);
 
-struct pkg_list *pkg_list_new(struct pkginfo *pkg, struct pkg_list *next);
-void pkg_list_free(struct pkg_list *head);
-void pkg_list_prepend(struct pkg_list **head, struct pkginfo *pkg);
+struct fileinlist **
+pkg_files_add_file(struct pkginfo *pkg, struct filenamenode *namenode,
+                   struct fileinlist **file_tail);
 
 /** @} */
 
 DPKG_END_DECLS
 
-#endif /* LIBDPKG_PKG_LIST_H */
+#endif /* LIBDPKG_PKG_FILES_H */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 78bb36950..ce3e29c56 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -43,6 +43,7 @@ lib/dpkg/parsehelp.c
 lib/dpkg/path-remove.c
 lib/dpkg/path.c
 lib/dpkg/pkg-array.c
+lib/dpkg/pkg-files.c
 lib/dpkg/pkg-format.c
 lib/dpkg/pkg-hash.c
 lib/dpkg/pkg-list.c

-- 
Dpkg.Org's dpkg

Reply via email to