push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
{
lib,
stdenvNoLibc,
makeScopeWithSplicing',
generateSplicesForMkScope,
buildPackages,
}:
let
otherSplices = generateSplicesForMkScope "openbsd";
buildOpenbsd = otherSplices.selfBuildHost;
in
makeScopeWithSplicing' {
inherit otherSplices;
f = (
self:
lib.packagesFromDirectoryRecursive {
callPackage = self.callPackage;
directory = ./pkgs;
}
// {
version = "7.5";
stdenvLibcMinimal = stdenvNoLibc.override (old: {
cc = old.cc.override {
libc = self.libcMinimal;
noLibc = false;
bintools = old.cc.bintools.override {
libc = self.libcMinimal;
noLibc = false;
sharedLibraryLoader = null;
};
};
});
makeMinimal = buildPackages.netbsd.makeMinimal.override { inherit (self) make-rules; };
# The manual callPackages below should in principle be unnecessary, but are
# necessary. See note in ../netbsd/default.nix
include = self.callPackage ./pkgs/include/package.nix {
inherit (buildOpenbsd) makeMinimal;
inherit (buildPackages.netbsd) install rpcgen mtree;
};
csu = self.callPackage ./pkgs/csu.nix {
inherit (self) include;
inherit (buildOpenbsd) makeMinimal;
inherit (buildPackages.netbsd) install;
};
libcMinimal = self.callPackage ./pkgs/libcMinimal/package.nix {
inherit (self) csu include;
inherit (buildOpenbsd) makeMinimal;
inherit (buildPackages.netbsd)
install
gencat
tsort
rpcgen
;
};
librpcsvc = self.callPackage ./pkgs/librpcsvc.nix {
inherit (buildOpenbsd) openbsdSetupHook makeMinimal lorder;
inherit (buildPackages.netbsd)
install
tsort
statHook
rpcgen
;
};
libutil = self.callPackage ./pkgs/libutil.nix {
inherit (self) libcMinimal;
inherit (buildOpenbsd) openbsdSetupHook makeMinimal lorder;
inherit (buildPackages.netbsd) install tsort statHook;
};
lorder = self.callPackage ./pkgs/lorder.nix { inherit (buildPackages.netbsd) install; };
make-rules = self.callPackage ./pkgs/make-rules/package.nix { };
mkDerivation = self.callPackage ./pkgs/mkDerivation.nix {
inherit (buildPackages.netbsd) install tsort;
inherit (buildPackages.buildPackages) rsync;
};
}
);
}

View File

@@ -0,0 +1,32 @@
{
mkDerivation,
lib,
flex,
byacc,
compatHook,
}:
mkDerivation {
path = "usr.sbin/config";
extraNativeBuildInputs = [
flex
byacc
compatHook
];
postPatch = ''
rm $BSDSRCDIR/usr.sbin/config/ukc.c
rm $BSDSRCDIR/usr.sbin/config/ukcutil.c
rm $BSDSRCDIR/usr.sbin/config/cmd.c
rm $BSDSRCDIR/usr.sbin/config/exec_elf.c
'';
buildPhase = ''
for f in *.l; do flex $f; done
for f in *.y; do yacc -H ''${f%.y}.h $f; done
for f in *.c; do $CC -I$TMP/include -DMAKE_BOOTSTRAP -c $f; done
$CC *.o -o config
'';
meta.platforms = lib.platforms.linux;
}

View File

@@ -0,0 +1,25 @@
{
mkDerivation,
lib,
flex,
byacc,
compatHook,
}:
mkDerivation {
path = "usr.bin/ctags";
extraNativeBuildInputs = [
flex
byacc
compatHook
];
buildPhase = ''
for f in *.l; do flex $f; done
for f in *.y; do yacc -H ''${f%.y}.h $f; done
for f in *.c; do $CC -I$TMP/include -DMAKE_BOOTSTRAP -c $f; done
$CC *.o -o ctags
'';
meta.platforms = lib.platforms.linux;
}

View File

@@ -0,0 +1,5 @@
{ mkDerivation }:
mkDerivation {
path = "usr.bin/cap_mkdb";
meta.mainProgram = "cap_mkdb";
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "bin/cat";
}

View File

@@ -0,0 +1,24 @@
diff --git a/bin/chmod/Makefile b/bin/chmod/Makefile
index 82854bae3a3..39813dc8882 100644
--- a/bin/chmod/Makefile
+++ b/bin/chmod/Makefile
@@ -3,17 +3,8 @@
PROG= chmod
MAN= chmod.1 chgrp.1 chown.8 chflags.1
LINKS= ${BINDIR}/chmod ${BINDIR}/chgrp \
- ${BINDIR}/chmod /sbin/chown
-
-# XXX compatibility
-afterinstall:
- (cd ${DESTDIR}/usr/sbin && \
- ln -sf ../../sbin/chown . && \
- ln -sf ../../bin/chgrp . && \
- chown -h ${BINOWN}:${BINGRP} chown chgrp)
- (cd ${DESTDIR}/usr/bin && \
- ln -sf ../../bin/chmod chflags && \
- chown -h ${BINOWN}:${BINGRP} chflags)
+ ${BINDIR}/chmod ${BINDIR}/chown \
+ ${BINDIR}/chmod ${BINDIR}/chflags
.include <bsd.prog.mk>

View File

@@ -0,0 +1,6 @@
{ mkDerivation }:
mkDerivation {
path = "bin/chmod";
patches = [ ./no-sbin.patch ];
}

View File

@@ -0,0 +1,17 @@
OpenBSD's bootloader supports input configuration lines from both the console
and configuration files of only up to 133 characters. This is easy to break
with nix store paths. Triple it to 399.
diff --git a/sys/stand/boot/cmd.h b/sys/stand/boot/cmd.h
index 5045f052b8b..9fc5ce9e50a 100644
--- a/sys/stand/boot/cmd.h
+++ b/sys/stand/boot/cmd.h
@@ -27,7 +27,7 @@
*
*/
-#define CMD_BUFF_SIZE 133
+#define CMD_BUFF_SIZE 399
#define BOOTDEVLEN 1024
struct cmd_table {

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "usr.bin/cmp";
}

View File

@@ -0,0 +1,30 @@
#pragma once
#include_next <err.h>
#include <errno.h>
#include <stdarg.h>
static inline void __attribute__((__format__(printf, 3, 4)))
errc(int eval, int code, const char *fmt, ...) {
// verr uses the error code from errno
// No need to keep the old value since this is noreturn anyway
errno = code;
va_list args;
va_start(args, fmt);
verr(eval, fmt, args);
va_end(args);
}
static inline void __attribute__((__format__(printf, 2, 3)))
warnc(int code, const char *fmt, ...) {
// verr uses the error code from errno
int old_errno = errno;
errno = code;
va_list args;
va_start(args, fmt);
vwarn(fmt, args);
va_end(args);
errno = old_errno;
}

View File

@@ -0,0 +1,6 @@
#pragma once
#include_next <fcntl.h>
// Linux doesn't let you lock during open, make these do nothing
#define O_EXLOCK 0
#define O_SHLOCK 0

View File

@@ -0,0 +1,4 @@
#include_next <sys/cdefs.h>
#define __packed __attribute__((__packed__))
#define __aligned(x) __attribute__((__aligned__(x)))

