-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Implement X11Requirement for Linux #3483
Conversation
@@ -5,8 +5,7 @@ class X11Requirement < Requirement | |||
attr_reader :min_version | |||
|
|||
fatal true | |||
cask "xquartz" | |||
download "https://xquartz.macosforge.org" | |||
default_formula "linuxbrew/xorg/xorg" |
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.
having a default formula in a non-core tap seems like asking for trouble
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.
Yeh, I'd rather avoid linuxbrew
tap usage for now until we're closer to merging the projects.
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.
Okay. How about default_formula "linuxbrew/xorg/xorg"
in extend/os/linux/requirements/x11_requirement.rb
?
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.
How does that change anything? It's still a non-core (i.e. not Linuxbrew/homebrew-core) tap.
@@ -0,0 +1,49 @@ | |||
require "requirement" | |||
|
|||
Object.send(:remove_const, :X11Requirement) |
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 a bit weird.
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 line removes the class X11Requirement
so that extend/os/mac/requirements/x11_requirement.rb
can redefine it. Creating a new class with a new name like XQuartzRequirement
and then assigning it with X11Requirement = XQuartzRequirement
causes a test to fail because be_an_instance_of(X11Requirement)
is false. We could make X11Requirement
be a base class, and have XQuartzRequirement
inherit from it. Alternatively, we could remove this test. Your thoughts?
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 replaced it with X11Requirement = XQuartzRequirement
.
def initialize(name = "x11", tags = []) | ||
@name = name | ||
if /(\d\.)+\d/ =~ tags.first | ||
@min_version = Version.create(tags.shift) |
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.
Do XQuartz versions map to X11/Xorg versions at all? Would be good to share the version logic if possible.
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.
The About
window in my xquartz says: "XQuartz 2.7.11 (xorg-server 1.18.4)"
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 haven't yet found a need in Linuxbrew for a version check in the X11Requirement. This code is here primarily so that this Requirement exposes the same version API as the XQuartz Requirement, so that the tests pass. I can instead remove this version logic and make that particular test :needs_macos
.
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.
The point is when it's satisfied by something other than the default formula (which will be forced to be up to date regardless), which I'm assuming remains untested.
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.
Before the xorg
formula existed, I used Linuxbrew with the host's X11 implementation. When installing a bottle that depends on :x11
, the default_formula
is used. The host's Xorg may be used when installing something from source that depends on :x11
.
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.
Headless Linux servers don't usually have the X server installed (/usr/bin/X
), just the X client libraries and executables. The X server is run on your local machine (which is not necessarily running Linuxbrew), whereas the X client is run on the headless server (which is running Linuxbrew). For this reason, I'm checking the version of a X client executable (/usr/bin/xdpyinfo
) rather than the X server. The X client libraries are needed to build software that depends on X11, but the X server is not needed at build time.
The most recent complete release of Xorg X11R7.7 shipped with xdpyinfo 1.3.0
.
The previous release of Xorg X11R7.6 shipped with xdpyinfo 1.2.0
.
See https://www.x.org/releases/X11R7.7/changelog.html
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.
That's the xdpyinfo
version rather than the X11 version, though; it's not particularly useful in this case. Can you see if there's anything else that provides the actual X11 version even with the X server not installed? If not, I think this should just assume the server is not headless and the Linux requirement can always override that.
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.
The katamari 7.7 had server version 1.12.2 and xdpyinfo 1.3.0. So I think starting with Xorg -version
>= 1.12.2 makes sense, and then if the Xorg
command isn't available, fall back on xdpyinfo -version
> = 1.3.0.
Linux:
openzfs ~ # Xorg -version 2>&1|grep Server
X.Org X Server 1.19.3
openzfs ~ # xdpyinfo -version
xdpyinfo 1.3.2
macOS with XQuartz 2.7.11:
iMac-TMP:~ joe$ Xorg -version 2>&1|grep Server
X.Org X Server 1.18.4
iMac-TMP:~ joe$ xdpyinfo -version
xdpyinfo 1.3.2
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.
@sjackman are you planning on actually using the satisfy
block from this upstreamed code or just continuing to use
satisfy build_env: false do
Formula["linuxbrew/xorg/xorg"].installed?
end
in Linuxbrew itself?
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.
Yes, once it's merged into Homebrew/brew, and then after that, merged into Linuxbrew/brew.
9fef2d4
to
0a21425
Compare
@@ -0,0 +1,3 @@ | |||
class X11Requirement | |||
default_formula "linuxbrew/xorg/xorg" |
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'd rather avoid any linuxbrew
tap references until we are further along with the migration to merge Linuxbrew/brew and Homebrew/brew.
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've removed extend/os/linux/requirements/x11_requirement.rb
11aecb5
to
615fd54
Compare
@sjackman My apologies but I misunderstood my conversation previously with @ilovezfs. Instead of needing a version tag that can be passed through let's just make the requirement enforce a minimum |
minor thing: I don't think
|
@@ -20,7 +20,7 @@ | |||
expect(subject).not_to eql(other) | |||
end | |||
|
|||
it "returns false if the minimum version differs" do | |||
it "returns false if the minimum version differs", :needs_macos do |
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.
Can you instead modify this test so it does something on 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.
I've added a test for Linux.
8c58355
to
7e49e62
Compare
Library/Homebrew/test/spec_helper.rb
Outdated
@@ -61,6 +61,10 @@ | |||
skip "Needs official command Taps." unless ENV["HOMEBREW_TEST_OFFICIAL_CMD_TAPS"] | |||
end | |||
|
|||
config.before(:each, :needs_linux) do |
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'd rather we didn't have these as they show up as pending
tests on macOS (I realise the inverse is the case on Linux). Here's a solution for pending tests (that I think we should do for Linux and, I guess, macOS): rspec/rspec-core#2377 (comment) but in this particular case I think an if
/else
within the test itself is better as they are testing essentially the same functionality. CC @reitermarkus for RSpec thoughts.
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've tweaked the macOS underlying code so this may no longer be needed.
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've tweaked the macOS underlying code so this may no longer be needed.
Meaning the PR is good as is, or you'd prefer the if
/else
instead?
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.
Ah, I think you're referring to 8b9ac2b x11_requirement: remove custom minimum version.
I'll rebase onto master
.
1949bad
to
189f322
Compare
I've rebased this PR onto |
Thanks for the reorganization of the macOS X11Requirement, Mike. |
|
||
def initialize(name = "x11", tags = []) | ||
@name = name | ||
# no-op on version specified as a tag argument |
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.
Let's do the same thing on the generic X11 requirement; they should have the same interface. I think the only thing they should probably differ on is the satisfy
and min_version
stuff (and would be good to have a min_version
method there too).
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.
These two initialize
functions are identical. What do you mean here exactly?
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.
Apologies, I misread this.
@@ -17,32 +13,26 @@ def initialize(name = "x11", tags = []) | |||
end | |||
|
|||
def min_version |
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.
Maybe a min_xdpyinfo_version
method too would be good.
return Version::NULL unless OS.mac? | ||
|
||
MacOS::XQuartz.minimum_version | ||
Version.new "1.12.2" |
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 think this actually needs a Version.new
given you're always comparing them to Version
s below.
s | ||
end | ||
|
||
def <=>(other) |
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.
Want to keep this method in some form for API compatability
min_version <= MacOS::XQuartz.version | ||
end | ||
|
||
def message |
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.
Want to keep this method in some form.
Fixed up. |
|
||
def initialize(name = "x11", tags = []) | ||
@name = name | ||
# no-op on version specified as a tag argument |
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.
Apologies, I misread this.
s = "XQuartz #{min_version} (or newer) is required to install this formula." | ||
s += super | ||
s | ||
"X11 is required to install this formula.\n" |
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.
Insert #{min_version}
in here somewhere and may as well += super
, too.
|
||
def inspect | ||
"#<#{self.class.name}: #{name.inspect} #{tags.inspect}>" | ||
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.
Let's keep this method as-is.
next false unless MacOS::XQuartz.installed? | ||
min_version <= MacOS::XQuartz.version | ||
if which "Xorg" | ||
version = Utils.popen_read "Xorg", "-version", err: :out |
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.
@sjackman I think this needs to pass the return value of which "Xorg"
to Utils.popen_read
, otherwise when env filtering is enabled, it will end up with command not found: Xorg
. Ditto xdpyinfo
below.
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 believe that both which
and Utils.popen_read
will experience the same PATH
. Either they'll both succeed, or they'll both fail. Do you believe that one of the two experiences env filtering, while the other does not? When Xorg
and xdpyinfo
are in the standard system path, both which
and Utils.popen_read
should work with env filtering enabled.
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 believe that both which and Utils.popen_read will experience the same PATH.
They will not. My comment was not speculative but based on testing. which
is Homebrew's custom which
, which brings back in the ORIGINAL_PATH.
Other requirements use Homebrew's which
for this reason. There's no guarantee things used to satisfy requirements are in the env filtered PATH.
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.
Please point me to the relevant code.
which
uses PATH
https://github.com/Homebrew/brew/blob/master/Library/Homebrew/utils.rb#L309
popen_read
uses PATH
https://github.com/Homebrew/brew/blob/master/Library/Homebrew/utils/popen.rb#L18
What you're saying may well be true, but it's not evident from the code.
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.
Fixed. Thanks for the feedback, Joe.
@sjackman once this is merged, non-formulae (i.e. x11 other than linuxbrew/xorg/xorg) will be allowed to satisfy the x11 requirement. But as far as I can tell, Linuxbrew doesn't have an It's not relevant to whether this PR gets merged in Homebrew/brew now as-is, but it does seem like in its current form it can't be merged into Linuxbrew/brew. |
With stdenv, the default no-op |
8e42095
to
ce27a33
Compare
Move the XQuartz implementation to extend/os/mac/requirements.
Thanks again @sjackman! |
Thanks again for merging, Mike! Thanks for the feedback, @ilovezfs! |
@sjackman can you address this (today if possible of I may need to revert)? Check out how |
Yes, I can address it now. |
Fixed. |
brew tests
with your changes locally?Move the XQuartz implementation to extend/os/mac/requirements.