This commit is contained in:
Jeremy Soller 2025-08-24 08:29:04 -06:00
commit fc48fb9cf4
No known key found for this signature in database
GPG Key ID: 670FDFB5428E05CA
28 changed files with 634 additions and 176 deletions

View File

@ -288,6 +288,7 @@ function op {
;;
unstage)
rm -rfv "${COOKBOOK_STAGE}"
rm -fv "${TARGET_DIR}/auto_deps.toml"
;;
pkg)
pkgar \

View File

@ -15,12 +15,10 @@ dependencies = [
"shared-mime-info",
"zlib",
]
template = "custom"
script = """
DYNAMIC_INIT
cookbook_meson \
-Dbuiltin_loaders=all \
-Dgir=false \
-Dinstalled_tests=false \
-Dx11=false
"""
template = "meson"
mesonflags = [
"-Dbuiltin_loaders=all",
"-Dgir=false",
"-Dinstalled_tests=false",
"-Dx11=false",
]

View File

@ -4,24 +4,15 @@ blake3 = "a1b9e797a5058f5264d276805aef5643b7ea460916e491a0098ba32d87f1519e"
patches = ["redox.patch"]
[build]
dependencies = [
"libiconv",
"liborbital",
"libpng",
"pixman",
"sdl1",
"zlib",
dependencies = ["libiconv", "liborbital", "libpng", "pixman", "sdl1", "zlib"]
template = "cmake"
cmakeflags = [
"-DBUILD_QT=OFF",
"-DBUILD_SHARED=ON",
"-DBUILD_STATIC=OFF",
"-DUSE_SQLITE3=OFF",
"-DUSE_DEBUGGERS=OFF",
"-DBUILD_SDL=ON",
"-DSDL_VERSION=1.2",
"-DSDL_LIBRARY=-lSDL -lorbital",
]
template = "custom"
script = """
DYNAMIC_INIT
cookbook_cmake \
-DBUILD_QT=OFF \
-DBUILD_SHARED=ON \
-DBUILD_STATIC=OFF \
-DUSE_SQLITE3=OFF \
-DUSE_DEBUGGERS=OFF \
-DBUILD_SDL=ON \
-DSDL_VERSION="1.2" \
-DSDL_LIBRARY="-lSDL -lorbital"
"""

View File

@ -1,6 +1,7 @@
[source]
git = "https://github.com/OpenTTD/OpenTTD.git"
branch = "release/1.8"
shallow_clone = true
patches = ["redox.patch"]
[build]

View File

@ -1,13 +1,10 @@
[source]
tar = "https://ftp.gnu.org/gnu/wget/wget-1.21.4.tar.gz"
[build]
template = "custom"
dependencies = [
"openssl1",
]
script = """
COOKBOOK_CONFIGURE_FLAGS+=(
--with-ssl=openssl
)
cookbook_configure
"""
template = "configure"
configureflags = [
"--with-ssl=openssl"
]

View File

@ -5,7 +5,14 @@ branch = "master"
[build]
template = "custom"
script = """
mkdir -p ${COOKBOOK_STAGE}/share
cp -r ${COOKBOOK_SOURCE}/. ${COOKBOOK_STAGE}/share/
# only copy common TERM envar
mkdir -p ${COOKBOOK_STAGE}/share/terminfo/{a,d,l,s,t,v,x}
cp -r ${COOKBOOK_SOURCE}/tabset ${COOKBOOK_STAGE}/share/
cp ${COOKBOOK_SOURCE}/terminfo/a/ansi{,-*} ${COOKBOOK_STAGE}/share/terminfo/a/
cp ${COOKBOOK_SOURCE}/terminfo/d/dumb{,-*} ${COOKBOOK_STAGE}/share/terminfo/d/
cp ${COOKBOOK_SOURCE}/terminfo/l/linux{,-*} ${COOKBOOK_STAGE}/share/terminfo/l/
cp ${COOKBOOK_SOURCE}/terminfo/s/screen{,-*} ${COOKBOOK_STAGE}/share/terminfo/s/
cp ${COOKBOOK_SOURCE}/terminfo/t/tmux{,-*} ${COOKBOOK_STAGE}/share/terminfo/t/
cp ${COOKBOOK_SOURCE}/terminfo/v/vt100{,-*} ${COOKBOOK_STAGE}/share/terminfo/v/
cp ${COOKBOOK_SOURCE}/terminfo/x/xterm{,-*} ${COOKBOOK_STAGE}/share/terminfo/x/
"""

View File

@ -0,0 +1,17 @@
[source]
git = "https://gitlab.com/sortix/os-test"
[build]
template = "custom"
script = """
mkdir -pv "${COOKBOOK_STAGE}/share/os-test"
cp -rv "${COOKBOOK_SOURCE}"/* "${COOKBOOK_STAGE}/share/os-test"
"""
[package]
dependencies = [
"gnu-binutils",
"gnu-make",
"gcc13",
"libarchive",
]

View File

@ -1,2 +0,0 @@
GIT=https://gitlab.redox-os.org/redox-os/miniserve
BUILD_DEPENDS=(openssl1 zlib)

View File

@ -0,0 +1,6 @@
#TODO not compiled or tested
# build instructions: https://github.com/awslabs/flowgger/wiki/Installation
[source]
git = "https://github.com/awslabs/flowgger"
[build]
template = "cargo"

View File

@ -0,0 +1,8 @@
#TODO not compiled or tested
[source]
git = "https://github.com/hoxxep/rapidhash"
[build]
template = "custom"
script = """
cookbook_cargo_packages rapidhash
"""

View File

@ -0,0 +1,10 @@
#TODO not compiled or tested
[source]
git = "https://github.com/ccbrown/iocraft"
[build]
template = "custom"
script = """
cookbook_cargo_examples borders calculator counter \
fullscreen hello_world overlap progress_bar scrolling \
table use_input use_output weather
"""

View File

@ -0,0 +1,9 @@
#TODO not compiled or tested
[source]
git = "https://github.com/broccolingual/rustui"
[build]
template = "custom"
script = """
cookbook_cargo_examples hello_world colors inputs file_reader
cookbook_cargo_packages tetris
"""

View File

@ -0,0 +1,8 @@
#TODO not compiled or tested
[source]
git = "https://github.com/rezigned/tur"
[build]
template = "custom"
script = """
cookbook_cargo_packages tur-cli tur-tui
"""

View File

@ -0,0 +1,8 @@
#TODO not compiled or tested
[source]
git = "https://github.com/riffcc/lis"
[build]
template = "cargo"
dependencies = [
"libfuse3",
]

View File

@ -0,0 +1,5 @@
#TODO not compiled or tested
[source]
git = "https://github.com/doprz/dipc"
[build]
template = "cargo"

View File

@ -2,10 +2,8 @@
[source]
git = "https://github.com/Siriusmart/youtube-tui"
[build]
template = "custom"
template = "cargo"
cargoflags = "--no-default-features"
dependencies = [
"openssl1",
]
script = """
cookbook_cargo --no-default-features
"""

View File

@ -0,0 +1,12 @@
#TODO missing libc:: socket-related imports
[source]
git = "https://github.com/svenstaro/miniserve"
[build]
dependencies = [
"openssl1",
"zlib"
]
template = "cargo"

View File

@ -0,0 +1,8 @@
#TODO not compiled or tested
[source]
git = "https://github.com/fastn-stack/kulfi"
[build]
template = "custom"
script = """
cookbook_cargo_packages malai
"""

View File

@ -0,0 +1,5 @@
#TODO not compiled or tested
[source]
git = "https://github.com/n0-computer/dumbpipe"
[build]
template = "cargo"

View File

@ -0,0 +1,5 @@
#TODO not compiled or tested
[source]
git = "https://github.com/doEggi/do-ssh"
[build]
template = "cargo"

View File

@ -0,0 +1,5 @@
#TODO not compiled or tested
[source]
git = "https://github.com/rustonbsd/iroh-ssh"
[build]
template = "cargo"

View File

@ -0,0 +1,5 @@
#TODO not compiled or tested
[source]
git = "https://github.com/julianbuettner/zeco"
[build]
template = "cargo"

View File

@ -0,0 +1,5 @@
#TODO not compiled or tested
[source]
git = "https://github.com/0x676e67/vproxy"
[build]
template = "cargo"

View File

@ -0,0 +1,5 @@
#TODO not compiled or tested
[source]
git = "https://github.com/n0-computer/sendme"
[build]
template = "cargo"

View File

@ -1,13 +1,20 @@
#TODO update the patch to match the current version
#TODO does the patch is still needed?
#TODO compiled but not tested
#TODO lack of utmpx.h and resolv.h, expect dns not working
#TODO maybe actually implement utmpx.h in relibc?
[source]
tar = "https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.8p1.tar.gz"
patches = [
"redox.patch",
]
[build]
template = "configure"
template = "custom"
dependencies = [
"openssl1",
"zlib",
]
script = """
DYNAMIC_INIT
cookbook_configure
mv "${COOKBOOK_STAGE}"/usr/sbin/sshd "${COOKBOOK_STAGE}"/usr/bin/sshd
rmdir "${COOKBOOK_STAGE}"/usr/sbin
"""

View File

@ -1,138 +1,405 @@
diff -ruwN source/channels.c source-new/channels.c
--- source/channels.c 2018-10-16 18:01:20.000000000 -0600
+++ source-new/channels.c 2019-01-15 21:01:12.203686148 -0700
@@ -1865,10 +1865,10 @@
fatal(":%s: channel %d: no remote id", __func__, c->self);
/* for rdynamic the OPEN_CONFIRMATION has been sent already */
isopen = (c->type == SSH_CHANNEL_RDYNAMIC_FINISH);
- if (getsockopt(c->sock, SOL_SOCKET, SO_ERROR, &err, &sz) < 0) {
- err = errno;
- error("getsockopt SO_ERROR failed");
- }
+ // if (getsockopt(c->sock, SOL_SOCKET, SO_ERROR, &err, &sz) < 0) {
+ // err = errno;
+ // error("getsockopt SO_ERROR failed");
+ // }
if (err == 0) {
debug("channel %d: connected to %s port %d",
c->self, c->connect_ctx.host, c->connect_ctx.port);
diff -ruwN source/config.sub source-new/config.sub
--- source/config.sub 2018-10-16 18:01:20.000000000 -0600
+++ source-new/config.sub 2019-01-15 19:39:26.234492329 -0700
@@ -1407,7 +1407,7 @@
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
| -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \
- | -onefs* | -tirtos* | -phoenix*)
+ | -onefs* | -tirtos* | -phoenix* | -redox*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
diff -ruwN source/openbsd-compat/bindresvport.c source-new/openbsd-compat/bindresvport.c
--- source/openbsd-compat/bindresvport.c 2018-10-16 18:01:20.000000000 -0600
+++ source-new/openbsd-compat/bindresvport.c 2019-01-15 20:46:06.879804135 -0700
@@ -42,6 +42,10 @@
#include <errno.h>
#include <string.h>
diff -ruwN source/defines.h source-new/defines.h
--- source/defines.h 2024-07-01 11:36:28.000000000 +0700
+++ source-new/defines.h 2025-08-20 13:37:45.820728226 +0700
@@ -52,6 +52,18 @@
#define IPPORT_RESERVED 0
#endif
+#ifndef IPPORT_RESERVED
+#define IPPORT_RESERVED 1024
+#endif
+
#define STARTPORT 600
#define ENDPORT (IPPORT_RESERVED - 1)
#define NPORTS (ENDPORT - STARTPORT + 1)
diff -ruwN source/openbsd-compat/bsd-getpeereid.c source-new/openbsd-compat/bsd-getpeereid.c
--- source/openbsd-compat/bsd-getpeereid.c 2018-10-16 18:01:20.000000000 -0600
+++ source-new/openbsd-compat/bsd-getpeereid.c 2019-01-15 20:43:12.410583244 -0700
@@ -23,7 +23,7 @@
#include <unistd.h>
-#if defined(SO_PEERCRED)
+#if defined(SO_PEERCRED) && !defined(__redox__)
int
getpeereid(int s, uid_t *euid, gid_t *gid)
{
diff -ruwN source/openbsd-compat/bsd-misc.c source-new/openbsd-compat/bsd-misc.c
--- source/openbsd-compat/bsd-misc.c 2018-10-16 18:01:20.000000000 -0600
+++ source-new/openbsd-compat/bsd-misc.c 2019-01-15 20:28:46.619332501 -0700
@@ -25,6 +25,9 @@
# include <sys/time.h>
+#ifndef IN_LOOPBACKNET
+#define IN_LOOPBACKNET 127
+#endif
+
+#ifndef MAXDNAME
+#define MAXDNAME 256
+#endif
+
/*
* Definitions for IP type of service (ip_tos)
*/
@@ -454,19 +466,21 @@
# define _PATH_DEVNULL "/dev/null"
#endif
+#if defined(__redox__)
+#include <fcntl.h>
-/* user may have set a different path */
-#if defined(_PATH_MAILDIR) && defined(MAIL_DIRECTORY)
-# undef _PATH_MAILDIR
-#endif /* defined(_PATH_MAILDIR) && defined(MAIL_DIRECTORY) */
-
-#ifdef MAIL_DIRECTORY
-# define _PATH_MAILDIR MAIL_DIRECTORY
+#ifndef _PATH_MAILDIR
+# define _PATH_MAILDIR "/var/mail"
#endif
#ifndef _PATH_NOLOGIN
# define _PATH_NOLOGIN "/etc/nologin"
#endif
+#ifndef ST_RDONLY
+#define ST_RDONLY 1
+#endif
#include <string.h>
#include <signal.h>
+#ifndef ST_NOSUID
+#define ST_NOSUID 2
+#endif
+
/* Define this to be the path of the xauth program. */
#ifdef XAUTH_PATH
#define _PATH_XAUTH XAUTH_PATH
diff -ruwN source/hostfile.c source-new/hostfile.c
--- source/hostfile.c 2024-07-01 11:36:28.000000000 +0700
+++ source-new/hostfile.c 2025-08-20 11:51:28.964103232 +0700
@@ -44,7 +44,9 @@
#include <netinet/in.h>
#include <errno.h>
+#ifndef __redox__
#include <resolv.h>
+#endif
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
diff -ruwN source/loginrec.c source-new/loginrec.c
--- source/loginrec.c 2024-07-01 11:36:28.000000000 +0700
+++ source-new/loginrec.c 2025-08-20 13:43:02.970560664 +0700
@@ -1033,7 +1033,7 @@
return (0);
}
# else
- if (!utmpx_write_direct(li, &ut)) {
+ if (!utmpx_write_direct(li, &utx)) {
logit("%s: utmp_write_direct() failed", __func__);
return (0);
}
diff -ruwN source/loginrec.h source-new/loginrec.h
--- source/loginrec.h 2024-07-01 11:36:28.000000000 +0700
+++ source-new/loginrec.h 2025-08-20 13:39:08.570682776 +0700
@@ -30,6 +30,7 @@
**/
#include "includes.h"
+#include "openbsd-compat/utmpx.h"
struct ssh;
diff -ruwN source/openbsd-compat/bsd-statvfs.h source-new/openbsd-compat/bsd-statvfs.h
--- source/openbsd-compat/bsd-statvfs.h 2024-07-01 11:36:28.000000000 +0700
+++ source-new/openbsd-compat/bsd-statvfs.h 2025-08-20 13:37:42.000730245 +0700
@@ -37,13 +37,6 @@
typedef unsigned long fsfilcnt_t;
#endif
-#ifndef ST_RDONLY
-#define ST_RDONLY 1
-#endif
-#ifndef ST_NOSUID
-#define ST_NOSUID 2
-#endif
-
/* as defined in IEEE Std 1003.1, 2004 Edition */
struct statvfs {
unsigned long f_bsize; /* File system block size. */
diff -ruwN source/openbsd-compat/getrrsetbyname.c source-new/openbsd-compat/getrrsetbyname.c
--- source/openbsd-compat/getrrsetbyname.c 2018-10-16 18:01:20.000000000 -0600
+++ source-new/openbsd-compat/getrrsetbyname.c 2019-01-15 20:57:20.248721738 -0700
@@ -47,7 +47,7 @@
--- source/openbsd-compat/getrrsetbyname.c 2024-07-01 11:36:28.000000000 +0700
+++ source-new/openbsd-compat/getrrsetbyname.c 2025-08-20 13:51:15.020299084 +0700
@@ -67,6 +67,52 @@
#endif
#define _THREAD_PRIVATE(a,b,c) (c)
#include "includes.h"
+#ifdef __redox__
+
+#include <sys/types.h>
+#include <stdint.h>
+
+/*
+ * Minimalist replacement for <resolv.h> for systems that lack it,
+ * such as Redox OS. This provides the basic structures needed by
+ * the OpenSSH compatibility layer.
+ */
+
+// Define necessary constants
+#define MAXNS 3 /* max # name servers we'll track */
+#define MAXDNSRCH 6 /* max # domains in search path */
+#define MAXRESOLVSORT 10 /* number of nets to sort on */
+#define MAXDNAME 256 /* max length of a domain name */
+
+/*
+ * A simplified, portable version of the resolver state structure.
+ * Glibc-specific fields, hooks, and complex unions have been removed.
+ */
+struct __res_state {
+ int retrans; /* retransmission time interval */
+ int retry; /* number of times to retransmit */
+ unsigned long options; /* option flags */
+ int nscount; /* number of name servers */
+ struct sockaddr_in nsaddr_list[MAXNS]; /* address of name servers */
+ unsigned short id; /* current message id */
+ char *dnsrch[MAXDNSRCH + 1]; /* components of domain to search */
+ char defdname[MAXDNAME]; /* default domain name */
+
+ struct {
+ struct in_addr addr;
+ uint32_t mask;
+ } sort_list[MAXRESOLVSORT];
+
+ int res_h_errno; /* last error code for this context */
+
+ // Simplified bitfields, removing glibc internals
+ unsigned ndots : 4; /* threshold for initial abs. query */
+ unsigned nsort : 4; /* number of elements in sort_list[] */
+};
+
+typedef struct __res_state *res_state;
+#endif /* __redox */
+
#ifndef HAVE__RES_EXTERN
struct __res_state _res;
#endif
@@ -167,6 +213,24 @@
struct dns_rr *next;
};
-#if !defined (HAVE_GETRRSETBYNAME) && !defined (HAVE_LDNS)
+#if !defined (HAVE_GETRRSETBYNAME) && !defined (HAVE_LDNS) && !defined(__redox__)
+#ifdef __redox__
+typedef struct {
+ uint16_t id;
+ uint8_t rd : 1;
+ uint8_t tc : 1;
+ uint8_t aa : 1;
+ uint8_t opcode : 4;
+ uint8_t qr : 1;
+ uint8_t rcode : 4;
+ uint8_t z : 3;
+ uint8_t ra : 1;
+ uint16_t qdcount;
+ uint16_t ancount;
+ uint16_t nscount;
+ uint16_t arcount;
+} HEADER;
+#endif
+
struct dns_response {
HEADER header;
struct dns_query *query;
@@ -221,10 +285,10 @@
}
#include <stdlib.h>
#include <string.h>
/* initialize resolver */
- if ((_resp->options & RES_INIT) == 0 && res_init() == -1) {
+ // if (res_init() == -1) {
result = ERRSET_FAIL;
goto fail;
- }
+ // }
#ifdef DEBUG
_resp->options |= RES_DEBUG;
@@ -482,12 +546,12 @@
prev->next = curr;
/* name */
- length = dn_expand(answer, answer + size, *cp, name,
- sizeof(name));
- if (length < 0) {
+ // length = dn_expand(answer, answer + size, *cp, name,
+ // sizeof(name));
+ // if (length < 0) {
free_dns_query(head);
return (NULL);
- }
+ // }
curr->name = strdup(name);
if (curr->name == NULL) {
free_dns_query(head);
@@ -542,12 +606,12 @@
prev->next = curr;
/* name */
- length = dn_expand(answer, answer + size, *cp, name,
- sizeof(name));
- if (length < 0) {
+ // length = dn_expand(answer, answer + size, *cp, name,
+ // sizeof(name));
+ // if (length < 0) {
free_dns_rr(head);
return (NULL);
- }
+ // }
curr->name = strdup(name);
if (curr->name == NULL) {
free_dns_rr(head);
diff -ruwN source/openbsd-compat/getrrsetbyname.h source-new/openbsd-compat/getrrsetbyname.h
--- source/openbsd-compat/getrrsetbyname.h 2018-10-16 18:01:20.000000000 -0600
+++ source-new/openbsd-compat/getrrsetbyname.h 2019-01-15 19:54:39.564320719 -0700
@@ -50,7 +50,7 @@
#include "includes.h"
-#ifndef HAVE_GETRRSETBYNAME
+#if !defined(HAVE_GETRRSETBYNAME) && !defined(__redox__)
--- source/openbsd-compat/getrrsetbyname.h 2024-07-01 11:36:28.000000000 +0700
+++ source-new/openbsd-compat/getrrsetbyname.h 2025-08-20 11:51:00.744118526 +0700
@@ -54,9 +54,13 @@
#include <sys/types.h>
#include <netinet/in.h>
+#ifndef __redox__
#include <arpa/nameser.h>
+#endif
#include <netdb.h>
+#ifndef __redox__
#include <resolv.h>
+#endif
#ifndef HFIXEDSZ
#define HFIXEDSZ 12
diff -ruwN source/openbsd-compat/inet_ntop.c source-new/openbsd-compat/inet_ntop.c
--- source/openbsd-compat/inet_ntop.c 2024-07-01 11:36:28.000000000 +0700
+++ source-new/openbsd-compat/inet_ntop.c 2025-08-20 11:39:15.244488902 +0700
@@ -26,7 +26,9 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#ifndef __redox__
#include <arpa/nameser.h>
+#endif
#include <string.h>
#include <errno.h>
#include <stdio.h>
diff -ruwN source/openbsd-compat/openbsd-compat.h source-new/openbsd-compat/openbsd-compat.h
--- source/openbsd-compat/openbsd-compat.h 2018-10-16 18:01:20.000000000 -0600
+++ source-new/openbsd-compat/openbsd-compat.h 2019-01-15 20:14:24.316498869 -0700
@@ -36,6 +36,10 @@
--- source/openbsd-compat/openbsd-compat.h 2024-07-01 11:36:28.000000000 +0700
+++ source-new/openbsd-compat/openbsd-compat.h 2025-08-20 13:15:22.721439992 +0700
@@ -36,6 +36,8 @@
#include <stddef.h> /* for wchar_t */
+#if defined(__redox__)
+#include <stdio.h>
+#endif
+#include "getopt.h"
+
/* OpenBSD function replacements */
#include "base64.h"
#include "sigact.h"
diff -ruwN source/openbsd-compat/utmpx.c source-new/openbsd-compat/utmpx.c
--- source/openbsd-compat/utmpx.c 1970-01-01 07:00:00.000000000 +0700
+++ source-new/openbsd-compat/utmpx.c 2025-08-20 13:13:54.971486065 +0700
@@ -0,0 +1,13 @@
+#include "utmpx.h"
+#include <stddef.h> // For NULL
+
+#ifdef __redox__
+
+void endutxent(void) { /* Do nothing */ }
+struct utmpx *getutxent(void) { return NULL; }
+struct utmpx *getutxid(const struct utmpx *ut) { return NULL; }
+struct utmpx *getutxline(const struct utmpx *ut) { return NULL; }
+struct utmpx *pututxline(const struct utmpx *ut) { return NULL; }
+void setutxent(void) { /* Do nothing */ }
+
+#endif
\ No newline at end of file
diff -ruwN source/openbsd-compat/utmpx.h source-new/openbsd-compat/utmpx.h
--- source/openbsd-compat/utmpx.h 1970-01-01 07:00:00.000000000 +0700
+++ source-new/openbsd-compat/utmpx.h 2025-08-20 13:13:07.201511825 +0700
@@ -0,0 +1,69 @@
+#ifndef _COMPAT_UTMPX_H
+#define _COMPAT_UTMPX_H
+#ifdef __redox__
+#include <sys/types.h>
+#include <sys/time.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * This header provides a POSIX-compliant definition of the utmpx structure
+ * and related functions for systems that lack a native <utmpx.h>, such as Redox OS.
+ */
+
+// Define standard sizes for character arrays, based on common practice (e.g., Linux)
+#define UT_LINESIZE 32
+#define UT_NAMESIZE 32
+#define UT_HOSTSIZE 256
+#define UT_IDSIZE 4
+
+/*
+ * The utmpx structure, containing user accounting information.
+ */
+struct utmpx {
+ char ut_user[UT_NAMESIZE]; /* User login name */
+ char ut_id[UT_IDSIZE]; /* Unspecified terminal id */
+ char ut_line[UT_LINESIZE]; /* Device name of tty */
+ pid_t ut_pid; /* Process ID */
+ short ut_type; /* Type of entry */
+ struct timeval ut_tv; /* Time entry was made */
+ // Non-standard but very common fields, often needed for compatibility
+ char ut_host[UT_HOSTSIZE]; /* Host name for remote login */
+ // Padding to align the structure, if necessary
+ char __padding[16];
+};
+
+/*
+ * Symbolic constants for the ut_type field.
+ */
+#define EMPTY 0 /* No valid user accounting information */
+#define BOOT_TIME 1 /* Time of system boot */
+#define OLD_TIME 2 /* Time when system clock changed */
+#define NEW_TIME 3 /* Time after system clock changed */
+#define USER_PROCESS 4 /* A user process */
+#define INIT_PROCESS 5 /* A process spawned by the init process */
+#define LOGIN_PROCESS 6 /* The session leader of a logged-in user */
+#define DEAD_PROCESS 7 /* A session leader who has exited */
+
+/*
+ * Function prototypes for utmpx database manipulation.
+ *
+ * NOTE: These are stubs. Since Redox OS does not have a utmp/utmpx
+ * database, these functions won't have a real implementation. They
+ * are declared here to satisfy the linker.
+ */
+void endutxent(void);
+struct utmpx *getutxent(void);
+struct utmpx *getutxid(const struct utmpx *);
+struct utmpx *getutxline(const struct utmpx *);
+struct utmpx *pututxline(const struct utmpx *);
+void setutxent(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __redox__ */
+#endif /* _COMPAT_UTMPX_H */
\ No newline at end of file
diff -ruwN source/regress/netcat.c source-new/regress/netcat.c
--- source/regress/netcat.c 2024-07-01 11:36:28.000000000 +0700
+++ source-new/regress/netcat.c 2025-08-20 11:50:49.164126484 +0700
@@ -1384,7 +1384,9 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#ifndef __redox__
#include <resolv.h>
+#endif
#define SOCKS_PORT "1080"
#define HTTP_PROXY_PORT "3128"
diff -ruwN source/sshbuf-misc.c source-new/sshbuf-misc.c
--- source/sshbuf-misc.c 2018-10-16 18:01:20.000000000 -0600
+++ source-new/sshbuf-misc.c 2019-01-15 20:45:08.969783102 -0700
--- source/sshbuf-misc.c 2024-07-01 11:36:28.000000000 +0700
+++ source-new/sshbuf-misc.c 2025-08-20 11:51:17.444108963 +0700
@@ -28,7 +28,9 @@
#include <stdio.h>
#include <limits.h>
#include <string.h>
+#if !defined(__redox__)
+#ifndef __redox__
#include <resolv.h>
+#endif
#include <ctype.h>
#include <unistd.h>
#include "ssherr.h"
@@ -158,4 +160,3 @@
r[l] = '\0';
return r;
}
-
diff -ruwN source/sshkey.c source-new/sshkey.c
--- source/sshkey.c 2018-10-16 18:01:20.000000000 -0600
+++ source-new/sshkey.c 2019-01-15 20:13:21.629829281 -0700
@@ -42,7 +42,9 @@
#include <limits.h>
--- source/sshkey.c 2024-07-01 11:36:28.000000000 +0700
+++ source-new/sshkey.c 2025-08-20 11:50:36.114133643 +0700
@@ -43,7 +43,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#if !defined(__redox__)
+#ifndef __redox__
#include <resolv.h>
+#endif
#include <time.h>
#ifdef HAVE_UTIL_H
#include <util.h>
#endif /* HAVE_UTIL_H */

View File

@ -1,7 +1,8 @@
use cookbook::blake3::blake3_progress;
use cookbook::recipe::{BuildKind, CookRecipe, Recipe, SourceRecipe};
use cookbook::recipe::{AutoDeps, BuildKind, CookRecipe, Recipe, SourceRecipe};
use pkg::package::Package;
use pkg::{recipes, PackageName};
use serde::Serialize;
use std::collections::VecDeque;
use std::convert::TryInto;
use std::{
@ -187,6 +188,20 @@ fn run_command_stdin(mut command: process::Command, stdin_data: &[u8]) -> Result
Ok(())
}
fn serialize_and_write<T: Serialize>(file_path: &Path, content: &T) -> Result<(), String> {
let toml_content = toml::to_string(content).map_err(|err| {
format!(
"Failed to serialize content for '{}': {}",
file_path.display(),
err
)
})?;
fs::write(file_path, toml_content)
.map_err(|err| format!("Failed to write to file '{}': {}", file_path.display(), err))?;
Ok(())
}
static SHARED_PRESCRIPT: &str = r#"
function DYNAMIC_INIT {
COOKBOOK_AUTORECONF="autoreconf"
@ -704,16 +719,16 @@ fn build(
let sysroot_dir = target_dir.join("sysroot");
// Rebuild sysroot if source is newer
//TODO: rebuild on recipe changes
if sysroot_dir.is_dir()
&& (modified_dir(&sysroot_dir)? < source_modified
|| modified_dir(&sysroot_dir)? < deps_modified)
{
eprintln!(
"DEBUG: '{}' newer than '{}'",
source_dir.display(),
sysroot_dir.display()
);
remove_all(&sysroot_dir)?;
if sysroot_dir.is_dir() {
let sysroot_modified = modified_dir(&sysroot_dir)?;
if sysroot_modified < source_modified || sysroot_modified < deps_modified {
eprintln!(
"DEBUG: '{}' newer than '{}'",
source_dir.display(),
sysroot_dir.display()
);
remove_all(&sysroot_dir)?;
}
}
if !sysroot_dir.is_dir() {
// Create sysroot.tmp
@ -754,16 +769,16 @@ fn build(
let stage_dir = target_dir.join("stage");
// Rebuild stage if source is newer
//TODO: rebuild on recipe changes
if stage_dir.is_dir()
&& (modified_dir(&stage_dir)? < source_modified
|| modified_dir(&stage_dir)? < deps_modified)
{
eprintln!(
"DEBUG: '{}' newer than '{}'",
source_dir.display(),
stage_dir.display()
);
remove_all(&stage_dir)?;
if stage_dir.is_dir() {
let stage_modified = modified_dir(&stage_dir)?;
if stage_modified < source_modified || stage_modified < deps_modified {
eprintln!(
"DEBUG: '{}' newer than '{}'",
source_dir.display(),
stage_dir.display()
);
remove_all(&stage_dir)?;
}
}
if !stage_dir.is_dir() {
@ -1014,6 +1029,17 @@ do
done
"#;
let flags_fn = |name, flags: &Vec<String>| {
format!(
"{name}+=(\n{}\n)\n",
flags
.iter()
.map(|s| format!(" \"{s}\""))
.collect::<Vec<String>>()
.join("\n")
)
};
//TODO: better integration with redoxer (library instead of binary)
//TODO: configurable target
//TODO: Add more configurability, convert scripts to Rust?
@ -1027,7 +1053,18 @@ done
package_path.as_deref().unwrap_or(".")
)
}
BuildKind::Configure => "cookbook_configure".to_owned(),
BuildKind::Configure { configureflags } => format!(
"DYNAMIC_INIT\n{}cookbook_configure",
flags_fn("COOKBOOK_CONFIGURE_FLAGS", configureflags),
),
BuildKind::Cmake { cmakeflags } => format!(
"DYNAMIC_INIT\n{}cookbook_cmake",
flags_fn("COOKBOOK_CMAKE_FLAGS", cmakeflags),
),
BuildKind::Meson { mesonflags } => format!(
"DYNAMIC_INIT\n{}cookbook_meson",
flags_fn("COOKBOOK_MESON_FLAGS", mesonflags),
),
BuildKind::Custom { script } => script.clone(),
BuildKind::None => "".to_owned(),
};
@ -1070,7 +1107,24 @@ done
}
// Calculate automatic dependencies
let auto_deps = auto_deps(&stage_dir, &dep_pkgars);
let auto_deps_path = target_dir.join("auto_deps.toml");
if auto_deps_path.is_file() && modified(&auto_deps_path)? < modified(&stage_dir)? {
remove_all(&auto_deps_path)?
}
let auto_deps = if auto_deps_path.exists() {
let toml_content =
fs::read_to_string(&auto_deps_path).map_err(|_| "failed to read cached auto_deps")?;
let wrapper: AutoDeps =
toml::from_str(&toml_content).map_err(|_| "failed to deserialize cached auto_deps")?;
wrapper.packages
} else {
let packages = auto_deps(&stage_dir, &dep_pkgars);
let wrapper = AutoDeps { packages };
serialize_and_write(&auto_deps_path, &wrapper)?;
wrapper.packages
};
Ok((stage_dir, auto_deps))
}
@ -1137,15 +1191,14 @@ fn package_toml(
depends.push(dep.clone());
}
}
let stage_toml = toml::to_string(&Package {
let package = Package {
name: name.clone(),
version: package_version(recipe),
target: env::var("TARGET").map_err(|err| format!("failed to read TARGET: {:?}", err))?,
depends,
})
.map_err(|err| format!("failed to serialize stage.toml: {:?}", err))?;
fs::write(target_dir.join("stage.toml"), stage_toml)
.map_err(|err| format!("failed to write stage.toml: {:?}", err))?;
};
serialize_and_write(&target_dir.join("stage.toml"), &package)?;
return Ok(());
}

View File

@ -1,4 +1,4 @@
use std::{convert::TryInto, fs, path::PathBuf};
use std::{collections::BTreeSet, convert::TryInto, fs, path::PathBuf};
use pkg::{package::PackageError, recipes, PackageName};
use serde::{
@ -71,13 +71,27 @@ pub enum BuildKind {
Cargo {
#[serde(default)]
package_path: Option<String>,
#[serde(default)]
cargoflags: String,
},
/// Will build and install using configure and make
#[serde(rename = "configure")]
Configure,
Configure {
#[serde(default)]
configureflags: Vec<String>,
},
/// Will build and install using cmake
#[serde(rename = "cmake")]
Cmake {
#[serde(default)]
cmakeflags: Vec<String>,
},
/// Will build and install using meson
#[serde(rename = "meson")]
Meson {
#[serde(default)]
mesonflags: Vec<String>,
},
/// Will build and install using custom commands
#[serde(rename = "custom")]
Custom { script: String },
@ -215,6 +229,11 @@ impl CookRecipe {
}
}
#[derive(Serialize, Deserialize)]
pub struct AutoDeps {
pub packages: BTreeSet<PackageName>,
}
#[cfg(test)]
mod tests {
use pkg::PackageName;