View File

@@ -0,0 +1 @@
#include <dirent.h>

View File

@@ -0,0 +1,2 @@
// Seems to be the only header for htonl
#include <netinet/in.h>

View File

@@ -0,0 +1,10 @@
#include_next <sys/types.h>
// for makedev, major, minor
#include <sys/sysmacros.h>
// For htonl, htons, etc.
#include <arpa/inet.h>
// for uint32_t etc.
#include <stdint.h>

View File

@@ -0,0 +1,8 @@
#pragma once
#include_next <unistd.h>
// Reimplementing pledge and unvail with seccomp would be a pain,
// so do nothing but claim they succeeded
static int pledge(const char *, const char *) { return 0; }
static int unveil(const char *, const char *) { return 0; }

View File

@@ -0,0 +1 @@
#include <sys/types.h>

View File

@@ -0,0 +1,16 @@
{ runCommand, lib }:
runCommand "openbsd-compat"
{
include = ./include;
meta = with lib; {
description = "Header-only library for running OpenBSD software on Linux";
platforms = lib.platforms.linux;
maintainers = with lib.maintainers; [ artemist ];
};
}
''
mkdir -p $out
cp -R $include $out/include
''

View File

@@ -0,0 +1,13 @@
{
stdenv,
makeSetupHook,
compat,
}:
makeSetupHook {
name = "openbsd-compat-hook";
substitutions = {
inherit compat;
inherit (stdenv.cc) suffixSalt;
};
} ./setup-hook.sh

View File

@@ -0,0 +1,5 @@
useOpenBSDCompat () {
export NIX_CFLAGS_COMPILE_@suffixSalt@+="-I@compat@/include"
}
postHooks+=(useOpenBSDCompat)

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "bin/cp";
}

View File

@@ -0,0 +1,33 @@
{
lib,
mkDerivation,
fetchpatch,
bsdSetupHook,
openbsdSetupHook,
makeMinimal,
install,
include,
}:
mkDerivation {
noLibc = true;
path = "lib/csu";
patches = [
# Support for a new NOBLIBSTATIC make variable
(fetchpatch {
name = "nolibstatic-support.patch";
url = "https://marc.info/?l=openbsd-tech&m=171972639411562&q=raw";
hash = "sha256-ZMegMq/A/SeFp8fofIyF0AA0IUo/11ZgKxg/UNT4z3E=";
includes = [ "libexec/ld.so/*" ];
})
];
nativeBuildInputs = [
bsdSetupHook
openbsdSetupHook
makeMinimal
install
];
buildInputs = [ include ];
meta.platforms = lib.platforms.openbsd;
extraPaths = [ "libexec/ld.so" ];
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "bin/date";
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "bin/dd";
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "usr.sbin/dev_mkdb";
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "bin/df";
}

View File

@@ -0,0 +1,7 @@
{ mkDerivation }:
mkDerivation {
path = "usr.sbin/dhcpleasectl";
extraPaths = [ "sbin/dhcpleased" ];
}

View File

@@ -0,0 +1,15 @@
{
mkDerivation,
libevent,
byacc,
}:
mkDerivation {
path = "sbin/dhcpleased";
postPatch = ''
sed -i 's/DPADD/#DPADD/' $BSDSRCDIR/sbin/dhcpleased/Makefile
'';
buildInputs = [ libevent ];
extraNativeBuildInputs = [ byacc ];
}

View File

@@ -0,0 +1,13 @@
{
lib,
mkDerivation,
mandoc,
}:
mkDerivation {
path = "sbin/disklabel";
extraNativeBuildInputs = [
mandoc
];
meta.platforms = lib.platforms.openbsd;
meta.mainProgram = "disklabel";
}

View File

@@ -0,0 +1,8 @@
{ mkDerivation }:
mkDerivation {
path = "sbin/dmesg";
postPatch = ''
sed -i /DPADD/d $BSDSRCDIR/sbin/dmesg/Makefile
'';
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "bin/domainname";
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "bin/echo";
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "bin/ed";
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "bin/expr";
}

View File

@@ -0,0 +1,11 @@
{
lib,
mkDerivation,
mandoc,
}:
mkDerivation {
path = "sbin/fdisk";
extraNativeBuildInputs = [ mandoc ];
meta.mainProgram = "fdisk";
meta.platforms = lib.platforms.openbsd;
}

View File

