Class: Beni::Vendor::Toolchain
- Inherits:
-
Object
- Object
- Beni::Vendor::Toolchain
- Defined in:
- lib/beni/vendor/toolchain.rb,
sig/beni/vendor/toolchain.rbs
Overview
Declarative value object describing a tarball-style vendored
toolchain. Captures the (remote, cache, unpacked) triple anchored
on vendor_dir, and exposes the three pipeline stages (+#fetch+,
#verify, #install) that Beni::Tasks wires into file /
task declarations.
Adding a new tarball-based vendor artifact is a single factory
method in Beni::Vendor; the rake DSL loop in Beni::Tasks
picks it up automatically.
Fields:
* +name+ — display name; also the basename of the unpacked
tree under +vendor_dir+ and the base for the
+setup:<name>+ task identifier.
* +version_label+ — version string; printed in the download log and
stamped into +final_dir+ as the idempotency key
that detects a bump and forces a re-extract.
* +base_url+ — remote URL prefix; resolved through
+Beni::Vendor.base_url_for+ so test fixtures
can override via +BENI_VENDOR_BASE_URL+.
* +tarball_name+ — filename joined to both +base_url+ (download)
and the +.cache+ directory (cache location).
* +top_level_dir+ — the single top-level directory produced when
the tarball is extracted; passed through to
+Tarball#prepare+ under the same name.
* +vendor_dir+ — root of the vendor tree; anchors +final_dir+
and +tarball_path+.
* +expected_sha256+ — the toolchain's selected checksum (resolved
by +Beni::Vendor+ from the built-in pair or a
consumer override); +nil+ falls to TOFU
sidecar pinning in +Checksum#verify_or_pin+.
Instance Attribute Summary collapse
-
#base_url ⇒ String
readonly
Returns the value of attribute base_url.
-
#expected_sha256 ⇒ String?
readonly
Returns the value of attribute expected_sha256.
-
#name ⇒ String
readonly
Returns the value of attribute name.
-
#tarball_name ⇒ String
readonly
Returns the value of attribute tarball_name.
-
#top_level_dir ⇒ String
readonly
Returns the value of attribute top_level_dir.
-
#vendor_dir ⇒ String
readonly
Returns the value of attribute vendor_dir.
-
#version_label ⇒ String
readonly
Returns the value of attribute version_label.
Instance Method Summary collapse
-
#downloader ⇒ Downloader
The network boundary — tests override this to script the download without opening a connection.
-
#fetch ⇒ String
Download the tarball into
tarball_pathand verify its SHA256. -
#final_dir ⇒ String
Destination under
vendor_dirwhere the unpacked tree is moved. -
#initialize ⇒ Toolchain
constructor
A new instance of Toolchain.
-
#install ⇒ void
Verify the cached tarball, then unpack it into
final_dirviaTarball#prepare. -
#tarball_path ⇒ String
Local cache path for the downloaded tarball.
-
#task_name ⇒ Symbol
Symbol used to identify the
setup:<task_name>rake task. -
#url ⇒ String
Resolved download URL.
-
#verify ⇒ String
Recompute the cached tarball's SHA256 and check it against
expected_sha256(or pin via TOFU sidecar).
Constructor Details
#initialize ⇒ Toolchain
Returns a new instance of Toolchain.
12 |
# File 'sig/beni/vendor/toolchain.rbs', line 12
def initialize: (name: String, version_label: String, base_url: String, tarball_name: String, top_level_dir: String, vendor_dir: String, expected_sha256: String?) -> void
|
Instance Attribute Details
#base_url ⇒ String (readonly)
Returns the value of attribute base_url.
6 7 8 |
# File 'sig/beni/vendor/toolchain.rbs', line 6 def base_url @base_url end |
#expected_sha256 ⇒ String? (readonly)
Returns the value of attribute expected_sha256.
10 11 12 |
# File 'sig/beni/vendor/toolchain.rbs', line 10 def expected_sha256 @expected_sha256 end |
#name ⇒ String (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'sig/beni/vendor/toolchain.rbs', line 4 def name @name end |
#tarball_name ⇒ String (readonly)
Returns the value of attribute tarball_name.
7 8 9 |
# File 'sig/beni/vendor/toolchain.rbs', line 7 def tarball_name @tarball_name end |
#top_level_dir ⇒ String (readonly)
Returns the value of attribute top_level_dir.
8 9 10 |
# File 'sig/beni/vendor/toolchain.rbs', line 8 def top_level_dir @top_level_dir end |
#vendor_dir ⇒ String (readonly)
Returns the value of attribute vendor_dir.
9 10 11 |
# File 'sig/beni/vendor/toolchain.rbs', line 9 def vendor_dir @vendor_dir end |
#version_label ⇒ String (readonly)
Returns the value of attribute version_label.
5 6 7 |
# File 'sig/beni/vendor/toolchain.rbs', line 5 def version_label @version_label end |
Instance Method Details
#downloader ⇒ Downloader
The network boundary — tests override this to script the download without opening a connection.
102 103 104 |
# File 'lib/beni/vendor/toolchain.rb', line 102 def downloader Downloader.new(url, tarball_path) end |
#fetch ⇒ String
Download the tarball into tarball_path and verify its SHA256.
Intended as the body of the file tarball_path rake task; the
task's mtime-based caching avoids re-downloading on a cache hit.
A tarball failing verification deliberately stays cached: a
checksum mismatch is an abort condition, never a re-download
trigger, and the cache-hit path re-fails it the same way.
70 71 72 73 74 |
# File 'lib/beni/vendor/toolchain.rb', line 70 def fetch puts "[beni] downloading #{name} #{version_label} from #{url}" downloader.download verify end |
#final_dir ⇒ String
Destination under vendor_dir where the unpacked tree is moved.
54 55 56 |
# File 'lib/beni/vendor/toolchain.rb', line 54 def final_dir File.join(vendor_dir, name) end |
#install ⇒ void
This method returns an undefined value.
Verify the cached tarball, then unpack it into final_dir via
Tarball#prepare. A no-op when the version stamped under final_dir
already matches version_label.
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/beni/vendor/toolchain.rb', line 87 def install verify Tarball.new( tarball: tarball_path, top_level_dir: top_level_dir, final_dir: final_dir, version: version_label ).prepare puts "[beni] #{name} ready at #{final_dir}" end |
#tarball_path ⇒ String
Local cache path for the downloaded tarball. Lives under
vendor_dir/.cache (the cache moves with the vendor tree).
60 61 62 |
# File 'lib/beni/vendor/toolchain.rb', line 60 def tarball_path File.join(vendor_dir, ".cache", tarball_name) end |
#task_name ⇒ Symbol
Symbol used to identify the setup:<task_name> rake task. Dashes
in name are not valid in rake task identifiers, so we map them
to underscores at this single seam.
42 43 44 |
# File 'lib/beni/vendor/toolchain.rb', line 42 def task_name name.tr("-", "_").to_sym end |
#url ⇒ String
Resolved download URL. Honours the BENI_VENDOR_BASE_URL test
fixture override at call time (not at construction time), so a
test can flip the env var after the Toolchain is built.
49 50 51 |
# File 'lib/beni/vendor/toolchain.rb', line 49 def url "#{Vendor.base_url_for(base_url)}/#{tarball_name}" end |
#verify ⇒ String
Recompute the cached tarball's SHA256 and check it against
expected_sha256 (or pin via TOFU sidecar). Idempotent — safe
to call from both file and setup task bodies when the latter
depends on the former.
80 81 82 |
# File 'lib/beni/vendor/toolchain.rb', line 80 def verify Checksum.new(tarball_path, expected_sha256).verify_or_pin end |