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

libcompat: Only test the strerror() if sys_errlist and sys_nerr are present

These are deprecated symbols, and some systems which do have strerror()
do not have these variables, most notably GNU/Hurd. So do not try to test
the current implementation there as it will fail.

Closes: #758199
Guillem Jover лет назад: 12
Родитель
Сommit
5fb63f2db0
5 измененных файлов с 26 добавлено и 2 удалено
  1. 1 0
      configure.ac
  2. 2 0
      debian/changelog
  3. 4 1
      lib/compat/Makefile.am
  4. 3 1
      lib/compat/strerror.c
  5. 16 0
      m4/dpkg-types.m4

+ 1 - 0
configure.ac

@@ -90,6 +90,7 @@ DPKG_TYPE_PTRDIFF_T
 AC_CHECK_SIZEOF([unsigned int])
 AC_CHECK_SIZEOF([unsigned int])
 AC_CHECK_SIZEOF([unsigned long])
 AC_CHECK_SIZEOF([unsigned long])
 DPKG_DECL_SYS_SIGLIST
 DPKG_DECL_SYS_SIGLIST
+DPKG_DECL_SYS_ERRLIST
 
 
 # Checks for library functions.
 # Checks for library functions.
 DPKG_FUNC_VA_COPY
 DPKG_FUNC_VA_COPY

+ 2 - 0
debian/changelog

@@ -17,6 +17,8 @@ dpkg (1.17.13) UNRELEASED; urgency=low
   * Fix dpkg-source not detecting modified files during --commit or -b.
   * Fix dpkg-source not detecting modified files during --commit or -b.
     Regression introduced in dpkg 1.17.11. Closes: #758426
     Regression introduced in dpkg 1.17.11. Closes: #758426
     Reported by Neil Williams <codehelp@debian.org>.
     Reported by Neil Williams <codehelp@debian.org>.
+  * Only test the strerror() compatible code if sys_errlist and sys_nerr
+    are present. This fixes a build failure on GNU/Hurd. Closes: #758199
 
 
   [ Updated programs translations ]
   [ Updated programs translations ]
   * Czech (Miroslav Kure).
   * Czech (Miroslav Kure).

+ 4 - 1
lib/compat/Makefile.am

@@ -12,7 +12,6 @@ libcompat_test_la_SOURCES = \
 	compat.h \
 	compat.h \
 	strnlen.c \
 	strnlen.c \
 	strndup.c \
 	strndup.c \
-	strerror.c \
 	strsignal.c \
 	strsignal.c \
 	snprintf.c vsnprintf.c \
 	snprintf.c vsnprintf.c \
 	asprintf.c vasprintf.c \
 	asprintf.c vasprintf.c \
@@ -20,6 +19,10 @@ libcompat_test_la_SOURCES = \
 	scandir.c \
 	scandir.c \
 	unsetenv.c
 	unsetenv.c
 
 
+if HAVE_SYS_ERRLIST
+libcompat_test_la_SOURCES += strerror.c
+endif
+
 if WITH_SELINUX
 if WITH_SELINUX
 libcompat_test_la_SOURCES += selinux.c
 libcompat_test_la_SOURCES += selinux.c
 endif
 endif

+ 3 - 1
lib/compat/strerror.c

@@ -26,8 +26,10 @@
 
 
 #define _(str) gettext(str)
 #define _(str) gettext(str)
 
 
-#ifndef HAVE_STRERROR
+#if !HAVE_DECL_SYS_ERRLIST
 extern const char *const sys_errlist[];
 extern const char *const sys_errlist[];
+#endif
+#if !HAVE_DECL_SYS_NERR
 extern const int sys_nerr;
 extern const int sys_nerr;
 #endif
 #endif
 
 

+ 16 - 0
m4/dpkg-types.m4

@@ -45,6 +45,22 @@ AC_CHECK_DECLS([sys_siglist],,,
 ])dnl
 ])dnl
 ])# DPKG_DECL_SYS_SIGLIST
 ])# DPKG_DECL_SYS_SIGLIST
 
 
+# DPKG_DECL_SYS_ERRLIST
+# ---------------------
+# Check for the sys_errlist and sys_nerr variables in either errno.h or
+# stdio.h
+AC_DEFUN([DPKG_DECL_SYS_ERRLIST],
+[
+  AC_CHECK_DECLS([sys_errlist, sys_nerr],,, [[
+#include <errno.h>
+/* glibc declares sys_errlist in stdio.h.  */
+#include <stdio.h>
+]])
+AM_CONDITIONAL([HAVE_SYS_ERRLIST],
+  [test "x$ac_cv_have_decl_sys_errlist" = "xyes" && \
+   test "x$ac_cv_have_decl_sys_nerr" = "xyes"])
+])# DPKG_DECL_SYS_SIGLIST
+
 # DPKG_CHECK_DECL([DECL], [HEADER])
 # DPKG_CHECK_DECL([DECL], [HEADER])
 # -----------------
 # -----------------
 # Define HAVE_DECL to 1 if declared in HEADER
 # Define HAVE_DECL to 1 if declared in HEADER