@@ -0,0 +1,34 @@
diff --git a/sbin/fsck/fsck.c b/sbin/fsck/fsck.c
index 19e730a484f..cb548971abd 100644
--- a/sbin/fsck/fsck.c
+++ b/sbin/fsck/fsck.c
@@ -115,6 +115,8 @@ main(int argc, char *argv[])
err(1, "unveil %s", _PATH_FSTAB);
if (unveil("/sbin", "x") == -1)
err(1, "unveil /sbin");
+ if (unveil("/nix/store", "rx") == -1)
+ err(1, "unveil /nix/store");
if (pledge("stdio rpath wpath disklabel proc exec", NULL) == -1)
err(1, "pledge");
@@ -308,18 +310,8 @@ checkfs(const char *vfstype, const char *spec, const char *mntpt, void *auxarg,
_exit(0);
/* Go find an executable. */
- edir = edirs;
- do {
- (void)snprintf(execname,
- sizeof(execname), "%s/fsck_%s", *edir, vfstype);
- execv(execname, (char * const *)argv);
- if (errno != ENOENT) {
- if (spec)
- warn("exec %s for %s", execname, spec);
- else
- warn("exec %s", execname);
- }
- } while (*++edir != NULL);
+ (void)snprintf(execname, sizeof(execname), "fsck_%s", vfstype);
+ execvp(execname, (char * const *)argv);
if (errno == ENOENT) {
if (spec)

View File

@@ -0,0 +1,6 @@
{ mkDerivation }:
mkDerivation {
path = "sbin/fsck";
patches = [ ./fsck-path.patch ];
}

View File

@@ -0,0 +1,8 @@
{ mkDerivation }:
mkDerivation {
path = "sbin/fsck_ffs";
extraPaths = [
"sbin/fsck"
"sys/ufs/ffs"
];
}

View File

@@ -0,0 +1,5 @@
{ mkDerivation }:
mkDerivation {
path = "sbin/fsck_msdos";
extraPaths = [ "sbin/fsck" ];
}

View File

@@ -0,0 +1 @@
{ mkDerivation }: mkDerivation { path = "usr.bin/getent"; }

View File

@@ -0,0 +1,21 @@
{
mkDerivation,
login,
}:
mkDerivation {
path = "libexec/getty";
extraPaths = [ "etc/gettytab" ];
postPatch = ''
substituteInPlace $BSDSRCDIR/libexec/getty/pathnames.h \
--replace-fail "/usr/libexec/getty" "$out/bin/getty" \
--replace-fail "/usr/bin/login" "${login}/bin/login"
'';
postInstall = ''
mkdir -p $out/etc
cp $BSDSRCDIR/etc/gettytab $out/etc/gettytab
'';
meta.mainProgram = "getty";
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "bin/hostname";
}

View File

@@ -0,0 +1,6 @@
{
mkDerivation,
}:
mkDerivation {
path = "usr.bin/id";
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "sbin/ifconfig";
}

View File

@@ -0,0 +1,56 @@
{
mkDerivation,
makeMinimal,
bsdSetupHook,
openbsdSetupHook,
install,
rpcgen,
mtree,
pax,
buildPackages,
}:
mkDerivation {
path = "include";
noCC = true;
extraPaths = [
"lib"
#"sys"
"sys/arch"
# LDIRS from the mmakefile
"sys/crypto"
"sys/ddb"
"sys/dev"
"sys/isofs"
"sys/miscfs"
"sys/msdosfs"
"sys/net"
"sys/netinet"
"sys/netinet6"
"sys/netmpls"
"sys/net80211"
"sys/nfs"
"sys/ntfs"
"sys/scsi"
"sys/sys"
"sys/ufs"
"sys/uvm"
];
nativeBuildInputs = [
bsdSetupHook
install
makeMinimal
mtree
openbsdSetupHook
pax
rpcgen
];
makeFlags = [
"RPCGEN_CPP=${buildPackages.stdenv.cc.cc}/bin/cpp"
"-B"
];
headersOnly = true;
}

View File

@@ -0,0 +1,8 @@
{ mkDerivation }:
mkDerivation {
path = "usr.bin/kdump";
extraPaths = [
"sys"
"usr.bin/ktrace"
];
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "bin/kill";
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "usr.bin/ktrace";
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "usr.sbin/kvm_mkdb";
}

View File

@@ -0,0 +1,56 @@
{
lib,
stdenvNoLibc,
symlinkJoin,
libcMinimal,
librthread,
libm,
librpcsvc,
libutil,
libexecinfo,
libkvm,
rtld,
version,
}:
symlinkJoin rec {
name = "${pname}-${version}";
pname = "libc-openbsd";
inherit version;
outputs = [
"out"
"dev"
"man"
];
paths =
lib.concatMap
(p: [
(lib.getDev p)
(lib.getLib p)
(lib.getMan p)
])
(
[
libcMinimal
libm
librthread
librpcsvc
libutil
libexecinfo
libkvm
]
++ (lib.optional (!stdenvNoLibc.hostPlatform.isStatic) rtld)
);
postBuild = ''
rm -r "$out/nix-support"
mkdir -p "$man/share/man"
mv "$out/share"/man* "$man/share/man"
rmdir "$out/share"
fixupPhase
'';
meta.platforms = lib.platforms.openbsd;
}

View File

@@ -0,0 +1,12 @@
diff --git a/lib/libc/Makefile b/lib/libc/Makefile
index 4bb4b67fcbb..1c8a8e08e60 100644
--- a/lib/libc/Makefile
+++ b/lib/libc/Makefile
@@ -6,7 +6,6 @@
.include <bsd.own.mk>
LIB=c
-LIBREBUILD=y
CLEANFILES+=tags Symbols.map
CFLAGS+=-Wimplicit
#CFLAGS+=-Werror

View File

@@ -0,0 +1,16 @@
NetBSD's make uses `${variable:tl}` not `${variable:L}`.
diff --git a/lib/libc/Makefile b/lib/libc/Makefile
index 4bb4b67fcbb..ffb35c196ea 100644
--- a/lib/libc/Makefile
+++ b/lib/libc/Makefile
@@ -11,8 +11,8 @@ CLEANFILES+=tags Symbols.map
CFLAGS+=-Wimplicit
#CFLAGS+=-Werror
LDADD=-nostdlib
-.if ${COMPILER_VERSION:L} == "clang"
+.if ${COMPILER_VERSION:tl} == "clang"
LDADD+=-lcompiler_rt
.else
LDADD+=-lgcc
.endif

View File

@@ -0,0 +1,90 @@
{
lib,
stdenvNoLibc,
mkDerivation,
fetchpatch,
bsdSetupHook,
openbsdSetupHook,
makeMinimal,
install,
flex,
byacc,
gencat,
lorder,
tsort,
rpcgen,
csu,
include,
}:
mkDerivation {
noLibc = true;
path = "lib/libc";
pname = "libcMinimal-openbsd";
outputs = [
"out"
"dev"
"man"
];
extraPaths = [
"lib/csu/os-note-elf.h"
"sys/arch"
];
patches = [
./netbsd-make-to-lower.patch
./disable-librebuild.patch
# Do not produce ctags, can do that separately.
(fetchpatch {
name = "skip-tags.patch";
url = "https://marc.info/?l=openbsd-tech&m=171575286706032&q=raw";
hash = "sha256-2fqabJZLUvXUIWe5WZ4NrTOwgQCXqH49Wo0hAPu5lu0=";
})
];
nativeBuildInputs = [
bsdSetupHook
openbsdSetupHook
makeMinimal
install
tsort
lorder
gencat
];
buildInputs = [
include
csu
];
env.NIX_CFLAGS_COMPILE = toString [
"-B${csu}/lib"
"-Wno-error"
];
# Suppress lld >= 16 undefined version errors
# https://github.com/freebsd/freebsd-src/commit/2ba84b4bcdd6012e8cfbf8a0d060a4438623a638
env.NIX_LDFLAGS = lib.optionalString (
stdenvNoLibc.hostPlatform.linker == "lld"
) "--undefined-version";
makeFlags = [
"COMPILER_VERSION=clang"
"LIBC_TAGS=no"
];
postInstall = ''
pushd ${include}
find include -type d -exec mkdir -p "$dev/{}" ';'
find include '(' -type f -o -type l ')' -exec cp -pr "{}" "$dev/{}" ';'
popd
substituteInPlace "$dev/include/sys/time.h" --replace "defined (_LIBC)" "true"
pushd ${csu}
find lib -type d -exec mkdir -p "$out/{}" ';'
find lib '(' -type f -o -type l ')' -exec cp -pr "{}" "$out/{}" ';'
popd
'';
meta.platforms = lib.platforms.openbsd;
}

View File

@@ -0,0 +1,13 @@
{
lib,
mkDerivation,
buildPackages,
}:
mkDerivation {
path = "lib/libcurses";
makeFlags = [
"AWK=${lib.getBin buildPackages.gawk}/bin/awk"
"HOSTCC=${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc"
];
}

View File

@@ -0,0 +1,7 @@
{ mkDerivation }:
mkDerivation {
path = "lib/libevent";
preInstall = ''
mkdir -p $out/include
'';
}

View File

@@ -0,0 +1,22 @@
{
lib,
mkDerivation,
}:
mkDerivation {
path = "gnu/lib/libexecinfo";
extraPaths = [
"gnu/llvm/libunwind"
"gnu/llvm/libcxx"
"gnu/lib/libcxx"
];
libcMinimal = true;
outputs = [
"out"
"man"
];
meta.platforms = lib.platforms.openbsd;
}

View File

@@ -0,0 +1,8 @@
{
mkDerivation,
}:
mkDerivation {
path = "lib/libkvm";
libcMinimal = true;
}

View File

@@ -0,0 +1,16 @@
{ lib, mkDerivation }:
mkDerivation {
path = "lib/libm";
libcMinimal = true;
outputs = [
"out"
"man"
];
extraPaths = [ "sys" ];
meta.platforms = lib.platforms.openbsd;
}

View File

@@ -0,0 +1,38 @@
{
lib,
mkDerivation,
bsdSetupHook,
openbsdSetupHook,
makeMinimal,
install,
tsort,
lorder,
rpcgen,
statHook,
}:
mkDerivation {
path = "lib/librpcsvc";
libcMinimal = true;
outputs = [
"out"
"dev"
];
nativeBuildInputs = [
bsdSetupHook
openbsdSetupHook
makeMinimal
install
tsort
lorder
rpcgen
statHook
];
makeFlags = [ "INCSDIR=$(dev)/include/rpcsvc" ];
meta.platforms = lib.platforms.openbsd;
}

View File

@@ -0,0 +1,28 @@
{
lib,
mkDerivation,
libcMinimal,
}:
mkDerivation {
path = "lib/librthread";
libcMinimal = true;
outputs = [
"out"
"dev"
];
makeFlags = [ "LIBCSRCDIR=../libc" ];
env.NIX_CFLAGS_COMPILE = "-Wno-error";
extraPaths = [
"lib/libpthread"
libcMinimal.path
#"sys"
];
meta.platforms = lib.platforms.openbsd;
}

View File

@@ -0,0 +1,39 @@
{
lib,
mkDerivation,
libcMinimal,
bsdSetupHook,
openbsdSetupHook,
makeMinimal,
byacc,
install,
tsort,
lorder,
mandoc,
statHook,
}:
mkDerivation {
path = "lib/libutil";
libcMinimal = true;
outputs = [
"out"
"man"
];
nativeBuildInputs = [
bsdSetupHook
openbsdSetupHook
makeMinimal
byacc
install
tsort
lorder
mandoc
statHook
];
meta.platforms = lib.platforms.openbsd;
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "bin/ln";
}

View File

@@ -0,0 +1,12 @@
{
mkDerivation,
libutil,
}:
mkDerivation {
path = "usr.bin/login";
buildInputs = [
libutil
];
meta.mainProgram = "login";
}

View File

@@ -0,0 +1,10 @@
{
mkDerivation,
}:
mkDerivation {
path = "libexec/login_passwd";
postPatch = ''
sed -i 's/4555/0555/' $BSDSRCDIR/libexec/login_passwd/Makefile
'';
}

View File

@@ -0,0 +1,21 @@
{
lib,
mkDerivation,
bsdSetupHook,
openbsdSetupHook,
makeMinimal,
install,
}:
mkDerivation {
noCC = true;
path = "usr.bin/lorder";
nativeBuildInputs = [
bsdSetupHook
openbsdSetupHook
makeMinimal
install
];
meta.platforms = lib.platforms.unix;
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "bin/ls";
}

View File

@@ -0,0 +1,15 @@
NetBSD make prefers `.-include` to `sinclude` (without a dot)
diff --git a/share/mk/bsd.dep.mk b/share/mk/bsd.dep.mk
index 7019adb57f7..277064eb5c2 100644
--- a/share/mk/bsd.dep.mk
+++ b/share/mk/bsd.dep.mk
@@ -11,7 +11,7 @@ depend:
# catch22: don't include potentially bogus files we are going to clean
. if !(make(clean) || make(cleandir) || make(obj))
. for o in ${DEPS}
- sinclude $o
+. -include "$o"
. endfor
. endif
.endif

View File

@@ -0,0 +1,46 @@
{
fetchpatch,
lib,
mkDerivation,
}:
mkDerivation {
path = "share/mk";
noCC = true;
buildInputs = [ ];
nativeBuildInputs = [ ];
dontBuild = true;
patches = [
# Use `$AR` not hardcoded `ar`
(fetchpatch {
name = "use-ar-variable.patch";
url = "https://marc.info/?l=openbsd-tech&m=171575284906018&q=raw";
hash = "sha256-bigxJGbaf9mCmFXxLVzQpnUUaEMMDfF3eZkTXVzd6B8=";
})
./netbsd-make-sinclude.patch
# Support for a new NOBLIBSTATIC make variable
(fetchpatch {
name = "nolibstatic-support.patch";
url = "https://marc.info/?l=openbsd-tech&m=171972639411562&q=raw";
hash = "sha256-p4izV6ZXkfgJud+ZZU1Wqr5qFuHUzE6qVXM7QnXvV3k=";
includes = [ "share/mk/*" ];
})
];
postPatch = ''
sed -i -E \
-e 's|/usr/lib|\$\{LIBDIR\}|' \
share/mk/bsd.prog.mk
substituteInPlace share/mk/bsd.obj.mk --replace-fail /bin/pwd pwd
'';
installPhase = ''
cp -r share/mk $out
'';
meta.platforms = lib.platforms.unix;
}

View File

@@ -0,0 +1,18 @@
diff --git a/etc/MAKEDEV.common b/etc/MAKEDEV.common
index 1e7bb3d235a..1cc64a38985 100644
--- a/etc/MAKEDEV.common
+++ b/etc/MAKEDEV.common
@@ -315,10 +315,10 @@ _mkdev(pty, pty*, {-if [ $U -gt 15 ]; then
echo bad unit for pty in: $i
continue
fi
- set -A letters p q r s t u v w x y z P Q R S T
- set -A suffixes 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q \
+ letters=(p q r s t u v w x y z P Q R S T)
+ suffixes=(0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q \
r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X \
- Y Z
+ Y Z)
name=${letters[$U]}
n=0

View File

@@ -0,0 +1,37 @@
{
mkDerivation,
runtimeShell,
m4,
}:
mkDerivation {
pname = "MAKEDEV";
path = "etc";
patches = [ ./bash.patch ];
extraNativeBuildInputs = [
m4
];
preBuild = ''
mkdir -p $out/share/doc
'';
buildTargets = [ "MAKEDEV" ];
# patch some build artifacts
# gnu m4 doesn't seem to recognize the expr() macro but it's only used for simple arithmetic so we convert it to bash
postBuild = ''
substituteInPlace etc.$TARGET_MACHINE_ARCH/MAKEDEV --replace-fail "/bin/sh -" "${runtimeShell}"
sed -E -i -e '/^PATH=.*/d' -e 's/expr\((.*)\)/$((\1))/g' etc.$TARGET_MACHINE_ARCH/MAKEDEV
'';
# The install procedure is also weird since this is supposed to live in /dev
postInstall = ''
mkdir -p $out/bin
cp etc.$TARGET_MACHINE_ARCH/MAKEDEV $out/bin
chmod +x $out/bin/MAKEDEV
'';
meta.mainProgram = "MAKEDEV";
}

View File

@@ -0,0 +1,343 @@
diff --git a/usr.sbin/makefs/cd9660.c b/usr.sbin/makefs/cd9660.c
index 9fbcc5d0dbc..6b68508585a 100644
--- a/usr.sbin/makefs/cd9660.c
+++ b/usr.sbin/makefs/cd9660.c
@@ -97,6 +97,7 @@
*/
#include <sys/queue.h>
+#include <sys/param.h>
#include <string.h>
#include <ctype.h>
diff --git a/usr.sbin/makefs/cd9660.h b/usr.sbin/makefs/cd9660.h
index f3b8d2238be..178ab84bf04 100644
--- a/usr.sbin/makefs/cd9660.h
+++ b/usr.sbin/makefs/cd9660.h
@@ -37,7 +37,7 @@
#define _MAKEFS_CD9660_H
#include <sys/queue.h>
-#include <sys/endian.h>
+#include <sys/param.h>
#include <assert.h>
#include <errno.h>
diff --git a/usr.sbin/makefs/cd9660/cd9660_conversion.c b/usr.sbin/makefs/cd9660/cd9660_conversion.c
index d010c4002cf..6722891d77d 100644
--- a/usr.sbin/makefs/cd9660/cd9660_conversion.c
+++ b/usr.sbin/makefs/cd9660/cd9660_conversion.c
@@ -34,9 +34,9 @@
*/
#include "cd9660.h"
-#define bswap16 swap16
-#define bswap32 swap32
-
+#include <arpa/inet.h>
+#define bswap16 htons
+#define bswap32 htonl
static char cd9660_compute_gm_offset(time_t);
diff --git a/usr.sbin/makefs/cd9660/cd9660_strings.c b/usr.sbin/makefs/cd9660/cd9660_strings.c
index dd0622e0f10..acc9006848b 100644
--- a/usr.sbin/makefs/cd9660/cd9660_strings.c
+++ b/usr.sbin/makefs/cd9660/cd9660_strings.c
@@ -34,6 +34,7 @@
*/
#include <ctype.h>
+#include <stdint.h>
#include "makefs.h"
diff --git a/usr.sbin/makefs/cd9660/iso.h b/usr.sbin/makefs/cd9660/iso.h
index 3ed58d1dedc..96e7b96b35a 100644
--- a/usr.sbin/makefs/cd9660/iso.h
+++ b/usr.sbin/makefs/cd9660/iso.h
@@ -46,6 +46,8 @@
#ifndef _ISOFS_CD9660_ISO_H_
#define _ISOFS_CD9660_ISO_H_
+#include "compat.h"
+
#define ISODCL(from, to) (to - from + 1)
struct iso_volume_descriptor {
diff --git a/usr.sbin/makefs/compat.h b/usr.sbin/makefs/compat.h
new file mode 100644
index 00000000000..8cc830662bd
--- /dev/null
+++ b/usr.sbin/makefs/compat.h
@@ -0,0 +1,71 @@
+#pragma once
+#include <stdint.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#define u_int8_t uint8_t
+#define u_int16_t uint16_t
+#define u_int32_t uint32_t
+#define u_int64_t uint64_t
+typedef unsigned char u_char;
+typedef unsigned short u_short;
+typedef unsigned int u_int;
+typedef unsigned long u_long;
+typedef uint64_t dev_t;
+typedef int64_t off_t;
+#define __unused
+#define __dead
+#define pledge(x, y) 0
+#define unveil(x, y) 0
+#define srandom_deterministic srandom
+#define MAXBSIZE (64 * 1024)
+
+static inline void errc(int status, int code, const char *fmt, ...) {
+ // TODO
+ printf("You're outta here!\n");
+ exit(status);
+}
+
+static inline void warnc(int code, const char *fmt, ...) {
+ // TODO
+ printf("You're outta here!\n");
+}
+
+static inline int scan_scaled(char* number_w_scale, long long *result) {
+ int number, fraction = 0;
+ char scale[3];
+ long long tresult;
+ if (sscanf(number_w_scale, "%d.%1d%2s", &number, &fraction, &scale[0]) == 3 ||
+ sscanf(number_w_scale, "%d%2s", &number, &scale[0]) == 2) {
+ tresult = number * 10 + fraction;
+ switch (scale[0]) {
+ case 'E':
+ tresult *= 1024;
+ case 'P':
+ tresult *= 1024;
+ case 'T':
+ tresult *= 1024;
+ case 'G':
+ tresult *= 1024;
+ case 'M':
+ tresult *= 1024;
+ case 'K':
+ tresult *= 1024;
+ case 'B':
+ case ' ':
+ case '\0':
+ break;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+ tresult /= 10;
+ *result = tresult;
+ return 0;
+ } else {
+ errno = EINVAL;
+ return -1;
+ }
+}
diff --git a/usr.sbin/makefs/ffs.c b/usr.sbin/makefs/ffs.c
index b055c62a598..c99cbfef5a7 100644
--- a/usr.sbin/makefs/ffs.c
+++ b/usr.sbin/makefs/ffs.c
@@ -198,7 +198,7 @@ ffs_parse_opts(const char *option, fsinfo_t *fsopts)
if (strcmp(ffs_options[rv].name, "disklabel") == 0) {
struct disklabel *dp;
- dp = getdiskbyname(buf);
+ dp = NULL;
if (dp == NULL)
errx(1, "unknown disk type: %s", buf);
@@ -603,8 +603,8 @@ ffs_build_dinode1(struct ufs1_dinode *dinp, dirbuf_t *dbufp, fsnode *cur,
dinp->di_mode = cur->inode->st.st_mode;
dinp->di_nlink = cur->inode->nlink;
dinp->di_size = cur->inode->st.st_size;
- dinp->di_flags = cur->inode->st.st_flags;
- dinp->di_gen = cur->inode->st.st_gen;
+ dinp->di_flags = 0;
+ dinp->di_gen = 0;
dinp->di_uid = cur->inode->st.st_uid;
dinp->di_gid = cur->inode->st.st_gid;
@@ -645,8 +645,8 @@ ffs_build_dinode2(struct ufs2_dinode *dinp, dirbuf_t *dbufp, fsnode *cur,
dinp->di_mode = cur->inode->st.st_mode;
dinp->di_nlink = cur->inode->nlink;
dinp->di_size = cur->inode->st.st_size;
- dinp->di_flags = cur->inode->st.st_flags;
- dinp->di_gen = cur->inode->st.st_gen;
+ dinp->di_flags = 0;
+ dinp->di_gen = 0;
dinp->di_uid = cur->inode->st.st_uid;
dinp->di_gid = cur->inode->st.st_gid;
diff --git a/usr.sbin/makefs/ffs/buf.c b/usr.sbin/makefs/ffs/buf.c
index ce512c7d389..8130f7e9cbc 100644
--- a/usr.sbin/makefs/ffs/buf.c
+++ b/usr.sbin/makefs/ffs/buf.c
@@ -47,6 +47,7 @@
#include "makefs.h"
#include "buf.h"
+#include "compat.h"
TAILQ_HEAD(buftailhead,mkfsbuf) buftail;
diff --git a/usr.sbin/makefs/include/machine/disklabel.h b/usr.sbin/makefs/include/machine/disklabel.h
new file mode 100644
index 00000000000..7c5aa45c998
--- /dev/null
+++ b/usr.sbin/makefs/include/machine/disklabel.h
@@ -0,0 +1,7 @@
+#define LABELSECTOR 1
+#define LABELOFFSET 0
+#define MAXPARTITIONS 16
+
+static inline struct disklabel *getdiskbyname(const char *name) {
+ return (void*)0;
+}
diff --git a/usr.sbin/makefs/include/msdosfs/bootsect.h b/usr.sbin/makefs/include/msdosfs/bootsect.h
new file mode 100644
index 00000000000..02e88ac2b9c
--- /dev/null
+++ b/usr.sbin/makefs/include/msdosfs/bootsect.h
@@ -0,0 +1 @@
+#include <bsdroot/sys/msdosfs/bootsect.h>
diff --git a/usr.sbin/makefs/include/msdosfs/bpb.h b/usr.sbin/makefs/include/msdosfs/bpb.h
new file mode 100644
index 00000000000..08598cc217b
--- /dev/null
+++ b/usr.sbin/makefs/include/msdosfs/bpb.h
@@ -0,0 +1 @@
+#include <bsdroot/sys/msdosfs/bpb.h>
diff --git a/usr.sbin/makefs/include/sys/disklabel.h b/usr.sbin/makefs/include/sys/disklabel.h
new file mode 100644
index 00000000000..f382f87226c
--- /dev/null
+++ b/usr.sbin/makefs/include/sys/disklabel.h
@@ -0,0 +1 @@
+#include <bsdroot/sys/sys/disklabel.h>
diff --git a/usr.sbin/makefs/include/sys/endian.h b/usr.sbin/makefs/include/sys/endian.h
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/usr.sbin/makefs/include/sys/uuid.h b/usr.sbin/makefs/include/sys/uuid.h
new file mode 100644
index 00000000000..7c2abace377
--- /dev/null
+++ b/usr.sbin/makefs/include/sys/uuid.h
@@ -0,0 +1,2 @@
+#include "compat.h"
+#include <bsdroot/sys/sys/uuid.h>
diff --git a/usr.sbin/makefs/include/ufs/ffs/fs.h b/usr.sbin/makefs/include/ufs/ffs/fs.h
new file mode 100644
index 00000000000..d7905d33c2a
--- /dev/null
+++ b/usr.sbin/makefs/include/ufs/ffs/fs.h
@@ -0,0 +1,2 @@
+#include "compat.h"
+#include <bsdroot/sys/ufs/ffs/fs.h>
diff --git a/usr.sbin/makefs/include/ufs/ufs/dinode.h b/usr.sbin/makefs/include/ufs/ufs/dinode.h
new file mode 100644
index 00000000000..0d29007bdd1
--- /dev/null
+++ b/usr.sbin/makefs/include/ufs/ufs/dinode.h
@@ -0,0 +1,2 @@
+#include "compat.h"
+#include <bsdroot/sys/ufs/ufs/dinode.h>
diff --git a/usr.sbin/makefs/include/ufs/ufs/dir.h b/usr.sbin/makefs/include/ufs/ufs/dir.h
new file mode 100644
index 00000000000..9ec3e81be3d
--- /dev/null
+++ b/usr.sbin/makefs/include/ufs/ufs/dir.h
@@ -0,0 +1 @@
+#include <bsdroot/sys/ufs/ufs/dir.h>
diff --git a/usr.sbin/makefs/include/util.h b/usr.sbin/makefs/include/util.h
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/usr.sbin/makefs/makefs.c b/usr.sbin/makefs/makefs.c
index af39605d996..10d86fa10e2 100644
--- a/usr.sbin/makefs/makefs.c
+++ b/usr.sbin/makefs/makefs.c
@@ -44,8 +44,10 @@
#include <string.h>
#include <unistd.h>
#include <util.h>
+#include <time.h>
#include "makefs.h"
+#include "compat.h"
/*
* list of supported file systems and dispatch functions
diff --git a/usr.sbin/makefs/makefs.h b/usr.sbin/makefs/makefs.h
index 303ec7a2c46..6d72859532e 100644
--- a/usr.sbin/makefs/makefs.h
+++ b/usr.sbin/makefs/makefs.h
@@ -41,6 +41,8 @@
#include <sys/stat.h>
#include <err.h>
+#include <stdint.h>
+#include <stddef.h>
/*
* fsnode -
diff --git a/usr.sbin/makefs/msdos/denode.h b/usr.sbin/makefs/msdos/denode.h
index 48cdf968945..baf3dc3d807 100644
--- a/usr.sbin/makefs/msdos/denode.h
+++ b/usr.sbin/makefs/msdos/denode.h
@@ -50,6 +50,8 @@
#ifndef _MSDOSFS_DENODE_H_
#define _MSDOSFS_DENODE_H_
+#include "compat.h"
+
struct genfs_node {
};
struct mkfsvnode;
diff --git a/usr.sbin/makefs/msdos/direntry.h b/usr.sbin/makefs/msdos/direntry.h
index 77f8d7dd657..9c3a19bae8c 100644
--- a/usr.sbin/makefs/msdos/direntry.h
+++ b/usr.sbin/makefs/msdos/direntry.h
@@ -48,6 +48,8 @@
* October 1992
*/
+#include "compat.h"
+
/*
* Structure of a dos directory entry.
*/
diff --git a/usr.sbin/makefs/msdos/mkfs_msdos.c b/usr.sbin/makefs/msdos/mkfs_msdos.c
index c9aa0877b7a..e72f1680585 100644
--- a/usr.sbin/makefs/msdos/mkfs_msdos.c
+++ b/usr.sbin/makefs/msdos/mkfs_msdos.c
@@ -596,7 +596,6 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op)
tm = localtime(&now);
img = emalloc(bpb.bps);
dir = bpb.res + (bpb.spf ? bpb.spf : bpb.bspf) * bpb.nft;
- signal(SIGINFO, infohandler);
for (lsn = 0; lsn < dir + (o.fat_type == 32 ? bpb.spc : rds); lsn++) {
if (got_siginfo) {
fprintf(stderr,"%s: writing sector %u of %u (%u%%)\n",
diff --git a/usr.sbin/makefs/msdos/msdosfs_conv.c b/usr.sbin/makefs/msdos/msdosfs_conv.c
index 7b73c19bd6e..d38f035a87c 100644
--- a/usr.sbin/makefs/msdos/msdosfs_conv.c
+++ b/usr.sbin/makefs/msdos/msdosfs_conv.c
@@ -52,8 +52,8 @@
* System include files.
*/
#include <sys/time.h>
-#include <sys/dirent.h>
-#include <sys/lock.h>
+#include <sys/param.h> // howmany
+#include "compat.h"
/*
* MSDOSFS include files.

View File

@@ -0,0 +1,17 @@
{ mkDerivation, lib }:
mkDerivation {
path = "usr.sbin/makefs";
extraPaths = [
"sys/sys"
"sys/ufs"
"sys/msdosfs"
"sys/dev"
];
patches = [ ./compat.patch ];
preBuild = ''
mkdir -p $BSDSRCDIR/usr.sbin/makefs/include
ln -s $BSDSRCDIR $BSDSRCDIR/usr.sbin/makefs/include/bsdroot
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I$BSDSRCDIR/usr.sbin/makefs/include"
'';
meta.platforms = lib.platforms.all;
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "bin/md5";
}

View File

@@ -0,0 +1,108 @@
{
lib,
stdenv,
stdenvNoCC,
stdenvNoLibc,
stdenvLibcMinimal,
runCommand,
rsync,
source,
bsdSetupHook,
openbsdSetupHook,
makeMinimal,
install,
tsort,
lorder,
}:
lib.makeOverridable (
attrs:
let
stdenv' =
if attrs.noCC or false then
stdenvNoCC
else if attrs.noLibc or false then
stdenvNoLibc
else if attrs.libcMinimal or false then
stdenvLibcMinimal
else
stdenv;
machineMap = {
aarch64 = "arm64";
armv7l = "armv7";
i486 = "i386";
i586 = "i386";
i686 = "i386";
x86_64 = "amd64";
};
archMap = {
aarch64 = "aarch64";
armv7l = "arm";
i486 = "i386";
i586 = "i386";
i686 = "i386";
x86_64 = "amd64";
};
in
stdenv'.mkDerivation (
rec {
pname = "${attrs.pname or (baseNameOf attrs.path)}-openbsd";
version = "0";
src = runCommand "${pname}-filtered-src" { nativeBuildInputs = [ rsync ]; } ''
for p in ${lib.concatStringsSep " " ([ attrs.path ] ++ attrs.extraPaths or [ ])}; do
set -x
path="$out/$p"
mkdir -p "$(dirname "$path")"
src_path="${source}/$p"
if [[ -d "$src_path" ]]; then src_path+=/; fi
rsync --chmod="+w" -r "$src_path" "$path"
set +x
done
'';
extraPaths = [ ];
nativeBuildInputs = [
bsdSetupHook
openbsdSetupHook
makeMinimal
install
tsort
lorder
]
++ (attrs.extraNativeBuildInputs or [ ]);
HOST_SH = stdenv'.shell;
MACHINE = machineMap.${stdenv'.hostPlatform.parsed.cpu.name};
MACHINE_ARCH = archMap.${stdenv'.hostPlatform.parsed.cpu.name};
MACHINE_CPU = MACHINE_ARCH;
TARGET_MACHINE_ARCH = archMap.${stdenv'.targetPlatform.parsed.cpu.name};
TARGET_MACHINE_CPU = TARGET_MACHINE_ARCH;
COMPONENT_PATH = attrs.path or null;
strictDeps = true;
meta = with lib; {
maintainers = with maintainers; [ ericson2314 ];
platforms = platforms.openbsd;
license = licenses.bsd2;
};
}
// lib.optionalAttrs stdenv'.hasCC {
# TODO should CC wrapper set this?
CPP = "${stdenv'.cc.targetPrefix}cpp";
}
// lib.optionalAttrs (attrs.headersOnly or false) {
installPhase = "includesPhase";
dontBuild = true;
}
// lib.optionalAttrs stdenv'.hostPlatform.isStatic { NOLIBSHARED = true; }
// (removeAttrs attrs [ "extraNativeBuildInputs" ])
)
)

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "bin/mkdir";
}

View File

@@ -0,0 +1,9 @@
{
lib,
mkDerivation,
}:
mkDerivation {
path = "sbin/mknod";
meta.mainProgram = "mknod";
meta.platforms = lib.platforms.openbsd;
}

View File

@@ -0,0 +1,9 @@
{
mkDerivation,
}:
mkDerivation {
path = "sbin/mount";
meta.mainProgram = "mount";
patches = [ ./search-path.patch ];
}

View File

@@ -0,0 +1,39 @@
diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c
index eaff190b572..4bce21559f6 100644
--- a/sbin/mount/mount.c
+++ b/sbin/mount/mount.c
@@ -338,12 +338,6 @@ mountfs(const char *vfstype, const char *spec, const char *name,
{
char *cp;
- /* List of directories containing mount_xxx subcommands. */
- static const char *edirs[] = {
- _PATH_SBIN,
- _PATH_USRSBIN,
- NULL
- };
const char **argv, **edir;
struct statfs sf;
pid_t pid;
@@ -427,15 +421,12 @@ mountfs(const char *vfstype, const char *spec, const char *name,
return (1);
case 0: /* Child. */
/* Go find an executable. */
- edir = edirs;
- do {
- (void)snprintf(execname,
- sizeof(execname), "%s/mount_%s", *edir, vfstype);
- argv[0] = execname;
- execv(execname, (char * const *)argv);
- if (errno != ENOENT)
- warn("exec %s for %s", execname, name);
- } while (*++edir != NULL);
+ (void)snprintf(execname,
+ sizeof(execname), "mount_%s", vfstype);
+ argv[0] = execname;
+ execvp(execname, (char * const *)argv);
+ if (errno != ENOENT)
+ warn("exec %s for %s", execname, name);
if (errno == ENOENT)
warn("no mount helper program found for %s", vfstype);

View File

@@ -0,0 +1,8 @@
{
mkDerivation,
}:
mkDerivation {
path = "sbin/mount_ffs";
extraPaths = [ "sbin/mount" ];
}

View File

@@ -0,0 +1,12 @@
{
lib,
mkDerivation,
}:
mkDerivation {
path = "sbin/mount_msdos";
extraPaths = [
"sbin/mount"
];
meta.mainProgram = "mount_msdos";
meta.platforms = lib.platforms.openbsd;
}

View File

@@ -0,0 +1,8 @@
{
mkDerivation,
}:
mkDerivation {
path = "sbin/mount_tmpfs";
extraPaths = [ "sbin/mount" ];
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "bin/mt";
}

View File

@@ -0,0 +1,6 @@
{
mkDerivation,
}:
mkDerivation {
path = "usr.sbin/mtree";
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "bin/mv";
}

View File

@@ -0,0 +1,14 @@
{
lib,
mkDerivation,
}:
mkDerivation {
path = "sbin/newfs";
extraPaths = [
"sbin/mount"
"sbin/disklabel"
];
meta.mainProgram = "newfs";
meta.platforms = lib.platforms.openbsd;
}

View File

@@ -0,0 +1,10 @@
{
lib,
mkDerivation,
}:
mkDerivation {
path = "sbin/newfs_msdos";
meta.mainProgram = "newfs_msdos";
meta.platforms = lib.platforms.openbsd;
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "usr.bin/newsyslog";
}

View File

@@ -0,0 +1,3 @@
{ makeSetupHook }:
makeSetupHook { name = "openbsd-setup-hook"; } ./setup-hook.sh

View File

@@ -0,0 +1,39 @@
addOpenBSDMakeFlags() {
prependToVar makeFlags "INCSDIR=${!outputDev}/include"
prependToVar makeFlags "MANDIR=${!outputMan}/share/man"
# Variables are used to declare dependencies, but we handle them with cc-wrapper
prependToVar makeFlags "CRTBEGIN="
prependToVar makeFlags "CRTEND="
prependToVar makeFlags "LIBCRT0="
prependToVar makeFlags "LIBC="
}
fixOpenBSDInstallDirs() {
find "$BSDSRCDIR" -name Makefile -exec \
sed -i -E \
-e 's|/usr/include|${INCSDIR}|' \
-e 's|/usr/bin|${BINDIR}|' \
-e 's|/usr/lib|${LIBDIR}|' \
{} \;
}
setBinownBingrp() {
export BINOWN=$(id -u)
export BINGRP=$(id -g)
}
makeOpenBSDUnversionedLinks() {
[[ -d "$out/lib" ]] || return 0
pushd "$out/lib"
local l
for l in lib*.so.*; do
l="${l//.so.*/}"
[[ ! -f "$l.so" ]] || continue
ln -s "$l".so.* "$l.so"
done
popd
}
preConfigureHooks+=(addOpenBSDMakeFlags)
postPatchHooks+=(fixOpenBSDInstallDirs setBinownBingrp)
preFixupHooks+=(makeOpenBSDUnversionedLinks)

View File

@@ -0,0 +1,16 @@
{
mkDerivation,
byacc,
}:
mkDerivation {
path = "sbin/pfctl";
extraPaths = [
"sys/net"
];
extraNativeBuildInputs = [
byacc
];
meta.mainProgram = "pfctl";
}

View File

@@ -0,0 +1,10 @@
{
mkDerivation,
}:
mkDerivation {
path = "usr.bin/pkill";
postPatch = ''
sed -i /DPADD/d $BSDSRCDIR/usr.bin/pkill/Makefile
'';
}

View File

@@ -0,0 +1,8 @@
{ mkDerivation }:
mkDerivation {
path = "bin/ps";
postPatch = ''
sed -i /DPADD/d $BSDSRCDIR/bin/ps/Makefile
'';
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "bin/pwd";
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation, ... }:
mkDerivation {
path = "usr.sbin/pwd_mkdb";
}

View File

@@ -0,0 +1,19 @@
When /bin/sh is bash, this code doesn't work right - bash has a "tail call"
optimization where the last command in a finite script will be run as if with
exec instead of forking a new shell. rc here expects `pkill -P $$` (kill all
processes with parent pid == shell) to effectively background a process, but
instead it kills it!
diff --git a/etc/rc.d/rc.subr b/etc/rc.d/rc.subr
index 1f872f0ebc8..0c32b00e2ef 100644
--- a/etc/rc.d/rc.subr
+++ b/etc/rc.d/rc.subr
@@ -178,7 +178,7 @@ rc_exec() {
${daemon_execdir:+cd ${daemon_execdir} && } \
$@ \
${daemon_logger:+ 2>&1 |
- logger -isp ${daemon_logger} -t ${_name}}"
+ logger -isp ${daemon_logger} -t ${_name}}; exit"
}
rc_start() {

View File

@@ -0,0 +1,146 @@
OpenBSD's rc is supremely, supremely uncooperative when it comes to
customization and configuration, providing exactly two places to inject
services (pkg_scripts from rc.conf and /etc/rc.local), which are very much not
useful for configuring more intimate parts of the boot process. This patch
pulls the scripts to start at various injection points from /etc/rc.order. It
also removes some of the parts of the boot script which are inappropriate for a
nix-based system, for example, re-linking code objects and setting PATH.
diff --git a/etc/rc b/etc/rc
index 9d87fac8caf..581c1e3f4ab 100644
--- a/etc/rc
+++ b/etc/rc
@@ -9,6 +9,10 @@ set +o sh
# Subroutines (have to come first).
+daemon_phase() {
+ . /etc/rc.order/$1
+}
+
# Strip in- and whole-line comments from a file.
# Strip leading and trailing whitespace if IFS is set.
# Usage: stripcom /path/to/file
@@ -337,7 +341,6 @@ trap : 3 # Shouldn't be needed.
export HOME=/
export INRC=1
-export PATH=/sbin:/bin:/usr/sbin:/usr/bin
# /etc/myname contains my symbolic name.
if [[ -f /etc/myname ]]; then
@@ -413,17 +416,12 @@ fi
# From now on, allow user to interrupt (^C) the boot process.
trap "echo 'Boot interrupted.'; exit 1" 3
-# Unmount all filesystems except root.
-umount -a >/dev/null 2>&1
-
# Mount all filesystems except those of type NFS and VND.
mount -a -t nonfs,vnd
# Re-mount the root filesystem read/writeable. (root on nfs requires this,
# others aren't hurt.)
mount -uw /
-chmod og-rwx /bsd
-ln -fh /bsd /bsd.booted
rm -f /fastboot
@@ -483,9 +481,9 @@ mount -s /var >/dev/null 2>&1 # cannot be on NFS
mount -s /var/log >/dev/null 2>&1 # cannot be on NFS
mount -s /usr >/dev/null 2>&1 # if NFS, fstab must use IP address
-reorder_libs 2>&1 |&
+daemon_phase 10
-start_daemon slaacd dhcpleased resolvd >/dev/null 2>&1
+daemon_phase 20
echo 'starting network'
@@ -495,12 +493,10 @@ ifconfig -g carp carpdemote 128
sh /etc/netstart
-start_daemon unwind >/dev/null 2>&1
+daemon_phase 30
random_seed
-wait_reorder_libs
-
# Load pf rules and bring up pfsync interface.
if [[ $pf != NO ]]; then
if [[ -f /etc/pf.conf ]]; then
@@ -522,8 +518,7 @@ dmesg >/var/run/dmesg.boot
make_keys
echo -n 'starting early daemons:'
-start_daemon syslogd ldattach pflogd nsd unbound ntpd
-start_daemon iscsid isakmpd iked sasyncd ldapd npppd
+daemon_phase 40
echo '.'
# Load IPsec rules.
@@ -532,11 +527,7 @@ if [[ $ipsec != NO && -f /etc/ipsec.conf ]]; then
fi
echo -n 'starting RPC daemons:'
-start_daemon portmap
-if [[ -n $(domainname) ]]; then
- start_daemon ypldap ypserv ypbind
-fi
-start_daemon mountd nfsd lockd statd amd
+daemon_phase 50
echo '.'
# Check and mount remaining file systems and enable additional swap.
@@ -626,43 +617,24 @@ echo 'preserving editor files.'; /usr/libexec/vi.recover
run_upgrade_script sysmerge
echo -n 'starting network daemons:'
-start_daemon ldomd sshd snmpd ldpd ripd ospfd ospf6d bgpd ifstated
-start_daemon relayd dhcpd dhcrelay mrouted dvmrpd radiusd eigrpd route6d
-start_daemon rad hostapd lpd smtpd slowcgi bgplgd httpd ftpd
-start_daemon ftpproxy ftpproxy6 tftpd tftpproxy identd inetd rarpd bootparamd
-start_daemon rbootd mopd vmd spamd spamlogd sndiod
+daemon_phase 60
echo '.'
# If rc.firsttime exists, run it just once, and make sure it is deleted.
run_upgrade_script firsttime
-# Run rc.d(8) scripts from packages.
-if [[ -n $pkg_scripts ]]; then
- echo -n 'starting package daemons:'
- for _daemon in $pkg_scripts; do
- if [[ -x /etc/rc.d/$_daemon ]]; then
- start_daemon $_daemon
- else
- echo -n " ${_daemon}(absent)"
- fi
- done
- echo '.'
-fi
-
[[ -f /etc/rc.local ]] && sh /etc/rc.local
+daemon_phase 70
+
# Disable carp interlock.
ifconfig -g carp -carpdemote 128
mixerctl_conf
echo -n 'starting local daemons:'
-start_daemon apmd sensorsd hotplugd watchdogd cron wsmoused xenodm
+daemon_phase 80
echo '.'
-# Re-link the kernel, placing the objects in a random order.
-# Replace current with relinked kernel and inform root about it.
-/usr/libexec/reorder_kernel &
-
date
exit 0

View File

@@ -0,0 +1,21 @@
{
mkDerivation,
}:
mkDerivation {
pname = "rc";
path = "etc";
patches = [
./boot-phases.patch
./binsh-is-bash.patch
];
buildPhase = ":";
installPhase = ''
mkdir -p $out/etc/rc.d
cp rc $out/etc
cp rc.d/rc.subr $out/etc/rc.d
chmod +x $out/etc/rc
'';
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "sbin/reboot";
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "bin/rm";
}

View File

@@ -0,0 +1,4 @@
{ mkDerivation }:
mkDerivation {
path = "bin/rmdir";
}

Some files were not shown because too many files have changed in this diff Show More