From 3f487fd52b9af3c4511f01b962efd77e42172c66 Mon Sep 17 00:00:00 2001 From: CroneKorkN Date: Fri, 23 Oct 2026 11:50:22 +0200 Subject: [PATCH] feat(build-server): build crystal binaries statically on home.server The 2022 binaries link libpcre.so.3, which Debian 13 no longer ships. crystal now comes from the openSUSE repo of the node's Debian release and links with --static, so the result runs on any release; the build runs locally instead of cross-compiling through the build-agent. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RywMtsL8qXG7GDY3MHq9Uh --- bundles/build-server/files/crystal | 16 ++++++++-------- bundles/build-server/metadata.py | 10 ++-------- bundles/crystal/metadata.py | 11 +++++++---- groups/applications/build-server.py | 1 + nodes/home.server.py | 5 +---- 5 files changed, 19 insertions(+), 24 deletions(-) diff --git a/bundles/build-server/files/crystal b/bundles/build-server/files/crystal index de49fb0..f542265 100644 --- a/bundles/build-server/files/crystal +++ b/bundles/build-server/files/crystal @@ -10,6 +10,7 @@ REPO_NAME=$(jq -r .repository.name <<< $JSON) CLONE_URL=$(jq -r .repository.clone_url <<< $JSON) BUILD_FILE=$(jq -r .file <<< $ARGS) DATE=$(date --utc +%s) +SSH_OPTIONS='-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' cd ~ rm -rf "$REPO_NAME" @@ -20,13 +21,12 @@ shards install for ARCH in $(jq -r '.architectures | keys[]' <<< $CONFIG) do TARGET=$(jq -r .architectures.$ARCH.target <<< $CONFIG) - IP=$(jq -r .architectures.$ARCH.ip <<< $CONFIG) - BUILD_CMD=$(crystal build "$BUILD_FILE" --cross-compile --target="$TARGET" --release -o "$REPO_NAME") + BINARY="$REPO_NAME-$ARCH-$DATE" - scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "$REPO_NAME.o" "build-agent@$IP:~" - ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "build-agent@$IP" $BUILD_CMD - scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "build-agent@$IP:~/$REPO_NAME" . - ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "downloads@$DOWNLOAD_SERVER" mkdir -p "~/$REPO_NAME" - scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "$REPO_NAME" "downloads@$DOWNLOAD_SERVER:~/$REPO_NAME/$REPO_NAME-$ARCH-$DATE" - ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "downloads@$DOWNLOAD_SERVER" ln -sf "$REPO_NAME-$ARCH-$DATE" "~/$REPO_NAME/$REPO_NAME-$ARCH-latest" + # static, so the binary does not depend on the libraries of a debian release + crystal build "$BUILD_FILE" --static --release --target="$TARGET" -o "$BINARY" + + ssh $SSH_OPTIONS "downloads@$DOWNLOAD_SERVER" mkdir -p "~/$REPO_NAME" + scp $SSH_OPTIONS "$BINARY" "downloads@$DOWNLOAD_SERVER:~/$REPO_NAME/$BINARY" + ssh $SSH_OPTIONS "downloads@$DOWNLOAD_SERVER" ln -sf "$BINARY" "~/$REPO_NAME/$REPO_NAME-$ARCH-latest" done diff --git a/bundles/build-server/metadata.py b/bundles/build-server/metadata.py index 49ec4d7..87d1cbc 100644 --- a/bundles/build-server/metadata.py +++ b/bundles/build-server/metadata.py @@ -24,18 +24,12 @@ defaults = { @metadata_reactor.provides( - 'build-server', + 'build-server/download_server_ip', ) -def agent_conf(metadata): +def download_server(metadata): download_server = repo.get_node(metadata.get('build-server/download_server')) return { 'build-server': { - 'architectures': { - architecture: { - 'ip': str(ip_interface(repo.get_node(conf['node']).metadata.get('network/internal/ipv4')).ip), - } - for architecture, conf in metadata.get('build-server/architectures').items() - }, 'download_server_ip': str(ip_interface(download_server.metadata.get('network/internal/ipv4')).ip), }, } diff --git a/bundles/crystal/metadata.py b/bundles/crystal/metadata.py index 2f98c45..19e4fb7 100644 --- a/bundles/crystal/metadata.py +++ b/bundles/crystal/metadata.py @@ -1,16 +1,19 @@ -debian_version = min([node.os_version, (11,)])[0] # FIXME - defaults = { 'apt': { 'packages': { 'crystal': {}, + # static linking (crystal build --static) + 'build-essential': {}, + 'libgc-dev': {}, + 'libpcre2-dev': {}, + 'libevent-dev': {}, }, 'sources': { 'crystal': { # https://software.opensuse.org/download.html?project=devel%3Alanguages%3Acrystal&package=crystal - # curl -fsSL https://download.opensuse.org/repositories/devel:/languages:/crystal/Debian_Testing/Release.key + # curl -fsSL https://download.opensuse.org/repositories/devel:/languages:/crystal/Debian_13/Release.key 'urls': { - 'http://download.opensuse.org/repositories/devel:/languages:/crystal/Debian_Testing/', + f'http://download.opensuse.org/repositories/devel:/languages:/crystal/Debian_{node.os_version[0]}/', }, 'suites': { '/', diff --git a/groups/applications/build-server.py b/groups/applications/build-server.py index eb332d3..2771f87 100644 --- a/groups/applications/build-server.py +++ b/groups/applications/build-server.py @@ -1,6 +1,7 @@ { 'bundles': { 'build-server', + 'crystal', 'flask', }, } diff --git a/nodes/home.server.py b/nodes/home.server.py index 3232a14..4f3292f 100644 --- a/nodes/home.server.py +++ b/nodes/home.server.py @@ -12,8 +12,6 @@ 'build-server', ], 'bundles': [ - 'build-agent', - #'crystal', 'gitea', # 'gollum', 'grub', @@ -53,11 +51,10 @@ 'hostname': 'build.sublimity.de', 'architectures': { 'amd64': { - 'node': 'home.server', 'target': 'x86_64-unknown-linux-gnu', }, + # arm64 needs a cross linker and arm64 static libs (multiarch): # 'arm64': { - # 'node': 'home.openhab', # 'target': 'aarch64-unknown-linux-gnu', # }, },