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

Please unblock man-db 2.5.2-4



Matt Domsch of Dell reported (actually against man, but the bug applies
to man-db as well; see
https://lists.ubuntu.com/archives/ubuntu-devel/2009-January/027197.html
and thread) that man-db fails to look up manual pages in the
/opt/<package>/share/man directory prescribed by FHS 2.3 when
/opt/<package>/bin is in $PATH, but only in the older /opt/<package>/man
directory.

I'm not sure if this is strictly RC, but it will make life difficult for
third-party packages on Debian systems if they care about working manual
pages, and I'd like to fix it. I've just uploaded man-db 2.5.2-4 to
unstable, and the complete diff (a trivial backport from upstream) is
attached to this mail. Please consider it for lenny.

Thanks,

-- 
Colin Watson                                       [cjwatson@debian.org]
diff -u man-db-2.5.2/debian/changelog man-db-2.5.2/debian/changelog
--- man-db-2.5.2/debian/changelog
+++ man-db-2.5.2/debian/changelog
@@ -1,3 +1,11 @@
+man-db (2.5.2-4) unstable; urgency=low
+
+  * Backport from trunk:
+    - Update manual page search order to permit FHS-compliant installation
+      of packages in /opt. Reported by Matt Domsch.
+
+ -- Colin Watson <cjwatson@debian.org>  Sat, 24 Jan 2009 12:29:08 +0000
+
 man-db (2.5.2-3) unstable; urgency=low
 
   * Backport from trunk:
only in patch2:
unchanged:
--- man-db-2.5.2.orig/manual/files.me
+++ man-db-2.5.2/manual/files.me
@@ -135,9 +135,11 @@
 However, if the element is not mentioned in the config file, a man directory
 relative to it will be sought.
 The subdirectories
-.i ../man
+.i ../man ,
+.i man ,
+.i ../share/man ,
 or
-.i man
+.i share/man
 relative to the path component are appended to the internal manpath if they
 exist.
 Finally, the internal manpath is stripped of duplicate paths before
only in patch2:
unchanged:
--- man-db-2.5.2.orig/src/manp.c
+++ man-db-2.5.2/src/manp.c
@@ -58,6 +58,7 @@
 #include <unistd.h>
 
 #include "xgetcwd.h"
+#include "xvasprintf.h"
 
 #include "gettext.h"
 #define _(String) gettext (String)
@@ -875,7 +876,8 @@
  * directories listed in the man_db.config file.  If so, and it is
  * not already in the manpath, add it.  If the directory is not listed
  * in the man_db.config file, see if there is a subdirectory `../man' or
- * `man'.  If so, and it is not already in the manpath, add it.
+ * `man', or, for FHS-compliance, `../share/man' or `share/man'.  If so,
+ * and it is not already in the manpath, add it.
  * Example:  user has $HOME/bin in his path and the directory
  * $HOME/man exists -- the directory $HOME/man will be added
  * to the manpath.
@@ -930,13 +932,15 @@
 
 		 	t = has_mandir (p);
 		 	if (t) {
-				debug ("but does have a ../man or man "
+				debug ("but does have a ../man, man, "
+				       "../share/man, or share/man "
 				       "subdirectory\n");
 	
 				add_dir_to_list (tmplist, t);
 				free (t);
 		 	} else
-				debug ("and doesn't have ../man or man "
+				debug ("and doesn't have ../man, man, "
+				       "../share/man, or share/man "
 				       "subdirectories\n");
 		}
 	}
@@ -1011,34 +1015,41 @@
 	}
 }
 
-/* path does not exist in config file: check to see if path/../man or 
-   path/man exist.  If so return it, if not return NULL. */
+/* path does not exist in config file: check to see if path/../man,
+   path/man, path/../share/man, or path/share/man exist.  If so return
+   it, if not return NULL. */
 static inline char *has_mandir (const char *path)
 {
-	char *newpath = NULL;
+	char *newpath;
 
 	/* don't assume anything about path, especially that it ends in 
 	   "bin" or even has a '/' in it! */
 	   
 	char *subdir = strrchr (path, '/');
 	if (subdir) {
-		const int prefix_len = subdir + 1 - path;
-		newpath = xmalloc (prefix_len + sizeof ("man") + 1);
-		strncpy (newpath, path, prefix_len);
-		strcpy (newpath + prefix_len, "man");
-
+		newpath = xasprintf ("%.*s/man", subdir - path, path);
 		if (is_directory (newpath) == 1)
 			return newpath;
-		else
-			*newpath = '\0';
+		free (newpath);
 	}
 
-	newpath = appendstr (newpath, path, "/man", NULL);
-
+	newpath = appendstr (NULL, path, "/man", NULL);
 	if (is_directory (newpath) == 1)
 		return newpath;
+	free (newpath);
+
+	if (subdir) {
+		newpath = xasprintf ("%.*s/share/man", subdir - path, path);
+		if (is_directory (newpath) == 1)
+			return newpath;
+		free (newpath);
+	}
 
+	newpath = appendstr (NULL, path, "/share/man", NULL);
+	if (is_directory (newpath) == 1)
+		return newpath;
 	free (newpath);
+
 	return NULL;
 }
 

Reply to: