netbsd: Adapt to BSD-common infra changes for FreeBSD

See https://github.com/NixOS/nixpkgs/pull/82131 for the rest of the
changes for FreeBSD. This is PRed separately because it is a macOS
moderate rebuild so we target staging.

The main change is that we CD to the path we're building *after*
applying patches, so we can patch other parts of the tree (from
`extraPaths`) as needed.

Another change is that `netbsd.install` no longer depends on `fts`,
which it evidently no longer needs.
This commit is contained in:
John Ericson 2022-10-06 00:51:05 -04:00
parent 3413bc7d80
commit dcf7a5ec3d
9 changed files with 41 additions and 33 deletions

View File

@ -1,6 +1,6 @@
diff -u -r1.35.2.1 nbtool_config.h.in
--- a/nbtool_config.h.in 22 Apr 2015 07:18:58 -0000 1.35.2.1
+++ b/nbtool_config.h.in 31 May 2018 01:46:53 -0000
--- a/tools/compat/nbtool_config.h.in 22 Apr 2015 07:18:58 -0000 1.35.2.1
+++ b/tools/compat/nbtool_config.h.in 31 May 2018 01:46:53 -0000
@@ -680,5 +680,14 @@
/* Define if you have u_int8_t, but not uint8_t. */
#undef uint8_t

View File

@ -6,8 +6,8 @@ Date: Wed Sep 1 15:38:56 2021 +0000
diff --git a/Makefile b/Makefile
index b5adb8a5f2e9..1a914ef16739 100644
--- a/Makefile
+++ b/Makefile
--- a/tools/compat/Makefile
+++ b/tools/compat/Makefile
@@ -76,11 +76,6 @@ _CURDIR:= ${.CURDIR}
SRCS:= ${SRCS:M*.c}

View File

@ -8,8 +8,8 @@ Date: Wed Sep 1 15:38:56 2021 +0000
diff --git a/Makefile b/Makefile
index 4bcf227f0e75..9ed1d6eea6ff 100644
--- a/Makefile
+++ b/Makefile
--- a/tools/compat/Makefile
+++ b/tools/compat/Makefile
@@ -1,6 +1,6 @@
# $NetBSD: Makefile,v 1.87 2019/05/08 02:25:50 thorpej Exp $

View File

