Skip to content

Instantly share code, notes, and snippets.

@grahampugh
Created March 29, 2019 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grahampugh/4e3523d73f0fe978a174ed9a9b2bc45d to your computer and use it in GitHub Desktop.
Save grahampugh/4e3523d73f0fe978a174ed9a9b2bc45d to your computer and use it in GitHub Desktop.
AutoPkg recipe for packaging up SPSSStatistics with a License Code
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Description</key>
<string>Downloads the latest version of SPSSStatistics and creates a package.</string>
<key>Identifier</key>
<string>com.github.grahampugh.recipes.pkg.SPSSStatisticsNode</string>
<key>Input</key>
<dict>
<key>LICENSE</key>
<string>Node</string>
<key>MAJOR_VERSION</key>
<string>25</string>
<key>NAME</key>
<string>SPSSStatistics</string>
</dict>
<key>MinimumVersion</key>
<string>1.0.0</string>
<key>Process</key>
<array>
<dict>
<key>Arguments</key>
<dict>
<key>pkgdirs</key>
<dict>
</dict>
<key>pkgroot</key>
<string>%RECIPE_CACHE_DIR%/Scripts</string>
</dict>
<key>Processor</key>
<string>PkgRootCreator</string>
</dict>
<dict>
<key>Arguments</key>
<dict>
<key>pkgdirs</key>
<dict>
</dict>
<key>pkgroot</key>
<string>%RECIPE_CACHE_DIR%/pkgroot</string>
</dict>
<key>Processor</key>
<string>PkgRootCreator</string>
</dict>
<dict>
<key>Arguments</key>
<dict>
<key>destination_path</key>
<string>%RECIPE_CACHE_DIR%/Scripts/SPSS_Statistics_Installer.bin</string>
<key>source_path</key>
<string>%pathname%/SPSS_Statistics_Installer.bin</string>
</dict>
<key>Processor</key>
<string>Copier</string>
</dict>
<dict>
<key>Arguments</key>
<dict>
<key>destination_path</key>
<string>%RECIPE_CACHE_DIR%/Scripts/installer.properties</string>
<key>source_path</key>
<string>%pathname%/installer.properties</string>
</dict>
<key>Processor</key>
<string>Copier</string>
</dict>
<dict>
<key>Arguments</key>
<dict>
<key>file_content</key>
<string>#!/bin/bash
## script to install SPSS %MAJOR_VERSION% %LICENSE%
echo "Installing SPSS %MAJOR_VERSION% %LICENSE%"
scriptsdir=$(dirname "$0")
# Installer will fail but report success if Java not already present
# so need to check for this
if ! /usr/libexec/java_home -X &gt; /dev/null 2&gt;&amp;1; then
echo "Java not present but is required for SPSS %MAJOR_VERSION% installation. Cannot proceed"
exit 1
fi
# Edit installer.properties to make it a node license
perl -pi -e "s|^###AUTHCODE=.*|AUTHCODE=%license_key%|" $scriptsdir/installer.properties
# run the installer
echo "Running SPSS %MAJOR_VERSION% base installer"
/bin/chmod a+x $scriptsdir/SPSS_Statistics_Installer.bin
$scriptsdir/SPSS_Statistics_Installer.bin -f $scriptsdir/installer.properties &gt; /dev/null 2&gt;&amp;1
# activate the license
/bin/chmod 750 /Applications/IBM/SPSS/Statistics/%MAJOR_VERSION%/SPSS\ Statistics\ License\ Authorization\ Wizard.app
echo "Running licenseactivator"
/bin/rm /tmp/licenseactivator.txt
cd /Applications/IBM/SPSS/Statistics/%MAJOR_VERSION%/SPSSStatistics.app/Contents/bin
./licenseactivator %license_key% | tee /tmp/licenseactivator.txt
if grep failed /tmp/licenseactivator.txt ; then
echo "ERROR: SPSS License %MAJOR_VERSION% activation failed."
grep "You are not allowed to generate any more new licenses" /tmp/licenseactivator.txt &amp;&amp; echo "No licenses remaining"
exit 1
elif [[ ! -s /tmp/licenseactivator.txt ]]; then
echo "ERROR: SPSS License %MAJOR_VERSION% activation failed."
exit 1
else
echo "SPSS %MAJOR_VERSION% Node License activation successful."
fi
# unblock SPSS in the firewall
echo "Unblocking SPSS in Application Firewall"
/usr/libexec/ApplicationFirewall/socketfilterfw --unblockapp /Applications/IBM/SPSS/Statistics/%MAJOR_VERSION%/SPSSStatistics.app/Contents/MacOS/spssLauncher
/usr/libexec/ApplicationFirewall/socketfilterfw --add /Applications/IBM/SPSS/Statistics/%MAJOR_VERSION%/SPSSStatistics.app/Contents/MacOS/spssLauncher
</string>
<key>file_mode</key>
<string>0755</string>
<key>file_path</key>
<string>%RECIPE_CACHE_DIR%/Scripts/postinstall</string>
</dict>
<key>Processor</key>
<string>FileCreator</string>
</dict>
<dict>
<key>Arguments</key>
<dict>
<key>force_pkg_build</key>
<true/>
<key>pkg_request</key>
<dict>
<key>chown</key>
<array>
</array>
<key>id</key>
<string>com.ibm.%NAME%%MAJOR_VERSION%%LICENSE%</string>
<key>pkgname</key>
<string>%NAME%-%MAJOR_VERSION%-%LICENSE%-%version%</string>
<key>pkgroot</key>
<string>%RECIPE_CACHE_DIR%/pkgroot</string>
<key>pkgtype</key>
<string>flat</string>
<key>scripts</key>
<string>Scripts</string>
<key>version</key>
<string>%version%</string>
</dict>
</dict>
<key>Processor</key>
<string>PkgCreator</string>
</dict>
</array>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment