Home > AutoPkg, Mac administration, macOS > Using AutoPkg to create an installer package for SAP GUI

Using AutoPkg to create an installer package for SAP GUI

I’ve previously posted guides on how to manually package SAP GUI:

However it’s also possible to automate creating a SAP GUI installer package using AutoPkg. To do this, you’ll need the following:

  1. AutoPkg
  2. The SAP GUI recipes from the rtrouton-recipes repo
  3. The latest SAP GUI installer application’s disk image
  4. A SAP GUI templates.jar file (optional)

For more details, please see below the jump.

The AutoPkg recipes I’ve written will need the following information provided:

  • SAP GUI’s numeric information
  • SAP GUI’s alphanumeric information
  • SAP GUI’s application bundle identifier information

None of this information is available from the installer application, so you’ll need to provide it to AutoPkg using a com.sapgui.identifier.plist file which will be included along with the latest SAP GUI installer application’s disk image. Please see below for how to gather this information.

Preparing SAP GUI for AutoPkg

1. Copy the latest SAP GUI installer application’s disk image to a test Mac or virtual machine.

2. Mount the disk image and launch the SAP GUI for Java Installer installer application on the test Mac or virtual machine.

Screen Shot 2021 07 22 at 2 16 27 PM

3. Follow the prompts to install.

Screen Shot 2021 07 22 at 2 16 55 PM

Screen Shot 2021 07 22 at 2 17 20 PM

Screen Shot 2021 07 22 at 2 17 32 PM

Screen Shot 2021 07 22 at 2 17 56 PM

4. Once installed, run the following command to get SAP GUI’s alphanumeric version.

defaults read "/Applications/SAP Clients/SAPGUI $version/SAPGUI $version.app/Contents/Info.plist" NSHumanReadableCopyright | awk '{print $2$3$4}'

For example, if this is SAPGUI 7.70rev2, use the following command:

defaults read "/Applications/SAP Clients/SAPGUI 7.70rev2/SAPGUI 7.70rev2.app/Contents/Info.plist" NSHumanReadableCopyright| awk '{print $2$3$4}'

Screen Shot 2021 07 22 at 2 34 18 PM

5. Once you have the alphanumeric version, run the following command to get SAP GUI’s numeric version.

defaults read "/Applications/SAP Clients/SAPGUI $version/SAPGUI $version.app/Contents/Info.plist" CFBundleShortVersionString

For example, if this is SAPGUI 7.70rev2, use the following command:

defaults read "/Applications/SAP Clients/SAPGUI 7.70rev2/SAPGUI 7.70rev2.app/Contents/Info.plist" CFBundleShortVersionString

Screen Shot 2021 07 22 at 2 35 47 PM

6. Once you have both versions, run the following command to get SAP GUI’s bundle identifier:

defaults read "/Applications/SAP Clients/SAPGUI $version/SAPGUI $version.app/Contents/Info.plist" CFBundleIdentifier

For example, if this is SAPGUI 7.70rev2, use the following command:

defaults read "/Applications/SAP Clients/SAPGUI 7.70rev2/SAPGUI 7.70rev2.app/Contents/Info.plist" CFBundleIdentifier

Screen Shot 2021 07 22 at 2 45 12 PM

7. Open Terminal and run the following command to create a com.sapgui.identifier.plist file with the alphanumeric version information for SAP GUI:

defaults write /path/to/com.sapgui.identifier AlphanumericVersionString version_info_goes_here

For example, if the SAP GUI alphanumeric version is 7.70rev2, run the following command to create a com.sapgui.identifier.plist file on the Desktop:

defaults write $HOME/Desktop/com.sapgui.identifier AlphanumericVersionString 7.70rev2

Screen Shot 2021 07 22 at 2 49 14 PM

8. Run the following command to add the numeric version information for SAP GUI to the com.sapgui.identifier.plist file:

defaults write /path/to/com.sapgui.identifier CFBundleShortVersionString version_info_goes_here

For example, if the SAP GUI numeric version is 770.4.200, run the following command

defaults write $HOME/Desktop/com.sapgui.identifier CFBundleShortVersionString 770.4.200

Screen Shot 2021 07 22 at 2 59 28 PM

9. Run the following command to add the bundle identifier information for SAP GUI to the com.sapgui.identifier.plist file:

defaults write /path/to/com.sapgui.identifier CFBundleIdentifier bundle_identifier_info_goes_here

For example, if the SAP GUI bundle identifier is com.sap.platin, run the following command

defaults write $HOME/Desktop/com.sapgui.identifier CFBundleIdentifier com.sap.platin

Screen Shot 2021 07 22 at 2 58 32 PM

10. Once the com.sapgui.identifier.plist file is created and populated with the version and bundle identifier information, copy it to a convenient location along with the latest SAP GUI installer application’s disk image.

11. If you’re planning to include a templates.jar file with the SAP GUI installer, copy the templates.jar file to the same location.

Screen Shot 2021 06 18 at 12 12 51 PM

12. Create a .zip file of the following files:

  • corp.sap.sapgui.identifier.plist
  • Latest SAP GUI installer application’s disk image
  • templates.jar (if applicable)

For this example, I’m going to use the following filename for the .zip file:

latestsapgui.zip

This .zip file will be what’s used by AutoPkg to create the SAP GUI installer package.

Screen Shot 2019 10 09 at 11 30 35 AM

 

Using the AutoPkg recipes

