Skip to content

Commit

Permalink
Merge pull request #315176 from rhelmot/freebsd-minimal3/freebsd-various
Browse files Browse the repository at this point in the history
freebsd: various improvements and new packages
  • Loading branch information
Ericson2314 committed Jun 17, 2024
2 parents ca4f0be + ae7c4ca commit c5b1ce1
Show file tree
Hide file tree
Showing 27 changed files with 598 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ diff --git a/tools/build/Makefile b/tools/build/Makefile
index 948a5f9dfdb..592af84eeae 100644
--- a/tools/build/Makefile
+++ b/tools/build/Makefile
@@ -327,15 +327,15 @@ host-symlinks:
@@ -327,14 +327,14 @@ host-symlinks:
# and cross-tools stages. We do this here using mkdir since mtree may not exist
# yet (this happens if we are crossbuilding from Linux/Mac).
INSTALLDIR_LIST= \
- bin \
- lib/casper \
- lib/geom \
- usr/include/casper \
- usr/include/private/ucl \
Expand All @@ -16,7 +15,6 @@ index 948a5f9dfdb..592af84eeae 100644
- usr/libdata/pkgconfig \
- usr/libexec
+ ${BINDIR} \
+ ${LIBDIR}/casper \
+ ${LIBDIR}/geom \
+ ${INCLUDEDIR}/casper \
+ ${INCLUDEDIR}/private/ucl \
Expand Down
11 changes: 11 additions & 0 deletions pkgs/os-specific/bsd/freebsd/patches/14.0/libcxxrt-headers.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- freebsd/lib/libcxxrt/Makefile 2024-05-30 14:27:42.328086005 -0700
+++ freebsd/lib/libcxxrt/Makefile.mod 2024-05-30 14:27:48.048014581 -0700
@@ -19,6 +19,8 @@
SRCS+= terminate.cc
SRCS+= typeinfo.cc

+INCS+=cxxabi.h unwind.h unwind-arm.h unwind-itanium.h
+
WARNS?= 0
CFLAGS+= -isystem ${SRCDIR} -nostdinc++
CXXSTD?= c++14
158 changes: 158 additions & 0 deletions pkgs/os-specific/bsd/freebsd/patches/14.0/localedef.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
diff --git a/include/_ctype.h b/include/_ctype.h
index 91e6b1d14f6b..a6896b598da3 100644
--- a/include/_ctype.h
+++ b/include/_ctype.h
@@ -44,7 +44,7 @@
#define __CTYPE_H_

#include <sys/cdefs.h>
-#include <sys/_types.h>
+#include <sys/types.h>

#define _CTYPE_A 0x00000100L /* Alpha */
#define _CTYPE_C 0x00000200L /* Control */
diff --git a/lib/libc/locale/collate.h b/lib/libc/locale/collate.h
index 2d3723b49f5b..6bbff732b9d7 100644
--- a/lib/libc/locale/collate.h
+++ b/lib/libc/locale/collate.h
@@ -36,6 +36,7 @@
#ifndef _COLLATE_H_
#define _COLLATE_H_

+#include <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <limits.h>
diff --git a/usr.bin/localedef/charmap.c b/usr.bin/localedef/charmap.c
index 44b7e3292eae..79c30b7cf372 100644
--- a/usr.bin/localedef/charmap.c
+++ b/usr.bin/localedef/charmap.c
@@ -31,6 +31,7 @@
/*
* CHARMAP file handling for localedef.
*/
+#include <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/tree.h>
diff --git a/usr.bin/localedef/collate.c b/usr.bin/localedef/collate.c
index 2a080773a95e..3f0030c638f5 100644
--- a/usr.bin/localedef/collate.c
+++ b/usr.bin/localedef/collate.c
@@ -31,6 +31,7 @@
/*
* LC_COLLATE database generation routines for localedef.
*/
+#include <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/tree.h>
diff --git a/usr.bin/localedef/ctype.c b/usr.bin/localedef/ctype.c
index ab7b76e57b2d..846c6d6480a8 100644
--- a/usr.bin/localedef/ctype.c
+++ b/usr.bin/localedef/ctype.c
@@ -32,6 +32,7 @@
/*
* LC_CTYPE database generation routines for localedef.
*/
+#include <stdint.h>
#include <sys/cdefs.h>
#include <sys/tree.h>

diff --git a/usr.bin/localedef/localedef.c b/usr.bin/localedef/localedef.c
index 5ff146d6f655..ed69aa1f0c0e 100644
--- a/usr.bin/localedef/localedef.c
+++ b/usr.bin/localedef/localedef.c
@@ -32,7 +32,7 @@
* POSIX localedef.
*/
#include <sys/cdefs.h>
-#include <sys/endian.h>
+#include <endian.h>
#include <sys/stat.h>
#include <sys/types.h>

