Commit 86ed210d by Jon Wood

Iterate on finding a database

parent 9af2d220
......@@ -2,22 +2,22 @@ require "rubygems"
require "rake/clean"
def locate_mime_database
# User provided path.
unless ENV["FREEDESKTOP_MIME_TYPES_PATH"].nil?
path = File.expand_path(ENV["FREEDESKTOP_MIME_TYPES_PATH"])
unless File.exist?(path)
raise "The path #{path} was provided for the MIME types database, but no file exists at that path."
end
return path
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")
possible_paths = [
(File.expand_path(ENV["FREEDESKTOP_MIME_TYPES_PATH"]) if ENV["FREEDESKTOP_MIME_TYPES_PATH"]),
"/usr/local/share/mime/packages/freedesktop.org.xml",
"/opt/homebrew/share/mime/packages/freedesktop.org.xml",
"/usr/share/mime/packages/freedesktop.org.xml"
].compact
path = possible_paths.find { |candidate| File.exist?(candidate) }
# Default path when installed with Homebrew
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")
return path unless path.nil?
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
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