Version, Major Version, Major.Minor Version, and the weather...

donmontalvo
Esteemed Contributor III

Where a vendor (in this case Microsoft) decides to shift gears between CFBundleVersion and CFBundleShortVersionString...and your management tool can't shift gears to keep up, or decides for you whether to use CFBundleVersion or CFBundleShortVersionString. ¯_(ツ)_/¯

We manage our own EAs so we don't end up with this nightmare...

b270ac4b3dd5481a9112578b94ab6101

The other problem with determining version, is the overhead incurred when using Like or Not Like in your Smart Computer Groups.

If you take the extra minute or three to create 2 or 3 EAs, instead of the usual 1, you'll thank yourself later...many many times.

Because JSS will be much better behaved, having less calculation to deal with...the less calculation, the faster JSS becomes.

Version (Major.Minor.Patch):

#!/bin/bash
if [ -d /Applications/Microsoft Word.app ]; then
    echo "<result>$( /usr/bin/defaults read /Applications/Microsoft Word.app/Contents/Info.plist CFBundleShortVersionString )</result>"
else
    echo "<result>NotInstalled</result>"
fi

Major.Minor Version (Major.Minor):

#!/bin/bash
if [ -d /Applications/Microsoft Word.app ]; then
    echo "<result>$( /usr/bin/defaults read /Applications/Microsoft Word.app/Contents/Info.plist CFBundleShortVersionString | cut -f1-2 -d"." )</result>"
else
    echo "<result>NotInstalled</result>"
fi

Major Version (Major):

#!/bin/bash
if [ -d /Applications/Microsoft Word.app ]; then
    echo "<result>$( /usr/bin/defaults read /Applications/Microsoft Word.app/Contents/Info.plist CFBundleShortVersionString | cut -f1 -d"." )</result>"
else
    echo "<result>NotInstalled</result>"
fi

The above three EAs give you plenty of flexibility, and reduces your need for JSS calculation overhead.

$ /usr/bin/defaults read /Applications/Microsoft Word.app/Contents/Info.plist CFBundleShortVersionString
15.19.1
$ /usr/bin/defaults read /Applications/Microsoft Word.app/Contents/Info.plist CFBundleShortVersionString | cut -f1-2 -d"."
15.19
$ /usr/bin/defaults read /Applications/Microsoft Word.app/Contents/Info.plist CFBundleShortVersionString | cut -f1 -d"."
15

Microsoft Word 2016 version Like "15.19." <-- requires JSS to perform a calculation.

but

Microsoft Word 2016 (Major.Minor) version Is "15.19" <-- does not require any calculation.

Now if we can just get the team responsible for Patch Reporting and/or Patch Management to stop using Spotlight for EAs...maybe @michael.scafide will pass the word along for us. ;)

Maybe we can get @amanda.wulff to provide one of her excellent analysis/overview summaries, of the pitfalls of using Like and Not Like...since there doesn't seem to be a lot of documentation on its effect on JSS performance.

8f64ee66f95d48878fbe0e9a20e01bd4

More info on Semantic Versioning standard: http://semver.org/

[EDIT: fixed the keys in the first paragraph, the commands were correct, thanks @mm2270]!

HTH,
Don

--
https://donmontalvo.com
7 REPLIES 7

donmontalvo
Esteemed Contributor III

Oops...forgot to post the weather...

5aca6411e150414583597eab026cd73f

--
https://donmontalvo.com

millersc
Valued Contributor

Where is the like button for this?!

mm2270
Legendary Contributor III

Quick question for you @donmontalvo, but what is the problem with using Spotlight for gathering application or version information? You mentioned above "Now if we can just get the team responsible for Patch Reporting and/or Patch Management to stop using Spotlight for EAs" Can you explain why this is an issue as you see it?
I'm asking honestly because I'm not currently using any of the Patch Management functionality, for a few reasons, the main one being that we are still on an older pre-Patch Management version of Casper. So I'm just wondering if there is something I'm not aware of that I'd need to know when we get to the point of using it.

And P.S. - thanks for posting the weather in CA and making me jealous! :)

Edit 2: BTW, there's an error in your post - its not CFShortBundleVersionString, its CFBundleShortVersionString The former doesn't exist. You might want to fix that in your post.

donmontalvo
Esteemed Contributor III

Patches rely on fixed paths. Spotlight doesn't. Not sure how "Patch Management" can be patch management, if the path you found the application in, may not be the path the patch expects it to be in. ¯_(ツ)_/¯

So if your EAs follow the same paths that the patches will expect the application to be in, its a win-win.

Else you can potentially report on an application that needs a patch, but not be able to patch it.

--
https://donmontalvo.com

bentoms
Release Candidate Programs Tester

@donmontalvo Actually.. you can.

If a PKG has a set "install-location" via pkgbuild, then yes this might be a fixed location.

Else, the PKG might replace a version of the app in another location. It's rare but I saw this when I built our own pkg building app.

Ideally Applications will be in /Applications/, but you know how vendors are with following best practice.

In regards to the BundleVersions, well.. Apple have some information here on how they expect them to be used.

So.. we might have to flip between the strings per release as per the developers wants.

donmontalvo
Esteemed Contributor III

Hi @bentoms,

That is true but fewer installers are doing it, because /Applications and Local domain is where stuff is put in most cases.

Developers who place stuff in ~ are usually winging it or cutting corners to save money. Or they don't care.

App Store puts stuff in /Applications, so do drag install DMGs (most come with aliases to to target that folder), and nearly all of the better written installers put their apps there.

Installers that offer User vs Local domain leave a BOM/receipt that ensure updates target the same (wrong) location. But why? Usually because the developer doesn't understand, or because they got themselves into a rabbit hole, or maybe they inherited someone else's mess.

Blue Jeans, Aspera, EFI, Polygram, Cisco, and many others are getting a clue and are fixing their bad installers, or providing both consumer and enterprise flavors. Adobe, Microsoft, and many others left that madness behind years ago. :)

So why use Spotlight? Maybe to report on out of compliance stuff, but what good is that info if you can't patch the stuff it finds?

Are you creating installers that offer install location options when they are run? Any AutoPkg/r recipes creating packages that offer install options? Does Composer give you the capability? What about Packages?

We use paths, for consistency and reliability. It works for us, and rarely have issues. When we do, we engage the vendors, and the ones who want to be successful listen and adapt.

Merry Christmas!

Don

--
https://donmontalvo.com

donmontalvo
Esteemed Contributor III

@millersc thanks, it's an important topic that deserves some air time. :)

--
https://donmontalvo.com