-
Notifications
You must be signed in to change notification settings - Fork 6
Conversation
This allows it to be called at runtime.
This is the first step in removing the dependency on distributing freedesktop.og.xml as part of the gem.
Currently looks at the value of `FREEDESKTOP_MIME_TYPES_PATH` and in `/usr/share/mime/packages/freedesktop.org.xml`, which is the path you would expect to find that file at on a typical Linux system.
b41c7d9
to
cd65290
Compare
|
||
# Unknown if this test failure is expected. Commenting out for now. | ||
# | ||
# assert_equal 'text/html', MimeMagic.by_path('/adsjkfa/kajsdfkadsf/kajsdfjasdf.html').to_s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is failing:
Actual: "application/xhtml+xml"Minitest::Assertion: Expected: "text/html"
Actual: "application/xhtml+xml"```
It seems like this should be "text/html"
https://stackoverflow.com/questions/6788934/what-is-the-difference-between-serving-a-page-as-text-xml-and-application-xhtml
But this older post makes it seem like `"application/xhtml+xml"` is correct https://www.w3.org/2003/01/xhtml-mimetype/
|
||
# Unknown if this test failure is expected. Commenting out for now. | ||
# | ||
# assert_equal 'text/html', MimeMagic.by_extension('.html').to_s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same issue as https://github.com/jellybob/mimemagic/pull/3/files#r600758072
Consider adding
sections. It will greatly help the longevity of the project to have a reminder that there are outstanding questions for @minad |
Because we're required to build a C extension in order to do so (don't ask, its a long story), use that C extension to make the path provided at build time available at run time.
As for Mac OS compatibility I am investigating the Homebrew path. The main prerequisite of shared-mime-info is
The install for
The source file for a MacOS BigSur install of
|
@jellybob I'd like to be able to configure the ENV variable via bundle config, which is what we do for
Which would result in this:
See the last lines! Then we just need to utilize the bundle config from within the gem... this bit of the config lets me build
this bit of the config lets me build
My understanding is that the
And we'd just need it to work the same way here. |
Here's a branch demonstrating how to use extconf.rb without actually building any C. You can cherry-pick this and build on it if you find it useful. externalise-source-data...elebow:externalise-source-data-no-c This also makes some other changes:
|
🎉 Thanks for this - just about to push a version that does this without a C extension now. |
@elebow thanks for that - I'd actually implemented the version without an extension before seeing your comment, so didn't make use of that. I'd definitely be interested in a PR to support downloading the file if a version that can be used in that manner can be found though. |
@pboling a PR to support this would be welcome, but at least for now I think I'm going to go with the current implementation for the sake of getting something shipped, and build unblocked, even if that is in an initially suboptimal way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MacOS install instructions unclear
README.md
Outdated
it's probably available via your package manager, and will probably be in the location it's being looked for | ||
when the gem is installed. | ||
|
||
macOS users can install via Homebrew with `brew install shared-mime-info`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does install the package, but the gem still fails to install, and supplying the path with FREEDESKTOP_MIME_TYPES_PATH
is still required. The way this is worded, that isn't clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, can you give it another try? A brew install, followed by just doing a gem install with a locally built version of the gem worked fine on my machine just now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jellybob Sorry I wasn't clear, and my suggestion isn't that great either. My comment was on the subtle implications derived from the text layout in the readme as it is in this PR. It might imply that you only need to set FREEDESKTOP_MIME_TYPES_PATH
iff you can't do either of those things
:
If for whatever reason you can't do either of those things, you'll need to obtain a copy from the Internet. Set the environment variable
FREEDESKTOP_MIME_TYPES_PATH
before installing the gem in order to point the build at that location.
By juxtaposing the two sentences without any additional context it can easily be misunderstood.
The following works!
brew install shared-mime-info
export FREEDESKTOP_MIME_TYPES_PATH=/usr/local/Cellar/shared-mime-info/2.1/share/shared-mime-info/packages/freedesktop.org.xml
bundle install
All versions prior to 0.3.6 have been pulled by the developer, presumably due to a security vulnerability. [1] [1] Conversation on the repo mimemagicrb/mimemagic#98
How about rebasing this on the 0.3.5 version to avoid
I tried this and there were some merge conflicts but nothing too serious. See this branch: https://github.com/Docbldr/mimemagic/tree/externalise-source-data-rebased |
@mvz I'm not overly concerned about rebasing from 0.3.5 in terms of licensing - we've been talking to the copyright holder who raised the initial issue, and there's agreement there that the approach being taken resolves their complaint, and no issues with reverting the license to MIT. On the other point around mimemagic/overlay, I'm honestly not familiar enough with this code to know what the implications are. I'm going to merge the changes I've made into master on this repository as I'm reasonably happy with them, so feel free to open a PR to reintroduce that. |
When releasing this as a |
Yes, it will potentially break creating a new Rails project on Windows, but that feels like a better option than quietly imposing GPL 2 licensing on every new Rails project which is the current situation. We're also looking at yanking 0.3.6 because of those licensing implications, so in practice whatever happens here new Rails projects on Windows are going to be broken to some degree. |
@jellybob Thanks for all your work in resolving this! I've opened a pull request to reintroduce |
I agree with yanking 0.3.6. I am sure that many people updated to it to make things work without understanding or noticing the licensing changes. I have personally seen MIT-licensed open source projects that did this. For their benefit and safety, as well as that of the closed source apps we can't see, we should yank 0.3.6. |
@jellybob Thanks so much for your hard work on this and ensuring that the gem can be used with the file loaded at runtime and no behavioral changes! Much appreciated |
I would probably even yank 0.4.0, TBH. I wouldn't expect a drastic license change in anything but a major version or a name change, and would prefer a name change. The GPL version should be renamed to mimemagic-gpl 1.0.0 |
Yup - 0.3.6 and 0.4.0 have both been yanked. |
See #2 for full details of what's going on here.
To ensure compliance with the upstream license on the Freedesktop.org Shared Mime Types database this PR removes it from the gem, and instead requires the user to provide one themselves. Most Linux distributions probably have a copy of this already, and it can probably be found in the location being checked in
ext/mimemagic/extconf.rb
, so we default to that. Otherwise an environment variable will need to be set to point it in the right direction. This path also gets baked into the installed version of the gem via a Gemfile pretending to be a native extension.