celerite 0.1.0-x86_64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +92 -0
- data/THIRD_PARTY_LICENSES.md +25 -0
- data/assets/bridge/server.rb +321 -0
- data/assets/licenses/bdw-gc.txt +33 -0
- data/assets/licenses/libiconv.txt +501 -0
- data/assets/licenses/libyaml.txt +20 -0
- data/assets/licenses/openssl-1.1.txt +125 -0
- data/assets/licenses/openssl.txt +177 -0
- data/assets/licenses/pcre2.txt +104 -0
- data/assets/licenses/zlib.txt +22 -0
- data/assets/licenses/zstd.txt +30 -0
- data/exe/celerite +57 -0
- data/lib/celerite/x86_64-linux/celerite +0 -0
- data/lib/celerite/x86_64-linux/libcrypto.so.3 +0 -0
- data/lib/celerite/x86_64-linux/libpcre2-8.so.0 +0 -0
- data/lib/celerite/x86_64-linux/libssl.so.3 +0 -0
- data/lib/celerite/x86_64-linux/libyaml-0.so.2 +0 -0
- data/lib/celerite/x86_64-linux/libz.so.1 +0 -0
- data/lib/celerite/x86_64-linux/libzstd.so.1 +0 -0
- metadata +63 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: fed87a610d403bc27e34153f261699a52d93f9ffc35f441a14ef490d26da8fab
|
|
4
|
+
data.tar.gz: 21b50a8e23210374f8eef82acd41cc9aaa1413c0d1f152cee0a2005b44a28e03
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: dca4970ff3db2350d49e26a00013c4480ded176646625be26b95dde338af6ea57f1384b59579becbdb2119c7d48cf553187e2fe600c98a4cdea4ca213d561d27
|
|
7
|
+
data.tar.gz: 4338bf0148331e9ba516785ee066c3cafb97bf38e1877830f0154f14d65a6ccedb41f8febcde4b85448b8baedc1b3b513061c9f4c7e9b1d45da24495c2ff28d8
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ShiningRay <tsowly@hotmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Celerite
|
|
2
|
+
|
|
3
|
+
A high-performance, Bundler-compatible Ruby dependency manager written in Crystal.
|
|
4
|
+
|
|
5
|
+
> **Status: M0+M1 complete (read-only locked path).** Celerite reads lockfiles,
|
|
6
|
+
> validates project state, and runs the locked-path versions of `check`,
|
|
7
|
+
> `list`, `show`/`info`, `platform`, `lock --print`, and `config get` — all
|
|
8
|
+
> verified byte-for-byte against pinned reference Bundlers via the differential
|
|
9
|
+
> harness. Resolution, installation, and the Ruby bridge are next (M2+).
|
|
10
|
+
> Compatibility is a release gate, not a claim based on parsing common Gemfiles.
|
|
11
|
+
|
|
12
|
+
## Goals
|
|
13
|
+
|
|
14
|
+
- Preserve Bundler's observable behavior: Gemfiles, lockfiles, CLI, installation,
|
|
15
|
+
runtime setup, and plugins.
|
|
16
|
+
- Move dependency resolution, Compact Index processing, downloads, verification,
|
|
17
|
+
and installation planning into native Crystal code.
|
|
18
|
+
- Keep a controlled Ruby compatibility bridge for arbitrary Ruby DSL, native
|
|
19
|
+
extension builds, and third-party Bundler plugins.
|
|
20
|
+
- Verify behavior with differential tests and the upstream Bundler test suite.
|
|
21
|
+
|
|
22
|
+
## Non-goals
|
|
23
|
+
|
|
24
|
+
- Replacing Ruby or RubyGems.
|
|
25
|
+
- Claiming compatibility through command names alone.
|
|
26
|
+
- Silently delegating an entire installation to `bundle install` when native
|
|
27
|
+
functionality is missing.
|
|
28
|
+
|
|
29
|
+
The `celerite` executable is the initial entry point. A `bundle` alias will be an
|
|
30
|
+
explicit, opt-in installation step; it will never be overwritten automatically.
|
|
31
|
+
|
|
32
|
+
## Documentation
|
|
33
|
+
|
|
34
|
+
- [架构方案](docs/architecture.md)
|
|
35
|
+
- [兼容性契约](docs/compatibility.md)
|
|
36
|
+
- [实施计划](docs/roadmap.md)
|
|
37
|
+
- [兼容矩阵基线](docs/compat-matrix/README.md) — per-version feature lists generated
|
|
38
|
+
from pinned upstream sources ([manifest](vendor/reference/MANIFEST.md))
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
One-liner (downloads the platform binary from GitHub Releases, verifies it
|
|
43
|
+
against `checksums.sha256`, installs to `~/.local/bin`; never replaces an
|
|
44
|
+
existing `bundle` — the shim lands as `celerite-bundle` instead):
|
|
45
|
+
|
|
46
|
+
```console
|
|
47
|
+
curl -fsSL https://github.com/ShiningRay/celerite/releases/latest/download/install.sh | bash
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Options: `PREFIX=<dir>`, pin a version with an argument (`... | bash -s -- 0.1.0`).
|
|
51
|
+
|
|
52
|
+
Via RubyGems (platform gems built per release):
|
|
53
|
+
|
|
54
|
+
```console
|
|
55
|
+
gem install celerite
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The gem ships the native binary plus the Ruby bridge; the installed shim
|
|
59
|
+
locates your Bundler gem automatically and exports the bridge environment
|
|
60
|
+
(`CELERITE_BRIDGE_SERVER`, `CELERITE_REFERENCE_BUNDLER_LIB`,
|
|
61
|
+
`CELERITE_PROFILE_BUNDLER_VERSION`).
|
|
62
|
+
|
|
63
|
+
Platform gems are self-contained: the release build bundles the non-system
|
|
64
|
+
shared libraries the binary links against (see `THIRD_PARTY_LICENSES.md`), for
|
|
65
|
+
Darwin (arm64 and x86_64), Linux x86_64, and Windows x64. No Homebrew, MSYS2, or
|
|
66
|
+
extra system packages are required.
|
|
67
|
+
|
|
68
|
+
Both channels are produced by `script/release` (dist bundle + platform gem
|
|
69
|
+
with an install smoke test); releases are published from the `v*` tag
|
|
70
|
+
workflow. A bare `gem build celerite.gemspec` produces a metadata-only gem —
|
|
71
|
+
always build through `script/gem`.
|
|
72
|
+
|
|
73
|
+
## Development
|
|
74
|
+
|
|
75
|
+
Requires Crystal 1.21.1 or newer.
|
|
76
|
+
|
|
77
|
+
```console
|
|
78
|
+
shards build # build bin/celerite
|
|
79
|
+
crystal spec # unit + property + behavior specs
|
|
80
|
+
crystal tool format --check src spec
|
|
81
|
+
script/differential # differential harness vs pinned reference Bundlers
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Reference Bundler versions (4.0.24 and 2.7.2) must be installed for the
|
|
85
|
+
differential harness: `gem install bundler -v 4.0.24 -v 2.7.2`. The harness runs
|
|
86
|
+
each fixture in isolated sandboxes (no network) and compares exit codes,
|
|
87
|
+
stdout/stderr, and the project file tree after path normalization.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
MIT. Celerite is an independent project and is not affiliated with the Bundler
|
|
92
|
+
or RubyGems teams.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Third-party licenses
|
|
2
|
+
|
|
3
|
+
Celerite itself is licensed under the MIT license (see `LICENSE`).
|
|
4
|
+
|
|
5
|
+
The platform gems bundle the non-system shared libraries the native binary
|
|
6
|
+
links against, so the gem runs without Homebrew, MSYS2, or extra system
|
|
7
|
+
packages. The corresponding license texts are shipped in `assets/licenses/`:
|
|
8
|
+
|
|
9
|
+
| Library | License | Text | Bundled on |
|
|
10
|
+
|---|---|---|---|
|
|
11
|
+
| Boehm-Demers-Weiser GC (`libgc`) | MIT-style | `assets/licenses/bdw-gc.txt` | macOS, Windows |
|
|
12
|
+
| OpenSSL 3/4 (`libssl`, `libcrypto`) | Apache-2.0 | `assets/licenses/openssl.txt` | macOS arm64, Linux, Windows |
|
|
13
|
+
| OpenSSL 1.1 (`libssl`, `libcrypto`) | OpenSSL/SSLeay | `assets/licenses/openssl-1.1.txt` | macOS x86_64 |
|
|
14
|
+
| PCRE2 (`libpcre2-8`) | BSD-3-Clause WITH PCRE2-exception | `assets/licenses/pcre2.txt` | macOS, Linux, Windows |
|
|
15
|
+
| libyaml (`libyaml`) | MIT | `assets/licenses/libyaml.txt` | macOS, Linux, Windows |
|
|
16
|
+
| zlib (`libz`) | zlib | `assets/licenses/zlib.txt` | Linux, Windows |
|
|
17
|
+
| zstd (`libzstd`) | BSD-3-Clause | `assets/licenses/zstd.txt` | Linux |
|
|
18
|
+
| libiconv (`iconv-2.dll`) | LGPL-2.1 | `assets/licenses/libiconv.txt` | Windows |
|
|
19
|
+
|
|
20
|
+
System libraries are not redistributed: macOS `libSystem`, `libz`, `libiconv`;
|
|
21
|
+
Linux glibc, `ld-linux`, and `libgcc_s`; Windows system DLLs and the Microsoft
|
|
22
|
+
VC++ runtime.
|
|
23
|
+
|
|
24
|
+
`iconv-2.dll` is dynamically linked and shipped as a separate library, so it
|
|
25
|
+
can be replaced by the user. libiconv source: https://www.gnu.org/software/libiconv/
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Celerite Ruby compatibility bridge — JSON Lines server.
|
|
4
|
+
#
|
|
5
|
+
# Architecture contract (docs/architecture.md §2.2): a short-lived, controlled
|
|
6
|
+
# Ruby subprocess implementing a versioned JSON Lines protocol. Each request
|
|
7
|
+
# carries a protocol version, request id, op and payload; responses are either
|
|
8
|
+
# structured results or structured errors — stderr/stdout Ruby text is never
|
|
9
|
+
# parsed back.
|
|
10
|
+
#
|
|
11
|
+
# Protocol v1 request: {"proto":1,"id":N,"op":"...","payload":{...}}
|
|
12
|
+
# Protocol v1 response: {"proto":1,"id":N,"ok":true,"result":{...}}
|
|
13
|
+
# {"proto":1,"id":N,"ok":false,"error":{"class":..,"message":..}}
|
|
14
|
+
#
|
|
15
|
+
# The bridge runs the Gemfile through the real Bundler::Dsl so arbitrary Ruby
|
|
16
|
+
# DSL semantics match the reference exactly. Which Bundler is loaded is chosen
|
|
17
|
+
# by the caller via $LOAD_PATH (CELERITE_REFERENCE_BUNDLER_LIB).
|
|
18
|
+
|
|
19
|
+
require "json"
|
|
20
|
+
require "digest"
|
|
21
|
+
require "rbconfig"
|
|
22
|
+
|
|
23
|
+
BRIDGE_PROTO = 1
|
|
24
|
+
|
|
25
|
+
def bridge_emit(response)
|
|
26
|
+
$stdout.puts JSON.generate(response)
|
|
27
|
+
$stdout.flush
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def bridge_error(id, klass, message)
|
|
31
|
+
bridge_emit("proto" => BRIDGE_PROTO, "id" => id, "ok" => false,
|
|
32
|
+
"error" => { "class" => klass, "message" => message })
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def bridge_platform_string
|
|
36
|
+
require "rubygems/platform"
|
|
37
|
+
Gem::Platform.local.to_s
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def op_ruby_environment(_payload)
|
|
41
|
+
require "rubygems"
|
|
42
|
+
{
|
|
43
|
+
"ruby_version" => RUBY_VERSION,
|
|
44
|
+
"ruby_description" => RUBY_DESCRIPTION,
|
|
45
|
+
"ruby_env_line" => "#{RUBY_VERSION}p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE} revision #{RUBY_REVISION}) [#{Gem::Platform.local}]",
|
|
46
|
+
"engine" => RUBY_ENGINE,
|
|
47
|
+
"engine_version" => RUBY_ENGINE_VERSION,
|
|
48
|
+
"rubygems_version" => Gem::VERSION,
|
|
49
|
+
"ruby_revision" => RUBY_REVISION.to_s,
|
|
50
|
+
"platform" => bridge_platform_string,
|
|
51
|
+
"ruby_exe" => RbConfig.ruby,
|
|
52
|
+
"gem_paths" => (ENV["GEM_PATH"] ? ENV["GEM_PATH"].split(Gem.path_separator) : Gem.path),
|
|
53
|
+
"default_gem_dir" => (ENV["GEM_HOME"] || Gem.default_dir),
|
|
54
|
+
"user_gem_dir" => (Gem.user_dir rescue nil),
|
|
55
|
+
"loaded_bundler_version" => (defined?(Bundler) ? Bundler::VERSION : (Gem.loaded_specs["bundler"]&.version.to_s)),
|
|
56
|
+
}
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Loads Bundler from the requested load path (or whatever `ruby` resolves),
|
|
60
|
+
# evaluates the Gemfile with the real Bundler::Dsl, and serializes the
|
|
61
|
+
# evaluation results for the native core.
|
|
62
|
+
def op_evaluate_gemfile(payload)
|
|
63
|
+
gemfile = payload["gemfile"]
|
|
64
|
+
raise ArgumentError, "missing gemfile path" unless gemfile
|
|
65
|
+
|
|
66
|
+
# Pin the reference Bundler when requested (isolated environments would
|
|
67
|
+
# otherwise fall back to the default gem). The load path wins because gem
|
|
68
|
+
# activation cannot see installed gems outside an isolated GEM_PATH.
|
|
69
|
+
if lib = ENV["CELERITE_REFERENCE_BUNDLER_LIB"]
|
|
70
|
+
$LOAD_PATH.unshift(lib) unless lib.empty?
|
|
71
|
+
elsif version = ENV["CELERITE_REFERENCE_BUNDLER_VERSION"]
|
|
72
|
+
gem "bundler", version unless version.empty?
|
|
73
|
+
end
|
|
74
|
+
require "bundler"
|
|
75
|
+
require "bundler/dsl"
|
|
76
|
+
|
|
77
|
+
builder = Bundler::Dsl.new
|
|
78
|
+
contents = File.read(gemfile)
|
|
79
|
+
builder.eval_gemfile(gemfile, contents)
|
|
80
|
+
|
|
81
|
+
deps = builder.dependencies.map do |dep|
|
|
82
|
+
source = dep.source
|
|
83
|
+
{
|
|
84
|
+
"name" => dep.name,
|
|
85
|
+
"requirements" => dep.requirement.as_list,
|
|
86
|
+
"groups" => dep.groups.map(&:to_s),
|
|
87
|
+
"platforms" => dep.platforms.map(&:to_s),
|
|
88
|
+
"autorequire" => dep.autorequire,
|
|
89
|
+
"force_ruby_platform" => dep.force_ruby_platform,
|
|
90
|
+
"gemspec_dev_dep" => !!dep.gemspec_dev_dep?,
|
|
91
|
+
"source" => source ? serialize_source(source) : nil,
|
|
92
|
+
}
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
{
|
|
96
|
+
"gemfile" => gemfile,
|
|
97
|
+
"dependencies" => deps,
|
|
98
|
+
"sources" => builder.instance_variable_get(:@sources).all_sources.map { |s| serialize_source(s) },
|
|
99
|
+
"ruby" => builder.instance_variable_get(:@ruby_version)&.to_s,
|
|
100
|
+
"bundler_version" => Bundler::VERSION,
|
|
101
|
+
"gemfile_sha256" => Digest::SHA256.hexdigest(contents),
|
|
102
|
+
}
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def op_bundler_cache_file(payload)
|
|
106
|
+
require "bundler"
|
|
107
|
+
version = payload["version"]
|
|
108
|
+
version = Bundler::VERSION if version.nil? || version.empty?
|
|
109
|
+
spec = Gem::Specification.find_by_name("bundler", version)
|
|
110
|
+
{ "path" => spec.cache_file, "exists" => File.exist?(spec.cache_file) }
|
|
111
|
+
rescue Gem::LoadError, Gem::MissingSpecError, Gem::MissingSpecVersionError
|
|
112
|
+
# Isolated GEM_PATH: fall back to the load-path-provided gem (the running
|
|
113
|
+
# Bundler), matching how the reference's metadata source finds it.
|
|
114
|
+
if lib = ENV["CELERITE_REFERENCE_BUNDLER_LIB"]
|
|
115
|
+
# lib = <repository>/gems/bundler-<version>/lib; the spec cache file lives
|
|
116
|
+
# at <repository>/cache/bundler-<version>.gem
|
|
117
|
+
repository = File.expand_path("../../..", lib)
|
|
118
|
+
cache = File.join(repository, "cache", "bundler-#{version}.gem")
|
|
119
|
+
{ "path" => cache, "exists" => File.exist?(cache), "lib_env" => lib }
|
|
120
|
+
else
|
|
121
|
+
{ "path" => nil, "exists" => false }
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Unmarshal the specification of a .gem file and serialize the fields the
|
|
126
|
+
# native installer needs (pinned: Gem::Package spec fields).
|
|
127
|
+
def op_read_gem_spec(payload)
|
|
128
|
+
require "rubygems/package"
|
|
129
|
+
path = payload["path"]
|
|
130
|
+
spec = Gem::Package.new(path).spec
|
|
131
|
+
{
|
|
132
|
+
"name" => spec.name,
|
|
133
|
+
"version" => spec.version.to_s,
|
|
134
|
+
"platform" => spec.platform.to_s,
|
|
135
|
+
"full_name" => spec.full_name,
|
|
136
|
+
"executables" => spec.executables,
|
|
137
|
+
"bindir" => spec.bindir,
|
|
138
|
+
"required_ruby_version" => spec.required_ruby_version.to_s,
|
|
139
|
+
"required_rubygems_version" => spec.required_rubygems_version.to_s,
|
|
140
|
+
"extensions" => spec.extensions,
|
|
141
|
+
"date" => (spec.date.to_s if spec.respond_to?(:date)),
|
|
142
|
+
"license" => (spec.license if spec.respond_to?(:license)),
|
|
143
|
+
"licenses" => (spec.licenses if spec.respond_to?(:licenses)),
|
|
144
|
+
"dependencies" => spec.runtime_dependencies.map { |d|
|
|
145
|
+
{ "name" => d.name, "type" => d.type.to_s, "requirements" => d.requirement.as_list }
|
|
146
|
+
},
|
|
147
|
+
}
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# Write the Marshal'd specification of an installed gem (specifications/*.gemspec)
|
|
151
|
+
# the way RubyGems does, given the extracted gem directory.
|
|
152
|
+
def op_write_installed_spec(payload)
|
|
153
|
+
require "rubygems/package"
|
|
154
|
+
require "fileutils"
|
|
155
|
+
gem_path = payload["gem_path"] # cache/<name>-<version>.gem
|
|
156
|
+
destination = payload["destination"] # specifications/<full_name>.gemspec
|
|
157
|
+
spec = Gem::Package.new(gem_path).spec
|
|
158
|
+
# Recording the install path keeps parity with RubyGems-installed specs
|
|
159
|
+
spec.full_gem_path = payload["gem_dir"] if payload["gem_dir"]
|
|
160
|
+
FileUtils.mkdir_p(File.dirname(destination))
|
|
161
|
+
# RubyGems writes Ruby-format stub specifications (not Marshal)
|
|
162
|
+
File.write(destination, spec.to_ruby_for_cache)
|
|
163
|
+
{
|
|
164
|
+
"name" => spec.name,
|
|
165
|
+
"full_name" => spec.full_name,
|
|
166
|
+
"executables" => spec.executables,
|
|
167
|
+
"bindir" => spec.bindir,
|
|
168
|
+
"extensions" => spec.extensions,
|
|
169
|
+
}
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Build native extensions with the reference Ruby/RubyGems toolchain
|
|
173
|
+
# (architecture §2.1: extensions run through the Ruby toolchain, not native code).
|
|
174
|
+
def op_build_extension(payload)
|
|
175
|
+
require "rubygems/ext"
|
|
176
|
+
require "rubygems/package"
|
|
177
|
+
require "rubygems/user_interaction"
|
|
178
|
+
require "fileutils"
|
|
179
|
+
# Builder output would corrupt the JSON Lines protocol on stdout; silence it
|
|
180
|
+
Gem::DefaultUserInteraction.ui = Gem::SilentUI.new
|
|
181
|
+
gem_dir = payload["gem_dir"]
|
|
182
|
+
destination = payload["destination"] # extensions/<platform>/<abi>/<full_name>
|
|
183
|
+
# The payload may not contain a .gemspec; load the spec from the cached .gem
|
|
184
|
+
spec = if payload["gem_path"] && File.exist?(payload["gem_path"])
|
|
185
|
+
Gem::Package.new(payload["gem_path"]).spec
|
|
186
|
+
else
|
|
187
|
+
Gem::Specification.load(File.join(gem_dir, "#{payload["name"]}.gemspec"))
|
|
188
|
+
end
|
|
189
|
+
raise "gemspec not found in #{gem_dir}" unless spec
|
|
190
|
+
gem_build_complete = File.join(destination, "gem.build_complete")
|
|
191
|
+
FileUtils.mkdir_p(destination)
|
|
192
|
+
spec.full_gem_path = gem_dir
|
|
193
|
+
spec.extension_dir = destination
|
|
194
|
+
Gem::Ext::Builder.new(spec).build_extensions
|
|
195
|
+
File.write(gem_build_complete, "")
|
|
196
|
+
{ "built" => spec.extensions, "complete" => gem_build_complete }
|
|
197
|
+
rescue StandardError => e
|
|
198
|
+
{ "error" => e.message, "backtrace" => e.backtrace.first(4) }
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# Load the gemspec of a directory source (path gems, git checkouts).
|
|
202
|
+
def op_load_gemspec_dir(payload)
|
|
203
|
+
require "rubygems/specification"
|
|
204
|
+
dir = payload["dir"].tr("\\", "/")
|
|
205
|
+
glob = payload["glob"] || "{,*}.gemspec"
|
|
206
|
+
candidates = Dir.glob(File.join(dir, glob)).sort
|
|
207
|
+
raise "no gemspec in #{dir}" if candidates.empty?
|
|
208
|
+
spec = Gem::Specification.load(candidates.first)
|
|
209
|
+
raise "invalid gemspec in #{dir}" unless spec
|
|
210
|
+
{
|
|
211
|
+
"name" => spec.name,
|
|
212
|
+
"version" => spec.version.to_s,
|
|
213
|
+
"platform" => spec.platform.to_s,
|
|
214
|
+
"full_name" => spec.full_name,
|
|
215
|
+
"executables" => spec.executables,
|
|
216
|
+
"bindir" => spec.bindir,
|
|
217
|
+
"required_ruby_version" => spec.required_ruby_version.to_s,
|
|
218
|
+
"required_rubygems_version" => spec.required_rubygems_version.to_s,
|
|
219
|
+
"extensions" => spec.extensions,
|
|
220
|
+
"dependencies" => spec.runtime_dependencies.map { |d|
|
|
221
|
+
{ "name" => d.name, "type" => d.type.to_s, "requirements" => d.requirement.as_list }
|
|
222
|
+
},
|
|
223
|
+
}
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# Execute a plugin lifecycle hook through the reference Bundler::Plugin API
|
|
227
|
+
# (architecture §2.2: plugin hooks are Ruby code, executed by the bridge).
|
|
228
|
+
# payload: event, plugins_root (dir holding the plugins index), context (hash).
|
|
229
|
+
def op_exec_plugin_hook(payload)
|
|
230
|
+
require "bundler"
|
|
231
|
+
require "bundler/plugin"
|
|
232
|
+
require "yaml"
|
|
233
|
+
event = payload["event"].to_s
|
|
234
|
+
index_path = payload["index_path"].to_s
|
|
235
|
+
return { "fired" => false, "reason" => "no plugin index" } unless File.exist?(index_path)
|
|
236
|
+
|
|
237
|
+
index = YAML.safe_load(File.read(index_path), permitted_classes: [Symbol], aliases: true) || {}
|
|
238
|
+
load_paths = index["load_paths"] || {}
|
|
239
|
+
hook_plugins = (index["hooks"] || {})[event] || []
|
|
240
|
+
return { "fired" => false, "reason" => "no plugins for event" } if hook_plugins.empty?
|
|
241
|
+
|
|
242
|
+
loaded = []
|
|
243
|
+
plugin_paths = index["plugin_paths"] || {}
|
|
244
|
+
hook_plugins.each do |name|
|
|
245
|
+
paths = load_paths[name]
|
|
246
|
+
if paths.is_a?(Array)
|
|
247
|
+
paths.each { |p| $LOAD_PATH.unshift(p) unless $LOAD_PATH.include?(p) }
|
|
248
|
+
end
|
|
249
|
+
begin
|
|
250
|
+
# Reference entry point: each plugin ships a root plugins.rb
|
|
251
|
+
entry = plugin_paths[name] ? File.join(plugin_paths[name].to_s, "plugins.rb") : name.to_s.tr("-", "/")
|
|
252
|
+
require entry
|
|
253
|
+
rescue LoadError, StandardError => e
|
|
254
|
+
return { "fired" => false, "reason" => "plugin #{name} failed to load: #{e.message}" }
|
|
255
|
+
end
|
|
256
|
+
loaded << name
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
# plugins.rb (or its lib) registered hooks through the reference
|
|
260
|
+
# Bundler::Plugin::API (global registry). Bundler::Plugin.hook gates on
|
|
261
|
+
# its global index; for project-local plugins we invoke the registered
|
|
262
|
+
# blocks directly (same objects the reference would call).
|
|
263
|
+
hooks = Bundler::Plugin.instance_variable_get(:@hooks_by_event) || {}
|
|
264
|
+
blocks = hooks[event] || []
|
|
265
|
+
context = payload["context"] || {}
|
|
266
|
+
blocks.each { |blk| blk.call(context) }
|
|
267
|
+
{ "fired" => blocks.any?, "plugins" => loaded }
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
def serialize_source(source)
|
|
271
|
+
type = source.class.name.split("::").last # Rubygems / Git / Path / Plugin / Metadata
|
|
272
|
+
result = { "type" => type }
|
|
273
|
+
if source.respond_to?(:remotes) && !source.remotes.empty?
|
|
274
|
+
result["remotes"] = source.remotes.map(&:to_s)
|
|
275
|
+
elsif source.respond_to?(:uri)
|
|
276
|
+
result["remote"] = source.uri.to_s
|
|
277
|
+
elsif source.respond_to?(:path) && source.path
|
|
278
|
+
# Path/Gemspec sources expose their location via #path
|
|
279
|
+
result["remote"] = source.path.to_s
|
|
280
|
+
end
|
|
281
|
+
%w[branch tag ref glob submodules].each do |key|
|
|
282
|
+
value = source.options[key] if source.respond_to?(:options)
|
|
283
|
+
result[key] = value if value
|
|
284
|
+
end
|
|
285
|
+
result
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
def bridge_dispatch(id, op, payload)
|
|
289
|
+
result = case op
|
|
290
|
+
when "ping" then { "proto" => BRIDGE_PROTO, "ruby" => RUBY_VERSION }
|
|
291
|
+
when "ruby_environment" then op_ruby_environment(payload)
|
|
292
|
+
when "evaluate_gemfile" then op_evaluate_gemfile(payload)
|
|
293
|
+
when "bundler_cache_file" then op_bundler_cache_file(payload)
|
|
294
|
+
when "read_gem_spec" then op_read_gem_spec(payload)
|
|
295
|
+
when "write_installed_spec" then op_write_installed_spec(payload)
|
|
296
|
+
when "build_extension" then op_build_extension(payload)
|
|
297
|
+
when "load_gemspec_dir" then op_load_gemspec_dir(payload)
|
|
298
|
+
when "exec_plugin_hook" then op_exec_plugin_hook(payload)
|
|
299
|
+
else
|
|
300
|
+
return bridge_error(id, "UnknownOp", "unknown bridge op #{op.inspect}")
|
|
301
|
+
end
|
|
302
|
+
bridge_emit("proto" => BRIDGE_PROTO, "id" => id, "ok" => true, "result" => result)
|
|
303
|
+
rescue Exception => e # rubocop:disable Lint/RescueException — bridge boundary: everything is reported, nothing escapes
|
|
304
|
+
bridge_error(id, e.class.name.to_s, e.message.to_s)
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
loop do
|
|
308
|
+
line = $stdin.gets
|
|
309
|
+
break if line.nil?
|
|
310
|
+
|
|
311
|
+
line = line.strip
|
|
312
|
+
next if line.empty?
|
|
313
|
+
|
|
314
|
+
request = JSON.parse(line)
|
|
315
|
+
id = request["id"]
|
|
316
|
+
unless request["proto"] == BRIDGE_PROTO
|
|
317
|
+
bridge_error(id, "ProtocolError", "unsupported proto #{request["proto"].inspect}")
|
|
318
|
+
next
|
|
319
|
+
end
|
|
320
|
+
bridge_dispatch(id, request["op"], request["payload"] || {})
|
|
321
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
MIT-style License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 1988-1989 Hans-J. Boehm, Alan J. Demers
|
|
4
|
+
Copyright (c) 1991-1996 by Xerox Corporation. All rights reserved.
|
|
5
|
+
Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
|
|
6
|
+
Copyright (c) 1998 by Fergus Henderson. All rights reserved.
|
|
7
|
+
Copyright (c) 1999-2001 by Red Hat, Inc. All rights reserved.
|
|
8
|
+
Copyright (c) 1999-2011 Hewlett-Packard Development Company, L.P.
|
|
9
|
+
Copyright (c) 2004-2005 Andrei Polushin
|
|
10
|
+
Copyright (c) 2007 Free Software Foundation, Inc.
|
|
11
|
+
Copyright (c) 2008-2026 Ivan Maidanski
|
|
12
|
+
Copyright (c) 2011 Ludovic Courtes
|
|
13
|
+
Copyright (c) 2018 Petter A. Urkedal
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
|
|
17
|
+
OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
|
18
|
+
|
|
19
|
+
Permission is hereby granted to use or copy this program
|
|
20
|
+
for any purpose, provided the above notices are retained on all copies.
|
|
21
|
+
Permission to modify the code and to distribute modified code is granted,
|
|
22
|
+
provided the above notices are retained, and a notice that the code was
|
|
23
|
+
modified is included with the above copyright notice.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
Several files (gc/gc_allocator.h, extra/msvc_dbg.c) come with slightly
|
|
27
|
+
different licenses, though they are all similar in spirit (the exact
|
|
28
|
+
licensing terms are given at the beginning of the corresponding source file).
|
|
29
|
+
|
|
30
|
+
A few of the files needed to use the GNU-style build procedure come with
|
|
31
|
+
a modified GPL license that appears not to significantly restrict use of
|
|
32
|
+
the collector, though use of those files for a purpose other than building
|
|
33
|
+
the collector may require the resulting code to be covered by the GPL.
|