From 0db0cf845adff6971170aa4465dd6bdd9a33fa51 Mon Sep 17 00:00:00 2001 From: Graham Gilbert Date: Tue, 8 Nov 2016 08:44:09 +0000 Subject: [PATCH] Cannot use xcodebuild if we've just got the command line tools --- lib/facter/xcode_command_line_tools.rb | 10 ++++++++++ lib/facter/xcode_product.rb | 1 - manifests/install.pp | 4 +++- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 lib/facter/xcode_command_line_tools.rb diff --git a/lib/facter/xcode_command_line_tools.rb b/lib/facter/xcode_command_line_tools.rb new file mode 100644 index 0000000..3e81345 --- /dev/null +++ b/lib/facter/xcode_command_line_tools.rb @@ -0,0 +1,10 @@ +Facter.add(:xcode_command_line_tools) do + confine kernel: 'Darwin' + setcode do + if Facter.value(:xcode_active_directory).include? '.app' + true + else + false + end + end +end diff --git a/lib/facter/xcode_product.rb b/lib/facter/xcode_product.rb index 235e2df..fdc8337 100644 --- a/lib/facter/xcode_product.rb +++ b/lib/facter/xcode_product.rb @@ -4,7 +4,6 @@ if Facter.value(:xcode_tools_present) == false # Oh man this is bad, but we need this file to exist Facter::Util::Resolution.exec('/usr/bin/touch /private/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress') - # Facter::Util::Resolution.exec('/usr/sbin/softwareupdate -l | grep "\*.*Command Line" | head -n 1 | awk -F"*" \'{print $2}\' | sed -e \'s/^ *//\' | tr -d \'\n\'') swupd_out = Facter::Util::Resolution.exec('/usr/sbin/softwareupdate -l') output = nil swupd_out.each_line do |line| diff --git a/manifests/install.pp b/manifests/install.pp index 94b8c0c..62ec290 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -5,6 +5,8 @@ ensure => 'present' } -> + exec {'/usr/bin/xcode-select -r': } -> + exec { "/usr/sbin/softwareupdate -i \"${xcode_product}\" --verbose": logoutput => true, timeout => 0, @@ -14,7 +16,7 @@ } - unless $facts['xcode_license_accepted'] { + if $facts['xcode_license_accepted'] == false and $facts['xcode_command_line_tools'] == false { exec { '/usr/bin/xcodebuild -license accept': } }