pkgsrc-Bugs archive

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

pkg/56910: sysutils/bsdinstall fails to build on Linux



>Number:         56910
>Category:       pkg
>Synopsis:       sysutils/bsdinstall fails to build on Linux
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 04 07:55:00 +0000 2022
>Originator:     Paolo Vincenzo Olivo
>Release:        pkgsrc-2022Q2
>Organization:
SDF Public Access UNIX system
>Environment:
Slackware Linux 15.0; kernel 5.15.38
>Description:
# PREMISE

A while ago I decided to set:

TOOLS_PLATFORM.install=         /usr/pkg/bin/bsdinstall

On my Linux workstation, to mimic my usual SunOS setup.
The syntax of GNU install(1) doesn't appear fully compatible with that of NetBSD's install and may break some packages on Linux at do-install target (e.g., by lacking `-l', which is used by some packages). This may or may not represent some food for thought in view of future revisions of bootstrap/README.Linux.

# ACTUAL PROBLEM

Attempting to compile sysutils/bsdinstall on Linux fails with:

```
--- bsdinstall.o ---
bsdinstall.c: In function 'main':
bsdinstall.c:265:32: warning: implicit declaration of function 'getmode'; did you mean 'setmode'? [-Wimplicit-function-declaration]
  265 |                         mode = getmode(set, 0);
      |                                ^~~~~~~
      |                                setmode
bsdinstall.c: In function 'makelink':
bsdinstall.c:611:29: warning: implicit declaration of function 'strlcat'; did you mean 'strncat'? [-Wimplicit-function-declaration]
  611 |                         if (strlcat(dst, "/", sizeof(dst)) > sizeof(dst))
      |                             ^~~~~~~
      |                             strncat
bsdinstall.c: In function 'copy':
bsdinstall.c:848:21: error: 'MAXBSIZE' undeclared (first use in this function)
  848 |         u_char  buf[MAXBSIZE];
      |                     ^~~~~~~~
bsdinstall.c:848:21: note: each undeclared identifier is reported only once for each function it appears in
bsdinstall.c: In function 'xbasename':
bsdinstall.c:1272:15: warning: implicit declaration of function 'strlcpy'; did you mean 'strncpy'? [-Wimplicit-function-declaration]
 1272 |         (void)strlcpy(tmp, path, sizeof(tmp));
      |               ^~~~~~~
      |               strncpy
bsdinstall.c: In function 'strip':
bsdinstall.c:1048:17: warning: ignoring return value of 'write' declared with attribute 'warn_unused_result' [-Wunused-result]
 1048 |                 write(STDERR_FILENO, progname, strlen(progname));
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bsdinstall.c:1049:17: warning: ignoring return value of 'write' declared with attribute 'warn_unused_result' [-Wunused-result]
 1049 |                 write(STDERR_FILENO, exec_failure, strlen(exec_failure));
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bsdinstall.c:1050:17: warning: ignoring return value of 'write' declared with attribute 'warn_unused_result' [-Wunused-result]
 1050 |                 write(STDERR_FILENO, stripprog, strlen(stripprog));
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bsdinstall.c:1051:17: warning: ignoring return value of 'write' declared with attribute 'warn_unused_result' [-Wunused-result]
 1051 |                 write(STDERR_FILENO, "\n", 1);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*** [bsdinstall.o] Error code 1
```
>How-To-Repeat:
Build sysutils/bsdinstall on a Linux distribution with a standard mk.conf. 
>Fix:
Using libnbcompat, strlcat() and srlcpy() can be provided by <nbcompat/string.h>  and getmode() with <nbcompat/unistd.h>.

libnbcompat can be patched in turn to define `MAXBSIZE' in <nbcompat/unistd.h>, before including the latter too in bsdinstall.c.


--- nbcompat/param.h.orig       2009-02-19 00:51:12.000000000 +0000
+++ nbcompat/param.h
@@ -52,4 +52,9 @@
 # define ARG_MAX sysconf(_SC_ARG_MAX)
 #endif
 
+/* At least Linux doesn't define max size for buffers in param.h */
+#ifndef MAXBSIZE
+#define MAXBSIZE (64 * 1024)
+#endif
+
 #endif /* !_NBCOMPAT_SYS_PARAM_H_ */



--- bsdinstall.c.orig   2022-07-04 06:43:27.741299340 +0000
+++ bsdinstall.c
@@ -59,7 +59,11 @@ __RCSID("NetBSD: xinstall.c,v 1.114 2009
 #endif /* not lint */
 
 #define __MKTEMP_OK__  /* All uses of mktemp have been checked */
+#if defined(HAVE_NBCOMPAT_H)
+#include <nbcompat/param.h>
+#else
 #include <sys/param.h>
+#endif
 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
@@ -73,8 +77,13 @@ __RCSID("NetBSD: xinstall.c,v 1.114 2009
 #include <fcntl.h>
 #include <libgen.h>
 #include <stdio.h>
+#if defined(HAVE_NBCOMPAT_H)
+#include <nbcompat/string.h>
+#include <nbcompat/unistd.h>
+#else
 #include <string.h>
 #include <unistd.h>
+#endif 
 #if defined(HAVE_NBCOMPAT_H)
 #include <nbcompat/grp.h>
 #include <nbcompat/paths.h>




Home | Main Index | Thread Index | Old Index