ソースを参照

dpkg-deb: Check and warn on duplicate conffiles

Closes: #131633
Guillem Jover 17 年 前
コミット
6257d864d6
共有2 個のファイルを変更した28 個の追加0 個の削除を含む
  1. 1 0
      debian/changelog
  2. 27 0
      dpkg-deb/build.c

+ 1 - 0
debian/changelog

@@ -5,6 +5,7 @@ dpkg (1.15.5) UNRELEASED; urgency=low
   * Update list of binaries dpkg checks on the PATH.
     - Remove install-info, now a wrapper that will disappear soonish.
     - Add programs used by dpkg itself: sh, rm, find, tar and dpkg-deb.
+  * Check and warn on duplicate conffiles in dpkg-deb. Closes: #131633
 
   [ Raphaël Hertzog ]
   * Add versioned dependency on base-files (>= 5.0.0) to dpkg-dev to ensure

+ 27 - 0
dpkg-deb/build.c

@@ -115,6 +115,18 @@ file_info_new(const char *filename)
   return fi;
 }
 
+static struct file_info *
+file_info_find_name(struct file_info *list, const char *filename)
+{
+  struct file_info *node;
+
+  for (node = list; node; node = node->next)
+    if (strcmp(node->fn, filename) == 0)
+      return node;
+
+  return NULL;
+}
+
 /*
  * Read the next filename from a filedescriptor and create a file_info struct
  * for it. If there is nothing to read return NULL.
@@ -341,6 +353,9 @@ void do_build(const char *const *argv) {
     strcpy(controlfile, directory);
     strcat(controlfile, "/" BUILDCONTROLDIR "/" CONFFILESFILE);
     if ((cf= fopen(controlfile,"r"))) {
+      struct file_info *conffiles_head = NULL;
+      struct file_info *conffiles_tail = NULL;
+
       while (fgets(conffilename,MAXCONFFILENAME+1,cf)) {
         n= strlen(conffilename);
         if (!n) ohshite(_("empty string from fgets reading conffiles"));
@@ -367,7 +382,19 @@ void do_build(const char *const *argv) {
           warning(_("conffile '%s' is not a plain file"), conffilename);
           warns++;
         }
+
+        if (file_info_find_name(conffiles_head, conffilename))
+          warning(_("conffile name '%s' is duplicated"), conffilename);
+        else {
+          struct file_info *conffile;
+
+          conffile = file_info_new(conffilename);
+          add_to_filist(&conffiles_head, &conffiles_tail, conffile);
+        }
       }
+
+      free_filist(conffiles_head);
+
       if (ferror(cf)) ohshite(_("error reading conffiles file"));
       fclose(cf);
     } else if (errno != ENOENT) {