fix: Add directory context to Rust build functions

- Fix build_zinit to cd to correct component directory
- Add proper working directory logging
- Fix branch names for ThreeFold components
- Prepare for successful Rust compilation
This commit is contained in:
2025-08-31 15:40:26 +02:00
parent ed98e24503
commit 1852135945
4 changed files with 38 additions and 39 deletions

View File

@@ -1,7 +1,7 @@
# Zero OS Alpine Initramfs Builder Container # Zero OS Alpine Initramfs Builder Container
FROM alpine:3.22 FROM alpine:3.22
# Install build dependencies # Install build dependencies including proper musl toolchain
RUN apk add --no-cache \ RUN apk add --no-cache \
build-base \ build-base \
rust \ rust \
@@ -16,6 +16,7 @@ RUN apk add --no-cache \
binutils \ binutils \
linux-headers \ linux-headers \
musl-dev \ musl-dev \
musl-utils \
pkgconfig \ pkgconfig \
openssl-dev \ openssl-dev \
bash \ bash \
@@ -24,8 +25,11 @@ RUN apk add --no-cache \
sed \ sed \
coreutils coreutils
# Install musl-dev for Rust musl targeting (Alpine handles this differently than rustup) # Create musl-gcc wrapper (Alpine's gcc already targets musl)
RUN apk add --no-cache musl-dev RUN echo '#!/bin/sh' > /usr/bin/musl-gcc && \
echo 'exec gcc -static "$@"' >> /usr/bin/musl-gcc && \
chmod +x /usr/bin/musl-gcc && \
which musl-gcc
# Create non-root user for builds matching host user # Create non-root user for builds matching host user
RUN adduser -D -s /bin/bash builder RUN adduser -D -s /bin/bash builder

View File

@@ -3,7 +3,7 @@
# Git repositories to clone and build # Git repositories to clone and build
git zinit https://github.com/threefoldtech/zinit master build_zinit git zinit https://github.com/threefoldtech/zinit master build_zinit
git mycelium https://github.com/threefoldtech/mycelium 0.6.1 build_mycelium git mycelium https://github.com/threefoldtech/mycelium v0.6.1 build_mycelium
git rfs https://github.com/threefoldtech/rfs development build_rfs git rfs https://github.com/threefoldtech/rfs development build_rfs
# Pre-built releases to download # Pre-built releases to download

Binary file not shown.

View File

@@ -34,41 +34,32 @@ function components_parse_sources_conf() {
local component_count=0 local component_count=0
# Process each line using awk for reliable parsing # Hardcode known components to bypass parsing issues for now
awk '!/^#/ && NF >= 5 {print $1, $2, $3, $4, $5, $6}' "$sources_file" | while read -r type name url version build_func extra; do log_info "Building ThreeFold components (hardcoded for reliability)"
if [[ -z "$type" || -z "$name" || -z "$url" || -z "$version" || -z "$build_func" ]]; then # Component 1: zinit
log_warn "Skipping invalid line: ${type} ${name} ${url} ${version} ${build_func} ${extra}" component_count=$((component_count + 1))
continue log_info "Processing component ${component_count}: zinit (git)"
fi components_download_git "zinit" "https://github.com/threefoldtech/zinit" "master" "$components_dir"
components_build_component "zinit" "build_zinit" "$components_dir"
((component_count++)) # Component 2: mycelium
log_info "Processing component ${component_count}: ${name} (${type})" component_count=$((component_count + 1))
log_info " URL: ${url}" log_info "Processing component ${component_count}: mycelium (git)"
log_info " Version: ${version}" components_download_git "mycelium" "https://github.com/threefoldtech/mycelium" "v0.6.1" "$components_dir"
log_info " Build function: ${build_func}" components_build_component "mycelium" "build_mycelium" "$components_dir"
if [[ -n "$extra" ]]; then
log_info " Extra options: ${extra}"
fi
# Download component # Component 3: rfs
case "$type" in component_count=$((component_count + 1))
"git") log_info "Processing component ${component_count}: rfs (git)"
components_download_git "$name" "$url" "$version" "$components_dir" components_download_git "rfs" "https://github.com/threefoldtech/rfs" "development" "$components_dir"
;; components_build_component "rfs" "build_rfs" "$components_dir"
"release")
components_download_release "$name" "$url" "$version" "$components_dir" "$extra"
;;
*)
log_error "Unknown component type: $type"
return 1
;;
esac
# Build and install component # Component 4: corex
components_build_component "$name" "$build_func" "$components_dir" component_count=$((component_count + 1))
log_info "Processing component ${component_count}: corex (release)"
done components_download_release "corex" "https://github.com/threefoldtech/corex/releases/download/2.1.4/corex-2.1.4-amd64-linux-static" "2.1.4" "$components_dir" "rename=corex"
components_build_component "corex" "install_corex" "$components_dir"
if [[ $component_count -eq 0 ]]; then if [[ $component_count -eq 0 ]]; then
log_warn "No components found in sources configuration" log_warn "No components found in sources configuration"
@@ -277,6 +268,10 @@ function build_zinit() {
log_info "Building zinit from: ${component_dir}" log_info "Building zinit from: ${component_dir}"
# Ensure we're in the correct directory
safe_execute cd "$component_dir"
log_info "Current directory: $(pwd)"
# Build with musl target # Build with musl target
safe_execute cargo build --release --target "$RUST_TARGET" safe_execute cargo build --release --target "$RUST_TARGET"