Skip to content

Commit

Permalink
Merge pull request #194698 from Ericson2314/freebsd-prep
Browse files Browse the repository at this point in the history
netbsd: Adapt to BSD-common infra changes for FreeBSD
  • Loading branch information
Ericson2314 authored Oct 6, 2022
2 parents 0b4912d + 044163d commit 9a5fa3b
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 36 deletions.
4 changes: 2 additions & 2 deletions pkgs/os-specific/bsd/netbsd/compat-cxx-safe-header.patch
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkgs/os-specific/bsd/netbsd/compat-dont-configure-twice.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions pkgs/os-specific/bsd/netbsd/compat-no-force-native.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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 $

Expand Down
40 changes: 21 additions & 19 deletions pkgs/os-specific/bsd/netbsd/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
, buildPackages, splicePackages, newScope
, bsdSetupHook, makeSetupHook, fetchcvs, groff, mandoc, byacc, flex
, zlib
, writeText, symlinkJoin
, writeShellScript, writeText, runtimeShell, symlinkJoin
}:

let
Expand Down Expand Up @@ -94,7 +94,7 @@ in lib.makeScopeWithSplicing
}.${stdenv'.hostPlatform.parsed.cpu.name}
or stdenv'.hostPlatform.parsed.cpu.name;

BSD_PATH = attrs.path;
COMPONENT_PATH = attrs.path;

makeFlags = defaultMakeFlags;

Expand All @@ -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" $COMPONENT_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 "";
Expand All @@ -146,7 +146,7 @@ in lib.makeScopeWithSplicing
skipIncludesPhase = true;

postPatch = ''
patchShebangs configure
patchShebangs $COMPONENT_PATH/configure
${self.make.postPatch}
'';

Expand Down Expand Up @@ -281,11 +281,11 @@ in lib.makeScopeWithSplicing

# HACK: to ensure parent directories exist. This emulates GNU
# install’s -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 = writeShellScript "binstall" ''
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";
Expand All @@ -297,13 +297,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
Expand Down Expand Up @@ -391,6 +392,7 @@ in lib.makeScopeWithSplicing
install mandoc groff rsync
];
};

##
## END BOOTSTRAPPING
##
Expand Down Expand Up @@ -705,10 +707,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' $COMPONENT_PATH/el.h
substituteInPlace $COMPONENT_PATH/config.h \
--replace "#define HAVE_STRUCT_DIRENT_D_NAMLEN 1" ""
substituteInPlace readline/Makefile --replace /usr/include "$out/include"
substituteInPlace $COMPONENT_PATH/readline/Makefile --replace /usr/include "$out/include"
'';
NIX_CFLAGS_COMPILE = [
"-D__noinline="
Expand All @@ -728,8 +730,8 @@ in lib.makeScopeWithSplicing
buildInputs = with self; compatIfNeeded;
SHLIBINSTALLDIR = "$(out)/lib";
postPatch = ''
substituteInPlace term.c --replace /usr/share $out/share
substituteInPlace setupterm.c \
substituteInPlace $COMPONENT_PATH/term.c --replace /usr/share $out/share
substituteInPlace $COMPONENT_PATH/setupterm.c \
--replace '#include <curses.h>' 'void use_env(bool);'
'';
postBuild = ''
Expand Down Expand Up @@ -757,10 +759,10 @@ in lib.makeScopeWithSplicing
MKDOC = "no"; # missing vfontedpr
makeFlags = defaultMakeFlags ++ [ "LIBDO.terminfo=${self.libterminfo}/lib" ];
postPatch = lib.optionalString (!stdenv.isDarwin) ''
substituteInPlace printw.c \
substituteInPlace $COMPONENT_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 $COMPONENT_PATH/scanw.c \
--replace "__strong_alias(vwscanw, vw_scanw)" 'extern int vwscanw(WINDOW*, const char*, va_list) __attribute__ ((alias ("vw_scanw")));'
'';
};
Expand Down Expand Up @@ -985,7 +987,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 $COMPONENT_PATH/man0/Makefile --replace "ps2pdf" "echo noop "
'';
makeFlags = defaultMakeFlags ++ [
"FILESDIR=$(out)/share"
Expand Down
4 changes: 2 additions & 2 deletions pkgs/os-specific/bsd/netbsd/getent.patch
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
4 changes: 2 additions & 2 deletions pkgs/os-specific/bsd/netbsd/locale.patch
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
4 changes: 2 additions & 2 deletions pkgs/os-specific/bsd/netbsd/no-dynamic-linker.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions pkgs/os-specific/bsd/netbsd/sys-headers-incsdir.patch
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
11 changes: 8 additions & 3 deletions pkgs/os-specific/bsd/setup-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -61,10 +62,13 @@ setBSDSourceDir() {
sourceRoot=$PWD/$sourceRoot
export BSDSRCDIR=$sourceRoot
export _SRC_TOP_=$BSDSRCDIR

cd $sourceRoot
if [ -d "$BSD_PATH" ]
then sourceRoot=$sourceRoot/$BSD_PATH
}

cdBSDPath() {
if [ -d "$COMPONENT_PATH" ]
then sourceRoot=$sourceRoot/$COMPONENT_PATH
cd $COMPONENT_PATH
fi
}

Expand Down Expand Up @@ -104,6 +108,7 @@ moveUsrDir() {
}

postUnpackHooks+=(setBSDSourceDir)
postPatchHooks+=(cdBSDPath)
preConfigureHooks+=(addMakeFlags)
preInstallHooks+=(includesPhase)
fixupOutputHooks+=(moveUsrDir)

0 comments on commit 9a5fa3b

Please sign in to comment.