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.

+41 -33
+2 -2
pkgs/os-specific/bsd/netbsd/compat-cxx-safe-header.patch
··· 1 diff -u -r1.35.2.1 nbtool_config.h.in 2 - --- a/nbtool_config.h.in 22 Apr 2015 07:18:58 -0000 1.35.2.1 3 - +++ b/nbtool_config.h.in 31 May 2018 01:46:53 -0000 4 @@ -680,5 +680,14 @@ 5 /* Define if you have u_int8_t, but not uint8_t. */ 6 #undef uint8_t
··· 1 diff -u -r1.35.2.1 nbtool_config.h.in 2 + --- a/tools/compat/nbtool_config.h.in 22 Apr 2015 07:18:58 -0000 1.35.2.1 3 + +++ b/tools/compat/nbtool_config.h.in 31 May 2018 01:46:53 -0000 4 @@ -680,5 +680,14 @@ 5 /* Define if you have u_int8_t, but not uint8_t. */ 6 #undef uint8_t
+2 -2
pkgs/os-specific/bsd/netbsd/compat-dont-configure-twice.patch
··· 6 7 diff --git a/Makefile b/Makefile 8 index b5adb8a5f2e9..1a914ef16739 100644 9 - --- a/Makefile 10 - +++ b/Makefile 11 @@ -76,11 +76,6 @@ _CURDIR:= ${.CURDIR} 12 13 SRCS:= ${SRCS:M*.c}
··· 6 7 diff --git a/Makefile b/Makefile 8 index b5adb8a5f2e9..1a914ef16739 100644 9 + --- a/tools/compat/Makefile 10 + +++ b/tools/compat/Makefile 11 @@ -76,11 +76,6 @@ _CURDIR:= ${.CURDIR} 12 13 SRCS:= ${SRCS:M*.c}
+2 -2
pkgs/os-specific/bsd/netbsd/compat-no-force-native.patch
··· 8 9 diff --git a/Makefile b/Makefile 10 index 4bcf227f0e75..9ed1d6eea6ff 100644 11 - --- a/Makefile 12 - +++ b/Makefile 13 @@ -1,6 +1,6 @@ 14 # $NetBSD: Makefile,v 1.87 2019/05/08 02:25:50 thorpej Exp $ 15
··· 8 9 diff --git a/Makefile b/Makefile 10 index 4bcf227f0e75..9ed1d6eea6ff 100644 11 + --- a/tools/compat/Makefile 12 + +++ b/tools/compat/Makefile 13 @@ -1,6 +1,6 @@ 14 # $NetBSD: Makefile,v 1.87 2019/05/08 02:25:50 thorpej Exp $ 15
+21 -18
pkgs/os-specific/bsd/netbsd/default.nix
··· 3 , buildPackages, splicePackages, newScope 4 , bsdSetupHook, makeSetupHook, fetchcvs, groff, mandoc, byacc, flex 5 , zlib 6 - , writeText, symlinkJoin 7 }: 8 9 let ··· 121 installPhase = "includesPhase"; 122 dontBuild = true; 123 } // attrs // { 124 postPatch = lib.optionalString (!stdenv'.hostPlatform.isNetBSD) '' 125 - # Files that use NetBSD-specific macros need to have nbtool_config.h 126 - # included ahead of them on non-NetBSD platforms. 127 set +e 128 grep -Zlr "^__RCSID 129 - ^__BEGIN_DECLS" | xargs -0r grep -FLZ nbtool_config.h | 130 xargs -0tr sed -i '0,/^#/s//#include <nbtool_config.h>\n\0/' 131 set -e 132 '' + attrs.postPatch or ""; ··· 146 skipIncludesPhase = true; 147 148 postPatch = '' 149 - patchShebangs configure 150 ${self.make.postPatch} 151 ''; 152 ··· 281 282 # HACK: to ensure parent directories exist. This emulates GNU 283 # install’s -D option. No alternative seems to exist in BSD install. 284 - install = let binstall = writeText "binstall" '' 285 - #!${stdenv.shell} 286 - for last in $@; do true; done 287 mkdir -p $(dirname $last) 288 - xinstall "$@" 289 ''; in mkDerivation { 290 path = "usr.bin/xinstall"; 291 version = "9.2"; ··· 297 mandoc groff rsync 298 ]; 299 skipIncludesPhase = true; 300 - buildInputs = with self; compatIfNeeded ++ [ fts ]; 301 installPhase = '' 302 runHook preInstall 303 304 install -D install.1 $out/share/man/man1/install.1 305 install -D xinstall $out/bin/xinstall 306 install -D -m 0550 ${binstall} $out/bin/binstall 307 ln -s $out/bin/binstall $out/bin/install 308 309 runHook postInstall ··· 391 install mandoc groff rsync 392 ]; 393 }; 394 ## 395 ## END BOOTSTRAPPING 396 ## ··· 705 SHLIBINSTALLDIR = "$(out)/lib"; 706 makeFlags = defaultMakeFlags ++ [ "LIBDO.terminfo=${self.libterminfo}/lib" ]; 707 postPatch = '' 708 - sed -i '1i #undef bool_t' el.h 709 - substituteInPlace config.h \ 710 --replace "#define HAVE_STRUCT_DIRENT_D_NAMLEN 1" "" 711 - substituteInPlace readline/Makefile --replace /usr/include "$out/include" 712 ''; 713 NIX_CFLAGS_COMPILE = [ 714 "-D__noinline=" ··· 728 buildInputs = with self; compatIfNeeded; 729 SHLIBINSTALLDIR = "$(out)/lib"; 730 postPatch = '' 731 - substituteInPlace term.c --replace /usr/share $out/share 732 - substituteInPlace setupterm.c \ 733 --replace '#include <curses.h>' 'void use_env(bool);' 734 ''; 735 postBuild = '' ··· 757 MKDOC = "no"; # missing vfontedpr 758 makeFlags = defaultMakeFlags ++ [ "LIBDO.terminfo=${self.libterminfo}/lib" ]; 759 postPatch = lib.optionalString (!stdenv.isDarwin) '' 760 - substituteInPlace printw.c \ 761 --replace "funopen(win, NULL, __winwrite, NULL, NULL)" NULL \ 762 --replace "__strong_alias(vwprintw, vw_printw)" 'extern int vwprintw(WINDOW*, const char*, va_list) __attribute__ ((alias ("vw_printw")));' 763 - substituteInPlace scanw.c \ 764 --replace "__strong_alias(vwscanw, vw_scanw)" 'extern int vwscanw(WINDOW*, const char*, va_list) __attribute__ ((alias ("vw_scanw")));' 765 ''; 766 }; ··· 985 # man0 generates a man.pdf using ps2pdf, but doesn't install it later, 986 # so we can avoid the dependency on ghostscript 987 postPatch = '' 988 - substituteInPlace man0/Makefile --replace "ps2pdf" "echo noop " 989 ''; 990 makeFlags = defaultMakeFlags ++ [ 991 "FILESDIR=$(out)/share"
··· 3 , buildPackages, splicePackages, newScope 4 , bsdSetupHook, makeSetupHook, fetchcvs, groff, mandoc, byacc, flex 5 , zlib 6 + , writeScript, writeText, runtimeShell, symlinkJoin 7 }: 8 9 let ··· 121 installPhase = "includesPhase"; 122 dontBuild = true; 123 } // attrs // { 124 + # Files that use NetBSD-specific macros need to have nbtool_config.h 125 + # included ahead of them on non-NetBSD platforms. 126 postPatch = lib.optionalString (!stdenv'.hostPlatform.isNetBSD) '' 127 set +e 128 grep -Zlr "^__RCSID 129 + ^__BEGIN_DECLS" $BSD_PATH | xargs -0r grep -FLZ nbtool_config.h | 130 xargs -0tr sed -i '0,/^#/s//#include <nbtool_config.h>\n\0/' 131 set -e 132 '' + attrs.postPatch or ""; ··· 146 skipIncludesPhase = true; 147 148 postPatch = '' 149 + patchShebangs $BSD_PATH/configure 150 ${self.make.postPatch} 151 ''; 152 ··· 281 282 # HACK: to ensure parent directories exist. This emulates GNU 283 # install’s -D option. No alternative seems to exist in BSD install. 284 + install = let binstall = writeScript "binstall" '' 285 + #!${runtimeShell} 286 + set -eu 287 + for last in "$@"; do true; done 288 mkdir -p $(dirname $last) 289 + @out@/bin/xinstall "$@" 290 ''; in mkDerivation { 291 path = "usr.bin/xinstall"; 292 version = "9.2"; ··· 298 mandoc groff rsync 299 ]; 300 skipIncludesPhase = true; 301 + buildInputs = with self; compatIfNeeded; 302 installPhase = '' 303 runHook preInstall 304 305 install -D install.1 $out/share/man/man1/install.1 306 install -D xinstall $out/bin/xinstall 307 install -D -m 0550 ${binstall} $out/bin/binstall 308 + substituteInPlace $out/bin/binstall --subst-var out 309 ln -s $out/bin/binstall $out/bin/install 310 311 runHook postInstall ··· 393 install mandoc groff rsync 394 ]; 395 }; 396 + 397 ## 398 ## END BOOTSTRAPPING 399 ## ··· 708 SHLIBINSTALLDIR = "$(out)/lib"; 709 makeFlags = defaultMakeFlags ++ [ "LIBDO.terminfo=${self.libterminfo}/lib" ]; 710 postPatch = '' 711 + sed -i '1i #undef bool_t' $BSD_PATH/el.h 712 + substituteInPlace $BSD_PATH/config.h \ 713 --replace "#define HAVE_STRUCT_DIRENT_D_NAMLEN 1" "" 714 + substituteInPlace $BSD_PATH/readline/Makefile --replace /usr/include "$out/include" 715 ''; 716 NIX_CFLAGS_COMPILE = [ 717 "-D__noinline=" ··· 731 buildInputs = with self; compatIfNeeded; 732 SHLIBINSTALLDIR = "$(out)/lib"; 733 postPatch = '' 734 + substituteInPlace $BSD_PATH/term.c --replace /usr/share $out/share 735 + substituteInPlace $BSD_PATH/setupterm.c \ 736 --replace '#include <curses.h>' 'void use_env(bool);' 737 ''; 738 postBuild = '' ··· 760 MKDOC = "no"; # missing vfontedpr 761 makeFlags = defaultMakeFlags ++ [ "LIBDO.terminfo=${self.libterminfo}/lib" ]; 762 postPatch = lib.optionalString (!stdenv.isDarwin) '' 763 + substituteInPlace $BSD_PATH/printw.c \ 764 --replace "funopen(win, NULL, __winwrite, NULL, NULL)" NULL \ 765 --replace "__strong_alias(vwprintw, vw_printw)" 'extern int vwprintw(WINDOW*, const char*, va_list) __attribute__ ((alias ("vw_printw")));' 766 + substituteInPlace $BSD_PATH/scanw.c \ 767 --replace "__strong_alias(vwscanw, vw_scanw)" 'extern int vwscanw(WINDOW*, const char*, va_list) __attribute__ ((alias ("vw_scanw")));' 768 ''; 769 }; ··· 988 # man0 generates a man.pdf using ps2pdf, but doesn't install it later, 989 # so we can avoid the dependency on ghostscript 990 postPatch = '' 991 + substituteInPlace $BSD_PATH/man0/Makefile --replace "ps2pdf" "echo noop " 992 ''; 993 makeFlags = defaultMakeFlags ++ [ 994 "FILESDIR=$(out)/share"
+2 -2
pkgs/os-specific/bsd/netbsd/getent.patch
··· 1 Author: Matthew Bauer 2 Description: Remove unavailable getent databases 3 Version: 7.1.2 4 - --- a/getent.c 2018-04-16 13:33:49.000000000 -0500 5 - +++ b/getent.c 2018-04-16 13:29:30.000000000 -0500 6 @@ -42,7 +42,6 @@ 7 #include <grp.h> 8 #include <limits.h>
··· 1 Author: Matthew Bauer 2 Description: Remove unavailable getent databases 3 Version: 7.1.2 4 + --- a/usr.bin/getent/getent.c 2018-04-16 13:33:49.000000000 -0500 5 + +++ b/usr.bin/getent/getent.c 2018-04-16 13:29:30.000000000 -0500 6 @@ -42,7 +42,6 @@ 7 #include <grp.h> 8 #include <limits.h>
+2 -2
pkgs/os-specific/bsd/netbsd/locale.patch
··· 1 - --- a/locale.c 2018-06-11 14:39:06.449762000 -0400 2 - +++ b/locale.c 2018-06-11 14:42:28.461122899 -0400 3 @@ -56,14 +56,8 @@ 4 #include <stringlist.h> 5 #include <unistd.h>
··· 1 + --- a/usr.bin/locale/locale.c 2018-06-11 14:39:06.449762000 -0400 2 + +++ b/usr.bin/locale/locale.c 2018-06-11 14:42:28.461122899 -0400 3 @@ -56,14 +56,8 @@ 4 #include <stringlist.h> 5 #include <unistd.h>
+2 -2
pkgs/os-specific/bsd/netbsd/no-dynamic-linker.patch
··· 4 retrieving revision 1.16 5 retrieving revision 1.17 6 diff -u -p -r1.16 -r1.17 7 - --- sys/arch/i386/stand/efiboot/Makefile.efiboot 2019/09/13 02:19:45 1.16 8 - +++ sys/arch/i386/stand/efiboot/Makefile.efiboot 2020/04/04 15:30:46 1.17 9 @@ -41,6 +41,7 @@ BINMODE=444 10 .PATH: ${.CURDIR}/../../libsa 11
··· 4 retrieving revision 1.16 5 retrieving revision 1.17 6 diff -u -p -r1.16 -r1.17 7 + --- a/sys/arch/i386/stand/efiboot/Makefile.efiboot 2019/09/13 02:19:45 1.16 8 + +++ b/sys/arch/i386/stand/efiboot/Makefile.efiboot 2020/04/04 15:30:46 1.17 9 @@ -41,6 +41,7 @@ BINMODE=444 10 .PATH: ${.CURDIR}/../../libsa 11
+2 -2
pkgs/os-specific/bsd/netbsd/sys-headers-incsdir.patch
··· 1 diff --git a/Makefile b/Makefile 2 index 3f1e18dc659d..163362b82f94 100644 3 - --- a/Makefile 4 - +++ b/Makefile 5 @@ -2,6 +2,8 @@ 6 7 .include <bsd.own.mk>
··· 1 diff --git a/Makefile b/Makefile 2 index 3f1e18dc659d..163362b82f94 100644 3 + --- a/sys/Makefile 4 + +++ b/sys/Makefile 5 @@ -2,6 +2,8 @@ 6 7 .include <bsd.own.mk>
+6 -1
pkgs/os-specific/bsd/setup-hook.sh
··· 48 makeFlags="BINDIR=${!outputBin}/bin $makeFlags" 49 makeFlags="LIBDIR=${!outputLib}/lib $makeFlags" 50 makeFlags="SHLIBDIR=${!outputLib}/lib $makeFlags" 51 makeFlags="MANDIR=${!outputMan}/share/man $makeFlags" 52 makeFlags="INFODIR=${!outputInfo}/share/info $makeFlags" 53 makeFlags="DOCDIR=${!outputDoc}/share/doc $makeFlags" ··· 61 sourceRoot=$PWD/$sourceRoot 62 export BSDSRCDIR=$sourceRoot 63 export _SRC_TOP_=$BSDSRCDIR 64 65 - cd $sourceRoot 66 if [ -d "$BSD_PATH" ] 67 then sourceRoot=$sourceRoot/$BSD_PATH 68 fi 69 } 70 ··· 104 } 105 106 postUnpackHooks+=(setBSDSourceDir) 107 preConfigureHooks+=(addMakeFlags) 108 preInstallHooks+=(includesPhase) 109 fixupOutputHooks+=(moveUsrDir)
··· 48 makeFlags="BINDIR=${!outputBin}/bin $makeFlags" 49 makeFlags="LIBDIR=${!outputLib}/lib $makeFlags" 50 makeFlags="SHLIBDIR=${!outputLib}/lib $makeFlags" 51 + makeFlags="SHAREDIR=${!outputLib}/share $makeFlags" 52 makeFlags="MANDIR=${!outputMan}/share/man $makeFlags" 53 makeFlags="INFODIR=${!outputInfo}/share/info $makeFlags" 54 makeFlags="DOCDIR=${!outputDoc}/share/doc $makeFlags" ··· 62 sourceRoot=$PWD/$sourceRoot 63 export BSDSRCDIR=$sourceRoot 64 export _SRC_TOP_=$BSDSRCDIR 65 + cd $sourceRoot 66 + } 67 68 + cdBSDPath() { 69 if [ -d "$BSD_PATH" ] 70 then sourceRoot=$sourceRoot/$BSD_PATH 71 + cd $BSD_PATH 72 fi 73 } 74 ··· 108 } 109 110 postUnpackHooks+=(setBSDSourceDir) 111 + postPatchHooks+=(cdBSDPath) 112 preConfigureHooks+=(addMakeFlags) 113 preInstallHooks+=(includesPhase) 114 fixupOutputHooks+=(moveUsrDir)