From aebb7206f488656a7619f9358eae125ced979245 Mon Sep 17 00:00:00 2001 From: mueller_minki Date: Sun, 4 Oct 2026 10:39:58 +0200 Subject: [PATCH] Fix build env issues with manual build --- Makefile | 13 +++++++++++-- backend/src/hub.c | 6 +++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index aa7401b..59a0a4e 100644 --- a/Makefile +++ b/Makefile @@ -20,20 +20,29 @@ OBJS_TEST := $(addprefix $(BUILD)/,$(addsuffix .o,config log net proto json ser PYTHON ?= python3 -.PHONY: all test test-c test-web install clean docker-test +.PHONY: all test test-c test-web install clean docker-test check-deps all: $(BUILD)/patchbayd $(BUILD): mkdir -p $(BUILD) +# Fails early with a hint instead of a missing-header compiler error. +check-deps: + @pkg-config --exists $(PKGS) || { \ + echo "missing build dependencies (pkg-config cannot find: $(PKGS))" >&2; \ + echo " APT: sudo apt-get install build-essential pkg-config libssh2-1-dev libsqlite3-dev" >&2; \ + echo " XBPS: sudo xbps-install base-devel pkg-config libssh2-devel sqlite-devel" >&2; \ + echo " or: sudo ./install.sh --role client|target (keeps an existing config)" >&2; \ + exit 1; } + # Embed schema.sql as a C string so the daemon has no runtime file dependency. $(BUILD)/schema.h: schema.sql | $(BUILD) { printf 'static const char pb_schema_sql[] =\n'; \ sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/\\n"/' $<; \ printf ';\n'; } > $@ -$(BUILD)/%.o: $(SRC)/%.c $(wildcard $(SRC)/*.h) $(BUILD)/schema.h | $(BUILD) +$(BUILD)/%.o: $(SRC)/%.c $(wildcard $(SRC)/*.h) $(BUILD)/schema.h | $(BUILD) check-deps $(CC) $(CFLAGS) $(PKG_CFLAGS) -I$(BUILD) -c -o $@ $< $(BUILD)/patchbayd: $(OBJS_ALL) diff --git a/backend/src/hub.c b/backend/src/hub.c index a19aa8e..2fe1647 100644 --- a/backend/src/hub.c +++ b/backend/src/hub.c @@ -45,7 +45,7 @@ struct route { int sink_id; int sink_type; int sink_client; - char bind[64]; + char bind[256]; char sink_iface[IFNAMSIZ]; int port; int proto; @@ -80,7 +80,7 @@ struct tsink { struct ev ev; struct tsink *next; int sink_id; - char bind[64]; + char bind[256]; char iface[IFNAMSIZ]; unsigned ifindex; // detects a recreated tun interface int port; @@ -1144,7 +1144,7 @@ static void apply_target_sinks(void) int fd = net_listen(r->bind, r->port, r->proto, r->sink_iface); if (fd < 0) { char msg[128]; - snprintf(msg, sizeof(msg), "bind %s:%d failed: %s", r->bind, r->port, strerror(errno)); + snprintf(msg, sizeof(msg), "bind %.64s:%d failed: %s", r->bind, r->port, strerror(errno)); if (strcmp(r->state_err, msg)) log_warn("sink %d: %s", r->sink_id, msg); snprintf(r->state_err, sizeof(r->state_err), "%s", msg);