coatless-mac / r-macos-rtools

Scripts to build an **unofficial** Rtools-esq installer for the macOS R toolchain
171 stars 6 forks source link

Headless logic issue for macOS Catalina #33

Closed coatless closed 4 years ago

coatless commented 4 years ago

Poking softwareupdate on macOS 10.14 gives:

* Command Line Tools (macOS Mojave version 10.14) for Xcode-10.3
        #        Command Line Tools (macOS Mojave version 10.14) for Xcode (10.3), 199140K [recommended]

With macOS Catalina 10.15, the output changed to:

* Label: Command Line Tools for Xcode-11.3
    Title: Command Line Tools for Xcode, Version: 11.3, Size: 224878K, Recommended: YES, 

We initially attempted to fix this by splitting on OS:

https://github.com/rmacoslib/r-macos-rtools/blob/8816c5c0a37f9db3177db1406d07b38e5f8083da/scripts/postinstall#L68-L83

I think the issue here is we're using head instead of tail.


Elsewhere around the macOS community, homebrew approaches the headless install with:

  clt_label_command = "/usr/sbin/softwareupdate -l | " \
                      "grep -B 1 -E 'Command Line Tools' | " \
                      "awk -F'*' '/^ *\\*/ {print $2}' | " \
                      "sed -e 's/^ *Label: //' -e 's/^ *//' | " \
                      "sort -V | " \
                      "tail -n1"
  clt_label = `#{clt_label_command}`.chomp

This is limited to macOS 10.13 and above.