diff --git a/lib/rbpkg.rb b/lib/rbpkg.rb
index d7b41b7..798f4a9 100644
--- a/lib/rbpkg.rb
+++ b/lib/rbpkg.rb
@@ -325,7 +325,6 @@ EOF
CC: #{cc.inspect},
dir: #{dir.inspect},
ncpu: #{ncpu.inspect},
- sha256: #{sha256.inspect},
target: #{target.inspect}
}"""
end
@@ -430,29 +429,6 @@ EOF
end
end
- @@sha256 = nil
- def self.sha256
- @@sha256 || @@sha256 = if system("which sha256sum >/dev/null 2>&1")
- "sha256sum"
- elsif system("which sha256 >/dev/null 2>&1")
- "sha256"
- else
- raise "sha256 executable not found"
- end
- end
-
- def self.sha256_file(path)
- c = "#{sh_quote(sha256)} #{sh_quote(path)}"
- r = `#{c}`
- raise "#{sha256} #{path.inspect} failed" unless $?.success?
- if r.match?(/^SHA256 \(/)
- r
- else
- part = r.split(' ')
- "SHA256 (#{part[1]}) = #{part[0]}"
- end
- end
-
def self.src_dir
"#{dir}/src"
end
diff --git a/lib/rbpkg/repo.rb b/lib/rbpkg/repo.rb
index 5e6bb07..22f6b47 100644
--- a/lib/rbpkg/repo.rb
+++ b/lib/rbpkg/repo.rb
@@ -359,7 +359,8 @@ class Rbpkg::Repo
if File.directory?(path_f)
package_checksum_rec(path_f, Dir.new(path_f).children, output)
else
- output.write(Rbpkg.sha256_file(path_f))
+ digest = Rbpkg::SHA256.file(path_f)
+ output.write("SHA256 (#{path_f}) = #{digest}\n")
end
end
end
@@ -481,9 +482,8 @@ class Rbpkg::Repo
file = scan[1]
hash = scan[2]
path = "#{Rbpkg.prefix}/#{file}"
- STDERR.puts "echo 'SHA256 (#{sh_quote(path)}) = #{sh_quote(hash)}' | #{Rbpkg.sha256} -c /dev/stdin"
- `echo 'SHA256 (#{sh_quote(path)}) = #{sh_quote(hash)}' | #{Rbpkg.sha256} -c /dev/stdin`
- if $?.success?
+ digest = Rbpkg::SHA256.file(path)
+ if (hash == digest)
cmd! "rm #{sh_quote(path)}"
end
end
diff --git a/lib/rbpkg/repos/libmd.rb b/lib/rbpkg/repos/libmd.rb
index 41f6b11..a51c7c4 100644
--- a/lib/rbpkg/repos/libmd.rb
+++ b/lib/rbpkg/repos/libmd.rb
@@ -17,7 +17,8 @@ class Rbpkg::Repos::Libmd < Rbpkg::Repo
end
def system_package?
- Rbpkg.os.match?(/BSD/)
+ Rbpkg.os.match?(/BSD/) ||
+ Rbpkg.os.match?(/Darwin/)
end
repo_register