Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to run Bundix without Nix tools in some cases #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/bundix/source.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'digest/sha2'

class Bundix
class Fetcher
def sh(*args, &block)
Expand Down Expand Up @@ -111,7 +113,11 @@ def fetch_local_hash(spec)
spec.source.caches.each do |cache|
path = File.join(cache, "#{spec.full_name}.gem")
next unless File.file?(path)
hash = nix_prefetch_url(path)&.[](SHA256_32)
hash = Digest::SHA256.file(path).digest.bytes
.reverse
.reduce(0) {|n, b| (n << 8) + b }
.digits(32).map {|d| "0123456789abcdfghijklmnpqrsvwxyz"[d] }.join.ljust(52, '0')
.reverse
return format_hash(hash) if hash
end

Expand Down