nbalonso.com

Prepare Office SP2 for InstaDMG

| Comments

It has been a while since I wrote on the blog. I could put here different excuses like vacations, attending the MacSysAdmin… but I promise I won’t :)

For a while there has been a thread open in AFP548 about how to patch Office 2011 to make it compatible with InstaDMG, so I decided to explain how I do it for the SP2.

Let’s begin!

We will need:

  • The volume installation iso file downloaded from the Microsoft portal: SW_DVD5_Office_Mac_Standard_2011w_SP2_English_-2_ISO_MLF_X18-49336.ISO
  • A computer running Mac OS X
  • A bit of terminal knowledge and bash (or not even if you just copy and paste from here!)

Double click on the iso to mount it.

Expand the flat package to a new folder in your desktop with

1
bash-3.2$ pkgutil --expand /Volumes/Microsoft\ Office\ 2011/Office\ Installer.pkg ~/Desktop/office_installer

I found that the expansion screws up two things, first it removes the execute attribute from all the PackageInfo files and second it stops the python script that changes the folder icon from working. Let’s fix the execute attribute for now with the following command and will fix the python script at the end.

1
bash-3.2$ find ~/Desktop/office_installer/ -name PackageInfo -print0 | xargs -0 chmod +x

We are going now to stop the unload of the licensing helper because on the machine that we run InstaDMG is not the destination host. So a simple check of destination install will do

Edit ~/Desktop/office_installer/Office2011_all_licensing_14.2.3.pkg/Scripts/preinstall and put this content:

1
2
3
4
5
6
7
8
9
10
#!/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

Then we are going to fix the script that fixes the license permissions so that our clients don’t get prompted for the S/N

Edit ~/Desktop/office_installer/Office2011_all_licensing_14.2.3.pkg/Scripts/postinstall and put this content:

1
2
3
4
5
6
7
8
9
10
11
12
13
#!/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

Now we are going to stop the installer from quitting the applications because again the machine the installer runs is not the target of the installation (Thanks to Rich Trouton for the heads up). This one liner will do:

1
bash-3.2$ echo -e '#!/bin/bash \n\nexit 0' >  ~/Desktop/office_installer/Office2011_all_quit_14.2.3.pkg/Scripts/preinstall

And finally fixing the folder icon. Edit ~/Desktop/office_installer/Office2011_en_required_14.2.3.pkg/Scripts/postinstall and put this content:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/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
#MS code commented below
#!/usr/bin/python -Wignore
#import sys
#import commands
#import os
#postflight_script_dirname = os.path.dirname(sys.argv[0])
#set_icon_file_path = os.path.join(postflight_script_dirname, "fix_custom_icon")
#installation_folder = "/Applications/Microsoft Office 2011"
#command = "'%s' '%s'" % (set_icon_file_path, installation_folder)
#status = os.system(command)

Then we can just warp it all up:

1
bash-3.2$ pkgutil --flatten ~/Desktop/office_installer/ ~/Desktop/My_Office_2011_installer.pkg

You are now ready to put that into your InstaDMG workflow.

Your comments and thoughts are always welcome below.

Comments