Extension Attribute For "Swift Runtime for CLT"

derek_ritchison
Contributor

I'm rolling out OneLogin Desktop in a couple of weeks and to successfully deploy to any pre-10.14.4 machine I need to push out Swift Runtime for CLT. I did this yesterday, but I would love to see if the policy failed on any machines. Not sure how to make a Smart Group for this since Swift for CLT isn't an "app," per se. Any suggestions?

10 REPLIES 10

afarnsworth
Contributor

Something that comes to mind is using pkgutil --pkgs to see if you can find the Swift Runtime for CLT package receipt. If you can, then add a pipe to the command and grep the receipt name out. An EA would look something like

#!/bin/bash
swiftReceipt=$(pkgutil --pkgs | grep com.apple.pkg.something)
if [ "$swiftReceipt" = "receiptname" ]; then
echo "<result>Swift CLT Installed</result>"
else
echo "<result>Swift CLT Not Installed</result>"
fi

derek_ritchison
Contributor

Interesting. I'll try this later today and post here.

derek_ritchison
Contributor

I got a "Not Installed" response on a machine that I know it was installed on, so I think I might have the receipt name wrong. Will keep digging, but assuming this will work once I get the names right.

tlarkin
Honored Contributor

What is the bundle ID of the Swift Runtime?

derek_ritchison
Contributor

Alright, I'm not sure what the Bundle ID is but I did create an Extension Attribute using that same script:

#!/bin/bash
swiftReceipt=$(pkgutil --info com.apple.pkg.SwiftRuntimeForCommandLineTools)
if [ "$swiftReceipt" = "No receipt for 'com.apple.pkg.SwiftRuntimeForCommandLineTools' found at '/'." ]; then
echo "<result>Swift Runtime For CLT Not Installed</result>"
else
echo "<result> Swift Runtime For CLT Installed</result>"
fi

...and scoping it to computers running only older than a 10.14.4 macOS. I'm seeing some results filter into the INSTALLED Smart Group, but not the NOT INSTALLED Smart Group. Will give it some time and update.

derek_ritchison
Contributor

No luck. I checked my work against some of the laptops in the INSTALLED group by running:

pkgutil --info com.apple.pkg.SwiftRuntimeForCommandLineTools

...silently in the background. While I assumed I had a successful install earlier, it clearly did not install. Don't know how I got my Extension Attribute / Smart Group wrong.
77e9c0bb56d5442b82dae95b3d853e31

c46e883481784e6a8ae7d0372582428d

derek_ritchison
Contributor

Ok, so my final stab at this is it base a Smart Group of the exit code of an EA script.

#!/bin/bash

exit=?(pkgutil --info com.apple.pkg.SwiftRuntimeForCommandLineTools)

if [ $exit -eq 0 ]
then
  echo "Success"
else
  echo "Failure" >
fi

I'm not terribly familiar with bash, and this is clearly not working. Any suggestions?

jhamil50
New Contributor III

Can you use the "Packages Installed By Installer.app/SWU" for this?

c891161e2f464216afab978c2fbbc6ec

derek_ritchison
Contributor

Just updated the Smart Group and my one known computer populated. I'll push the install out again and give it some time to run to see if the Smart Groups update. Thanks! I had no idea that was even in option there!

derek_ritchison
Contributor

Got it. You're a genius.