forked from tfgrid/zosbuilder
components: read config/sources.conf to determine components, versions, and build funcs; remove hardcoded list. verification: accept rfs built or prebuilt binary paths.
This commit is contained in:
@@ -33,33 +33,42 @@ function components_parse_sources_conf() {
|
||||
log_info "Install directory: ${install_dir}"
|
||||
|
||||
local component_count=0
|
||||
|
||||
# Hardcode known components to bypass parsing issues for now
|
||||
log_info "Building ThreeFold components (hardcoded for reliability)"
|
||||
|
||||
# Component 1: zinit
|
||||
component_count=$((component_count + 1))
|
||||
log_info "Processing component ${component_count}: zinit (git)"
|
||||
components_download_git "zinit" "https://github.com/threefoldtech/zinit" "master" "$components_dir"
|
||||
components_build_component "zinit" "build_zinit" "$components_dir"
|
||||
|
||||
# Component 2: mycelium
|
||||
component_count=$((component_count + 1))
|
||||
log_info "Processing component ${component_count}: mycelium (git)"
|
||||
components_download_git "mycelium" "https://github.com/threefoldtech/mycelium" "v0.6.2" "$components_dir"
|
||||
components_build_component "mycelium" "build_mycelium" "$components_dir"
|
||||
|
||||
# Component 3: rfs (pre-built release)
|
||||
component_count=$((component_count + 1))
|
||||
log_info "Processing component ${component_count}: rfs (release)"
|
||||
components_download_git "rfs" "https://github.com/threefoldtech/rfs" "development" "$components_dir"
|
||||
components_build_component "rfs" "build_rfs" "$components_dir"
|
||||
|
||||
# Component 4: corex
|
||||
component_count=$((component_count + 1))
|
||||
log_info "Processing component ${component_count}: corex (release)"
|
||||
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"
|
||||
|
||||
# Read entries from sources.conf (TYPE NAME URL VERSION BUILD_FUNCTION [EXTRA])
|
||||
while IFS= read -r _raw || [[ -n "$_raw" ]]; do
|
||||
# Strip comments and trim whitespace
|
||||
local line="${_raw%%#*}"
|
||||
line="${line#"${line%%[![:space:]]*}"}"
|
||||
line="${line%"${line##*[![:space:]]}"}"
|
||||
[[ -z "$line" ]] && continue
|
||||
|
||||
local type name url version build_func extra
|
||||
# shellcheck disable=SC2086
|
||||
read -r type name url version build_func extra <<< "$line"
|
||||
|
||||
if [[ -z "${type:-}" || -z "${name:-}" || -z "${url:-}" || -z "${version:-}" || -z "${build_func:-}" ]]; then
|
||||
log_warn "Skipping malformed entry: ${_raw}"
|
||||
continue
|
||||
fi
|
||||
|
||||
component_count=$((component_count + 1))
|
||||
log_info "Processing component ${component_count}: ${name} (${type})"
|
||||
|
||||
case "$type" in
|
||||
git)
|
||||
components_download_git "$name" "$url" "$version" "$components_dir"
|
||||
;;
|
||||
release)
|
||||
components_download_release "$name" "$url" "$version" "$components_dir" "$extra"
|
||||
;;
|
||||
*)
|
||||
log_error "Unknown component type in sources.conf: ${type}"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
components_build_component "$name" "$build_func" "$components_dir"
|
||||
done < "$sources_file"
|
||||
|
||||
if [[ $component_count -eq 0 ]]; then
|
||||
log_warn "No components found in sources configuration"
|
||||
@@ -398,7 +407,6 @@ function build_rfs() {
|
||||
return 1
|
||||
fi
|
||||
# remove rust-toolchain.toml, as not needed with latest release
|
||||
safe_execute rm rust-toolchain.toml
|
||||
# Build with musl target
|
||||
safe_execute cargo build --release --target "$RUST_TARGET" --features build-binary
|
||||
|
||||
@@ -509,29 +517,55 @@ function components_verify_installation() {
|
||||
|
||||
section_header "Verifying Component Build"
|
||||
|
||||
# List of expected built binaries and their locations in components directory
|
||||
local expected_binaries=(
|
||||
"zinit/target/x86_64-unknown-linux-musl/release/zinit"
|
||||
"rfs/target/x86_64-unknown-linux-musl/release/rfs"
|
||||
"mycelium/myceliumd/target/x86_64-unknown-linux-musl/release/mycelium"
|
||||
"corex/corex"
|
||||
)
|
||||
|
||||
local ok_count=0
|
||||
local missing_count=0
|
||||
|
||||
for binary in "${expected_binaries[@]}"; do
|
||||
local full_path="${components_dir}/${binary}"
|
||||
if [[ -f "$full_path" && -x "$full_path" ]]; then
|
||||
local size=$(get_file_size "$full_path")
|
||||
log_info "✓ Built ${binary##*/} (${size}) at: ${binary}"
|
||||
else
|
||||
log_error "✗ Missing or not executable: ${binary}"
|
||||
((missing_count++))
|
||||
fi
|
||||
done
|
||||
|
||||
# zinit
|
||||
local zinit_bin="${components_dir}/zinit/target/x86_64-unknown-linux-musl/release/zinit"
|
||||
if [[ -x "$zinit_bin" ]]; then
|
||||
log_info "✓ zinit ($(get_file_size "$zinit_bin")) at: ${zinit_bin#${components_dir}/}"
|
||||
((ok_count++))
|
||||
else
|
||||
log_error "✗ zinit missing: ${zinit_bin#${components_dir}/}"
|
||||
((missing_count++))
|
||||
fi
|
||||
|
||||
# rfs: accept both built and prebuilt locations
|
||||
local rfs_built="${components_dir}/rfs/target/x86_64-unknown-linux-musl/release/rfs"
|
||||
local rfs_release="${components_dir}/rfs/rfs"
|
||||
if [[ -x "$rfs_built" ]]; then
|
||||
log_info "✓ rfs (built) ($(get_file_size "$rfs_built")) at: ${rfs_built#${components_dir}/}"
|
||||
((ok_count++))
|
||||
elif [[ -x "$rfs_release" ]]; then
|
||||
log_info "✓ rfs (release) ($(get_file_size "$rfs_release")) at: ${rfs_release#${components_dir}/}"
|
||||
((ok_count++))
|
||||
else
|
||||
log_error "✗ rfs missing: checked rfs/target/.../rfs and rfs/rfs"
|
||||
((missing_count++))
|
||||
fi
|
||||
|
||||
# mycelium
|
||||
local mycelium_bin="${components_dir}/mycelium/myceliumd/target/x86_64-unknown-linux-musl/release/mycelium"
|
||||
if [[ -x "$mycelium_bin" ]]; then
|
||||
log_info "✓ mycelium ($(get_file_size "$mycelium_bin")) at: ${mycelium_bin#${components_dir}/}"
|
||||
((ok_count++))
|
||||
else
|
||||
log_error "✗ mycelium missing: ${mycelium_bin#${components_dir}/}"
|
||||
((missing_count++))
|
||||
fi
|
||||
|
||||
# corex
|
||||
local corex_bin="${components_dir}/corex/corex"
|
||||
if [[ -x "$corex_bin" ]]; then
|
||||
log_info "✓ corex ($(get_file_size "$corex_bin")) at: ${corex_bin#${components_dir}/}"
|
||||
((ok_count++))
|
||||
else
|
||||
log_error "✗ corex missing: ${corex_bin#${components_dir}/}"
|
||||
((missing_count++))
|
||||
fi
|
||||
|
||||
if [[ $missing_count -eq 0 ]]; then
|
||||
log_info "All components built successfully"
|
||||
log_info "All components built/installed successfully"
|
||||
return 0
|
||||
else
|
||||
log_error "${missing_count} components missing or failed to build"
|
||||
|
||||
Reference in New Issue
Block a user