diff --git a/script/buildDist.py b/script/buildDist.py index 6f41726..72b904c 100755 --- a/script/buildDist.py +++ b/script/buildDist.py @@ -5,6 +5,7 @@ import argparse import getpass import math import os +import platform import shutil import signal import subprocess @@ -89,7 +90,7 @@ def checkForRequiredApplicationsAndExit(): """Method to ensure we have all of the required applications installed to support building of distributions. If there are mandatory applications that are missing then this will be printed to stderr and the program will exit. The current set of required applications are: - java, jar, genisoimage""" + java, jar, (genisoimage or hdiutil)""" evalPath = distutils.spawn.find_executable('java') errList = [] if evalPath == None: @@ -97,9 +98,14 @@ def checkForRequiredApplicationsAndExit(): evalPath = distutils.spawn.find_executable('jar') if evalPath == None: errList.append('Failed while trying to locate jar. Please install jar (typically included with Java)') - evalPath = distutils.spawn.find_executable('genisoimage') - if evalPath == None: - errList.append('Failed while trying to locate genisoimage. Please install genisoimage') + + genisoimagePath = distutils.spawn.find_executable('genisoimage') + hdiutilPath = distutils.spawn.find_executable('hdiutil') + if genisoimagePath == None and hdiutilPath == None: + if platform.system() == 'Darwin': + errList.append('Failed while trying to locate executable hdiutil. Please install hdiutil') + else: + errList.append('Failed while trying to locate executable genisoimage. Please install genisoimage') # Bail if there are no issues if len(errList) == 0: @@ -182,6 +188,7 @@ if __name__ == "__main__": parser.add_argument('-icnsFile', help='Icon file used for apple build.') parser.add_argument('-forceSingleInstance', help='Force the application to have only one instance.', default=False) parser.add_argument('-digest', help='Digest used to ensure integrity of application upgrades. Default: sha256', choices=['md5', 'sha256', 'sha512'], default='sha256') + parser.add_argument('-enableJmx', help='Enables JMX technology on the target client. Allows one to attach jconsole, jvisualvm, or other JMX tools.', action='store_true', default=False) # parser.add_argument('-bundleId', help='Apple specific id descriptor.') # Intercept any request for a help message and bail @@ -245,6 +252,14 @@ if __name__ == "__main__": else: newJvmArgs.append(aJvmArg) args.jvmArgs = newJvmArgs + + # Add the flag -Dcom.sun.management.jmxremote to allow JMX clients to attach to the Java application + # Add the flag -Djava.rmi.server.hostname=localhost to allow connections when using VPN. Not sure why??? + # It appears that when the root class loader is replaced then JMX is disabled by default + # See also: http://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html + if args.enableJmx == True: + args.jvmArgs.append('-Dcom.sun.management.jmxremote') + args.jvmArgs.append('-Djava.rmi.server.hostname=localhost') # Bail if the release has already been built buildPath = os.path.abspath(args.name + '-' + args.version) diff --git a/script/windowsUtils.py b/script/windowsUtils.py index 941656b..3573517 100644 --- a/script/windowsUtils.py +++ b/script/windowsUtils.py @@ -2,7 +2,9 @@ import copy import os +import platform import shutil +import subprocess import tempfile import glob @@ -38,6 +40,21 @@ def buildRelease(args, buildPath): # Create a tmp (working) folder tmpPath = tempfile.mkdtemp(prefix=platformStr, dir=buildPath) + # Unpack the proper launch4j release (for the platform we are + # running on) into the tmp (working) folder + appInstallRoot = miscUtils.getInstallRoot() + appInstallRoot = os.path.dirname(appInstallRoot) + l4jPath = os.path.join(appInstallRoot, 'template', 'launch4j') + if platform.system() == 'Darwin': + exeCmd = ['tar', '-C', tmpPath, '-xf', l4jPath + '/launch4j-3.8-macosx-x86-10.8.tgz'] + else: + exeCmd = ['tar', '-C', tmpPath, '-xf', l4jPath + '/launch4j-3.8-linux.tgz'] + retCode = subprocess.call(exeCmd) + if retCode != 0: + print('Failed to extract launch4j package...') + shutil.rmtree(tmpPath) + return + # Create the various distributions for (aDistName, aJreTarGzFile) in distList: print('Building {0} distribution: {1}'.format(platformStr.capitalize(), aDistName)) @@ -119,7 +136,8 @@ def buildDistTree(buildPath, rootPath, args, jreTarGzFile): buildLaunch4JConfig(configFile, args, jreTarGzFile, winIconFile) # Build the Windows executable - launch4jExe = os.path.join(appInstallRoot, "launch4j", "launch4j") + tmpPath = os.path.dirname(rootPath) + launch4jExe = os.path.join(tmpPath, "launch4j", "launch4j") cmd = [launch4jExe, configFile] print('\tBuilding windows executable via launch4j') proc = miscUtils.executeAndLog(cmd, "\t\t") @@ -200,14 +218,6 @@ def buildLaunch4JConfig(destFile, args, jreTarGzFile, iconFile): def checkSystemEnvironment(): """Checks to ensure that all system application / environment variables needed to build a Windows distribution are installed and properly configured. Returns False if the system environment is insufficient""" - # Bail if launch4j is not installed - appInstallRoot = miscUtils.getInstallRoot() - appInstallRoot = os.path.dirname(appInstallRoot) - launch4jExe = os.path.join(appInstallRoot, "launch4j", "launch4j") - if os.path.exists(launch4jExe) == False: - print('Launch4j is not installed. Windows releases will not be built.') - return False - return True diff --git a/template/appLauncher.jar b/template/appLauncher.jar index 382e719..65516f5 100644 Binary files a/template/appLauncher.jar and b/template/appLauncher.jar differ diff --git a/template/apple/JavaAppLauncher b/template/apple/JavaAppLauncher index 0b73f8a..0c94089 100755 Binary files a/template/apple/JavaAppLauncher and b/template/apple/JavaAppLauncher differ diff --git a/template/launch4j/launch4j b/template/launch4j/launch4j deleted file mode 100755 index f9520e6..0000000 --- a/template/launch4j/launch4j +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -cd `dirname $0` -if [ -n "$JAVA_HOME" ]; then - $JAVA_HOME/bin/java -jar ./launch4j.jar "$*" -else - java -jar ./launch4j.jar "$*" -fi -cd $OLDPWD diff --git a/template/launch4j/launch4j-3.1.0-beta1-linux.tgz b/template/launch4j/launch4j-3.1.0-beta1-linux.tgz deleted file mode 100644 index 2f33ba0..0000000 Binary files a/template/launch4j/launch4j-3.1.0-beta1-linux.tgz and /dev/null differ diff --git a/template/launch4j/launch4j-3.8-linux.tgz b/template/launch4j/launch4j-3.8-linux.tgz new file mode 100644 index 0000000..1a6a294 Binary files /dev/null and b/template/launch4j/launch4j-3.8-linux.tgz differ diff --git a/template/launch4j/launch4j-3.8-macosx-x86-10.8.tgz b/template/launch4j/launch4j-3.8-macosx-x86-10.8.tgz new file mode 100644 index 0000000..c2a9619 Binary files /dev/null and b/template/launch4j/launch4j-3.8-macosx-x86-10.8.tgz differ diff --git a/template/launch4j/readme.txt b/template/launch4j/readme.txt deleted file mode 100644 index 139531f..0000000 --- a/template/launch4j/readme.txt +++ /dev/null @@ -1 +0,0 @@ -The file launch4j, is an update to the script found when the package launch3j-3.1.0-beta1-linux.tgz is unpacked. It is a slight modification to the original script, to allow the script to be run from any location rather than the folder where the script is located. \ No newline at end of file diff --git a/tools/buildRelease b/tools/buildRelease index a78542e..dccd3a5 100755 --- a/tools/buildRelease +++ b/tools/buildRelease @@ -11,7 +11,7 @@ import time # Globals # The default version of DistMaker -version = '0.41' +version = '0.43' def logAndPrint(message="", indent=0, showTime=False): @@ -20,7 +20,7 @@ def logAndPrint(message="", indent=0, showTime=False): message = ' ' + message if showTime == True: message = '[' + getCurrTimeStr() + '] ' + message; -# logging.info(message) +# logging.info(message) print(message) @@ -78,7 +78,7 @@ def buildRelease(version, doNotClean=False): # Copy the (tar.gz) JREs globPath = os.path.join(installPath, 'jre/jre-*.tar.gz') dstPath = os.path.join(workPath, 'jre') - os.mkdir(dstPath) + os.mkdir(dstPath) for aFile in glob.glob(globPath): shutil.copy2(aFile, dstPath) @@ -86,19 +86,11 @@ def buildRelease(version, doNotClean=False): dstPath = os.path.join(workPath, 'template') os.makedirs(dstPath + '/apple') os.makedirs(dstPath + '/background') - for aFile in ['appLauncher.jar', '.DS_Store.template', 'apple/JavaAppLauncher', 'apple/JavaApplicationStub', 'background/background.png']: + os.makedirs(dstPath + '/launch4j') + for aFile in ['appLauncher.jar', '.DS_Store.template', 'apple/JavaAppLauncher', 'apple/JavaApplicationStub', 'background/background.png', 'launch4j/launch4j-3.8-linux.tgz', 'launch4j/launch4j-3.8-macosx-x86-10.8.tgz']: srcPath = os.path.join(installPath, 'template', aFile) shutil.copy2(srcPath, dstPath + '/' + aFile) - # Setup the launch4j tree - l4jPath = os.path.join(installPath, 'template', 'launch4j') - exeCmd = ['tar', '-C', workPath, '-xf', l4jPath + '/launch4j-3.1.0-beta1-linux.tgz'] - retCode = subprocess.call(exeCmd) - if retCode != 0: - print('Failed to extract launch4j package...') - exit(-1) - shutil.copy2(l4jPath + '/launch4j', workPath + '/launch4j/') - # Form the archive exeCmd = ['tar', '-czf', destFileGZ, '-C', os.path.dirname(workPath), os.path.basename(workPath)] retCode = subprocess.call(exeCmd) @@ -117,7 +109,7 @@ def getInstallRoot(): """Returns the root path where the running script is installed.""" argv = sys.argv; installRoot = os.path.dirname(argv[0]) -# print('appInstallRoot: ' + appInstallRoot) +# print('appInstallRoot: ' + appInstallRoot) return installRoot @@ -173,7 +165,7 @@ if __name__ == "__main__": # Logic to capture Ctrl-C and bail signal.signal(signal.SIGINT, handleSignal) - #TODO: Finish this functionality + # TODO: Finish this functionality if doFullBuild == True: print("Unsupported action: [-full]. Skipping...")