From 4324f23d481d17d3c69beedd3d88ab6a5ee38036 Mon Sep 17 00:00:00 2001 From: vxtls <187420201+vxtls@users.noreply.github.com> Date: Fri, 13 Mar 2026 21:58:50 -0400 Subject: [PATCH] fix(guix): add dedicated build step to compile and run loopback bind helper before python server --- .../files/loopback-bind-127001.c | 53 +++++++++++++++++++ steps-guix/loopback-bind-127001/pass1.sh | 21 ++++++++ steps-guix/manifest | 1 + 3 files changed, 75 insertions(+) create mode 100644 steps-guix/loopback-bind-127001/files/loopback-bind-127001.c create mode 100644 steps-guix/loopback-bind-127001/pass1.sh diff --git a/steps-guix/loopback-bind-127001/files/loopback-bind-127001.c b/steps-guix/loopback-bind-127001/files/loopback-bind-127001.c new file mode 100644 index 00000000..d1dcf7b2 --- /dev/null +++ b/steps-guix/loopback-bind-127001/files/loopback-bind-127001.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include +#include +#include +#include + +int main(void) { + int fd; + struct ifreq ifr; + struct sockaddr_in addr; + + fd = socket(AF_INET, SOCK_DGRAM, 0); + if (fd < 0) { + perror("socket"); + return 1; + } + + memset(&ifr, 0, sizeof(ifr)); + memset(&addr, 0, sizeof(addr)); + + addr.sin_family = AF_INET; + if (inet_pton(AF_INET, "127.0.0.1", &addr.sin_addr) != 1) { + perror("inet_pton"); + close(fd); + return 1; + } + + strncpy(ifr.ifr_name, "lo", IFNAMSIZ - 1); + memcpy(&ifr.ifr_addr, &addr, sizeof(addr)); + if (ioctl(fd, SIOCSIFADDR, &ifr) < 0) { + perror("ioctl(SIOCSIFADDR)"); + close(fd); + return 1; + } + + if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) { + perror("ioctl(SIOCGIFFLAGS)"); + close(fd); + return 1; + } + + ifr.ifr_flags |= IFF_UP | IFF_RUNNING; + if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) { + perror("ioctl(SIOCSIFFLAGS)"); + close(fd); + return 1; + } + + close(fd); + return 0; +} diff --git a/steps-guix/loopback-bind-127001/pass1.sh b/steps-guix/loopback-bind-127001/pass1.sh new file mode 100644 index 00000000..1f6a1803 --- /dev/null +++ b/steps-guix/loopback-bind-127001/pass1.sh @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +src_prepare() { + default +} + +src_configure() { + : +} + +src_compile() { + gcc -O2 -std=c99 -Wall -Wextra -Werror \ + -o /tmp/loopback-bind-127001 \ + loopback-bind-127001.c + + /tmp/loopback-bind-127001 +} + +src_install() { + install -D -m 0644 /dev/null "${DESTDIR}/usr/share/loopback-bind-127001.done" +} diff --git a/steps-guix/manifest b/steps-guix/manifest index 9a51bf22..093f2af0 100644 --- a/steps-guix/manifest +++ b/steps-guix/manifest @@ -69,6 +69,7 @@ build: mescc-tools-static-stripped-0.5.2-i686-linux # End of Guix Bootstrap seeds build: guix-hash-compat-1.5.0 build: guix-1.5.0 +build: loopback-bind-127001 improve: services improve: guix-daemon-and-pull improve: guix-build-iso