Homebrew / homebrew-core

🍻 Default formulae for the missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
13.75k stars 12.44k forks source link

x11 migration tracking issue #64166

Closed jonchang closed 3 years ago

jonchang commented 4 years ago

Now that X in all its legion forms can be installed as a formula, we should start migrating our current formulae that depends_on :x11 to instead depend on the brewed versions of the various X libraries.

This is part of our long-term goal to remove all cask Requirements from Homebrew/core, which will help speed up our CI deployment time. Once this is complete the only cask Requirements remaining would be java and osxfuse.

General instructions:

  1. brew install FORMULA on this list (should be poured from a bottle, not built from source)
  2. Run brew linkage FORMULA and observe which X11 libraries it links against
  3. Modify the formula to remove depends_on :x11 and replace it with e.g. depends_on "libx11" and any additional X libraries
  4. Update /opt/X11 or MacOS::XQuartz references to instead point them to the brewed formula paths
  5. revision bump
  6. brew install -s FORMULA and brew linkage FORMULA to check that it's now linking against brewed X and not XQuartz

See an example here: https://github.com/Homebrew/homebrew-core/pull/64165

Some caveats to these instructions:

issyl0 commented 4 years ago

xpa doesn't seem to link against any X11 libraries:

➜ brew linkage xpa
System libraries:
  /usr/lib/libSystem.B.dylib
jonchang commented 4 years ago

xpa doesn't seem to link against any X11 libraries:

My guess is that it has a build-time dependency. Looking at the README maybe depends_on "libxt" => :build would work?

SeekingMeaning commented 4 years ago

Copy-and-pasteable checklist:

- [ ] `brew install FORMULA` on this list (should be poured from a bottle, not built from source)
- [ ] Run `brew linkage FORMULA` and observe which X11 libraries it links against
- [ ] Modify the formula to remove `depends_on :x11` and replace it with e.g. `depends_on "libx11"` and any additional X libraries
- [ ] Update `/opt/X11` or `MacOS::XQuartz` references to instead point them to the brewed formula paths
- [ ] `revision` bump
- [ ] `brew install -s FORMULA` and `brew linkage FORMULA` to check that it's now linking against brewed X and not XQuartz
gromgit commented 4 years ago

Just a couple of working notes:

carlocab commented 4 years ago

A number of formulae link against

/opt/X11/lib/libGL.1.dylib

such as freeglut and mesalib-glw. I can't find a libgl formula (or one like it), unfortunately. I'm guessing this has to do with OpenGL being deprecated in favour of Metal?

jonchang commented 4 years ago

I believe we can link against opengl with -framework OpenGL but I don't know if that makes sense if Apple has deprecated that going forward. We disabled building libgl in https://github.com/homebrew/homebrew-core/pull/46992 so one solution might be to re-enable that in the mesa formula and then depend on mesa going forward for formulae that need OpenGL. See https://github.com/Homebrew/homebrew-core/pull/64330 for my attempt

gromgit commented 4 years ago

I've added a couple of new formulae that were not in #57995, which are needed in certain cases:

gromgit commented 4 years ago

Important note: If you usually ssh into your macOS box like me, X11 migration builds and tests absolutely need to be run from the console. For instance, I was getting false successes from brew install/test nedit because the lack of a valid DISPLAY actually caused it to not attempt any GUI operations at all. When I started running it from the console, even brew install would fail with the same errors as the CI box.

It's also possible that remote-displaying to a separate X11 server could also trigger false successes (XQuartz seems to be a finicky beast), so best to stick to console runs.

iMichka commented 4 years ago

Just a small comment about the libgl thing: on linux we use the one provided by mesa, so this is the right thing to do.

jonchang commented 4 years ago

I've merged libxp in https://github.com/Homebrew/homebrew-core/pull/64337

carlocab commented 3 years ago

Not sure what I'm doing wrong, but brew install fox is giving me errors after I tried migrating fox. (It says it can't find the formula, but then suggests a similarly named formula called "fox". Weird.)

Anyway, if someone else wants to try migrating fox, here's a patch: fox_diff.txt

And the original linkage:

❯ brew linkage fox #before
System libraries:
  /opt/X11/lib/libGL.1.dylib
  /opt/X11/lib/libGLU.1.dylib
  /opt/X11/lib/libX11.6.dylib
  /opt/X11/lib/libXcursor.1.dylib
  /opt/X11/lib/libXext.6.dylib
  /opt/X11/lib/libXfixes.3.dylib
  /opt/X11/lib/libXft.2.dylib
  /opt/X11/lib/libXi.6.dylib
  /opt/X11/lib/libXrandr.2.dylib
  /opt/X11/lib/libXrender.1.dylib
  /usr/lib/libSystem.B.dylib
  /usr/lib/libbz2.1.0.dylib
  /usr/lib/libc++.1.dylib
  /usr/lib/libz.1.dylib
Homebrew libraries:
  /usr/local/opt/fontconfig/lib/libfontconfig.1.dylib (fontconfig)
  /usr/local/Cellar/fox/1.6.56_1/lib/libFOX-1.6.0.dylib (fox)
  /usr/local/opt/freetype/lib/libfreetype.6.dylib (freetype)
  /usr/local/opt/jpeg/lib/libjpeg.9.dylib (jpeg)
  /usr/local/opt/libpng/lib/libpng16.16.dylib (libpng)
  /usr/local/opt/libtiff/lib/libtiff.5.dylib (libtiff)
gromgit commented 3 years ago

@carlocab, your patch is b0rked:

$ brew audit --strict --online fox
Error: fox: undefined method `on' for Formulary::FormulaNamespace5faef846cfba2b699fd0b4ba2c6a26ec::Fox:Class

which led me rather quickly to:

+  depends on "libxi"

Pretty sure that's supposed to be an underscore between depends and on, not a space.

carlocab commented 3 years ago

Yes, I figured I messed something up. :) Thanks for looking at it!

Edit: Fixed now. Thanks, @gromgit.

carlocab commented 3 years ago

robot-framework:

On macOS:

❯ brew linkage robot-framework
System libraries:
  /usr/lib/libSystem.B.dylib
  /usr/lib/libffi.dylib
Homebrew libraries:
  /usr/local/opt/openssl@1.1/lib/libcrypto.1.1.dylib (openssl@1.1)
  /usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib (openssl@1.1)

I'm guessing linkage needs to be checked on Linux, as in https://github.com/Homebrew/homebrew-core/pull/64584

I grepped the repo, though, and I couldn't find a reference to X11, so I don't know if it's a build-dependency either.

carlocab commented 3 years ago

The fmsx license (found here) doesn't appear to be Homebrew-compatible:

fMSX source code is open for everyone to see but it is not in public domain. You can look and learn from it, but you cannot change it or copy it without giving a credit to the original author and a few other conditions. If you would like to port fMSX to another platform or make changes to the code, please, contact me by email or some other means.

You cannot use fMSX source code for commercial purposes unless you contact me to arrange the conditions of such usage. If your company intends to use MSX software in its products and you are considering using fMSX source code, please, email me about licensing.

At the very least, this seems similar to the case of pgplot: https://github.com/Homebrew/homebrew-core/pull/64332

jonchang commented 3 years ago

This is now complete! Thanks to @gromgit, @issyl0, @SeekingMeaning, @yurikoles, and new contributor @carlocab for helping with migrations, @fxcoudert and @SMillerDev for reviewing pull requests, and @iMichka and @maxim-belkin for maintaining and migrating the X formula to homebrew/core from linuxbrew/xorg!

:tada: :partying_face:

iMichka commented 3 years ago

Amazing. Who would have thought we would achieve this one day :)

SMillerDev commented 3 years ago

I wouldn't have expected it last month.