always generate CLT demand file
This commit is contained in:
Родитель
8dde4a5580
Коммит
e9d015e8cb
|
@ -1,11 +1,11 @@
|
||||||
# command_line_tools
|
# command_line_tools
|
||||||
|
|
||||||
The [``command_line_tools``](https://github.com/Microsoft/macos-cookbook/blob/master/resources/command_line_tools.rb) resource manages the state of a single Xcode Command Line Tools installation, and will only install the latest version for the current running version of macOS.
|
The [`command_line_tools`](https://github.com/Microsoft/macos-cookbook/blob/master/resources/command_line_tools.rb) resource manages the state of a single Xcode Command Line Tools installation, and will only install the latest version for the current running version of macOS.
|
||||||
|
|
||||||
## Syntax
|
## Syntax
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
command_line_tools 'name' do
|
command_line_tools 'name' do # defaults to '' if not specified
|
||||||
compile_time true, false # defaults to false if not specified
|
compile_time true, false # defaults to false if not specified
|
||||||
action Symbol # defaults to :install if not specified
|
action Symbol # defaults to :install if not specified
|
||||||
end
|
end
|
||||||
|
@ -13,32 +13,32 @@ end
|
||||||
|
|
||||||
where:
|
where:
|
||||||
|
|
||||||
- ``command_line_tools`` is the resource.
|
- `command_line_tools` is the resource.
|
||||||
- ``name`` is the name given to the resource block.
|
- `name` is the name given to the resource block, which is optional.
|
||||||
- ``action`` identifies which steps the chef-client will take to bring the node into the desired state.
|
- `action` identifies which steps the chef-client will take to bring the node into the desired state.
|
||||||
- ``compile_time`` is the property available to this resource.
|
- `compile_time` is the property available to this resource.
|
||||||
|
|
||||||
## Actions
|
## Actions
|
||||||
|
|
||||||
The ``command_line_tools`` resource has the following actions:
|
The `command_line_tools` resource has the following actions:
|
||||||
|
|
||||||
``:install``
|
`:install`
|
||||||
|
|
||||||
Default. Install Command Line Tools from Apple. Takes no action if any version has previously been installed on the system.
|
Default. Install Command Line Tools from Apple. Takes no action if any version has previously been installed on the system, unless that version has been deleted, in which case it will attempt to install that version again.
|
||||||
|
|
||||||
``:upgrade``
|
`:upgrade`
|
||||||
|
|
||||||
Check for an updated version of Command Line Tools and install them if available.
|
Check for an updated version of Command Line Tools and install them, unless the latest version is already installed.
|
||||||
|
|
||||||
``:nothing``
|
`:nothing`
|
||||||
|
|
||||||
This resource block does not act unless notified by another resource to take action. Once notified, this resource block either runs immediately or is queued up to run at the end of the Chef Client run.
|
This resource block does not act unless notified by another resource to take action. Once notified, this resource block either runs immediately or is queued up to run at the end of the Chef Client run.
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
``compile_time``
|
`compile_time`
|
||||||
|
|
||||||
**Ruby Type:** true, false | **Default Value:** ``false``
|
**Ruby Type:** true, false | **Default Value:** `false`
|
||||||
|
|
||||||
Install the Xcode Command Line Tools at compile time.
|
Install the Xcode Command Line Tools at compile time.
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ The ``command_line_tools`` resource has the following actions:
|
||||||
### Install Xcode Command Line Tools
|
### Install Xcode Command Line Tools
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
command_line_tools 'random_name'
|
command_line_tools
|
||||||
```
|
```
|
||||||
|
|
||||||
If running **macOS 10.14.2**, it will install **'Command Line Tools (macOS Mojave version 10.14) for Xcode-10.14'** via the `softwareupdate` utility.
|
If running **macOS 10.14.2**, it will install **'Command Line Tools (macOS Mojave version 10.14) for Xcode-10.14'** via the `softwareupdate` utility.
|
||||||
|
|
34
kitchen.yml
34
kitchen.yml
|
@ -7,6 +7,7 @@ driver:
|
||||||
|
|
||||||
provisioner:
|
provisioner:
|
||||||
product_name: chef
|
product_name: chef
|
||||||
|
product_version: 18
|
||||||
multiple_converge: 2
|
multiple_converge: 2
|
||||||
|
|
||||||
verifier:
|
verifier:
|
||||||
|
@ -19,33 +20,20 @@ verifier:
|
||||||
- test/integration/default
|
- test/integration/default
|
||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: mojave-chef17
|
- name: big-sur-x86
|
||||||
driver:
|
|
||||||
box: microsoft/macos-mojave
|
|
||||||
box_version: 10.14.6
|
|
||||||
provisioner:
|
|
||||||
product_version: 17
|
|
||||||
|
|
||||||
- name: catalina-chef17
|
|
||||||
driver:
|
|
||||||
box: microsoft/macos-catalina
|
|
||||||
box_version: 10.15.7
|
|
||||||
provisioner:
|
|
||||||
product_version: 17
|
|
||||||
|
|
||||||
- name: big-sur-chef17
|
|
||||||
driver:
|
driver:
|
||||||
box: microsoft/macos-big-sur
|
box: microsoft/macos-big-sur
|
||||||
box_version: 11.6.5
|
box_version: 11.7.8
|
||||||
provisioner:
|
|
||||||
product_version: 17
|
|
||||||
|
|
||||||
- name: monterey-chef17
|
- name: monterey-x86
|
||||||
driver:
|
driver:
|
||||||
box: microsoft/macos-monterey
|
box: microsoft/macos-monterey
|
||||||
box_version: 12.6.3
|
box_version: 12.6.7
|
||||||
provisioner:
|
|
||||||
product_version: 17
|
- name: ventura-arm
|
||||||
|
driver:
|
||||||
|
box: microsoft/macos-ventura-arm
|
||||||
|
box_version: 13.4.1
|
||||||
|
|
||||||
suites:
|
suites:
|
||||||
- name: default
|
- name: default
|
||||||
|
@ -104,7 +92,7 @@ suites:
|
||||||
- recipe[macos_test::command_line_tools]
|
- recipe[macos_test::command_line_tools]
|
||||||
verifier:
|
verifier:
|
||||||
controls:
|
controls:
|
||||||
- command-line-tool-sentinel
|
- command-line-tool-demand
|
||||||
- xcrun
|
- xcrun
|
||||||
|
|
||||||
- name: certificate
|
- name: certificate
|
||||||
|
|
|
@ -6,20 +6,20 @@ module MacOS
|
||||||
attr_reader :version
|
attr_reader :version
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@version = if installed.empty?
|
@version = if install_receipts.empty?
|
||||||
latest_from_catalog
|
latest_from_catalog
|
||||||
else
|
else
|
||||||
latest_installed
|
latest_receipt
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def installed
|
def install_receipts
|
||||||
packages = Plist.parse_xml(install_history_plist)
|
packages = Plist.parse_xml(install_history_plist)
|
||||||
packages.select { |package| package['displayName'].match? 'Command Line Tools' }
|
packages.select { |package| package['displayName'].match? 'Command Line Tools' }
|
||||||
end
|
end
|
||||||
|
|
||||||
def latest_installed
|
def latest_receipt
|
||||||
[installed.last['displayName'], installed.last['displayVersion']].join '-'
|
[install_receipts.last['displayName'], install_receipts.last['displayVersion']].join '-'
|
||||||
end
|
end
|
||||||
|
|
||||||
def latest_from_catalog
|
def latest_from_catalog
|
||||||
|
@ -46,7 +46,7 @@ module MacOS
|
||||||
end
|
end
|
||||||
|
|
||||||
def all_available
|
def all_available
|
||||||
softwareupdate_list.select { |product_name| product_name.match /\*.{1,8}Command Line Tools/ }
|
softwareupdate_list.select { |product_name| product_name.match(/\*.{1,8}Command Line Tools/) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def platform_specific
|
def platform_specific
|
||||||
|
@ -54,9 +54,9 @@ module MacOS
|
||||||
end
|
end
|
||||||
|
|
||||||
def enable_install_on_demand
|
def enable_install_on_demand
|
||||||
install_sentinel = '/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress'
|
install_demand = '/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress'
|
||||||
FileUtils.touch install_sentinel
|
FileUtils.touch install_demand
|
||||||
FileUtils.chown 'root', 'wheel', install_sentinel
|
FileUtils.chown 'root', 'wheel', install_demand
|
||||||
end
|
end
|
||||||
|
|
||||||
def xcode_version(product)
|
def xcode_version(product)
|
||||||
|
|
|
@ -2,45 +2,46 @@ unified_mode true
|
||||||
|
|
||||||
provides :command_line_tools
|
provides :command_line_tools
|
||||||
|
|
||||||
|
property :name, String, default: ''
|
||||||
property :compile_time, [true, false],
|
property :compile_time, [true, false],
|
||||||
description: 'Install the Xcode Command Line Tools at compile time.',
|
description: 'Install the Xcode Command Line Tools at compile time.',
|
||||||
default: false, desired_state: false
|
default: false, desired_state: false
|
||||||
|
|
||||||
action :install do
|
action :install do
|
||||||
command_line_tools = CommandLineTools.new
|
file 'create demand file' do
|
||||||
|
|
||||||
file 'create sentinel file' do
|
|
||||||
path '/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress'
|
path '/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress'
|
||||||
group 'wheel'
|
group 'wheel'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
command_line_tools = CommandLineTools.new
|
||||||
|
|
||||||
execute "install #{command_line_tools.version}" do
|
execute "install #{command_line_tools.version}" do
|
||||||
command ['softwareupdate', '--install', command_line_tools.version]
|
command ['softwareupdate', '--install', command_line_tools.version]
|
||||||
not_if { ::File.exist?('/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib') }
|
not_if { ::File.exist?('/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib') }
|
||||||
live_stream true
|
live_stream true
|
||||||
end
|
end
|
||||||
|
|
||||||
file 'delete sentinel file' do
|
file 'delete demand file' do
|
||||||
path '/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress'
|
path '/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress'
|
||||||
action :delete
|
action :delete
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
action :upgrade do
|
action :upgrade do
|
||||||
command_line_tools = CommandLineTools.new
|
file 'create demand file' do
|
||||||
|
|
||||||
file 'create sentinel file' do
|
|
||||||
path '/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress'
|
path '/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress'
|
||||||
group 'wheel'
|
group 'wheel'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
command_line_tools = CommandLineTools.new
|
||||||
|
|
||||||
execute "upgrade #{command_line_tools.version}" do
|
execute "upgrade #{command_line_tools.version}" do
|
||||||
command ['softwareupdate', '--install', command_line_tools.latest_from_catalog]
|
command ['softwareupdate', '--install', command_line_tools.latest_from_catalog]
|
||||||
not_if { command_line_tools.version == command_line_tools.latest_from_catalog }
|
not_if { command_line_tools.version == command_line_tools.latest_from_catalog }
|
||||||
live_stream true
|
live_stream true
|
||||||
end
|
end
|
||||||
|
|
||||||
file 'delete sentinel file' do
|
file 'delete demand file' do
|
||||||
path '/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress'
|
path '/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress'
|
||||||
action :delete
|
action :delete
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
include MacOS
|
include MacOS
|
||||||
|
|
||||||
shared_context 'able to create on-demand installation sentinel' do
|
shared_context 'able to create on-demand installation demand' do
|
||||||
before do
|
before do
|
||||||
allow(FileUtils).to receive(:touch).and_return(true)
|
allow(FileUtils).to receive(:touch).and_return(true)
|
||||||
allow(FileUtils).to receive(:chown).and_return(true)
|
allow(FileUtils).to receive(:chown).and_return(true)
|
||||||
|
@ -38,7 +38,7 @@ end
|
||||||
|
|
||||||
describe MacOS::CommandLineTools do
|
describe MacOS::CommandLineTools do
|
||||||
context 'when there are several products for one Xcode version but several macOS versions' do
|
context 'when there are several products for one Xcode version but several macOS versions' do
|
||||||
include_context 'able to create on-demand installation sentinel'
|
include_context 'able to create on-demand installation demand'
|
||||||
include_context 'on macOS Mojave'
|
include_context 'on macOS Mojave'
|
||||||
include_context 'with no CLT previously installed'
|
include_context 'with no CLT previously installed'
|
||||||
before do
|
before do
|
||||||
|
@ -59,7 +59,7 @@ describe MacOS::CommandLineTools do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when there are no products for the current macOS version' do
|
context 'when there are no products for the current macOS version' do
|
||||||
include_context 'able to create on-demand installation sentinel'
|
include_context 'able to create on-demand installation demand'
|
||||||
include_context 'on macOS Mojave'
|
include_context 'on macOS Mojave'
|
||||||
include_context 'with no CLT previously installed'
|
include_context 'with no CLT previously installed'
|
||||||
before do
|
before do
|
||||||
|
@ -79,7 +79,7 @@ describe MacOS::CommandLineTools do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when provided an available list of software update products in Catalina' do
|
context 'when provided an available list of software update products in Catalina' do
|
||||||
include_context 'able to create on-demand installation sentinel'
|
include_context 'able to create on-demand installation demand'
|
||||||
include_context 'on macOS Catalina'
|
include_context 'on macOS Catalina'
|
||||||
include_context 'with no CLT previously installed'
|
include_context 'with no CLT previously installed'
|
||||||
before do
|
before do
|
||||||
|
@ -97,7 +97,7 @@ describe MacOS::CommandLineTools do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when provided an available list of software update products in Catalina' do
|
context 'when provided an available list of software update products in Catalina' do
|
||||||
include_context 'able to create on-demand installation sentinel'
|
include_context 'able to create on-demand installation demand'
|
||||||
include_context 'on macOS Catalina'
|
include_context 'on macOS Catalina'
|
||||||
include_context 'with CLT previously installed'
|
include_context 'with CLT previously installed'
|
||||||
before do
|
before do
|
||||||
|
|
|
@ -21,9 +21,9 @@ describe 'command_line_tools' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to create_file('create sentinel file') }
|
it { is_expected.to create_file('create demand file') }
|
||||||
it { is_expected.to run_execute('install Command Line Tools (macOS High Sierra version 10.13) for Xcode-10.0') }
|
it { is_expected.to run_execute('install Command Line Tools (macOS High Sierra version 10.13) for Xcode-10.0') }
|
||||||
it { is_expected.to delete_file('delete sentinel file') }
|
it { is_expected.to delete_file('delete demand file') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with libxcrun present' do
|
context 'with libxcrun present' do
|
||||||
|
@ -37,9 +37,9 @@ describe 'command_line_tools' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to create_file('create sentinel file') }
|
it { is_expected.to create_file('create demand file') }
|
||||||
it { is_expected.to_not run_execute('install Command Line Tools (macOS High Sierra version 10.13) for Xcode-10.0') }
|
it { is_expected.to_not run_execute('install Command Line Tools (macOS High Sierra version 10.13) for Xcode-10.0') }
|
||||||
it { is_expected.to delete_file('delete sentinel file') }
|
it { is_expected.to delete_file('delete demand file') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -65,11 +65,11 @@ describe 'command_line_tools' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to create_file('create sentinel file') }
|
it { is_expected.to create_file('create demand file') }
|
||||||
it {
|
it {
|
||||||
is_expected.to run_execute('upgrade Command Line Tools for Xcode-11.0')
|
is_expected.to run_execute('upgrade Command Line Tools for Xcode-11.0')
|
||||||
.with(command: ['softwareupdate', '--install', 'Command Line Tools for Xcode-22.0'])
|
.with(command: ['softwareupdate', '--install', 'Command Line Tools for Xcode-22.0'])
|
||||||
}
|
}
|
||||||
it { is_expected.to delete_file('delete sentinel file') }
|
it { is_expected.to delete_file('delete demand file') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1 @@
|
||||||
command_line_tools 'install them' do
|
command_line_tools
|
||||||
action :install
|
|
||||||
end
|
|
||||||
|
|
||||||
command_line_tools 'upgrade them' do
|
|
||||||
action :upgrade
|
|
||||||
end
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
title 'xcode command line tools'
|
title 'xcode command line tools'
|
||||||
|
|
||||||
control 'command-line-tool-sentinel' do
|
control 'command-line-tool-demand' do
|
||||||
title 'Command Line Tools sentinel has been deleted'
|
title 'Command Line Tools demand has been deleted'
|
||||||
desc '
|
desc '
|
||||||
Verify that the Command Line Tools sentinel has been deleted, and that
|
Verify that the Command Line Tools demand has been deleted, and that
|
||||||
there are no lingering CLT updates since we should have installed the latest
|
there are no lingering CLT updates since we should have installed the latest
|
||||||
'
|
'
|
||||||
describe file('/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress') do
|
describe file('/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress') do
|
||||||
|
|
Загрузка…
Ссылка в новой задаче