Commit 86ed210d by Jon Wood

Iterate on finding a database

parent 9af2d220
...@@ -2,22 +2,22 @@ require "rubygems" ...@@ -2,22 +2,22 @@ require "rubygems"
require "rake/clean" require "rake/clean"
def locate_mime_database def locate_mime_database
# User provided path. possible_paths = [
unless ENV["FREEDESKTOP_MIME_TYPES_PATH"].nil? (File.expand_path(ENV["FREEDESKTOP_MIME_TYPES_PATH"]) if ENV["FREEDESKTOP_MIME_TYPES_PATH"]),
path = File.expand_path(ENV["FREEDESKTOP_MIME_TYPES_PATH"]) "/usr/local/share/mime/packages/freedesktop.org.xml",
unless File.exist?(path) "/opt/homebrew/share/mime/packages/freedesktop.org.xml",
raise "The path #{path} was provided for the MIME types database, but no file exists at that path." "/usr/share/mime/packages/freedesktop.org.xml"
end ].compact
return path path = possible_paths.find { |candidate| File.exist?(candidate) }
end
# Default path on Linux installs for the MIME types database.
return "/usr/share/mime/packages/freedesktop.org.xml" if File.exist?("/usr/share/mime/packages/freedesktop.org.xml")
# Default path when installed with Homebrew return path unless path.nil?
return "/usr/local/Cellar/shared-mime-info/2.1/share/shared-mime-info/packages/freedesktop.org.xml" if File.exist?("/usr/local/Cellar/shared-mime-info/2.1/share/shared-mime-info/packages/freedesktop.org.xml") raise(<<~ERROR)
Could not find MIME type database in the following locations: #{possible_paths}
raise "No database of MIME types could be found. Ensure you have either installed the shared-mime-types package for your distribution, or obtain a version of freedesktop.org.xml, and set FREEDESKTOP_MIME_TYPES_PATH to the location of that file." Ensure you have either installed the shared-mime-types package for your distribution, or
obtain a version of freedesktop.org.xml and set FREEDESKTOP_MIME_TYPES_PATH to the location
of that file.
ERROR
end end
desc "Build a file pointing at the database" desc "Build a file pointing at the database"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment