Skip to content
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 Homebrew as the system deployer for macOS. #1185

Merged
merged 6 commits into from
Sep 23, 2022

Conversation

simonjwright
Copy link
Contributor

See Issue #1172.

It's not clear to me how we could deal with MacPorts as an alternate deployer, if anyone wants to do the work (won't be me).

I'm not sure about System_Package_For_Tool in src/alire/alire-utils-tools.adb; I've treated macOS like all the other distributions so as to get a build, but I don't understand how/when this is used.

  * src/alire/alire-origins-deployers-system-homebrew.adb: new.
  * src/alire/alire-origins-deployers-system-homebrew.ads: new.
  * src/alire/alire-origins-deployers-system.adb (Platform_Deployer):
      When the platform distro manager is Homebrew, return Homebrew.Deployer.
  * src/alire/alire-platforms.ads (Distributions): include macOS.
    (Package_Managers): add Homebrew.
    (Distro_Manager): for macOS, use Homebrew.
  * src/alire/alire-utils-tools.adb (System_Package_For_Tool): treat MacOS
      like other distributions.
  * src/alire/os_macos/alire-platforms-current__macos.adb
    (Detected_Distribution): return Platforms.MacOS.
  * testsuite/drivers/helpers.py (on_macos()): new.
    (distribution()): return 'MACOS' if on_macos() is True.

; Squashed commit of the following:

; commit 0110299ceb66f58cd4793fd78a69fc5b100b4ccf
; Author: Simon Wright <[email protected]>
; Date:   Fri Sep 9 17:45:04 2022 +0100

;     Restore test to correct sense.

; commit d396b6b54a73bbbfd59071539bf6268bccce3cf0
; Author: Simon Wright <[email protected]>
; Date:   Fri Sep 9 17:34:54 2022 +0100

;     Replace assertions in Homebrew deployer with exceptions

; commit d7603110b9543bdaac9516fa844599e87fac70aa
; Author: Simon Wright <[email protected]>
; Date:   Mon Sep 5 14:14:03 2022 +0100

;     Recognise macOS as a distribution.

;       * testsuite/drivers/helpers.py (on_macos()): new.
;         (distribution()): check on_macos(). Return 'MACOS' if true.

; commit 8703acfeb8fdf336d862cefc16706eac5d3f0758
; Author: Simon Wright <[email protected]>
; Date:   Sun Sep 4 17:33:13 2022 +0100

;     Use 'brew info' to get available, installed versions.

; commit 8b22b904e19d64fecb89233e6527c2faf655d982
; Author: Simon Wright <[email protected]>
; Date:   Wed Aug 31 15:54:51 2022 +0100

;     Continuing.

; commit a9821ed9a605e30b5699a49df6fffd11224ab931
; Author: Simon Wright <[email protected]>
; Date:   Mon Aug 22 17:09:48 2022 +0100

;     First changes for macOS Homebrew.
Copy link
Member

@Fabien-Chouteau Fabien-Chouteau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome @simonjwright !

I have a few comments, the main one being about the MacOS vs Homebrew distrib.

Thanks for your contribution,


begin
Trace.Debug ("detect? " & This.Base.Package_Name);
if Homebrew_Present then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detection of the "distrib" should be done in the platform specific code. There's no need to do it here as far as I know.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@@ -9,7 +9,7 @@ package body Alire.Platforms.Current is
------------------

function Detected_Distribution return Platforms.Distributions is
(Platforms.Distro_Unknown);
(Platforms.MacOS);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where you detect the HOMEBREW_PREFIX env variable and return Platforms.Homebew if present, Platforms.Distro_Unknown otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

