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

Install Command Line Tools as part of Xcode setup #79

Merged
merged 6 commits into from
Mar 25, 2018

Conversation

jazaval
Copy link
Contributor

@jazaval jazaval commented Mar 25, 2018

This PR ensures the xcode-install gem can be installed into Chef gems by verifying that Command Line Tools are installed. If not installed, a temporary file is created to trigger the softwareupdate -l command into providing the product name for the latest CLT, which is then downloaded and installed.

Fixes #79.

@jazaval jazaval self-assigned this Mar 25, 2018
Copy link
Collaborator

@americanhanko americanhanko left a comment

Choose a reason for hiding this comment

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

My only legitimate concern here is that I don't see where CommandLineTools.new.product is used in the xcode resource. I do see a unit test for it though, which leads me to believe something is missing.

end

def available_products
shell_out('softwareupdate -l').stdout
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Break the command into separate arguments and use the long version of the list option?

shell_out('softwareupdate', '--list').stdout

Copy link
Contributor Author

@jazaval jazaval Mar 25, 2018

Choose a reason for hiding this comment

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

Yep. Done.

end

execute 'install Xcode CLT' do
command lazy { "softwareupdate --verbose -i '#{CommandLineTools.new}'" }
Copy link
Collaborator

Choose a reason for hiding this comment

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

A couple legitimate questions:

  • Based on the unit test, do we need to use CommandLineTools.new.product in the command?
  • Do we want to be live-streaming here? If not, is the verbose option needed?

Nitpicks. Could we:

  • extract the command to a list variable for readability (clearer that we need CommandLineTools in quotes)
  • use the long version of the install option
execute 'install Xcode CLT' do
  install_clt_command = ['softwareupdate', '--install', "'#{CommandLineTools.new}'"]
  command lazy { install_clt_command }
  action :nothing
  notifies :delete, 'file[sentinel to make CLT available]', :immediately
end

Copy link
Contributor Author

@jazaval jazaval Mar 25, 2018

Choose a reason for hiding this comment

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

Yep, fixed. And yep, but not with verbose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CommandLineTools also is handled by the command array properly (something I hadn't tested before)

Finding available software
Software Update found the following new or updated software:
* Command Line Tools (macOS El Capitan version 10.11) for Xcode-8.2
\tCommand Line Tools (macOS El Capitan version 10.11) for Xcode (8.2), 150374K [recommended]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, neat. I didn't realize you could use\t for a tab in a heredoc!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I meant to use <<~ here actually - the tabs make more sense in that context.

@americanhanko
Copy link
Collaborator

Looks great. Thanks for making the changes quickly.

@americanhanko americanhanko merged commit 3ea7c14 into release/1.10 Mar 25, 2018
@americanhanko americanhanko deleted the feature/xcode branch March 25, 2018 23:29
@americanhanko americanhanko mentioned this pull request Mar 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants