Responsible for downloading and managing ERTS (Erlang Runtime System) cache.
Flow:
- Auto-detect platform (or use specified target)
- Download MANIFEST.json from remote URL (with local cache)
- If download fails, use local MANIFEST.json from priv/
- Look up ERTS URL in MANIFEST for the OTP version and platform
- Download and extract ERTS
:explicit(user-specified) - Uses exact version match only. Fails if not found.:auto(auto-detected) - Uses conservative fallback (28.0 → 28.1 → ...)
Auto-detects: OS (linux/macos/windows), Architecture (x86_64/aarch64), Libc (gnu/musl)
Summary
Functions
Returns the download URL for the specified OTP version and target.
Builds the platform key string from a platform map. Examples: "amd64-glibc", "amd64-musl", "darwin-arm64", etc.
Returns the platform detected from the current system as an atom (for backwards compatibility).
Returns the platform detected from the current system.
Fetches ERTS for the specified OTP version.
Finds the ERTS download URL for the specified OTP version and platform key.
Returns the user's cache directory for Batamanta.
Returns the path to the system ERTS.
Converts a target atom (e.g., :ubuntu_22_04_x86_64) to a platform map.
Types
@type otp_version() :: String.t()
@type version_mode() :: :explicit | :auto
Functions
@spec build_download_url(otp_version(), atom()) :: String.t()
Returns the download URL for the specified OTP version and target.
Builds the platform key string from a platform map. Examples: "amd64-glibc", "amd64-musl", "darwin-arm64", etc.
Returns the platform detected from the current system as an atom (for backwards compatibility).
@spec detect_platform() :: map()
Returns the platform detected from the current system.
@spec fetch(otp_version(), map() | atom() | nil, keyword()) :: {:ok, Path.t()} | {:error, String.t()}
Fetches ERTS for the specified OTP version.
otp_version- OTP version string (e.g., "28.0", "27.3.4")target- Optional target. Can be:nil- Auto-detect platform:auto- Same as nil- A target map with: os, arch, libc
opts- Optional keyword list::version_mode-:explicit(exact match only) or:auto(fallback)
= Batamanta.ERTS.Fetcher.fetch("28.0") {:ok, erts_path} = Batamanta.ERTS.Fetcher.fetch("28.0", os: "linux", arch: "x86_64", libc: "gnu") {:ok, erts_path} = Batamanta.ERTS.Fetcher.fetch("28.0", :ubuntu_22_04_x86_64, version_mode: :explicit)
@spec find_erts_url(otp_version(), String.t(), version_mode()) :: String.t() | nil
Finds the ERTS download URL for the specified OTP version and platform key.
:explicit- Returns exact match only, no fallbacks:auto- Uses conservative fallback strategy
@spec get_cache_dir() :: Path.t()
Returns the user's cache directory for Batamanta.
@spec system_erts_path() :: Path.t()
Returns the path to the system ERTS.
Converts a target atom (e.g., :ubuntu_22_04_x86_64) to a platform map.