updates
ober
e802d7ef684069a8b3af9f4448218a3d6b3ca45c
--- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ export JSH_VERSION_SHORT JERBOA_VERSION ?= v0.2.0 JERBOA_TOOL_DIR ?= $(CURDIR)/.jerboa/bin JERBOA_SHELL_EXTRAS_URL ?= https://git.sr.ht/~lisp/jerboa-shell-extras -JERBOA_SHELL_EXTRAS_DIR ?= $(CURDIR)/_vendor/jerboa-shell-extras +JERBOA_SHELL_EXTRAS_DIR ?= $(shell if [ -f "$(CURDIR)/../jerboa-shell-extras/Makefile" ]; then printf '%s\n' "$(CURDIR)/../jerboa-shell-extras"; else printf '%s\n' "$(CURDIR)/_vendor/jerboa-shell-extras"; fi) JSH_EXTRAS_EMBED_CONF ?= $(CURDIR)/.jsh-extras-embed.conf JSH_EXTRAS_DEFAULT_EMBED ?= $(JERBOA_SHELL_EXTRAS_DIR)/embed JERBUILD ?= $(shell if [ -x ./jerbuild ]; then echo ./jerbuild; \ --- a/support/jsh-jerbuild-main.c +++ b/support/jsh-jerbuild-main.c @@ -23,6 +23,7 @@ #include <unistd.h> #include <fcntl.h> #include <sys/types.h> +#include <sys/stat.h> #include <sys/mman.h> #ifdef __FreeBSD__ #include <sys/sysctl.h> @@ -36,6 +37,8 @@ #include "program_boot.h" #include "ffi_symbols.h" +extern uptr S_nthreads; + struct jsh_program_image; struct jsh_program_image *jsh_program_image_create( const unsigned char *data, size_t length, const char *requested_tmpdir); @@ -155,6 +158,13 @@ int main(int argc, const char *argv[]) { register_ffi_symbols(); /* Direct libc bindings imported by bundled Jerboa modules are not part of * the ffi-shim symbol list, so static builds register them explicitly. */ + Sforeign_symbol("S_nthreads", (void *)&S_nthreads); + Sforeign_symbol("getuid", (void *)getuid); + Sforeign_symbol("geteuid", (void *)geteuid); + Sforeign_symbol("getgid", (void *)getgid); + Sforeign_symbol("getegid", (void *)getegid); + Sforeign_symbol("realpath", (void *)realpath); + Sforeign_symbol("lstat", (void *)lstat); Sforeign_symbol("kill", (void *)kill); Sforeign_symbol("read", (void *)read); Sforeign_symbol("write", (void *)write); --- a/test/test-make-extras.sh +++ b/test/test-make-extras.sh @@ -27,6 +27,16 @@ for target in extras configure features features-all features-minimal show-featu target_exists "$target" || fail "missing Makefile target: $target" done +default_extras_dir="$(make -s --no-print-directory -f - print-default-extras-dir <<'EOF' +include Makefile +print-default-extras-dir: + @printf '%s\n' "$(JERBOA_SHELL_EXTRAS_DIR)" +EOF +)" +if [ -f "$ROOT/../jerboa-shell-extras/Makefile" ] && [ "$default_extras_dir" != "$ROOT/../jerboa-shell-extras" ]; then + fail "default extras checkout should prefer sibling ../jerboa-shell-extras" +fi + if grep -Fq 'JSH_EMBED="$(JERBOA_SHELL_EXTRAS_DIR)/embed"' Makefile; then fail "make extras must not force JSH_EMBED to the extras repo embed directory" fi --- a/tools/select-extras-embed.sh +++ b/tools/select-extras-embed.sh @@ -9,6 +9,7 @@ DEFAULT_EMBED="${HOME}/.embed" PROMPT=0 SHOW=0 NO_PROMPT=0 +TTY="" usage() { cat <<EOF @@ -125,6 +126,14 @@ write_state() { mv "$tmp" "$STATE_FILE" } +usable_tty() { + TTY="" + [ -r /dev/tty ] && [ -w /dev/tty ] || return 1 + exec 3<>/dev/tty || return 1 + TTY=/dev/fd/3 + return 0 +} + choose_path() { local current input if [ -n "${JSH_EMBED:-}" ]; then @@ -140,16 +149,17 @@ choose_path() { fi current="$(expand_path "$current")" - if [ "$PROMPT" -eq 1 ] && [ "$NO_PROMPT" -eq 0 ] && embed_selected && [ -r /dev/tty ] && [ -w /dev/tty ]; then + if [ "$PROMPT" -eq 1 ] && [ "$NO_PROMPT" -eq 0 ] && embed_selected && usable_tty; then { echo echo "Embed feature selected." printf 'JSH_EMBED source directory [%s]: ' "$current" - } > /dev/tty - IFS= read -r input < /dev/tty || input="" + } > "$TTY" + IFS= read -r input < "$TTY" || input="" if [ -n "$input" ]; then current="$(expand_path "$input")" fi + exec 3>&- fi write_state "$current"