diff --git a/usr.bin/localedef/messages.c b/usr.bin/localedef/messages.c
index 6b8eb9d684dd..0155821d0e56 100644
--- a/usr.bin/localedef/messages.c
+++ b/usr.bin/localedef/messages.c
@@ -31,6 +31,7 @@
/*
* LC_MESSAGES database generation routines for localedef.
*/
+#include <stdint.h>
#include <sys/cdefs.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/usr.bin/localedef/monetary.c b/usr.bin/localedef/monetary.c
index 7a77ac7e256c..7636c4deca1f 100644
--- a/usr.bin/localedef/monetary.c
+++ b/usr.bin/localedef/monetary.c
@@ -31,6 +31,7 @@
/*
* LC_MONETARY database generation routines for localedef.
*/
+#include <stdint.h>
#include <sys/cdefs.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/usr.bin/localedef/numeric.c b/usr.bin/localedef/numeric.c
index 5533b7c10e1a..9c47494f815c 100644
--- a/usr.bin/localedef/numeric.c
+++ b/usr.bin/localedef/numeric.c
@@ -31,6 +31,7 @@
/*
* LC_NUMERIC database generation routines for localedef.
*/
+#include <stdint.h>
#include <sys/cdefs.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/usr.bin/localedef/parser.y b/usr.bin/localedef/parser.y
index 23b3b54f8a6e..e01330f0152d 100644
--- a/usr.bin/localedef/parser.y
+++ b/usr.bin/localedef/parser.y
@@ -33,6 +33,7 @@
* POSIX localedef grammar.
*/

+#include <stdint.h>
#include <wchar.h>
#include <stdio.h>
#include <limits.h>
diff --git a/usr.bin/localedef/scanner.c b/usr.bin/localedef/scanner.c
index c6d45a993f28..b17670ef4b4a 100644
--- a/usr.bin/localedef/scanner.c
+++ b/usr.bin/localedef/scanner.c
@@ -32,6 +32,7 @@
* This file contains the "scanner", which tokenizes the input files
* for localedef for processing by the higher level grammar processor.
*/
+#include <stdint.h>
#include <sys/cdefs.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/usr.bin/localedef/time.c b/usr.bin/localedef/time.c
index 7a56e244c921..0e409a742d0a 100644
--- a/usr.bin/localedef/time.c
+++ b/usr.bin/localedef/time.c
@@ -31,6 +31,7 @@
/*
* LC_TIME database generation routines for localedef.
*/
+#include <stdint.h>
#include <sys/cdefs.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/usr.bin/localedef/wide.c b/usr.bin/localedef/wide.c
index 062e120e6912..a199cddb198d 100644
--- a/usr.bin/localedef/wide.c
+++ b/usr.bin/localedef/wide.c
@@ -34,6 +34,7 @@
* to the wide character forms used internally by libc. Unfortunately,
* this approach means that we need a method for each and every encoding.
*/
+#include <stdint.h>
#include <sys/cdefs.h>
#include <ctype.h>
#include <stdlib.h>
15 changes: 15 additions & 0 deletions pkgs/os-specific/bsd/freebsd/patches/14.0/tinfo-host-cc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--- a/lib/ncurses/tinfo/Makefile 2023-12-26 23:02:07.827892619 -0800
+++ b/lib/ncurses/tinfo/Makefile 2023-12-26 23:01:24.175546100 -0800
@@ -282,10 +282,10 @@
build-tools: make_hash make_keys

make_keys: make_keys.c names.c ncurses_def.h ${HEADERS} ${BUILD_TOOLS_META}
- ${CC:N${CCACHE_BIN}} -o $@ ${CFLAGS} ${NCURSES_DIR}/ncurses/tinfo/make_keys.c
+ ${CC_HOST:N${CCACHE_BIN}} -o $@ ${CFLAGS} ${NCURSES_DIR}/ncurses/tinfo/make_keys.c