@ -3,7 +3,7 @@
, buildPackages, splicePackages, newScope
, bsdSetupHook, makeSetupHook, fetchcvs, groff, mandoc, byacc, flex
, zlib
, writeText, symlinkJoin
, writeScript, writeText, runtimeShell, symlinkJoin
}:
let
@ -121,12 +121,12 @@ in lib.makeScopeWithSplicing
installPhase = "includesPhase";
dontBuild = true;
} // attrs // {
# Files that use NetBSD-specific macros need to have nbtool_config.h
# included ahead of them on non-NetBSD platforms.
postPatch = lib.optionalString (!stdenv'.hostPlatform.isNetBSD) ''
# Files that use NetBSD-specific macros need to have nbtool_config.h
# included ahead of them on non-NetBSD platforms.
set +e
grep -Zlr "^__RCSID
^__BEGIN_DECLS" | xargs -0r grep -FLZ nbtool_config.h |
^__BEGIN_DECLS" $BSD_PATH | xargs -0r grep -FLZ nbtool_config.h |
xargs -0tr sed -i '0,/^#/s//#include <nbtool_config.h>\n\0/'
set -e
'' + attrs.postPatch or "";
@ -146,7 +146,7 @@ in lib.makeScopeWithSplicing
skipIncludesPhase = true;
postPatch = ''
patchShebangs configure
patchShebangs $BSD_PATH/configure
${self.make.postPatch}
'';
@ -281,11 +281,12 @@ in lib.makeScopeWithSplicing
# HACK: to ensure parent directories exist. This emulates GNU
# installs -D option. No alternative seems to exist in BSD install.
install = let binstall = writeText "binstall" ''
#!${stdenv.shell}
for last in $@; do true; done
install = let binstall = writeScript "binstall" ''
#!${runtimeShell}
set -eu
for last in "$@"; do true; done
mkdir -p $(dirname $last)
xinstall "$@"
@out@/bin/xinstall "$@"
''; in mkDerivation {
path = "usr.bin/xinstall";
version = "9.2";
@ -297,13 +298,14 @@ in lib.makeScopeWithSplicing
mandoc groff rsync
];
skipIncludesPhase = true;
buildInputs = with self; compatIfNeeded ++ [ fts ];
buildInputs = with self; compatIfNeeded;
installPhase = ''
runHook preInstall
install -D install.1 $out/share/man/man1/install.1
install -D xinstall $out/bin/xinstall
install -D -m 0550 ${binstall} $out/bin/binstall
substituteInPlace $out/bin/binstall --subst-var out
ln -s $out/bin/binstall $out/bin/install
runHook postInstall
@ -391,6 +393,7 @@ in lib.makeScopeWithSplicing
install mandoc groff rsync
];
};
##
## END BOOTSTRAPPING
##
@ -705,10 +708,10 @@ in lib.makeScopeWithSplicing
SHLIBINSTALLDIR = "$(out)/lib";
makeFlags = defaultMakeFlags ++ [ "LIBDO.terminfo=${self.libterminfo}/lib" ];
postPatch = ''
sed -i '1i #undef bool_t' el.h
substituteInPlace config.h \
sed -i '1i #undef bool_t' $BSD_PATH/el.h
substituteInPlace $BSD_PATH/config.h \
--replace "#define HAVE_STRUCT_DIRENT_D_NAMLEN 1" ""
substituteInPlace readline/Makefile --replace /usr/include "$out/include"
substituteInPlace $BSD_PATH/readline/Makefile --replace /usr/include "$out/include"
'';
NIX_CFLAGS_COMPILE = [
"-D__noinline="
@ -728,8 +731,8 @@ in lib.makeScopeWithSplicing
buildInputs = with self; compatIfNeeded;
SHLIBINSTALLDIR = "$(out)/lib";
postPatch = ''
substituteInPlace term.c --replace /usr/share $out/share
substituteInPlace setupterm.c \
substituteInPlace $BSD_PATH/term.c --replace /usr/share $out/share
substituteInPlace $BSD_PATH/setupterm.c \
--replace '#include <curses.h>' 'void use_env(bool);'
'';
postBuild = ''
@ -757,10 +760,10 @@ in lib.makeScopeWithSplicing
MKDOC = "no"; # missing vfontedpr
makeFlags = defaultMakeFlags ++ [ "LIBDO.terminfo=${self.libterminfo}/lib" ];
postPatch = lib.optionalString (!stdenv.isDarwin) ''
substituteInPlace printw.c \
substituteInPlace $BSD_PATH/printw.c \
--replace "funopen(win, NULL, __winwrite, NULL, NULL)" NULL \
--replace "__strong_alias(vwprintw, vw_printw)" 'extern int vwprintw(WINDOW*, const char*, va_list) __attribute__ ((alias ("vw_printw")));'
substituteInPlace scanw.c \
substituteInPlace $BSD_PATH/scanw.c \
--replace "__strong_alias(vwscanw, vw_scanw)" 'extern int vwscanw(WINDOW*, const char*, va_list) __attribute__ ((alias ("vw_scanw")));'
'';
};
@ -985,7 +988,7 @@ in lib.makeScopeWithSplicing
# man0 generates a man.pdf using ps2pdf, but doesn't install it later,
# so we can avoid the dependency on ghostscript
postPatch = ''
substituteInPlace man0/Makefile --replace "ps2pdf" "echo noop "
substituteInPlace $BSD_PATH/man0/Makefile --replace "ps2pdf" "echo noop "
'';
makeFlags = defaultMakeFlags ++ [
"FILESDIR=$(out)/share"

View File

@ -1,8 +1,8 @@
Author: Matthew Bauer
Description: Remove unavailable getent databases
Version: 7.1.2
--- a/getent.c 2018-04-16 13:33:49.000000000 -0500
+++ b/getent.c 2018-04-16 13:29:30.000000000 -0500
--- a/usr.bin/getent/getent.c 2018-04-16 13:33:49.000000000 -0500
+++ b/usr.bin/getent/getent.c 2018-04-16 13:29:30.000000000 -0500
@@ -42,7 +42,6 @@
#include <grp.h>
#include <limits.h>

View File

@ -1,5 +1,5 @@
--- a/locale.c 2018-06-11 14:39:06.449762000 -0400
+++ b/locale.c 2018-06-11 14:42:28.461122899 -0400
--- a/usr.bin/locale/locale.c 2018-06-11 14:39:06.449762000 -0400
+++ b/usr.bin/locale/locale.c 2018-06-11 14:42:28.461122899 -0400
@@ -56,14 +56,8 @@
#include <stringlist.h>
#include <unistd.h>

View File

@ -4,8 +4,8 @@ rcsdiff: /ftp/cvs/cvsroot/src/sys/arch/i386/stand/efiboot/Makefile.efiboot,v: wa
retrieving revision 1.16
retrieving revision 1.17
diff -u -p -r1.16 -r1.17
--- sys/arch/i386/stand/efiboot/Makefile.efiboot 2019/09/13 02:19:45 1.16
+++ sys/arch/i386/stand/efiboot/Makefile.efiboot 2020/04/04 15:30:46 1.17
--- a/sys/arch/i386/stand/efiboot/Makefile.efiboot 2019/09/13 02:19:45 1.16
+++ b/sys/arch/i386/stand/efiboot/Makefile.efiboot 2020/04/04 15:30:46 1.17
@@ -41,6 +41,7 @@ BINMODE=444
.PATH: ${.CURDIR}/../../libsa

View File

@ -1,7 +1,7 @@
diff --git a/Makefile b/Makefile
index 3f1e18dc659d..163362b82f94 100644
--- a/Makefile
+++ b/Makefile
--- a/sys/Makefile
+++ b/sys/Makefile
@@ -2,6 +2,8 @@
.include <bsd.own.mk>

View File

@ -48,6 +48,7 @@ addMakeFlags() {
makeFlags="BINDIR=${!outputBin}/bin $makeFlags"
makeFlags="LIBDIR=${!outputLib}/lib $makeFlags"
makeFlags="SHLIBDIR=${!outputLib}/lib $makeFlags"
makeFlags="SHAREDIR=${!outputLib}/share $makeFlags"
makeFlags="MANDIR=${!outputMan}/share/man $makeFlags"
makeFlags="INFODIR=${!outputInfo}/share/info $makeFlags"
makeFlags="DOCDIR=${!outputDoc}/share/doc $makeFlags"
@ -61,10 +62,13 @@ setBSDSourceDir() {
sourceRoot=$PWD/$sourceRoot
export BSDSRCDIR=$sourceRoot
export _SRC_TOP_=$BSDSRCDIR
cd $sourceRoot
}
cdBSDPath() {
if [ -d "$BSD_PATH" ]
then sourceRoot=$sourceRoot/$BSD_PATH
cd $BSD_PATH
fi
}
@ -104,6 +108,7 @@ moveUsrDir() {
}
postUnpackHooks+=(setBSDSourceDir)
postPatchHooks+=(cdBSDPath)
preConfigureHooks+=(addMakeFlags)
preInstallHooks+=(includesPhase)
fixupOutputHooks+=(moveUsrDir)