I am using hjuutilainen LibreOffice
recipes to download LibreOffice and import it to munki.
My users also need LibreOffice language pack (Czech language) since core LibreOffice application is US English only. I used to prepare language pack manually. When AutoPkg found new version of LibreOffice I went to LibreOffice website, downloaded langaguage pack, ran script to extract it's contents, built package with luggage and imported it into Munki. That was a lot of labour so I decided to automate this process with AutoPkg. I am comfortable with autopkg and Recipe Overrides but I am quite new to processors.
Desired state
- Download recipe is able to download language pack with language code specified in variable.
- Pkg recipe creates package with version number corresponding to CFBundleShortVersionString version of latest LibreOffice.
- Munki recipe imports package into munki with correct "requires" key
- For language pack for LibreOffice 5.0.0 which has CFBundleShortVersionString 5.0.5 it should look like this:
<key>name</key>
<string>LibreOffice_langpack_cs</string>
<key>version</key>
<string>5.0.5</string><key>requires</key>
<array>
<string>LibreOffice-5.0.5</string>
</array>
How language pack install works
Language pack is a dmg with .app installer inside. Installer is wraper for AppleScript Contents/osx_install.applescript which unpacks Contets/tarball.tar.bz2 to correct location (with user's help). That is usually /Applications/LibreOffice.app/Contents/Resources. There is langugage pack for every version of LibreOffice and since it is installed into LibreOffice .app bundle you should probably download and install corresponding language pack for every version of LibreOffice.
Problem with versions
LibreOffice has little version problem on Mac side. For example there is new LibreOffice 5.0.0 release on their website. Unfortunately CFBundleShortVersionString of actual LibreOffice.app is 5.0.5 <- this version is also used in munki pkginfo file created by hjuutilainen LibreOffice recipe. I think language pack for LibreOffice 5.0.5 should also be version 5.0.5 with "requires" pkginfo key pointing to LibreOffice-5.0.5. When I inspected original langugage pack dmg I was able to find only two pieces of version information. Name of dmg contains 5.0.0, CFBundleShortVersionString of language pack installer app is 9. Sight...
My AutoPkg solution
I created AutoPkg recipes and they work but I feel they are bit of a hack. All files are in post attachment.
(please note this a work in progress and name of recipes and variables are not final)
- LangPack.download.recipe
- ParentRecipe: io.github.hjuutilainen.download.LibreOffice - I download latest version of LibreOffice solely for purpose of getting correct version number (LibreOffice.app CFBundleShortVersionString).
- StoreVariable.py - I created this simple processor because I want to store pathname of LibreOffice dmg because %pathname% variable gets overwritten with language pack dmg path
- LibreOfficeLanguagePackURLProvider.py - This is hjuutilainen's renamed download script with only one important change = modified regular expression used for finding langugage pack url
- URLDownloader
- EndOfCheckPhase
- LangPack.Pkg.recipe
- AppDmgVersioner - gets LibreOffice CFBundleShortVersionString version from LibreOffice dmg
- PkgRootCreator
- Copier - copies tarball.tar.bz2 into autopkg cache directory
- Unarchiver - unpacks tarball.tar.bz2 into PkgRoot
- PkgCreator
- LangPack.munki.recipe
- MunkiImporter
- PlistEditor - adds "requires" key to pkginfo because version in not known beforehand
Problems
- Using io.github.hjuutilainen.download.LibreOffice as parent recipe of LangPack.download.recipe
- It downloads LibreOffice.dmg to LangPack.munki.recipe Cache folder -> AutoPkg run with both LibreOffice and LangPack recipes will download LibreOffice.dmg twice
- io.github.hjuutilainen.download.LibreOffice uses CodeSignatureVerifier -> AutoPkg run -||- will verify LibreOffice.dmg twice (it takes some time)
- LibreOfficeLanguagePackURLProvider.py modifies minimum amout of code.
- Should original processor script be modified to enable geting URL for both LibreOffice and language packs? -> Should I try to make a pull request out of this?
- StoreVariable.py processor is not pretty. Is there a better way to store (backup) value of variable which is about to be overwriten by another processor?
How should I approach problem with versions?
Any other ideas how to improve this?