To accomodate the fact that some folks will have a templates.jar file which they want to include and some folks won’t, I’ve written two sets of .pkg recipes:

  • SAPGUIWithTemplate.pkg – Use when you’re using a templates.jar file
  • SAPGUIWithoutTemplate.pkg – Use when you’re not using a templates.jar file

Both sets of recipes share a common SAPGUI.download recipe.

SAP GUI does not have a publicly accessible download link, so there are two options available for adding the .zip file you created earlier to your AutoPkg workflow:

1. Posting the .zip file to a web server for download.

You can upload the .zip file to a web server or other online storage location which AutoPkg can download files from. This is my preferred method because you can set the download URL in an AutoPkg override. Once that’s done, you just need to replace the .zip file on the web server when a new version of SAP GUI comes out. The next time it’s run, AutoPkg will download the new .zip file and handle the rest automatically.

2. Using AutoPkg’s -p option.

AutoPkg includes an -p option for specifying a file for input, in place of downloading from a URL.

Screen shot 2015 01 26 at 7 36 26 am

For example, if you wanted to run the SAPGUIWithTemplate.pkg recipe and use a .zip file stored locally on your Mac, you would use the following command to run an AutoPkg override of the SAPGUIWithTemplate.pkg recipe and specify a .zip file named latestsapgui.zip:

autopkg run local.pkg.SAPGUIWithTemplate -p /path/to/latestsapgui.zip

Once you’ve sorted out how you’re adding the .zip file you created to your AutoPkg workflow, you should be able to use these recipes to create SAP GUI installer packages for use in your own environment.

For those who want to use code signing to sign the SAP GUI installers created by AutoPkg, I’ve also created the following .sign recipes:

SAPGUIWithTemplate.sign – Use when you’re using a templates.jar file
SAPGUIWithoutTemplate.sign – Use when you’re not using a templates.jar file

Each .sign recipe uses the appropriate .pkg recipe as a parent recipe.

  1. Daniel
    October 28, 2021 at 11:29 am

    Hi folks,
    maybe you can help me.
    I did all the steps which you have mentioned above. Now I receive the following errors:

    #autopkg run local.pkg.SAPGUIWithTemplate -p /Users/zzcwpsadmin/Documents/latestsapgui.zip -v
    Processing local.pkg.SAPGUIWithTemplate…
    URLDownloader
    URLDownloader: Given /Users/zzcwpsadmin/Documents/latestsapgui.zip, no download needed.
    Unarchiver
    Unarchiver: Guessed archive format ‘zip’ from filename latestsapgui.zip
    Unarchiver: Unarchived /Users/zzcwpsadmin/Documents/latestsapgui.zip to /Users/zzcwpsadmin/Library/AutoPkg/Cache/local.pkg.SAPGUIWithTemplate/SAP
    Versioner
    Versioner: Found version 770.4.300 in file /Users/zzcwpsadmin/Library/AutoPkg/Cache/local.pkg.SAPGUIWithTemplate/SAP/com.sapgui.identifier.plist
    EndOfCheckPhase
    PlistReader
    PlistReader: Reading: /Users/zzcwpsadmin/Library/AutoPkg/Cache/local.pkg.SAPGUIWithTemplate/SAP/com.sapgui.identifier.plist
    PlistReader: Assigning value of ‘770.4.300’ to output variable ‘version’
    PlistReader: Assigning value of ‘7.70rev3’ to output variable ‘alphanumeric_version’
    PlistReader: Assigning value of ‘com.sap.platin’ to output variable ‘bundle_identifier’
    StopProcessingIf
    StopProcessingIf: (version == “”) is False
    StopProcessingIf
    StopProcessingIf: (alphanumeric_version == “”) is False
    StopProcessingIf
    StopProcessingIf: (bundle_identifier == “”) is False
    PkgRootCreator
    PkgRootCreator: Created /Users/zzcwpsadmin/Library/AutoPkg/Cache/local.pkg.SAPGUIWithTemplate/pkgroot
    PkgRootCreator
    PkgRootCreator: Created /Users/zzcwpsadmin/Library/AutoPkg/Cache/local.pkg.SAPGUIWithTemplate/pkgroot
    FileFinder
    No matching filename found
    Failed.
    Receipt written to /Users/zzcwpsadmin/Library/AutoPkg/Cache/local.pkg.SAPGUIWithTemplate/receipts/local.pkg-receipt-20211028-131259.plist

    The following recipes failed:
    local.pkg.SAPGUIWithTemplate
    Error in local.pkg.SAPGUIWithTemplate: Processor: FileFinder: Error: No matching filename found

    Nothing downloaded, packaged or imported.

    What am I doing wrong? It seems to be as if the recipe found my initial zip-archive, extracted the plist-File but then nothing happens.
    Many thanks

    • October 28, 2021 at 11:34 am

      Do you have a templates.jar file included in the latestsapgui.zip file? If you don’t, you should be using the SAPGUIWithoutTemplate recipes.

      • Daniel
        October 28, 2021 at 11:41 am

        Hi,
        i double checked it. Inside the archive there is the plist, DMG and the templates.jar.
        I excluded the templates.jar and made an override from SAPGUIWithoutTemplate. I received the same error message at the end.
        Many thanks

      • October 28, 2021 at 11:50 am

        In that case, it’s not finding the disk image file. Please make sure that the disk image filename ends in “.dmg” (no quotes, all lower-case). The recipe is looking for that: https://github.com/autopkg/rtrouton-recipes/blob/master/SAPGUI/SAPGUIWithTemplate.pkg.recipe#L95

      • Daniel
        October 28, 2021 at 12:09 pm

        That`s it… Nice!
        Many thanks

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: