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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RywMtsL8qXG7GDY3MHq9Uh
This commit is contained in:
parent
3b4ebda91d
commit
3f487fd52b
5 changed files with 19 additions and 24 deletions
|
|
@ -10,6 +10,7 @@ REPO_NAME=$(jq -r .repository.name <<< $JSON)
|
||||||
CLONE_URL=$(jq -r .repository.clone_url <<< $JSON)
|
CLONE_URL=$(jq -r .repository.clone_url <<< $JSON)
|
||||||
BUILD_FILE=$(jq -r .file <<< $ARGS)
|
BUILD_FILE=$(jq -r .file <<< $ARGS)
|
||||||
DATE=$(date --utc +%s)
|
DATE=$(date --utc +%s)
|
||||||
|
SSH_OPTIONS='-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'
|
||||||
|
|
||||||
cd ~
|
cd ~
|
||||||
rm -rf "$REPO_NAME"
|
rm -rf "$REPO_NAME"
|
||||||
|
|
@ -20,13 +21,12 @@ shards install
|
||||||
for ARCH in $(jq -r '.architectures | keys[]' <<< $CONFIG)
|
for ARCH in $(jq -r '.architectures | keys[]' <<< $CONFIG)
|
||||||
do
|
do
|
||||||
TARGET=$(jq -r .architectures.$ARCH.target <<< $CONFIG)
|
TARGET=$(jq -r .architectures.$ARCH.target <<< $CONFIG)
|
||||||
IP=$(jq -r .architectures.$ARCH.ip <<< $CONFIG)
|
BINARY="$REPO_NAME-$ARCH-$DATE"
|
||||||
BUILD_CMD=$(crystal build "$BUILD_FILE" --cross-compile --target="$TARGET" --release -o "$REPO_NAME")
|
|
||||||
|
|
||||||
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "$REPO_NAME.o" "build-agent@$IP:~"
|
# static, so the binary does not depend on the libraries of a debian release
|
||||||
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "build-agent@$IP" $BUILD_CMD
|
crystal build "$BUILD_FILE" --static --release --target="$TARGET" -o "$BINARY"
|
||||||
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"
|
ssh $SSH_OPTIONS "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"
|
scp $SSH_OPTIONS "$BINARY" "downloads@$DOWNLOAD_SERVER:~/$REPO_NAME/$BINARY"
|
||||||
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "downloads@$DOWNLOAD_SERVER" ln -sf "$REPO_NAME-$ARCH-$DATE" "~/$REPO_NAME/$REPO_NAME-$ARCH-latest"
|
ssh $SSH_OPTIONS "downloads@$DOWNLOAD_SERVER" ln -sf "$BINARY" "~/$REPO_NAME/$REPO_NAME-$ARCH-latest"
|
||||||
done
|
done
|
||||||
|
|
|
||||||
|
|
@ -24,18 +24,12 @@ defaults = {
|
||||||
|
|
||||||
|
|
||||||
@metadata_reactor.provides(
|
@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'))
|
download_server = repo.get_node(metadata.get('build-server/download_server'))
|
||||||
return {
|
return {
|
||||||
'build-server': {
|
'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),
|
'download_server_ip': str(ip_interface(download_server.metadata.get('network/internal/ipv4')).ip),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,19 @@
|
||||||
debian_version = min([node.os_version, (11,)])[0] # FIXME
|
|
||||||
|
|
||||||
defaults = {
|
defaults = {
|
||||||
'apt': {
|
'apt': {
|
||||||
'packages': {
|
'packages': {
|
||||||
'crystal': {},
|
'crystal': {},
|
||||||
|
# static linking (crystal build --static)
|
||||||
|
'build-essential': {},
|
||||||
|
'libgc-dev': {},
|
||||||
|
'libpcre2-dev': {},
|
||||||
|
'libevent-dev': {},
|
||||||
},
|
},
|
||||||
'sources': {
|
'sources': {
|
||||||
'crystal': {
|
'crystal': {
|
||||||
# https://software.opensuse.org/download.html?project=devel%3Alanguages%3Acrystal&package=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': {
|
'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': {
|
'suites': {
|
||||||
'/',
|
'/',
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
'bundles': {
|
'bundles': {
|
||||||
'build-server',
|
'build-server',
|
||||||
|
'crystal',
|
||||||
'flask',
|
'flask',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,6 @@
|
||||||
'build-server',
|
'build-server',
|
||||||
],
|
],
|
||||||
'bundles': [
|
'bundles': [
|
||||||
'build-agent',
|
|
||||||
#'crystal',
|
|
||||||
'gitea',
|
'gitea',
|
||||||
# 'gollum',
|
# 'gollum',
|
||||||
'grub',
|
'grub',
|
||||||
|
|
@ -53,11 +51,10 @@
|
||||||
'hostname': 'build.sublimity.de',
|
'hostname': 'build.sublimity.de',
|
||||||
'architectures': {
|
'architectures': {
|
||||||
'amd64': {
|
'amd64': {
|
||||||
'node': 'home.server',
|
|
||||||
'target': 'x86_64-unknown-linux-gnu',
|
'target': 'x86_64-unknown-linux-gnu',
|
||||||
},
|
},
|
||||||
|
# arm64 needs a cross linker and arm64 static libs (multiarch):
|
||||||
# 'arm64': {
|
# 'arm64': {
|
||||||
# 'node': 'home.openhab',
|
|
||||||
# 'target': 'aarch64-unknown-linux-gnu',
|
# 'target': 'aarch64-unknown-linux-gnu',
|
||||||
# },
|
# },
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue