In this Munki3dev commit:
https://github.com/munki/munki/commit/3f3d3ea0324d2db735cc1410fb76a632c065db2c I've merged in some code to support the precaching of certain optional installs.
You can mark an item for precache by adding
<key>precache</key>
<true/> to the item's pkginfo.
If such an item is in the optional_installs for a given machine and is available for install/update, additional information about the item will be recorded in InstallInfo.plist, and the installer item, if it exists in the Managed Installs Cache folder, will not be deleted even if it's not currently scheduled to be installed.
Mark one or more (currently uninstalled) optional items with the precache flag, then run the managedsoftwareupdate from this branch.
Examine /Library/Managed Installs/InstallInfo.plist for those items to see the additional detail.
There is also code to actually download items marked for precache, but it is not currently "wired up" to anything. You can manually run it like so:
% python
Python 2.7.10 (default, Feb 7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from munkilib.updatecheck import precaching
>>> precaching.cache()
You should see it download the optional_installs items that have the precache flag in /Library/Managed Installs/InstallInfo.plist.
I haven't wired this up anywhere yet because I can't decide how to implement the actual precaching. Two strategies occur to me, each with their plusses and minuses:
1) Do the precaching as part of a `managedsoftwareupdate --auto` run; that is, during the "normal" periodic background runs on `managedsoftwareupdate`. This would be fairly easy to implement. But if a poor soul happened to open Managed Software Center while a large item was precaching, they might be frustrated that they could not install some optional item for some possibly very long time until after the precaching completed. (This type of issue can happen today if Munki happens to be doing a lengthy managed_install download or install when Managed Software Center is launched, so maybe this is not a huge deal).
2) Have a secondary process do the precaching independently of managedsoftwareupdate runs. This avoids some of the issues in #1, but presents a few issues of its own. For example, while the secondary process was precaching Foo, a user could launch MSC.app and choose Foo for immediate install. managedsoftwareupdate would start downloading the item -- it would have no idea that the secondary process was already downloading the item. This could lead to less than excellent results.
There are ways to work around the issues with either approach, but I think we should take the time to think through the options, the possible issues, the possible workarounds, and the implementation difficulties.
-Greg