NetBSD Problem Report #56910
From www@netbsd.org Mon Jul 4 07:53:20 2022
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 7D39C1A921F
for <gnats-bugs@gnats.NetBSD.org>; Mon, 4 Jul 2022 07:53:20 +0000 (UTC)
Message-Id: <20220704075318.B81811A9239@mollari.NetBSD.org>
Date: Mon, 4 Jul 2022 07:53:18 +0000 (UTC)
From: vms@retrobsd.ddns.net
Reply-To: vms@retrobsd.ddns.net
To: gnats-bugs@NetBSD.org
Subject: sysutils/bsdinstall fails to build on Linux
X-Send-Pr-Version: www-1.0
>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
>Last-Modified: Sun Jul 10 00:35:02 +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>
>Audit-Trail:
From: David Holland <dholland-pbugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: pkg/56910: sysutils/bsdinstall fails to build on Linux
Date: Sun, 10 Jul 2022 00:34:07 +0000
Not sent to gnats.
------
From: Paolo Vincenzo Olivo <vms@retrobsd.ddns.net>
To: pkg-manager@netbsd.org, gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org
Subject: Re: pkg/56910: sysutils/bsdinstall fails to build on Linux
Date: Mon, 4 Jul 2022 11:33:03 +0200
> libnbcompat can be patched in turn to define `MAXBSIZE' in
> <nbcompat/unistd.h>, before including the latter too in bsdinstall.c
's/unistd.h/param.h/'
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.