-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
bzip2 and zip dependencies_if_needed #3813
Conversation
On some systems identified as Linux, zip and bzip2 might not be available. Therefore, on such platforms we add them unconditionally as dependencies when required. On Mac, these dependencies are always satisfied.
I'd suggest modelling
The macOS implementation is…
and no Linux-specific implementation. |
@@ -72,6 +72,10 @@ def xz_dep_if_needed(tags) | |||
|
|||
def ld64_dep_if_needed(*); end | |||
|
|||
def zip_dep_if_needed(*); end | |||
|
|||
def bzip2_dep_if_needed(*); end |
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.
Model these after xz_dep_if_needed
.
@@ -1,2 +1,3 @@ | |||
require "dependency_collector" | |||
require "extend/os/mac/dependency_collector" if OS.mac? | |||
require "extend/os/linux/dependency_collector" if OS.linux? |
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.
Remove this line.
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.
had to add it back to override xz_dep_if_needed
def bzip2_dep_if_needed(tags) | ||
Dependency.new("bzip2", tags) | ||
end | ||
end |
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.
Remove this file.
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.
Same as above: had to add it back to override xz_dep_if_needed
(14d7a7a#r169467375)
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.
Don't override xz_dep_if_needed
for Linux. This implementation ought to be the generic implementation.
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.
Does xz
exist on all Linux systems? If so - sure. Otherwise, it would make sense to keep it conditional.
|
||
def zip_dep_if_needed(*); end | ||
|
||
def bzip2_dep_if_needed(*); end |
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.
👍
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.
Name the argument tags
like subversion_dep_if_needed
above.
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.
Also: put these below xz_dep_if_needed
I agree with this. |
That's not what you're handling here, though, you're instead installing Homebrew's |
Some more questions here:
I think really what Linuxbrew should start doing to address those problems is:
As a more general point: try to think more about designing Linuxbrew as a system. A bunch of these changes (#3809 included) are essentially just hacks to try and get Linuxbrew working on more Linux systems. This way lies madness. Linuxbrew should define (both in terms of documentation and code) what they are willing to support. If you'd rather take the approach of "we're going to try and support literally every case of running Linuxbrew on any Linux distro" then I think the upstreaming efforts may need to part ways (and perhaps be partially reverted). |
Bare-bones distros, most commonly used in Docker and CI systems.
This could be conditional on
Linuxbrew uses host executables when possible. Linuxbrew uses no host libraries, except for
There's nearly unlimited variation in what packages may or may not be installed for a given distribution.
Linuxbrew uses a single bottle that's portable to all Linux systems by provided brewed versions of all the necessary libraries. |
We actively support the major distributions of Linux, such as Debian, Ubuntu, Fedora, and CentOS. I believe Homebrew also had issues with the system version of
Although I appreciate your effort to help upstream Linux patches, Maxim—Thank you!—you may not have the context of when and why patches were introduced, and whether those patches are still needed upstream, or could instead be reverted in Linuxbrew. I suggest we have more discussion within the Linuxbrew team before opening PRs to upstream Linuxbrew patches. Reverting changes to Linuxbrew/brew that are no longer needed is an important component of merging Linuxbrew/brew into Homebrew/brew. |
I could not agree more: everything should be conditional and if the system provides required components - Homebrew should use these. In fact, I was disappointed to see This PR is merely an attempt to bring changes that currently exist in Linuxbrew to Homebrew.
🔪 First of all, thank you for editing the comment thus making it a bit easier to pull out from my back 😄 The context I usually use consists of (1) git log messages (2) comments within the code (not the strongest side of Linuxbrew/Homebrew) (3) Slack (when needed) (4) related GitHub PRs and Issues if changes are hard to make sense of otherwise. Please, let me know of any other context I'm missing. Changes introduced in this as well as #3809 PRs seem straightforward so I only mentioned you here.
sounds good |
Which distros specifically, though? Can you name a few?
My point was more: it doesn't seem there's a definition of what you don't support and won't try to e.g. the bare-bones distros you mention above. It's also worth asking what Linuxbrew wants to do differently to tools like Gentoo Prefix which are much more established. With a smaller team and fewer resources spreading yourselves too thin means a tool that's less useful to anyone.
That's not the case in #3809 with
That's true but the standard or minimal installation for a distribution provides a minimal subset.
This is not the same solution, though. In this case you're saying "if there's a Homebrew curl: always use it". In the macOS case the relevant formulae have audit checks so that a modern
This was as the vast majority of users are now using bottles exclusively with Homebrew which means that these requirements were only using system versions when building from source and untested by CI. That's not the case here where the vast majority of Linuxbrew users will have
Our model is completely sustainable because we rely on a macOS base system that only changes versions once a year. With respect, MacOS.version makes life much easier for Homebrew but just not for Linuxbrew. This is why I've been saying for years Linuxbrew should create their own formulae that are not designed to be used on macOS (i.e. don't use
👍 . I also think it's worth a discussion at some point between Linuxbrew and Homebrew maintainers as to what the end goal is, a (very loosely) estimated timescale and the similarities and differences in ethos between the projects. This could result in documentation that would make PRs and issues between the projects less confusing. My starter for ten on this:
|
Our ubuntu docker image we use for the circle.ci build does not have
I agree that it is easier on mac. As I have been doing the core merges for the last year, I see that on Linux it is a little bit more of work; but at the end it is just "some" dependencies missing ( When you say we should create our own formulae, how should that work? As patch files that we would apply on top of the homebrew-core repo? I think whatever way we choose, the amount of work is probably equivalent. I must say that the merges from homebrew-core to linuxbrew-core are working quite well; it is a lot o work during the week, but I think it is because I am doing this mostly alone. You have the same bottleneck in homebrew where most of the updates are done by one or two dedicated persons :) If we had 5 maintainers more everything would be fine :) I am open for changes though, if it can reduce the workload: but most of the time is spent fixing dependencies and rebuilding bottles, so I am not sure how we can improve this without more maintainers.
One small note: Linuxbrew tries to follow that philosophy too. Though we have some users that can not create a
Right. I think there was never such a case, at least not last year. We just have the regular sha256 mismatches (at least a few per month), which then get fixed by me or reported if I have no time to fix them myself.
+1 on that. I think I never backported anything to core. Maybe once I wanted some linker flags in a different order for a test, but that's all. Merge conflicts are not a problem, I fix some of them each day, and it is working quite well. In fact, there are not so many merge conflicts at the end, and they are all trivial to solve. |
BTW, I am not sure this PR is the best place to discuss this :) |
Defaulting zip_dep_if_needed(tags) and bzip2_dep_if_needed(tags) methods to those on Linux and overriding them on macOS.
@@ -72,6 +72,14 @@ def xz_dep_if_needed(tags) | |||
|
|||
def ld64_dep_if_needed(*); end | |||
|
|||
def zip_dep_if_needed(tags) | |||
Dependency.new("zip", tags) |
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.
Use which
to check first whether zip
is provided by the host, and make this dependency conditional.
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.
Any preference as to which one to use:
Dependency.new("zip", tags) unless which("zip")
or
return if which("zip")
Dependency.new("zip", tags)
?
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.
I prefer the former.
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.
Ok, done.
end | ||
|
||
def bzip2_dep_if_needed(tags) | ||
Dependency.new("bzip2", tags) |
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.
Ditto here.
Here, we are adding `unless which("zip")` and `unless which("bzip2")` and, thus, make `zip` and `bzip2` dependencies conditional.
Files are globbed based on their name. Therefore, we have to rename them so tests for Linux are not executed on a Mac.
@@ -140,3 +140,4 @@ def find_requirement(klass) | |||
end | |||
end | |||
end | |||
require "test/os/dependency_collector_spec" |
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.
Don't need this line for tests.
@@ -0,0 +1 @@ | |||
require "test/os/linux/dependency_collector" if OS.linux? |
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 can just be dependency_collector_spec.rb
without the if
or the os/linux
file.
|
||
def zip_dep_if_needed(*); end | ||
|
||
def bzip2_dep_if_needed(*); end |
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.
Name the argument tags
like subversion_dep_if_needed
above.
@@ -162,6 +170,8 @@ def parse_url_spec(url, tags) | |||
when ".lz" then Dependency.new("lzip", tags) | |||
when ".rar" then Dependency.new("unrar", tags) | |||
when ".7z" then Dependency.new("p7zip", tags) | |||
when ".zip" then zip_dep_if_needed(tags) |
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.
Put these at the top below xz_dep_if_needed
|
||
def bzip2_dep_if_needed(tags) | ||
Dependency.new("bzip2", tags) unless which("bzip2") | ||
end |
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.
Put these below xz_dep_if_needed
|
||
def zip_dep_if_needed(*); end | ||
|
||
def bzip2_dep_if_needed(*); end |
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.
Also: put these below xz_dep_if_needed
@@ -0,0 +1 @@ | |||
require "test/dependency_collector" |
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 file should instead be filled with the contents of Library/Homebrew/test/os/linux/dependency_collector.rb
(which should be deleted)
@@ -0,0 +1,23 @@ | |||
require "dependency_collector" |
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.
Sorry, I may have misread/typed before but this is still the wrong filename: please put it in test/dependency_collector_spec.rb
and add tests in test/os/mac/dependency_collector_spec.rb
(these files both already exist)
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.
😕 I'm confused as to what goes where. Coincidentally, tests have to be updated to account for the "conditional nature" of bzip2
and zip
dependencies. Shall I make tests for macOS unconditional?
Unconditional version that will work on macOS only:
it "creates a resource dependency from a '.bz2' URL" do
resource = Resource.new
resource.url("http://example.com/foo.tar.bz2")
expect(subject.add(resource)).to be nil
end
Conditional version that (I think) will work on both macOS and Linux
though, I don't know whether if which("bzip2")
works in tests.
it "creates a resource dependency from a '.bz2' URL" do
resource = Resource.new
resource.url("http://example.com/foo.tar.bz2")
if which("bzip2")
expect(subject.add(resource)).to be nil
else
expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build]))
end
end
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.
Sorry, I've not been clear here at all as I kinda forgot how things were structured. Put macOS tests in test/os/mac/dependency_collector_spec.rb
(and see how those are done there). If we want to have both macOS and Linux tests (for existing examples we don't have Linux ones) then have a look at test/os/linux/osxfuse_requirement_spec.rb
and add relevant tests in there. You may also, while you're there, add tests for e.g. xz
and other behaviours that differ.
Would it be useful to have docs to spell more of this out? Thanks and sorry again for all the back and forth.
Debian and Ubuntu for example ❯❯❯ docker run debian:9 which gzip bzip2 xz
/bin/gzip
❯❯❯ docker run ubuntu:xenial which gzip bzip2 xz
/bin/gzip
We don't actively support 32-bit Intel, or distributions of Linux that use a libc other than glibc. We can add more systems to the unsupported list as they come up, but they don't come up too terribly often. Most issues are reported from users running the typical distributions. Docker images help a lot in confirming whether an issue is reproducible on their distribution of Linux, or somehow unique to their system configuration (not reproducible in Docker).
I develop data analysis applications on macOS and then deploy them to Linux servers using the same package manager (Brew) on both macOS and Linux. I teach workshops where users install packages using a single set of instructions to install software on their laptops running macOS using Homebrew, on Linux using Linuxbrew, and on Windows using Linuxbrew thanks to Windows Subsystem for Linux. Being able to use the same package manager on multiple operating systems is quite powerful.
@maxim-belkin is fixing that now.
Here's the list of essential (required) Debian packages. It's pretty safe to assume that these packages will be available on most Linux systems.
I'm on board with all of these goals. End of 2018 is a good target date. |
Thanks for all the information above.
Is it worth having a Linuxbrew/brew tracking issue to discuss this? I'm happy to create it. |
👍 I've created a tracking issue at Linuxbrew/brew#612 |
What else could be done:
|
def bzip2_dep_if_needed(tags) | ||
Dependency.new("bzip2", tags) | ||
end | ||
end |
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.
Don't override xz_dep_if_needed
for Linux. This implementation ought to be the generic implementation.
@@ -70,6 +70,14 @@ def xz_dep_if_needed(tags) | |||
Dependency.new("xz", tags) |
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.
If Mike agrees, change this to…
Dependency.new("xz", tags) unless which("xz")
That makes sense to me. |
if default implementation of |
@@ -0,0 +1,5 @@ | |||
class DependencyCollector | |||
def xz_dep_if_needed(tags) | |||
Dependency.new("xz", tags) unless which("xz") |
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.
I'm 👍 on changing the default implementation in Library/Homebrew/dependency_collector.rb
to do this for consistency. Could also do cvs_dep_if_needed
if desired. The only potential gotcha is self.tar_needs_xz_dependency?
; is it a safe assumption that xz
in the PATH
means tar
is built with xz
support? CC @sjackman
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.
from looking at the gnu-tar
's ./configure
script, it looks like tar is always built with "tar" support and the only thing one can override is which "xz" to use. By default, tar uses the first 'xz' that appears in the PATH first.
And I don't see anything related to xz
hard-coded in tar
:
$ strings /usr/local/Cellar/gnu-tar/1.30/bin/gtar | grep xz
$ strings /usr/local/Cellar/gnu-tar/1.30/libexec/gnubin/tar | grep xz
Thanks @maxim-belkin! A long, painful journey but we got there in the end! |
Thanks for this PR, Maxim! And thanks for merging, Mike! |
brew style
with your changes locally?brew tests
with your changes locally?Continuing to merge changes from Linuxbrew to Homebrew. Therefore, mentioning @sjackman @iMichka
Brining
zip
andbzip2
related changes from Linux. The PR addresses the issue that not all distros are created equal and lackbzip2
andzip
.I have written simple tests based on
p7zip
example.