Prepare Office SP3 for InstaDMG

Howdy monolithic admins!

As a couple of you had some issues with the SP2 method I posted here. This time I made a bash script to automate the process.

No need for sudo. The script expects SW_DVD5_Office_Mac_Standard_2011w_SP3_English_ISO_MLF_X18-77844.ISO path as an argument

#!/bin/sh

#
#Modifies Office 2011 SP3 installer to make it instaDMG ready. Expects $1 with the iso
#http://blog-nbalonso.rhcloud.com

TMPDIR='/tmp/buildoffice'

if [ "$1" == "" ]; then
	echo "Usage:
	./buildoffice.sh [path to iso file]\n"
	exit -1
fi

echo "INFO: Starting"

##
if [ "`md5 ${1} | awk '{ print $NF }' `" == "2acc0fadb6050e15aacd51958be24571" ]; then
	echo "INFO: The iso provided matches the 14.3.0 volume installer"
else
	echo "ERROR: the iso does not match the 14.3.0 volume installer"
	exit -1
fi
##

##
echo "INFO: Silently mounting the iso"
hdiutil attach ${1} -quiet -nobrowse
##

##
echo "INFO: Expanding the pkg"
pkgutil --expand '/Volumes/Microsoft Office 2011/Office Installer.pkg' /tmp/buildoffice/
##

##
echo "INFO: Unmounting the iso"
hdiutil detach '/Volumes/Microsoft Office 2011/' -quiet
##

##
echo "INFO: Fixing things..."
find /tmp/buildoffice/ -name PackageInfo -print0 | xargs -0 chmod +x

echo '#!/bin/sh
#MS code commented below
#launchctl unload -w /Library/LaunchDaemons/com.microsoft.office.licensing.helper.plist
HELPERPLIST="$3/Library/LaunchDaemons/com.microsoft.office.licensing.helper.plist"
if [ "$3" == "/" ]; then
	#installing on the startup disk // running OSX
	launchctl unload -w $HELPERPLIST
fi
exit 0' > ${TMPDIR}/Office2011_all_licensing_14.3.0.pkg/Scripts/preinstall

echo '#!/bin/sh
chown root:wheel "$3/Library/LaunchDaemons/com.microsoft.office.licensing.helper.plist"
chmod 644 "$3/Library/LaunchDaemons/com.microsoft.office.licensing.helper.plist"
chown root:wheel "$3/Library/PrivilegedHelperTools/com.microsoft.office.licensing.helper"
chmod 755 "$3/Library/PrivilegedHelperTools/com.microsoft.office.licensing.helper"
if [ "$3" == "/" ]; then
    #installing on the startup disk // running OSX
    launchctl load -w "$3/Library/LaunchDaemons/com.microsoft.office.licensing.helper.plist"
fi
exit 0' > ${TMPDIR}/Office2011_all_licensing_14.3.0.pkg/Scripts/postinstall

echo '#!/bin/sh
exit 0' > ${TMPDIR}/Office2011_all_quit_14.3.0.pkg/Scripts/preinstall

echo '#!/bin/bash
RESOURCES_DIRECTORY=`/usr/bin/dirname "$0"`
SET_ICON_FILE_PATH="${RESOURCES_DIRECTORY}/fix_custom_icon"
INSTALLATION_FOLDER="$3/Applications/Microsoft Office 2011/"
"$SET_ICON_FILE_PATH" "$INSTALLATION_FOLDER"
exit 0' > ${TMPDIR}/Office2011_en_required_14.3.0.pkg/Scripts/postinstall
##

##
echo "INFO: Compressing the new installer"
pkgutil --flatten ${TMPDIR} ~/Desktop/My_Office_2011_SP3_installer.pkg
##

##Clean the house
echo "INFO: Deleting the temporary folder"
rm -rfd '${TMPDIR}/'
##

echo "SUCCESS"
exit 0

PS: should be easy enough to adapt the method to work both with the SP2 and SP3 isos

Posted in IT and stuff Tagged with: , , , ,
9 comments on “Prepare Office SP3 for InstaDMG
  1. Ethernomad says:

    In using the script. I have placed the Office ISO on my desktop.

    I have changed line 6 of the script from:
    if [ "$1" == "" ]; then
    to
    if [ “$1″ == “/Users/[me]/Desktop/SW_DVD5_Office_Mac_Standard_2011w_SP3_English_ISO_MLF_X18-77844.ISO” ]; then

    Running the script yields the below result:
    INFO: Starting

    The script then sits there forever. I am sure I have misinterpreted something. Please let me know what I should do differently.

    • nbalonso says:

      line 6 is actually a check to make sure you provided the extra argument, you should not change it.

      Copy both script and the iso to your desktop, cd to it and run:
      ./prepareoffice.sh SW_DVD5_Office_Mac_Standard_2011w_SP3_English_ISO_MLF_X18-77844.ISO

  2. Ethernomad says:

    That did the trick. It’s working like a charm! Thanks for the quick reply!

  3. Jeremy Kemp says:

    The cript was crashing for me until I put the file references ${1} in double-quotes. The path to the file had spaces in it and wasn’t being quoted. :)

  4. Stevie says:

    Thanks for this!

    I’m trying to adapt it to work with the SP2 installer. (SW_DVD5_Office_Mac_Standard_2011w_SP2_English_-2_ISO_MLF_X18-49336.ISO)

    I’m falling down with ERROR: the iso does not match the 14.3.0 volume installer

    Any ideas?

  5. Chris says:

    Your script is awesome, Thanks!

    Just wondering if you have any idea’s about getting the Office 2011 – 14.3.7 update to install with InstaDMG?

    • nbalonso says:

      I wrote an answer some time ago to Robby Griffin on the same question. Bottom line is, because Munki is such a great tool and the incremental update does not take much time to install I do not bother to update my image further than the service packs.

      Thanks for the question tho (:

      My old reply below:

      On Mon, Jul 22, 2013 at 3:50 PM, Noel B. A. wrote:
      Hey Robby,

      I’m glad the post helped you. I do not have modified any update to work with instaDMG, ’cause new updates come out very often, plus in my case Munki does install them on the first boot.

      Still you should be able to get it to work using the same principles. Expand the update, check and modify the preflight and postflight scripts and package it back.

      The main think you want to look for in the scripts is the target volume. There are three cases where you want to take special attention:
      -Scripts that check whether the application to patch exists in the target volume. These should find the application installed in instaDMG volume
      -Permissions modifications should be done in the target volume. Example of this is the problem with the activation agent.
      -Scripts that unload/kill agents are not needed when installed into a different volume. I used an if for this

      Basically you’d be tuning the scripts from Microsoft to use $3 before the / . Here there is a useful table of what $3 means http://s.sudre.free.fr/Stuff/PackageMaker_Howto.html

      once you get it done let me know where you post it (:

      best,
      Noel

1 Pings/Trackbacks for "Prepare Office SP3 for InstaDMG"
  1. [...] Office 2011 is a common application to get baked into an InstaDMG image (or any other pre-compiled, modular style image).  There are a few quirks to installing Office 2011 in this way as it was made to be installed on a live system.  Noel Alonso put a script together that fixes some of these issues on the Office 2011 SP3 Installer.  These changes help it install correctly and also fix some bugs with the installer itself.  You can take a look at the script over on Noel’s Blog. [...]

Leave a Reply