pack-rb 0.1.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8fcc3c6b2afa83dab5eeea8421f61e9c5fc89c4ec8cdac5ec679d7d4cb54c551
4
+ data.tar.gz: c6c8629d199f1472a0a40183e891b17ab0c5ef6e1d69a673bfb1d025536ef68d
5
+ SHA512:
6
+ metadata.gz: 991e7b738fd63b7edfc303a931f81d86de289cf5f758692ecca6e18011cecb2f1ad31745f1e344fe278a6e0eb719fcaee9c02c4c4708384745ff585b771a16ed
7
+ data.tar.gz: cc3430255f66129741fb25c7d98d557958a3de82ecc6e9f285ee12ce4c29198142fb8eac0e5a218bf2f2ed3d050bd4f1833dc3cc1c416ce23e41172f837345f1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Piper Software
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,20 @@
1
+ # pack-rb
2
+
3
+ `pack-rb` installs a `pack` executable through RubyGems and delegates to the Pack Rust binary.
4
+
5
+ ```bash
6
+ gem install pack-rb
7
+ pack --help
8
+ ```
9
+
10
+ On first run, the wrapper detects the current platform, downloads the matching Pack release asset from GitHub Releases, stores it in the user cache, and execs it.
11
+
12
+ The wrapper follows GitHub release redirects and verifies the downloaded binary against the published `SHA256SUMS` file before it is installed.
13
+
14
+ Environment variables:
15
+
16
+ - `PACK_RB_VERSION` forces a specific Pack version instead of the gem version.
17
+ - `PACK_RB_GITHUB_REPOSITORY` overrides the default release repository.
18
+ - `PACK_RB_DOWNLOAD_BASE_URL` overrides the release download base URL completely.
19
+ - `PACK_RB_INSTALL_DIR` overrides the local binary cache directory.
20
+ - `PACK_RB_SKIP_CHECKSUM=1` disables checksum verification for custom development mirrors.
data/exe/pack ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "pack/rb"
5
+
6
+ Pack::RB::Launcher.run(ARGV)
@@ -0,0 +1,176 @@
1
+ require "fileutils"
2
+ require "digest"
3
+ require "net/http"
4
+ require "rbconfig"
5
+ require "tempfile"
6
+ require "tmpdir"
7
+ require "uri"
8
+
9
+ module Pack
10
+ module RB
11
+ class Launcher
12
+ class Error < StandardError; end
13
+
14
+ class << self
15
+ def run(argv = ARGV)
16
+ new(argv).run
17
+ end
18
+ end
19
+
20
+ def initialize(argv)
21
+ @argv = argv
22
+ end
23
+
24
+ def run
25
+ binary = ensure_binary!
26
+ exec(binary, *@argv)
27
+ rescue SystemCallError => e
28
+ raise Error, "failed to launch pack binary: #{e.message}"
29
+ end
30
+
31
+ private
32
+
33
+ def ensure_binary!
34
+ path = installed_binary_path
35
+ return path if File.exist?(path)
36
+
37
+ FileUtils.mkdir_p(File.dirname(path))
38
+ download_to(path)
39
+ FileUtils.chmod("+x", path) unless windows?
40
+ path
41
+ end
42
+
43
+ def download_to(path)
44
+ checksum = expected_checksum_for(asset_name)
45
+ with_download_response(download_url) do |response|
46
+ Tempfile.create(["pack-rb", windows? ? ".exe" : ""], File.dirname(path)) do |tmp|
47
+ tmp.binmode
48
+ response.read_body { |chunk| tmp.write(chunk) }
49
+ tmp.flush
50
+ staged_path = tmp.path
51
+ tmp.close
52
+ verify_checksum!(staged_path, checksum)
53
+ FileUtils.mv(staged_path, path)
54
+ end
55
+ end
56
+ rescue SocketError, IOError, SystemCallError, Timeout::Error => e
57
+ raise Error, "failed to download pack binary: #{e.message}"
58
+ end
59
+
60
+ def with_download_response(url, limit = 5, &block)
61
+ raise Error, "too many redirects while downloading #{url}" if limit <= 0
62
+
63
+ uri = URI.parse(url)
64
+ Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |http|
65
+ http.open_timeout = 15
66
+ http.read_timeout = 120
67
+
68
+ request = Net::HTTP::Get.new(uri.request_uri)
69
+ request["User-Agent"] = "pack-rb/#{VERSION}"
70
+ request["Accept"] = "application/octet-stream"
71
+
72
+ http.request(request) do |response|
73
+ case response
74
+ when Net::HTTPSuccess
75
+ yield response
76
+ when Net::HTTPRedirection
77
+ location = response["location"]
78
+ raise Error, "redirect missing location for #{url}" unless location
79
+
80
+ redirected = URI.join(url, location).to_s
81
+ with_download_response(redirected, limit - 1, &block)
82
+ else
83
+ raise Error, "download failed with HTTP #{response.code} from #{url}"
84
+ end
85
+ end
86
+ end
87
+ end
88
+
89
+ def expected_checksum_for(target_asset)
90
+ return nil if ENV["PACK_RB_SKIP_CHECKSUM"] == "1"
91
+
92
+ body = +""
93
+ with_download_response("#{download_base_url}/SHA256SUMS") do |response|
94
+ response.read_body { |chunk| body << chunk }
95
+ end
96
+
97
+ match = body.each_line.map(&:strip).find { |line| line.end_with?(" #{target_asset}") }
98
+ raise Error, "checksum entry missing for #{target_asset}" unless match
99
+
100
+ match.split(/\s+/, 2).first
101
+ end
102
+
103
+ def verify_checksum!(path, expected)
104
+ return unless expected
105
+
106
+ actual = Digest::SHA256.file(path).hexdigest
107
+ return if actual == expected
108
+
109
+ raise Error, "checksum mismatch for downloaded pack binary"
110
+ end
111
+
112
+ def download_url
113
+ "#{download_base_url}/#{asset_name}"
114
+ end
115
+
116
+ def download_base_url
117
+ ENV["PACK_RB_DOWNLOAD_BASE_URL"] || "https://github.com/#{github_repository}/releases/download/v#{pack_version}"
118
+ end
119
+
120
+ def github_repository
121
+ ENV["PACK_RB_GITHUB_REPOSITORY"] || "Blu3Ph4ntom/pack"
122
+ end
123
+
124
+ def installed_binary_path
125
+ File.join(install_dir, pack_version, asset_name)
126
+ end
127
+
128
+ def install_dir
129
+ ENV["PACK_RB_INSTALL_DIR"] || File.join(Dir.home, ".pack-rb", "bin")
130
+ end
131
+
132
+ def pack_version
133
+ ENV["PACK_RB_VERSION"] || VERSION
134
+ end
135
+
136
+ def asset_name
137
+ "pack-#{target_triple}#{windows? ? '.exe' : ''}"
138
+ end
139
+
140
+ def target_triple
141
+ @target_triple ||= begin
142
+ cpu = normalize_cpu
143
+ os = RbConfig::CONFIG["host_os"]
144
+
145
+ case os
146
+ when /linux/
147
+ raise Error, "unsupported CPU for Linux: #{cpu}" unless cpu == "x86_64"
148
+ "x86_64-unknown-linux-gnu"
149
+ when /darwin/
150
+ "#{cpu}-apple-darwin"
151
+ when /mswin|mingw|cygwin/
152
+ raise Error, "unsupported CPU for Windows: #{cpu}" unless cpu == "x86_64"
153
+ "x86_64-pc-windows-msvc"
154
+ else
155
+ raise Error, "unsupported platform: #{RbConfig::CONFIG["host_cpu"]} #{os}"
156
+ end
157
+ end
158
+ end
159
+
160
+ def normalize_cpu
161
+ case RbConfig::CONFIG["host_cpu"]
162
+ when "x86_64", "amd64", "x64"
163
+ "x86_64"
164
+ when "arm64", "aarch64"
165
+ "aarch64"
166
+ else
167
+ raise Error, "unsupported CPU: #{RbConfig::CONFIG["host_cpu"]}"
168
+ end
169
+ end
170
+
171
+ def windows?
172
+ (/mswin|mingw|cygwin/ =~ RbConfig::CONFIG["host_os"]) != nil
173
+ end
174
+ end
175
+ end
176
+ end
@@ -0,0 +1,5 @@
1
+ module Pack
2
+ module RB
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
data/lib/pack/rb.rb ADDED
@@ -0,0 +1,2 @@
1
+ require_relative "rb/version"
2
+ require_relative "rb/launcher"
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pack-rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Hemanth
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2026-04-30 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: pack-rb installs a Ruby wrapper executable named `pack` that downloads
14
+ the matching Pack release binary for the current platform and then hands control
15
+ to it.
16
+ email:
17
+ - opensource@blu3phantom.dev
18
+ executables:
19
+ - pack
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - LICENSE.txt
24
+ - README.md
25
+ - exe/pack
26
+ - lib/pack/rb.rb
27
+ - lib/pack/rb/launcher.rb
28
+ - lib/pack/rb/version.rb
29
+ homepage: https://github.com/Blu3Ph4ntom/pack
30
+ licenses:
31
+ - MIT
32
+ metadata:
33
+ homepage_uri: https://blu3ph4ntom.github.io/pack/
34
+ source_code_uri: https://github.com/Blu3Ph4ntom/pack
35
+ documentation_uri: https://blu3ph4ntom.github.io/pack/docs/
36
+ changelog_uri: https://github.com/Blu3Ph4ntom/pack/releases
37
+ rubygems_mfa_required: 'true'
38
+ post_install_message: |
39
+ pack-rb installed the `pack` launcher.
40
+ First run will download the matching Pack binary from GitHub Releases.
41
+
42
+ Example:
43
+ pack --help
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '3.1'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubygems_version: 3.5.22
59
+ signing_key:
60
+ specification_version: 4
61
+ summary: Install and launch the Pack Rust binary from RubyGems.
62
+ test_files: []