make_hash: make_hash.c hashsize.h ncurses_def.h ${HEADERS} ${BUILD_TOOLS_META}
- ${CC:N${CCACHE_BIN}} -o $@ ${CFLAGS} -DMAIN_PROGRAM \
+ ${CC_HOST:N${CCACHE_BIN}} -o $@ ${CFLAGS} -DMAIN_PROGRAM \
${NCURSES_DIR}/ncurses/tinfo/make_hash.c
.endif
.if ${MK_DIRDEPS_BUILD} == "yes" && ${MACHINE} != "host"
92 changes: 92 additions & 0 deletions pkgs/os-specific/bsd/freebsd/pkgs/bin.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
mkDerivation,
pkgsBuildBuild,
libjail,
libmd,
libnetbsd,
libcapsicum,
libcasper,
libelf,
libxo,
libncurses-tinfo,
libedit,
lib,
stdenv,
bsdSetupHook,
freebsdSetupHook,
makeMinimal,
install,
tsort,
lorder,
mandoc,
groff,
byacc,
gencat,
}:
mkDerivation {
pname = "bins";
path = "bin";
extraPaths = [
"sys/conf"
"sys/sys/param.h"
"contrib/sendmail"
"contrib/tcsh"
"usr.bin/printf"
"lib/libsm"
];
buildInputs = [
libjail
libmd
libnetbsd
libcapsicum
libcasper
libelf
libxo
libncurses-tinfo
libedit
];
nativeBuildInputs = [
bsdSetupHook
freebsdSetupHook
makeMinimal
install
tsort
lorder
mandoc
groff

byacc
gencat
];

MK_TESTS = "no";

postPatch = ''
sed -E -i -e '/#define\tBSD.*/d' $BSDSRCDIR/sys/sys/param.h
sed -E -i -e '/^SYMLINKS.*/d' $BSDSRCDIR/bin/*/Makefile
sed -E -i -e 's/mktemp -t ka/mktemp -t kaXXXXXX/' $BSDSRCDIR/bin/sh/mkbuiltins $BSDSRCDIR/bin/sh/mktokens
'';

preBuild = ''
export NIX_CFLAGS_COMPILE="-I$BSDSRCDIR/sys $NIX_CFLAGS_COMPILE"
make -C $BSDSRCDIR/lib/libsm $makeFlags
make -C $BSDSRCDIR/bin/sh $makeFlags "CC=${pkgsBuildBuild.stdenv.cc}/bin/cc" CFLAGS="-D__unused= -D__printf0like\(a,b\)= -D__dead2=" ${
lib.optionalString (!stdenv.buildPlatform.isFreeBSD) "MK_PIE=no "
}mkbuiltins mksyntax mktokens mknodes
make -C $BSDSRCDIR/bin/csh $makeFlags "CC=${pkgsBuildBuild.stdenv.cc}/bin/cc" CFLAGS="-D__unused= -D__printf0like\(a,b\)= -D__dead2= -I$BSDSRCDIR/contrib/tcsh -I." ${
lib.optionalString (!stdenv.buildPlatform.isFreeBSD) "MK_PIE=no "
}gethost
'';

preInstall = ''
makeFlags="$makeFlags ROOTDIR=$out/root"
'';

outputs = [
"out"
"man"
"debug"
];
}
17 changes: 15 additions & 2 deletions pkgs/os-specific/bsd/freebsd/pkgs/boot-install.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
{ buildPackages, freebsd-lib }:

# Wrap NetBSD's install
# Wrap GNU coreutils' install
# The -l flag causes a symlink instead of a copy to be installed, so
# it is safe to discard during bootstrap since coreutils does not support it.

buildPackages.writeShellScriptBin "boot-install" (
freebsd-lib.install-wrapper
+ ''
fixed_args=()
while [[ ''${#args[0]} > 0 ]]; do
case "''${args[0]}" in
-l)
args=("''${args[@]:2}")
continue
esac
fixed_args+=("''${args[0]}")
args=("''${args[@]:1}")
done
${buildPackages.netbsd.install}/bin/xinstall "''${args[@]}"
${buildPackages.coreutils}/bin/install "''${fixed_args[@]}"
''
)
10 changes: 10 additions & 0 deletions pkgs/os-specific/bsd/freebsd/pkgs/cp.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{ mkDerivation }:
mkDerivation {
path = "bin/cp";

extraPaths = [ "sys" ];

postPatch = ''
substituteInPlace $BSDSRCDIR/bin/cp/Makefile --replace 'tests' ""
'';
}
2 changes: 1 addition & 1 deletion pkgs/os-specific/bsd/freebsd/pkgs/csu.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}:

mkDerivation {
isStatic = true;
noLibc = true;
path = "lib/csu";
extraPaths = [
"lib/Makefile.inc"
Expand Down
17 changes: 14 additions & 3 deletions pkgs/os-specific/bsd/freebsd/pkgs/filterSource.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ let
lib.concatMapStringsSep "\n" (path: "/${path}") sortedPaths
);
in
runCommand "${pname}-filtered-src" { nativeBuildInputs = [ pkgsBuildBuild.rsync ]; } ''
rsync -a -r --files-from=${filterText} ${source}/ $out
''
runCommand "${pname}-filtered-src"
{
nativeBuildInputs = [
(pkgsBuildBuild.rsync.override {
enableZstd = false;
enableXXHash = false;
enableOpenSSL = false;
enableLZ4 = false;
})
];
}
''
rsync -a -r --files-from=${filterText} ${source}/ $out
''
12 changes: 12 additions & 0 deletions pkgs/os-specific/bsd/freebsd/pkgs/iconv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
mkDerivation,
libcapsicum,
libcasper,
}:
mkDerivation {
path = "usr.bin/iconv";
buildInputs = [
libcapsicum
libcasper
];
}
2 changes: 1 addition & 1 deletion pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}:

mkDerivation {
isStatic = true;
noLibc = true;
path = "include";

extraPaths = [
Expand Down
Loading

0 comments on commit c5b1ce1

Please sign in to comment.