in src/aws/install-aws-cli/src.main.kts [165:205]
override fun install(version: String) {
val installDir = getInstallDir(version).also { File(it).mkdirs() }
installRosettaIfNeeded(installDir)
val url = "https://awscli.amazonaws.com/AWSCLIV2-$version.pkg"
val temp = prepareTempDir()
println("Downloading AWS CLI from $url to ${temp.absolutePath}")
val pkg = downloadFile(url, temp)
val choicesXml = File(temp, "choices.xml")
choicesXml.writeText(
"""
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>choiceAttribute</key>
<string>customLocation</string>
<key>attributeSetting</key>
<string>${installDir}</string>
<key>choiceIdentifier</key>
<string>default</string>
</dict>
</array>
</plist>
""".trimIndent()
)
runProcessOrFail(
listOf(
"installer",
"-pkg", pkg.name,
"-target", "CurrentUserHomeDirectory",
"-applyChoiceChangesXML", choicesXml.name,
), temp
)
updateEnvPath(version)
cleanUpAndLogSuccess(temp, version)
}