simonjwright added a commit to simonjwright/alire that referenced this pull request Sep 13, 2022
simonjwright added a commit to simonjwright/alire that referenced this pull request Sep 18, 2022
  * .github/workflows/ci-macos.yml (Run test script): renamed to
      "Run test script (without Homebrew)".
    (Run test script (with Homebrew)): added 'eval $(brew shellenv)' before
      running the test script, so that HOMEBREW_PREFIX gets defined.
  * src/alire/alire-origins-deployers-system-homebrew.adb
    (Homebrew_Prefix, Homebrew_Present): removed.
    (Get_Info): named the declare block. Removed commented-out exception
      handler.
    (Already_Installed): use Get_Info's returned Installed_Version's length
      to determine the result.
    (Detect): Get_Version_From_String uses Semantic_Versioning.Parse.
        Don't check for Homebrew_Present, it has to be or we wouldn't be
        called.
  * src/alire/alire-platforms.ads (Distributions): rename MacOS to Homebrew.
    (Distro_Manager): likewise.
  * src/alire/alire-utils-tools.adb (System_Package_For_Tool): MacOS (in
      'case Distribution)' changed to Homebrew.
  * src/alire/os_macos/alire-platforms-current__macos.adb
    (Homebrew_Prefix): new, gets the environment variable "HOMEBREW_PREFIX".
    (Homebrew_Present): new, true if the environment variable is present.
    (Detected_Distribution): checks Homebrew_Present, returns Homebrew
      or Distro_Unknown accordingly.
    (Distribution_Root): returns Homebrew_Prefix if present, otherwise "/".
  * testsuite/drivers/helpers.py (distribution()): if on macOS, return
      HOMEBREW if HOMEBREW_PREFIX is found, DISTRO_UNKNOWN otherwise.
Implement Homebrew for MacOS: response to comments on PR#1185
@mosteo
Copy link
Member

mosteo commented Sep 19, 2022

Looks good to me, outstanding effort, Simon. Since this PR has had quite some discussion, I'm going to wait for @Fabien-Chouteau feedback before merging.

simonjwright added a commit to simonjwright/alire that referenced this pull request Sep 22, 2022
  * src/alire/alire-origins-deployers-system-homebrew.adb: removed
      the innefective pragma Warnings (Off).
  * src/alire/alire-origins-deployers-system-homebrew.adb: removed
      the innefective pragma Warnings (Off).
@Fabien-Chouteau
Copy link
Member

Thanks @simonjwright, can you fix the conflicts with the OpenSUSE support that was just added? Sorry for that

  * src/alire/alire-origins-deployers-system.adb: added Homebrew option.
  * src/alire/alire-platforms.ads: likewise.
  * src/alire/alire-utils-tools.adb: likewise.
@simonjwright
Copy link
Contributor Author

I did fix the conflicts, and hoped to see CI runs; maybe the reason why they didn’t happen is that Github thinks there are still conflicts?

@Fabien-Chouteau
Copy link
Member

GitHub says there's still one conflic:

            System.Zypper.Deployer'(Deployers.Deployer'(Base => From)
<<<<<<< homebrew-merged
                                    with others => <>),
         when Platforms.Homebrew =>
            System.Homebrew.Deployer'(Deployers.Deployer'(Base => From)
                                      with others => <>));
=======
                                    with others => <>));
>>>>>>> master

@simonjwright
Copy link
Contributor Author

Actually, Github says there are 3 conflicts, but they are in fact the changes that I want to make. I don’t see how I can fix this ...

Oh. Perhaps the problem is that I cherry-picked the openSuse commit from master? ... but that introduced conflicts which I fixed, and I don’t see any other trace of it than the commit (cb3ca3b) author ...

Oh². I can make it happen here. Baffled for the time being

@mosteo
Copy link
Member

mosteo commented Sep 23, 2022

Let me take a stab at this

@mosteo mosteo merged commit 9842f32 into alire-project:master Sep 23, 2022
@mosteo
Copy link
Member

mosteo commented Sep 23, 2022

Sorry for stepping in in your fixing, Simon. Merged now!

@simonjwright
Copy link
Contributor Author

Sorry for stepping in in your fixing, Simon. Merged now!

Brilliant! Thanks ..

@simonjwright simonjwright deleted the homebrew-merged branch September 23, 2022 12:24
@simonjwright simonjwright mentioned this pull request Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants