diff --git a/.classpath b/.classpath index 677371b..18c3c02 100644 --- a/.classpath +++ b/.classpath @@ -2,16 +2,7 @@ - - - - - - - - - - + @@ -23,5 +14,6 @@ + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 7a4c51e..cb952ac 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,15 +1,18 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..4b0782c --- /dev/null +++ b/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,63 @@ +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=_NobesFormat-2019Aug +formatter_settings_version=16 +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_functional_interfaces=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=false +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.insert_inferred_type_arguments=false +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_modifiers=false +sp_cleanup.remove_redundant_semicolons=false +sp_cleanup.remove_redundant_type_arguments=false +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_lambda=true +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/lib/glum-1.3.7-src.jar b/lib/glum-1.3.7-src.jar deleted file mode 100644 index 5344327..0000000 Binary files a/lib/glum-1.3.7-src.jar and /dev/null differ diff --git a/lib/glum-1.3.7.jar b/lib/glum-1.3.7.jar deleted file mode 100644 index 129a0c7..0000000 Binary files a/lib/glum-1.3.7.jar and /dev/null differ diff --git a/lib/glum-2.0.0-RC3-src.jar b/lib/glum-2.0.0-RC3-src.jar new file mode 100644 index 0000000..cba49ba Binary files /dev/null and b/lib/glum-2.0.0-RC3-src.jar differ diff --git a/lib/glum-2.0.0-RC3.jar b/lib/glum-2.0.0-RC3.jar new file mode 100644 index 0000000..5fb92dd Binary files /dev/null and b/lib/glum-2.0.0-RC3.jar differ diff --git a/script/appleUtils.py b/script/appleUtils.py index 8f82f1c..4ae38b0 100644 --- a/script/appleUtils.py +++ b/script/appleUtils.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 import copy import math @@ -224,9 +224,8 @@ def buildDistTree(aBuildPath, aRootPath, aArgs, aJreNode): # Write out the PkgInfo file dstPath = os.path.join(aRootPath, appName + '.app', 'Contents', "PkgInfo") - f = open(dstPath, 'wb') - f.write('APPL????') - f.close() + with open(dstPath, mode='wt', encoding='utf-8', newline='\n') as tmpFO: + tmpFO.write('APPL????') # Define the payloadPath for where to store the appLauncher payloadPath = os.path.join(aRootPath, appName + '.app', 'Contents') @@ -284,14 +283,14 @@ def buildDistTree(aBuildPath, aRootPath, aArgs, aJreNode): # Update the .DS_Store file to reflect the new volume name srcPath = os.path.join(aRootPath, '.DS_Store') - classPath = appInstallRoot + '/lib/glum-1.3.7.jar:' + appInstallRoot + '/lib/distMaker.jar:' + appInstallRoot + '/lib/guava-18.0.jar' + classPath = appInstallRoot + '/lib/glum-2.0.0-RC3.jar:' + appInstallRoot + '/lib/distMaker-0.61.jar:' + appInstallRoot + '/lib/guava-18.0.jar' cmd = ['java', '-cp', classPath, 'dsstore.MainApp', srcPath, appName] proc = miscUtils.executeAndLog(cmd, "\t\tdsstore.MainApp: ") if proc.returncode != 0: print('\tError: Failed to update .DS_Store. Return code: ' + str(proc.returncode)) -def buildPListInfo(aDestFile, aArgs, aJreNode): +def buildPListInfo(aDstFile, aArgs, aJreNode): """Method that will construct and populate the Info.plist file. This file defines the attributes associated with the (Apple) app.""" # Retrieve vars of interest @@ -299,84 +298,82 @@ def buildPListInfo(aDestFile, aArgs, aJreNode): if aArgs.icnsFile != None: icnsStr = os.path.basename(aArgs.icnsFile) - f = open(aDestFile, 'wb') -# writeln(f, 0, '') - writeln(f, 0, '') - writeln(f, 0, '') - writeln(f, 1, '') + with open(aDstFile, mode='wt', encoding='utf-8', newline='\n') as tmpFO: +# writeln(tmpFO, 0, '') + writeln(tmpFO, 0, '') + writeln(tmpFO, 0, '') + writeln(tmpFO, 1, '') - tupL = [] - tupL.append(('CFBundleDevelopmentRegion', 'English')) - tupL.append(('CFBundleExecutable', 'JavaAppLauncher')) - tupL.append(('CFBundleGetInfoString', aArgs.company)) - tupL.append(('CFBundleInfoDictionaryVersion', 6.0)) - tupL.append(('CFBundleIconFile', icnsStr)) - tupL.append(('CFBundleIdentifier', aArgs.name.lower())) - tupL.append(('CFBundleDisplayName', aArgs.name)) - tupL.append(('CFBundleName', aArgs.name)) - tupL.append(('CFBundlePackageType', 'APPL')) - tupL.append(('CFBundleSignature', '????')) - tupL.append(('CFBundleVersion', aArgs.version)) - tupL.append(('NSHighResolutionCapable', 'true')) - tupL.append(('NSHumanReadableCopyright', '')) + tupL = [] + tupL.append(('CFBundleDevelopmentRegion', 'English')) + tupL.append(('CFBundleExecutable', 'JavaAppLauncher')) + tupL.append(('CFBundleGetInfoString', aArgs.company)) + tupL.append(('CFBundleInfoDictionaryVersion', 6.0)) + tupL.append(('CFBundleIconFile', icnsStr)) + tupL.append(('CFBundleIdentifier', aArgs.name.lower())) + tupL.append(('CFBundleDisplayName', aArgs.name)) + tupL.append(('CFBundleName', aArgs.name)) + tupL.append(('CFBundlePackageType', 'APPL')) + tupL.append(('CFBundleSignature', '????')) + tupL.append(('CFBundleVersion', aArgs.version)) + tupL.append(('NSHighResolutionCapable', 'true')) + tupL.append(('NSHumanReadableCopyright', '')) - # Define the JVM that is to be uesd - if aJreNode != None: - jrePath = jreUtils.getBasePathFor(aJreNode) - tupL.append(('JVMRuntime', jrePath)) - else: -# tupL.append(('JVMVersion', '1.7+')) - raise Exception('Support for utilizing the system JRE has not been added yet.') + # Define the JVM that is to be uesd + if aJreNode != None: + jrePath = jreUtils.getBasePathFor(aJreNode) + tupL.append(('JVMRuntime', jrePath)) + else: +# tupL.append(('JVMVersion', '1.7+')) + raise Exception('Support for utilizing the system JRE has not been added yet.') - # Define the main entry point (AppLauncher) and the working directory - tupL.append(('JVMMainClassName', 'appLauncher.AppLauncher')) + # Define the main entry point (AppLauncher) and the working directory + tupL.append(('JVMMainClassName', 'appLauncher.AppLauncher')) - cwdPath = os.path.join('$APP_ROOT', 'Contents', 'app') - tupL.append(('WorkingDirectory', cwdPath)) + cwdPath = os.path.join('$APP_ROOT', 'Contents', 'app') + tupL.append(('WorkingDirectory', cwdPath)) - # Application configuration - for (key, val) in tupL: - writeln(f, 2, '' + key + '') - writeln(f, 2, '' + str(val) + '') + # Application configuration + for (key, val) in tupL: + writeln(tmpFO, 2, '' + key + '') + writeln(tmpFO, 2, '' + str(val) + '') - # JVM options - jvmArgs = list(aArgs.jvmArgs) - if any(aStr.startswith('-Dapple.laf.useScreenMenuBar') == False for aStr in jvmArgs) == True: - jvmArgs.append('-Dapple.laf.useScreenMenuBar=true') - if any(aStr.startswith('-Dcom.apple.macos.useScreenMenuBar') == False for aStr in jvmArgs) == True: - jvmArgs.append('-Dcom.apple.macos.useScreenMenuBar=true') - if any(aStr.startswith('-Dcom.apple.macos.use-file-dialog-packages') == False for aStr in jvmArgs) == True: - jvmArgs.append('-Dcom.apple.macos.use-file-dialog-packages=true') - jvmArgs.append('-Dcom.apple.mrj.application.apple.menu.about.name=' + aArgs.name) - jvmArgs.append('-Dapple.awt.application.name=' + aArgs.name) - jvmArgs.append('-Djava.system.class.loader=appLauncher.RootClassLoader') -# if icnsStr != None: -# jvmArgs.append('-Xdock:icon=Contents/Resources/' + icnsStr) + # JVM options + jvmArgs = list(aArgs.jvmArgs) + if any(aStr.startswith('-Dapple.laf.useScreenMenuBar') == False for aStr in jvmArgs) == True: + jvmArgs.append('-Dapple.laf.useScreenMenuBar=true') + if any(aStr.startswith('-Dcom.apple.macos.useScreenMenuBar') == False for aStr in jvmArgs) == True: + jvmArgs.append('-Dcom.apple.macos.useScreenMenuBar=true') + if any(aStr.startswith('-Dcom.apple.macos.use-file-dialog-packages') == False for aStr in jvmArgs) == True: + jvmArgs.append('-Dcom.apple.macos.use-file-dialog-packages=true') + jvmArgs.append('-Dcom.apple.mrj.application.apple.menu.about.name=' + aArgs.name) + jvmArgs.append('-Dapple.awt.application.name=' + aArgs.name) + jvmArgs.append('-Djava.system.class.loader=appLauncher.RootClassLoader') +# if icnsStr != None: +# jvmArgs.append('-Xdock:icon=Contents/Resources/' + icnsStr) - writeln(f, 2, 'JVMOptions') - writeln(f, 2, '') - for aStr in jvmArgs: - writeln(f, 3, '' + aStr + '') - writeln(f, 2, '') + writeln(tmpFO, 2, 'JVMOptions') + writeln(tmpFO, 2, '') + for aStr in jvmArgs: + writeln(tmpFO, 3, '' + aStr + '') + writeln(tmpFO, 2, '') -# # ClassPath: AppLauncher -# writeln(f, 2, 'Java') -# writeln(f, 2, '') +# # ClassPath: AppLauncher +# writeln(tmpFO, 2, 'Java') +# writeln(tmpFO, 2, '') # -# classPathStr = '$JAVAROOT/' + deployJreDist.getAppLauncherFileName() +# classPathStr = '$JAVAROOT/' + deployJreDist.getAppLauncherFileName() # -# tupL = [] -# tupL.append(('ClassPath', classPathStr)) +# tupL = [] +# tupL.append(('ClassPath', classPathStr)) # -# for (key, val) in tupL: -# writeln(f, 3, '' + key + '') -# writeln(f, 3, '' + str(val) + '') +# for (key, val) in tupL: +# writeln(tmpFO, 3, '' + key + '') +# writeln(tmpFO, 3, '' + str(val) + '') # -# writeln(f, 2, '') - writeln(f, 1, '') - writeln(f, 0, '') - - f.close() +# writeln(tmpFO, 2, '') + writeln(tmpFO, 1, '') + writeln(tmpFO, 0, '') def checkSystemEnvironment(): @@ -386,9 +383,9 @@ def checkSystemEnvironment(): return True -def writeln(f, tabL, aStr, tabStr=' '): +def writeln(aFO, tabL, aStr, tabStr=' '): tStr = '' for i in range(tabL): tStr += tabStr - f.write(tStr + aStr + '\n') + aFO.write(tStr + aStr + '\n') diff --git a/script/buildDist.py b/script/buildDist.py index 64c5a8d..9a2ce2c 100755 --- a/script/buildDist.py +++ b/script/buildDist.py @@ -1,6 +1,5 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 -from __future__ import print_function import argparse import os import platform @@ -11,7 +10,6 @@ import subprocess import sys import tempfile -import distutils.spawn import jreUtils import miscUtils import appleUtils @@ -73,12 +71,11 @@ def buildCatalogFile(aArgs, aDeltaPath): # Save the records to the catalog file dstPath = os.path.join(aDeltaPath, "catalog.txt") - f = open(dstPath, 'wb') - for aRecord in records: - f.write(','.join(aRecord) + '\n') + with open(dstPath, mode='wt', encoding='utf-8', newline='\n') as tmpFO: + for aRecord in records: + tmpFO.write(','.join(aRecord) + '\n') - f.write('exit\n') - f.close() + tmpFO.write('exit\n') def checkForRequiredApplicationsAndExit(): @@ -87,26 +84,29 @@ def checkForRequiredApplicationsAndExit(): The current set of required applications are: java, jar, (genisoimage or hdiutil)""" # Check for java (version 1.8 or later) - evalPath = distutils.spawn.find_executable('java') + evalPath = shutil.which('java') errL = [] if evalPath == None: errL.append('Failed while trying to locate java. Please install Java') else: - tmpStr = subprocess.check_output(['java', '-version'], stderr=subprocess.STDOUT) - pattern = '\"(\d+\.\d+).*\"' - verStr = re.search(pattern, tmpStr).groups()[0] - verVal = float(verStr) - if verVal < 1.8: + verStrRaw = subprocess.check_output(['java', '-version'], stderr=subprocess.STDOUT) + verStrRaw = verStrRaw.decode("utf-8") + pattern = '\"(\d+)(\.\d+)*.*\"' + verStrFull = re.search(pattern, verStrRaw).group().strip('"') + pattern = '(\d+)(\.\d+){0,1}' + verStrPart = re.search(pattern, verStrFull).group() + javaVer = float(verStrPart) + if javaVer < 1.8: errL.append('Installed version of Java is too old. Require Java 1.8. Installed version: {}'.format(verVal)) # Check for jar - evalPath = distutils.spawn.find_executable('jar') + evalPath = shutil.which('jar') if evalPath == None: errL.append('Failed while trying to locate jar. Please install jar (typically included with Java)') # Check for genisoimage or hdiutil - genisoimagePath = distutils.spawn.find_executable('genisoimage') - hdiutilPath = distutils.spawn.find_executable('hdiutil') + genisoimagePath = shutil.which('genisoimage') + hdiutilPath = shutil.which('hdiutil') if genisoimagePath == None and hdiutilPath == None: if platform.system() == 'Darwin': errL.append('Failed while trying to locate executable hdiutil. Please install hdiutil') @@ -137,7 +137,7 @@ def checkForSuggestedApplications(): The current set of suggested applications are: ImageMagick:convert""" retL = [] - evalPath = distutils.spawn.find_executable('convert') + evalPath = shutil.which('convert') if evalPath == None: retL.append('Application \'convert\' was not found. Please install (ImageMagick) convert') retL.append('\tWindows icons will not be supported when using argument: -iconFile.') @@ -293,6 +293,22 @@ if __name__ == "__main__": if args.javaCode != None and len(args.classPath) == 0: args.classPath = getClassPath(args.javaCode) + # Ensure all specified classPath files exist + errMsgL = [] + for aPath in args.classPath: + fullPath = os.path.join(args.javaCode, aPath) + if os.path.exists(fullPath) == False: + errMsgL += ['Specified file does not exist: ' + aPath] + elif os.path.isfile(fullPath) == False: + errMsgL += ['Specified path is not a regular file: ' + aPath] + + if len(errMsgL) > 0: + print('There are issues with the --classPath argument.') + print('Utilized --javaCode argument: ' + args.javaCode) + for aErrMsg in errMsgL: + print(' ' + aErrMsg) + exit() + # Clean up the jvmArgs to replace the escape sequence '\-' to '-' # and to ensure that all the args start with the '-' character newJvmArgs = [] @@ -377,7 +393,11 @@ if __name__ == "__main__": exit(-1) dstPath = deltaCodePath; try: - shutil.copytree(srcPath, dstPath, symlinks=False, ignore=checkReadable) + os.makedirs(deltaCodePath) + for aPath in args.classPath: + fullSrcPath = os.path.join(args.javaCode, aPath) + dstPath = os.path.join(deltaCodePath, os.path.basename(fullSrcPath)) + shutil.copy(fullSrcPath, dstPath) except (ErrorDM, shutil.Error) as aExp: print(' [ERROR] There were issues while copying the javaCode files. Path: ' + srcPath) print(' {}\n'.format(aExp), file=sys.stderr) diff --git a/script/deployAppDist.py b/script/deployAppDist.py index e2692f7..94673fd 100755 --- a/script/deployAppDist.py +++ b/script/deployAppDist.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 import argparse import getpass @@ -24,18 +24,17 @@ def getDistInfo(aDistPath): exit() exeMode = None - f = open(cfgFile, 'r') - for aLine in f: - aLine = aLine[:-1] - if aLine.startswith('-') == True: - exeMode = aLine; - elif exeMode == '-name' and len(aLine) > 0: - appName = aLine - elif exeMode == '-version' and len(aLine) > 0: - version = aLine - elif exeMode == '-buildDate' and len(aLine) > 0: - buildDate = aLine - f.close() + with open(cfgFile, mode='rt', encoding='utf-8') as tmpFO: + for aLine in tmpFO: + aLine = aLine[:-1] + if aLine.startswith('-') == True: + exeMode = aLine; + elif exeMode == '-name' and len(aLine) > 0: + appName = aLine + elif exeMode == '-version' and len(aLine) > 0: + version = aLine + elif exeMode == '-buildDate' and len(aLine) > 0: + buildDate = aLine if appName == None or version == None or buildDate == None: print('Distribution corresponding to the folder: ' + aDistPath + ' does not appear to be valid!') @@ -51,16 +50,15 @@ def getDistInfo(aDistPath): print('Release will not be deployed...') exit() - f = open(catFile, 'r') - for aLine in f: - aLine = aLine[:-1] - tokenL = aLine.split(',') - # Check to see if legacy JREs are allowed - if len(tokenL) >= 2 and tokenL[0] == 'jre' and isLegacyJre == None: - isLegacyJre = False - if tokenL[1].strip().startswith('1.') == True: - isLegacyJre = True - f.close() + with open(catFile, mode='rt', encoding='utf-8') as tmpFO: + for aLine in tmpFO: + aLine = aLine[:-1] + tokenL = aLine.split(',') + # Check to see if legacy JREs are allowed + if len(tokenL) >= 2 and tokenL[0] == 'jre' and isLegacyJre == None: + isLegacyJre = False + if tokenL[1].strip().startswith('1.') == True: + isLegacyJre = True if isLegacyJre == None: print('Distribution corresponding to the folder: ' + aDistPath + ' does not appear to be valid!') @@ -84,66 +82,61 @@ def addReleaseInfo(aDeployPath, aAppName, aVerStr, aBuildDate, aIsLegacyJre): verFile = os.path.join(aDeployPath, 'releaseInfo.txt') if os.path.isfile(verFile) == True: # Read the legacy releases - f = open(verFile, 'r') - for aLine in f: - aLine = aLine[:-1] - # Ignore empty lines and comments - if len(aLine) == 0: - continue - if aLine.startswith('#') == True: - continue + with open(verFile, mode='rt', encoding='utf-8') as tmpFO: + for aLine in tmpFO: + aLine = aLine[:-1] + # Ignore empty lines and comments + if len(aLine) == 0: + continue + if aLine.startswith('#') == True: + continue - tokenL = aLine.split(',') - if len(tokenL) >= 2 and tokenL[0] == 'name': - isLegacyRelease = True - continue + tokenL = aLine.split(',') + if len(tokenL) >= 2 and tokenL[0] == 'name': + isLegacyRelease = True + continue - # Ignore legacy exit instructions - if len(tokenL) >= 1 and tokenL[0] == 'exit': - continue + # Ignore legacy exit instructions + if len(tokenL) >= 1 and tokenL[0] == 'exit': + continue - # Record all legacy releases - if len(tokenL) == 2: - legacyReleaseL += [(tokenL[0], tokenL[1])] - continue - f.close() + # Record all legacy releases + if len(tokenL) == 2: + legacyReleaseL += [(tokenL[0], tokenL[1])] + continue # Create the appCatalog.txt file catFile = os.path.join(aDeployPath, 'appCatalog.txt') if os.path.isfile(catFile) == False: if isLegacyRelease == True and len(legacyReleaseL) > 0: - f = open(catFile, 'w') - f.write('name' + ',' + aAppName + '\n\n') - # Copy the legacy releases - for (aLegacyVer, aLegacyDate) in legacyReleaseL: - f.write('R,{},{}\n'.format(aLegacyVer, aLegacyDate)) - f.write('info,msg,This is a legacy release.\n') - f.write('info,msg,\n') - if aIsLegacyJre == True: - f.write('info,msg,Downgrading to this version may require a mandatory upgrade (ver: ' + aVerStr + ') before further upgrades are allowed.\n\n') - else: - f.write('# A release should be made using a legacy JRE (1.8+) and this DistMaker release. The release notes will need to be manually.\n') - f.write('info,msg,Downgrading to this version will require a mandatory 2-step upgrade in order to use releases made with non legacy JREs.\n\n') - f.close() - os.chmod(catFile, 0o644) + with open(catFile, mode='wt', encoding='utf-8', newline='\n') as tmpFO: + tmpFO.write('name' + ',' + aAppName + '\n\n') + # Copy the legacy releases + for (aLegacyVer, aLegacyDate) in legacyReleaseL: + tmpFO.write('R,{},{}\n'.format(aLegacyVer, aLegacyDate)) + tmpFO.write('info,msg,This is a legacy release.\n') + tmpFO.write('info,msg,\n') + if aIsLegacyJre == True: + tmpFO.write('info,msg,Downgrading to this version may require a mandatory upgrade (ver: ' + aVerStr + ') before further upgrades are allowed.\n\n') + else: + tmpFO.write('# A release should be made using a legacy JRE (1.8+) and this DistMaker release. The release notes will need to be manually.\n') + tmpFO.write('info,msg,Downgrading to this version will require a mandatory 2-step upgrade in order to use releases made with non legacy JREs.\n\n') else: # Form the default (empty) appCatalog.txt - f = open(catFile, 'w') - f.write('name' + ',' + aAppName + '\n\n') - f.close() - os.chmod(catFile, 0o644) + with open(catFile, mode='wt', encoding='utf-8', newline='\n') as tmpFO: + tmpFO.write('name' + ',' + aAppName + '\n\n') + + os.chmod(catFile, 0o644) # Updated the appCatalog.txt info file - f = open(catFile, 'a') - f.write('R,{},{}\n'.format(aVerStr, aBuildDate)) - f.write('info,msg,There are no release notes available.\n\n') - f.close() + with open(catFile, mode='at', encoding='utf-8', newline='\n') as tmpFO: + tmpFO.write('R,{},{}\n'.format(aVerStr, aBuildDate)) + tmpFO.write('info,msg,There are no release notes available.\n\n') # Update the (legacy) releaseInfo.txt file if isLegacyRelease == True and aIsLegacyJre == True: - f = open(verFile, 'a') - f.write(aVerStr + ',' + aBuildDate + '\n') - f.close() + with open(verFile, mode='at', encoding='utf-8', newline='\n') as tmpFO: + tmpFO.write(aVerStr + ',' + aBuildDate + '\n') def delReleaseInfoLegacy(aDeployPath, aAppName, aVerStr, aBuildDate): @@ -155,22 +148,20 @@ def delReleaseInfoLegacy(aDeployPath, aAppName, aVerStr, aBuildDate): # Read the file releaseInfo = [] - f = open(verFile, 'r') - for line in f: - tokens = line[:-1].split(',', 1); - if len(tokens) == 2 and tokens[0] == aVerStr: - # By not adding the current record to the releaseInfo list, we are effectively removing the record - print('Removing release record from info file. Version: ' + aVerStr) - elif len(tokens) == 2 and tokens[0] != 'name': - releaseInfo.append((tokens[0], tokens[1])) - f.close() + with open(verFile, mode='rt', encoding='utf-8') as tmpFO: + for line in tmpFO: + tokens = line[:-1].split(',', 1); + if len(tokens) == 2 and tokens[0] == aVerStr: + # By not adding the current record to the releaseInfo list, we are effectively removing the record + print('Removing release record from info file. Version: ' + aVerStr) + elif len(tokens) == 2 and tokens[0] != 'name': + releaseInfo.append((tokens[0], tokens[1])) # Write the updated file - f = open(verFile, 'w') - f.write('name' + ',' + aAppName + '\n') - for verTup in releaseInfo: - f.write(verTup[0] + ',' + verTup[1] + '\n') - f.close() + with open(verFile, mode='wt', encoding='utf-8', newline='\n') as tmpFO: + tmpFO.write('name' + ',' + aAppName + '\n') + for verTup in releaseInfo: + tmpFO.write(verTup[0] + ',' + verTup[1] + '\n') def delReleaseInfo(aDeployPath, aAppName, aVerStr, aBuildDate): @@ -188,33 +179,31 @@ def delReleaseInfo(aDeployPath, aAppName, aVerStr, aBuildDate): # Read the file (and skip over all lines found after the release we are searching for) isDeleteMode = False passLineL = [] - f = open(catFile, 'r') - for aLine in f: - aLine = aLine[:-1] - tokenL = aLine.split(','); - # Determine when to enter / exit isDeleteMode - if len(tokenL) == 3 and tokenL[0] == 'R' and tokenL[1] == aVerStr: - # By not adding the current record to the releaseInfo list, we are effectively removing the record - isDeleteMode = True - # We exit deleteMode when see a different release or exit instruction - elif len(tokenL) == 3 and tokenL[0] == 'R' and tokenL[1] != aVerStr: - isDeleteMode = False - elif len(tokenL) >= 1 and tokenL[0] == 'exit': - isDeleteMode = False + with open(catFile, mode='rt', encoding='utf-8') as tmpFO: + for aLine in tmpFO: + aLine = aLine[:-1] + tokenL = aLine.split(','); + # Determine when to enter / exit isDeleteMode + if len(tokenL) == 3 and tokenL[0] == 'R' and tokenL[1] == aVerStr: + # By not adding the current record to the releaseInfo list, we are effectively removing the record + isDeleteMode = True + # We exit deleteMode when see a different release or exit instruction + elif len(tokenL) == 3 and tokenL[0] == 'R' and tokenL[1] != aVerStr: + isDeleteMode = False + elif len(tokenL) >= 1 and tokenL[0] == 'exit': + isDeleteMode = False - # Skip to next if we are in deleteMode - if isDeleteMode == True: - continue + # Skip to next if we are in deleteMode + if isDeleteMode == True: + continue - # Save off all lines when we are not in delete mode - passLineL += [aLine] - f.close() + # Save off all lines when we are not in delete mode + passLineL += [aLine] # Write the updated file - f = open(catFile, 'w') - for aLine in passLineL: - f.write(aLine + '\n') - f.close() + with open(catFile, mode='wt', encoding='utf-8', newline='\n') as tmpFO: + for aLine in passLineL: + tmpFO.write(aLine + '\n') def addRelease(aRootPath, aAppName, aVerStr, aBuildDate, aIsLegacyJre): @@ -223,8 +212,8 @@ def addRelease(aRootPath, aAppName, aVerStr, aBuildDate, aIsLegacyJre): if os.path.isdir(deployPath) == False: print('Application ' + aAppName + ' has never been deployed to the root location: ' + aRootPath) print('Create a new release of the application at the specified location?') - input = raw_input('--> ').upper() - if input != 'Y' and input != 'YES': + tmpAns = input('--> ').upper() + if tmpAns != 'Y' and tmpAns != 'YES': print('Release will not be made for app ' + aAppName) exit() diff --git a/script/deployJreDist.py b/script/deployJreDist.py index a63d49c..ed359ba 100755 --- a/script/deployJreDist.py +++ b/script/deployJreDist.py @@ -1,6 +1,5 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 -from __future__ import print_function import argparse import collections import getpass @@ -83,20 +82,18 @@ def addAppLauncherRelease(aRootPath): # Create the appCatalog file catFile = os.path.join(deployPath, 'appCatalog.txt') if os.path.isfile(catFile) == False: - f = open(catFile, 'w') - f.write('name' + ',' + 'AppLauncher' + '\n') - f.write('digest' + ',' + 'sha256' + '\n\n') - f.close() + with open(catFile, mode='wt', encoding='utf-8', newline='\n') as tmpFO: + tmpFO.write('name' + ',' + 'AppLauncher' + '\n') + tmpFO.write('digest' + ',' + 'sha256' + '\n\n') os.chmod(catFile, 0o644) # Updated the appCatalog file - f = open(catFile, 'a') - digestStr = miscUtils.computeDigestForFile(srcFile, 'sha256') - stat = os.stat(srcFile) - fileLen = stat.st_size - f.write("F,{},{},{},{}\n".format(digestStr, fileLen, dstFileName, version)) -# f.write('\n') - f.close() + with open(catFile, mode='at', encoding='utf-8', newline='\n') as tmpFO: + digestStr = miscUtils.computeDigestForFile(srcFile, 'sha256') + stat = os.stat(srcFile) + fileLen = stat.st_size + tmpFO.write("F,{},{},{},{}\n".format(digestStr, fileLen, dstFileName, version)) +# tmpFO.write('\n') # Copy the src appLauncher.jar file to it's deployed location shutil.copy2(srcFile, dstFile) @@ -112,8 +109,8 @@ def addRelease(aRootPath, aJreNodeL, aVerStr): if os.path.isdir(installPath) == False: regPrintln('A JRE has never been deployed to the root location: ' + aRootPath) regPrintln('Create a new release of the JRE at the specified location?') - input = raw_input('--> ').upper() - if input != 'Y' and input != 'YES': + tmpAns = input('--> ').upper() + if tmpAns != 'Y' and tmpAns != 'YES': regPrintln('Release will not be made for JRE version: ' + aVerStr) exit() @@ -141,27 +138,25 @@ def addReleaseInfo(aInstallPath, aJreNodeL, aVerStr): # Create the jreCatalogfile catFile = os.path.join(aInstallPath, 'jreCatalog.txt') if os.path.isfile(catFile) == False: - f = open(catFile, 'w') - f.write('name' + ',' + 'JRE' + '\n') - f.write('digest' + ',' + 'sha256' + '\n\n') - # Note new JRE catalogs require DistMaker versions 0.55 or later - f.write('exit,DistMaker,0.55' + '\n\n') - f.close() + with open(catFile, mode='wt', encoding='utf-8', newline='\n') as tmpFO: + tmpFO.write('name' + ',' + 'JRE' + '\n') + tmpFO.write('digest' + ',' + 'sha256' + '\n\n') + # Note new JRE catalogs require DistMaker versions 0.55 or later + tmpFO.write('exit,DistMaker,0.55' + '\n\n') os.chmod(catFile, 0o644) exitVerDM = [0, 55] # Determine the last exit,DistMaker instruction specified else: - f = open(catFile, 'r') - for line in f: - tokens = line[:-1].split(','); - # Record the (exit) version of interest - if len(tokens) == 3 and tokens[0] == 'exit' and tokens[1] == 'DistMaker': - try: - exitVerDM = jreUtils.verStrToVerArr(tokens[2]) - except: - exitVerDM = None - f.close() + with open(catFile, mode='rt', encoding='utf-8') as tmpFO: + for line in tmpFO: + tokens = line[:-1].split(','); + # Record the (exit) version of interest + if len(tokens) == 3 and tokens[0] == 'exit' and tokens[1] == 'DistMaker': + try: + exitVerDM = jreUtils.verStrToVerArr(tokens[2]) + except: + exitVerDM = None # Locate the list of JREs with a matching version matchJreNodeL = jreUtils.getJreNodesForVerStr(aJreNodeL, aVerStr) @@ -176,29 +171,28 @@ def addReleaseInfo(aInstallPath, aJreNodeL, aVerStr): needExitInstr = True # Updated the jreCatalogfile - f = open(catFile, 'a') - # Write the exit info to stop legacy DistMakers from processing further - if needExitInstr == True: - f.write('exit,DistMaker,0.48\n\n') - # Write out the JRE release info - f.write("jre,{}\n".format(aVerStr)) - if needExitInstr == True: - f.write("require,AppLauncher,0.1,0.2\n") - for aJreNode in matchJreNodeL: - tmpFile = aJreNode.getFile() - stat = os.stat(tmpFile) - digestStr = miscUtils.computeDigestForFile(tmpFile, 'sha256') - fileLen = stat.st_size - archStr = aJreNode.getArchitecture(); - platStr = aJreNode.getPlatform() - if exitVerDM != None and exitVerDM > [0, 54]: - f.write("F,{},{},{},{},{}\n".format(archStr, platStr, os.path.basename(tmpFile), digestStr, fileLen)) - elif exitVerDM != None: - f.write("F,{},{},{},{}\n".format(digestStr, fileLen, platStr, os.path.basename(tmpFile))) - else: - f.write("F,{},{},{}\n".format(digestStr, fileLen, os.path.basename(tmpFile))) - f.write('\n') - f.close() + with open(catFile, mode='at', encoding='utf-8', newline='\n') as tmpFO: + # Write the exit info to stop legacy DistMakers from processing further + if needExitInstr == True: + tmpFO.write('exit,DistMaker,0.48\n\n') + # Write out the JRE release info + tmpFO.write("jre,{}\n".format(aVerStr)) + if needExitInstr == True: + tmpFO.write("require,AppLauncher,0.1,0.2\n") + for aJreNode in matchJreNodeL: + tmpFile = aJreNode.getFile() + stat = os.stat(tmpFile) + digestStr = miscUtils.computeDigestForFile(tmpFile, 'sha256') + fileLen = stat.st_size + archStr = aJreNode.getArchitecture(); + platStr = aJreNode.getPlatform() + if exitVerDM != None and exitVerDM > [0, 54]: + tmpFO.write("F,{},{},{},{},{}\n".format(archStr, platStr, os.path.basename(tmpFile), digestStr, fileLen)) + elif exitVerDM != None: + tmpFO.write("F,{},{},{},{}\n".format(digestStr, fileLen, platStr, os.path.basename(tmpFile))) + else: + tmpFO.write("F,{},{},{}\n".format(digestStr, fileLen, os.path.basename(tmpFile))) + tmpFO.write('\n') destPath = os.path.join(aInstallPath, aVerStr) os.makedirs(destPath, 0o755) @@ -248,29 +242,27 @@ def delReleaseInfo(aInstallPath, aVerStr): # Read the file inputLineL = [] isDeleteMode = False - f = open(catFile, 'r') - for line in f: - tokens = line[:-1].split(',', 1); - # Switch to deleteMode when we find a matching JRE release - if len(tokens) == 2 and tokens[0] == 'jre' and tokens[1] == aVerStr: - isDeleteMode = True - continue - # Switch out of deleteMode when we find a different JRE release - elif len(tokens) == 2 and tokens[0] == 'jre' and tokens[1] != aVerStr: - isDeleteMode = False - # Skip over the input line if we are in deleteMode - elif isDeleteMode == True: - continue + with open(catFile, mode='rt', encoding='utf-8') as tmpFO: + for line in tmpFO: + tokens = line[:-1].split(',', 1); + # Switch to deleteMode when we find a matching JRE release + if len(tokens) == 2 and tokens[0] == 'jre' and tokens[1] == aVerStr: + isDeleteMode = True + continue + # Switch out of deleteMode when we find a different JRE release + elif len(tokens) == 2 and tokens[0] == 'jre' and tokens[1] != aVerStr: + isDeleteMode = False + # Skip over the input line if we are in deleteMode + elif isDeleteMode == True: + continue - # Save off the input line - inputLineL.append(line) - f.close() + # Save off the input line + inputLineL.append(line) # Write the updated file - f = open(catFile, 'w') - for aLine in inputLineL: - f.write(aLine) - f.close() + with open(catFile, mode='wt', encoding='utf-8', newline='\n') as tmpFO: + for aLine in inputLineL: + tmpFO.write(aLine) def showReleaseInfo(aRootPath, aJreNodeL): diff --git a/script/jreUtils.py b/script/jreUtils.py index a856242..f2e7169 100644 --- a/script/jreUtils.py +++ b/script/jreUtils.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 import glob import os @@ -110,7 +110,7 @@ def getJreNode(aJreNodeL, aArchStr, aPlatStr, aJvmVerSpec): any specific update for a major version of JAVA then just specify the major version. Example '1.8' instead of 1.8.0_73'""" # Transform a single string to a list of size 1 - if isinstance(aJvmVerSpec, basestring): + if isinstance(aJvmVerSpec, str): aJvmVerSpec = [aJvmVerSpec] # Retrieve the min and max JVM versions from aJvmVerSpec @@ -185,8 +185,8 @@ def loadJreCatalog(aFile): # Read the file regPrintln('Loading JRE catalog: {}'.format(aFile)) - with open(aFile, 'r') as workF: - for (lineNum, aLine) in enumerate(workF, 1): + with open(aFile, mode='rt', encoding='utf-8') as tmpFO: + for (lineNum, aLine) in enumerate(tmpFO, 1): # Skip empty lines / comments line = aLine.strip() if len(line) == 0 or line[0] == '#': diff --git a/script/linuxUtils.py b/script/linuxUtils.py index 677a6cd..abaddca 100644 --- a/script/linuxUtils.py +++ b/script/linuxUtils.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 import copy import os @@ -109,7 +109,7 @@ def buildDistTree(aBuildPath, aRootPath, aArgs, aJreNode): jreUtils.unpackAndRenameToStandard(aJreNode, aRootPath) -def buildBashScript(aDestFile, aArgs, aJreNode): +def buildBashScript(aDstFile, aArgs, aJreNode): # Form the jvmArgStr but strip away the -Xmx* component if it is specified # since the JVM maxMem is dynamically configurable (via DistMaker) maxMem = None @@ -120,63 +120,61 @@ def buildBashScript(aDestFile, aArgs, aJreNode): else: jvmArgsStr += aStr + ' ' - f = open(aDestFile, 'wb') -# f.write('#!/bin/bash\n') - f.write('#!/usr/bin/env bash\n') + with open(aDstFile, mode='wt', encoding='utf-8', newline='\n') as tmpFO: +# tmpFO.write('#!/bin/bash\n') + tmpFO.write('#!/usr/bin/env bash\n') - f.write('# Do not remove the opening or closing brackets: {}. This enables safe inline\n') - f.write('# mutations to this script while it is running\n') - f.write('{ # Do not remove this bracket! \n\n') + tmpFO.write('# Do not remove the opening or closing brackets: {}. This enables safe inline\n') + tmpFO.write('# mutations to this script while it is running\n') + tmpFO.write('{ # Do not remove this bracket! \n\n') - f.write('# Define where the Java executable is located\n') - if aJreNode == None: - f.write('javaExe=java\n\n') - else: - jrePath = jreUtils.getBasePathFor(aJreNode) - f.write('javaExe=../' + jrePath + '/bin/java\n\n') + tmpFO.write('# Define where the Java executable is located\n') + if aJreNode == None: + tmpFO.write('javaExe=java\n\n') + else: + jrePath = jreUtils.getBasePathFor(aJreNode) + tmpFO.write('javaExe=../' + jrePath + '/bin/java\n\n') - f.write('# Define the maximum memory to allow the application to utilize\n') - if maxMem == None: - f.write('#maxMem=512m # Uncomment out this line to change from defaults.\n\n') - else: - f.write('maxMem=' + maxMem + '\n\n') + tmpFO.write('# Define the maximum memory to allow the application to utilize\n') + if maxMem == None: + tmpFO.write('#maxMem=512m # Uncomment out this line to change from defaults.\n\n') + else: + tmpFO.write('maxMem=' + maxMem + '\n\n') - f.write('# Get the installation path\n') - f.write('# We support the Linux / Macosx variants explicitly and then default back to Linux\n') - f.write('if [ "$(uname -s)" == "Darwin" ]; then\n') - f.write(' # Macosx platform: We assume the coreutils package has been installed...\n') - f.write(' installPath=$(greadlink -f "$BASH_SOURCE")\n') - f.write('elif [ "$(uname -s)" == "Linux" ]; then\n') - f.write(' # Linux platform\n') - f.write(' installPath=$(readlink -f "$BASH_SOURCE")\n') - f.write('else\n') - f.write(' # Other platform: ---> Defaults back to Linux platform\n') - f.write(' installPath=$(readlink -f "$BASH_SOURCE")\n') - f.write('fi\n') - f.write('installPath=$(dirname "$installPath")\n\n') + tmpFO.write('# Get the installation path\n') + tmpFO.write('# We support the Linux / Macosx variants explicitly and then default back to Linux\n') + tmpFO.write('if [ "$(uname -s)" == "Darwin" ]; then\n') + tmpFO.write(' # Macosx platform: We assume the coreutils package has been installed...\n') + tmpFO.write(' installPath=$(greadlink -f "$BASH_SOURCE")\n') + tmpFO.write('elif [ "$(uname -s)" == "Linux" ]; then\n') + tmpFO.write(' # Linux platform\n') + tmpFO.write(' installPath=$(readlink -f "$BASH_SOURCE")\n') + tmpFO.write('else\n') + tmpFO.write(' # Other platform: ---> Defaults back to Linux platform\n') + tmpFO.write(' installPath=$(readlink -f "$BASH_SOURCE")\n') + tmpFO.write('fi\n') + tmpFO.write('installPath=$(dirname "$installPath")\n\n') - f.write('# Change the working directory to the app folder in the installation path\n') - f.write('cd "$installPath"/app\n\n') + tmpFO.write('# Change the working directory to the app folder in the installation path\n') + tmpFO.write('cd "$installPath"/app\n\n') - f.write('# Setup the xmxStr to define the maximum JVM memory.\n') - f.write('if [ -z ${maxMem+x} ]; then\n') - f.write(' xmxStr=""\n') - f.write('else\n') - f.write(' xmxStr=\'-Xmx\'$maxMem\n') - f.write('fi\n\n') + tmpFO.write('# Setup the xmxStr to define the maximum JVM memory.\n') + tmpFO.write('if [ -z ${maxMem+x} ]; then\n') + tmpFO.write(' xmxStr=""\n') + tmpFO.write('else\n') + tmpFO.write(' xmxStr=\'-Xmx\'$maxMem\n') + tmpFO.write('fi\n\n') - exeCmd = '$javaExe ' + jvmArgsStr + '$xmxStr -Djava.system.class.loader=appLauncher.RootClassLoader ' - exeCmd = exeCmd + '-cp ../launcher/' + deployJreDist.getAppLauncherFileName() + ' appLauncher.AppLauncher $*' - f.write('# Run the application\n') - f.write(exeCmd + '\n\n') + exeCmd = '$javaExe ' + jvmArgsStr + '$xmxStr -Djava.system.class.loader=appLauncher.RootClassLoader ' + exeCmd = exeCmd + '-cp ../launcher/' + deployJreDist.getAppLauncherFileName() + ' appLauncher.AppLauncher $*' + tmpFO.write('# Run the application\n') + tmpFO.write(exeCmd + '\n\n') - f.write('exit # Do not remove this exit! (just before the bracket)\n') - f.write('} # Do not remove this bracket! \n\n') - - f.close() + tmpFO.write('exit # Do not remove this exit! (just before the bracket)\n') + tmpFO.write('} # Do not remove this bracket! \n\n') # Make the script executable - os.chmod(aDestFile, 00755) + os.chmod(aDstFile, 0o755) def checkSystemEnvironment(): diff --git a/script/logUtils.py b/script/logUtils.py index d9e697d..617e13b 100644 --- a/script/logUtils.py +++ b/script/logUtils.py @@ -1,3 +1,5 @@ +#! /usr/bin/env python3 + import hashlib import os import time diff --git a/script/miscUtils.py b/script/miscUtils.py index c72edae..ed2750d 100644 --- a/script/miscUtils.py +++ b/script/miscUtils.py @@ -1,4 +1,5 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 + import argparse import hashlib import os @@ -56,14 +57,14 @@ def computeDigestForFile(evalFile, digestType, block_size=2**20): else: raise ErrorDM('Unrecognized hash function: ' + digestType); - f = open(evalFile, 'rb') - while True: - data = f.read(block_size) - if not data: - break - hash.update(data) - f.close() - return hash.hexdigest() + with open(evalFile, mode='rb') as tmpFO: + while True: + data = tmpFO.read(block_size) + if not data: + break + hash.update(data) + + return hash.hexdigest() def getPlatformTypes(aPlatformArr, aPlatformStr): @@ -103,7 +104,7 @@ def executeAndLog(aCommand, indentStr=""): try: proc = subprocess.Popen(aCommand, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) proc.wait() - outStr = proc.stdout.read() + outStr = proc.stdout.read().decode('utf-8') if outStr != "": outStr = logUtils.appendLogOutputWithText(outStr, indentStr) print(outStr) @@ -164,13 +165,7 @@ def requirePythonVersion(aVer): exit(-1) -def buildAppLauncherConfig(aDestFile, aArgs): - classPathStr = '' - for aStr in aArgs.classPath: - classPathStr += 'java/' + aStr + ':' - if len(classPathStr) > 0: - classPathStr = classPathStr[0:-1] - +def buildAppLauncherConfig(aDstFile, aArgs): jvmArgsStr = '' for aStr in aArgs.jvmArgs: if len(aStr) > 2 and aStr[0:1] == '\\': @@ -181,41 +176,39 @@ def buildAppLauncherConfig(aDestFile, aArgs): for aStr in aArgs.appArgs: appArgsStr += ' ' + aStr - f = open(aDestFile, 'wb') + with open(aDstFile, mode='wt', encoding='utf-8', newline='\n') as tmpFO: + # App name section + tmpFO.write('-name\n') + tmpFO.write(aArgs.name + '\n') + tmpFO.write('\n') - # App name section - f.write('-name\n') - f.write(aArgs.name + '\n') - f.write('\n') + # Version section + tmpFO.write('-version\n') + tmpFO.write(aArgs.version + '\n') + tmpFO.write('\n') - # Version section - f.write('-version\n') - f.write(aArgs.version + '\n') - f.write('\n') + # Build date section + exeDate = time.localtime() + buildDate = time.strftime('%Y%b%d %H:%M:%S', exeDate) + tmpFO.write('-buildDate\n') + tmpFO.write(buildDate + '\n') + tmpFO.write('\n') - # Build date section - exeDate = time.localtime() - buildDate = time.strftime('%Y%b%d %H:%M:%S', exeDate) - f.write('-buildDate\n') - f.write(buildDate + '\n') - f.write('\n') + # MainClass section + tmpFO.write('-mainClass\n') + tmpFO.write(aArgs.mainClass + '\n') + tmpFO.write('\n') - # MainClass section - f.write('-mainClass\n') - f.write(aArgs.mainClass + '\n') - f.write('\n') + # ClassPath section + tmpFO.write('-classPath\n') + for aPath in aArgs.classPath: + fileName = os.path.basename(aPath) + tmpFO.write(fileName + '\n') + tmpFO.write('\n') - # ClassPath section - f.write('-classPath\n') - for aStr in aArgs.classPath: - f.write(aStr + '\n') - f.write('\n') - - # Application args section - f.write('-appArgs\n') - for aStr in aArgs.appArgs: - f.write(aStr + '\n') - f.write('\n') - - f.close() + # Application args section + tmpFO.write('-appArgs\n') + for aStr in aArgs.appArgs: + tmpFO.write(aStr + '\n') + tmpFO.write('\n') diff --git a/script/windowsUtils.py b/script/windowsUtils.py index 2cf9961..21ca113 100644 --- a/script/windowsUtils.py +++ b/script/windowsUtils.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 import copy import glob @@ -55,13 +55,13 @@ def buildRelease(aArgs, aBuildPath, aJreNodeL): appInstallRoot = os.path.dirname(appInstallRoot) l4jPath = os.path.join(appInstallRoot, 'template', 'launch4j') if platform.system() == 'Darwin': - exeCmd = ['tar', '-C', tmpPath, '-xf', l4jPath + '/launch4j-3.12-macosx-x86.tgz'] + exeCmd = ['tar', '-C', tmpPath, '-xf', l4jPath + '/launch4j-3.14-macosx-x86.tgz'] else: is64Bit = sys.maxsize > 2**32 if is64Bit == True: - exeCmd = ['tar', '-C', tmpPath, '-xf', l4jPath + '/launch4j-3.12-linux-x64.tgz'] + exeCmd = ['tar', '-C', tmpPath, '-xf', l4jPath + '/launch4j-3.14-linux-x64.tgz'] else: - exeCmd = ['tar', '-C', tmpPath, '-xf', l4jPath + '/launch4j-3.12-linux.tgz'] + exeCmd = ['tar', '-C', tmpPath, '-xf', l4jPath + '/launch4j-3.14-linux.tgz'] retCode = subprocess.call(exeCmd) if retCode != 0: print('Failed to extract launch4j package...') @@ -166,66 +166,65 @@ def buildDistTree(aBuildPath, aRootPath, aArgs, aJreNode): if winIconFile != None: os.remove(winIconFile) -def buildLaunch4JConfig(aDestFile, aArgs, aJreNode, aIconFile): - f = open(aDestFile, 'wb') +def buildLaunch4JConfig(aDstFile, aArgs, aJreNode, aIconFile): + with open(aDstFile, mode='wt', encoding='utf-8', newline='\n') as tmpFO: - writeln(f, 0, "") - if aArgs.debug == True: - writeln(f, 1, "console"); - else: - writeln(f, 1, "gui"); - writeln(f, 1, "" + aArgs.name + ".exe"); - writeln(f, 1, "true"); - writeln(f, 1, "" + aArgs.name + ""); - writeln(f, 1, "http://java.com/download"); -# writeln(f, 1, "url"); + writeln(tmpFO, 0, "") + if aArgs.debug == True: + writeln(tmpFO, 1, "console"); + else: + writeln(tmpFO, 1, "gui"); + writeln(tmpFO, 1, "" + aArgs.name + ".exe"); + writeln(tmpFO, 1, "true"); + writeln(tmpFO, 1, "" + aArgs.name + ""); + writeln(tmpFO, 1, "http://java.com/download"); + # writeln(tmpFO, 1, "url"); -# writeln(f, 1, "app.cfg"); - writeln(f, 1, "app/"); - writeln(f, 1, "normal"); - writeln(f, 1, "true"); - writeln(f, 1, "false"); - if aIconFile != None: - writeln(f, 1, "" + aIconFile + ""); + # writeln(tmpFO, 1, "app.cfg"); + writeln(tmpFO, 1, "app/"); + writeln(tmpFO, 1, "normal"); + writeln(tmpFO, 1, "true"); + writeln(tmpFO, 1, "false"); + if aIconFile != None: + writeln(tmpFO, 1, "" + aIconFile + ""); - writeln(f, 1, ""); - writeln(f, 2, "appLauncher.AppLauncher"); - writeln(f, 2, "../launcher/" + deployJreDist.getAppLauncherFileName() + ""); - writeln(f, 1, ""); + writeln(tmpFO, 1, ""); + writeln(tmpFO, 2, "appLauncher.AppLauncher"); + writeln(tmpFO, 2, "../launcher/" + deployJreDist.getAppLauncherFileName() + ""); + writeln(tmpFO, 1, ""); - if aArgs.forceSingleInstance != False: - writeln(f, 0, ""); - writeln(f, 1, ""); - writeln(f, 2, "" + aArgs.name + ".mutex"); - writeln(f, 2, "" + aArgs.name + ""); - writeln(f, 1, ""); + if aArgs.forceSingleInstance != False: + writeln(tmpFO, 0, ""); + writeln(tmpFO, 1, ""); + writeln(tmpFO, 2, "" + aArgs.name + ".mutex"); + writeln(tmpFO, 2, "" + aArgs.name + ""); + writeln(tmpFO, 1, ""); - writeln(f, 0, ""); - writeln(f, 1, ""); - if aJreNode != None: - jrePath = jreUtils.getBasePathFor(aJreNode) - writeln(f, 2, "" + jrePath + ""); - else: - jreVer = getJreMajorVersion(aArgs.jreVerSpec) - writeln(f, 2, "" + jreVer + ""); # Valid values: '1.7.0' or '1.8.0' ... - writeln(f, 2, "preferJre"); # Valid values: jreOnlyjdkOnly|preferJre|preferJdk - for aJvmArg in aArgs.jvmArgs: - writeln(f, 2, "" + aJvmArg + ""); - writeln(f, 2, "-Djava.system.class.loader=appLauncher.RootClassLoader"); - writeln(f, 1, ""); + writeln(tmpFO, 0, ""); + writeln(tmpFO, 1, ""); + if aJreNode != None: + jrePath = jreUtils.getBasePathFor(aJreNode) + writeln(tmpFO, 2, "" + jrePath + ""); + else: + jreVer = getJreMajorVersion(aArgs.jreVerSpec) + writeln(tmpFO, 2, "" + jreVer + ""); # Valid values: '1.7.0' or '1.8.0' ... + writeln(tmpFO, 2, "preferJre"); # Valid values: jreOnlyjdkOnly|preferJre|preferJdk + for aJvmArg in aArgs.jvmArgs: + writeln(tmpFO, 2, "" + aJvmArg + ""); + writeln(tmpFO, 2, "-Djava.system.class.loader=appLauncher.RootClassLoader"); + writeln(tmpFO, 1, ""); - writeln(f, 0, ""); - writeln(f, 1, ""); - writeln(f, 2, "" + aArgs.name + " error..."); - writeln(f, 2, "Failed to locate the bundled JRE"); - writeln(f, 2, "Located JRE is not the proper version."); - writeln(f, 2, "Failed to launch " + aArgs.name + ""); - writeln(f, 1, ""); + writeln(tmpFO, 0, ""); + writeln(tmpFO, 1, ""); + writeln(tmpFO, 2, "" + aArgs.name + " error..."); + writeln(tmpFO, 2, "Failed to locate the bundled JRE"); + writeln(tmpFO, 2, "Located JRE is not the proper version."); + writeln(tmpFO, 2, "Failed to launch " + aArgs.name + ""); + writeln(tmpFO, 1, ""); - writeln(f, 0, "") - writeln(f, 0, "") - f.write('\n') - f.close() + writeln(tmpFO, 0, "") + writeln(tmpFO, 0, "") + tmpFO.write('\n') def checkSystemEnvironment(): diff --git a/src/distMaker/DistApp.java b/src/distMaker/DistApp.java index e6aeab5..26d626b 100644 --- a/src/distMaker/DistApp.java +++ b/src/distMaker/DistApp.java @@ -15,7 +15,7 @@ import glum.version.Version; public class DistApp { /** The DistMaker version is defined here. */ - public static final Version version = new PlainVersion(0, 57, 0); + public static final Version version = new PlainVersion(0, 61, 0); /** * Main entry point that will print out the version of DistMaker to stdout. diff --git a/src/distMaker/DistMakerEngine.java b/src/distMaker/DistMakerEngine.java index 19cad78..43c1139 100644 --- a/src/distMaker/DistMakerEngine.java +++ b/src/distMaker/DistMakerEngine.java @@ -12,8 +12,6 @@ import java.util.*; import javax.swing.JFrame; import javax.swing.SwingUtilities; -import com.google.common.base.Joiner; - import distMaker.gui.PickReleasePanel; import distMaker.jre.*; import distMaker.node.*; @@ -142,14 +140,16 @@ public class DistMakerEngine */ public UpdateStatus isUpToDate() { - LoggingTask task = new LoggingTask(); + var task = new BufferTask(); +// LoggingTask task = new LoggingTask(); String appName = currRelease.getName(); List unsortedReleaseL = DistUtils.getAvailableAppReleases(task, updateSiteUrl, appName, refCredential); if (unsortedReleaseL == null) { // The update check failed, so return a status of false with a message about the problem - String msg = Joiner.on("; ").join(task.getMessages()); +// String msg = Joiner.on("; ").join(task.getMessages()); + var msg = task.getBuffer(); return new UpdateStatus(msg); } // Sort the items, and isolate the newest item diff --git a/src/distMaker/LoggingTask.java b/src/distMaker/LoggingTask.java deleted file mode 100644 index 902a07e..0000000 --- a/src/distMaker/LoggingTask.java +++ /dev/null @@ -1,37 +0,0 @@ -package distMaker; - -import glum.task.SilentTask; - -import java.util.ArrayList; -import java.util.List; - -public class LoggingTask extends SilentTask -{ - private final List messageL = new ArrayList<>(); - - @Override - public void logReg(String aMsg) - { - messageL.add(aMsg); - super.logReg(aMsg); - } - - @Override - public void logRegln(String aMsg) - { - messageL.add(aMsg); - super.logRegln(aMsg); - } - - @Override - public void logRegUpdate(String aMsg) - { - messageL.add(aMsg); - super.logRegUpdate(aMsg); - } - - List getMessages() - { - return messageL; - } -} diff --git a/src/distMaker/gui/PickReleasePanel.java b/src/distMaker/gui/PickReleasePanel.java index 8b2f4c4..1ae9e45 100644 --- a/src/distMaker/gui/PickReleasePanel.java +++ b/src/distMaker/gui/PickReleasePanel.java @@ -38,7 +38,7 @@ public class PickReleasePanel extends GlassPanel implements ActionListener, Item // GUI vars private JLabel titleL; private JRadioButton newestRB, olderRB; - private ItemListPanel listPanel; + private ItemListPanel listPanel; private QueryTableCellRenderer col0Renderer, col1Renderer; private JButton abortB, proceedB; private JTextArea headTA, infoTA; @@ -197,7 +197,7 @@ public class PickReleasePanel extends GlassPanel implements ActionListener, Item // Latest version area newestRB = GuiUtil.createJRadioButton(this, "Unspecified", smallFont); - newestRB.setSelected(true); +// newestRB.setSelected(true); // Older version area olderRB = GuiUtil.createJRadioButton(this, "Select an older release:", smallFont); @@ -232,6 +232,9 @@ public class PickReleasePanel extends GlassPanel implements ActionListener, Item proceedB = GuiUtil.createJButton("Proceed", this, smallFont); add(abortB, "align right,span,split 2"); add(proceedB, ""); + + // Set the initial state + newestRB.setSelected(true); } /** @@ -255,10 +258,10 @@ public class PickReleasePanel extends GlassPanel implements ActionListener, Item tmpComposer.setRenderer(LookUp.Version, col0Renderer); tmpComposer.setRenderer(LookUp.BuildTime, col1Renderer); - tmpIH = new QueryItemHandler<>(tmpComposer); + tmpIH = new QueryItemHandler<>(); myItemProcessor = new StaticItemProcessor<>(); - listPanel = new ItemListPanel<>(tmpIH, myItemProcessor, false); + listPanel = new ItemListPanel<>(tmpIH, myItemProcessor, tmpComposer, false); listPanel.setSortingEnabled(false); listPanel.addListSelectionListener(this); return listPanel; diff --git a/src/distMaker/jre/JreVersion.java b/src/distMaker/jre/JreVersion.java index c067fc4..dbb2d53 100644 --- a/src/distMaker/jre/JreVersion.java +++ b/src/distMaker/jre/JreVersion.java @@ -30,8 +30,8 @@ public class JreVersion implements Comparable, Version { label = aLabel; - String[] tokenArr = label.split("[._]"); - ArrayList workL = new ArrayList<>(); + var tokenArr = label.split("[._]"); + var workL = new ArrayList(); for (String aStr : tokenArr) { int tmpVal = ParseUtil.readInt(aStr, Integer.MIN_VALUE); @@ -66,7 +66,6 @@ public class JreVersion implements Comparable, Version public static JreVersion getBetterVersion(JreVersion verA, JreVersion verB) { JreVersion defaultVer; - int valA, valB, idxCnt; // Default JreVersion is the version that is more specific defaultVer = null; @@ -76,14 +75,14 @@ public class JreVersion implements Comparable, Version defaultVer = verA; // Set the idxCnt to the less specific JreVersion - idxCnt = Math.min(verA.compL.size(), verB.compL.size()); + var idxCnt = Math.min(verA.compL.size(), verB.compL.size()); // Compare each integral component (which originated from the label) // Assume higher values correspond to later versions for (int c1 = 0; c1 < idxCnt; c1++) { - valA = verA.compL.get(c1); - valB = verB.compL.get(c1); + var valA = verA.compL.get(c1); + var valB = verB.compL.get(c1); if (valA > valB) return verA; if (valB > valA) @@ -95,7 +94,7 @@ public class JreVersion implements Comparable, Version } @Override - public int getMajorVersion() + public int major() { if (isLegacy == true) return compL.get(1); @@ -107,7 +106,7 @@ public class JreVersion implements Comparable, Version } @Override - public int getMinorVersion() + public int minor() { if (isLegacy == true) { @@ -123,7 +122,7 @@ public class JreVersion implements Comparable, Version } @Override - public int getPatchVersion() + public int patch() { if (isLegacy == true) { @@ -141,10 +140,8 @@ public class JreVersion implements Comparable, Version @Override public int compareTo(JreVersion aItem) { - JreVersion tmpVer; - // Note the natural ordering is from oldest version to most recent version - tmpVer = JreVersion.getBetterVersion(this, aItem); + var tmpVer = JreVersion.getBetterVersion(this, aItem); if (tmpVer == aItem) return -1; if (tmpVer == this) diff --git a/src/distMaker/platform/PlatformUtils.java b/src/distMaker/platform/PlatformUtils.java index 45d65fd..53db47c 100644 --- a/src/distMaker/platform/PlatformUtils.java +++ b/src/distMaker/platform/PlatformUtils.java @@ -34,7 +34,7 @@ public class PlatformUtils */ public static String getAppLauncherFileName(Version aVersion) { - if (aVersion.getMajorVersion() == 0 && aVersion.getMinorVersion() == 0) + if (aVersion.major() == 0 && aVersion.minor() == 0) return "appLauncher.jar"; return "appLauncher-" + aVersion + ".jar"; diff --git a/src/distMaker/utils/ParseUtils.java b/src/distMaker/utils/ParseUtils.java index 2bdeb9d..bbcb79b 100644 --- a/src/distMaker/utils/ParseUtils.java +++ b/src/distMaker/utils/ParseUtils.java @@ -14,7 +14,7 @@ public class ParseUtils *

* Processing of the configuration file should exit if the specified needed version is not met or the version string * could not be parsed into major minor components. - * + * * @param aTargName * The target component whose version will be evaluated. Current supported values are one of the following: * [AppLauncher, DistMaker] @@ -39,25 +39,22 @@ public class ParseUtils int needMinorVer = Integer.MAX_VALUE; try { - String[] versionArr; - - versionArr = aNeededVer.split("\\."); + var versionArr = aNeededVer.split("\\."); if (versionArr.length >= 1) needMajorVer = Integer.parseInt(versionArr[0]); if (versionArr.length >= 2) needMinorVer = Integer.parseInt(versionArr[1]); } - catch(Throwable aExp) + catch (Throwable aExp) { // Ignore just assume version components are whatever we managed to parse } - Version needVer; - needVer = new PlainVersion(needMajorVer, needMinorVer, 0); + var needVer = new PlainVersion(needMajorVer, needMinorVer, 0); // Exit the logic if the needVer > evalVer - if (needVer.getMajorVersion() > evalVer.getMajorVersion()) + if (needVer.major() > evalVer.major()) return true; - if (needVer.getMajorVersion() == needVer.getMajorVersion() && needVer.getMinorVersion() > evalVer.getMinorVersion()) + if (needVer.major() == needVer.major() && needVer.minor() > evalVer.minor()) return true; return false; diff --git a/template/launch4j/launch4j-3.12-linux.tgz b/template/launch4j/launch4j-3.14-linux-x64.tgz similarity index 50% rename from template/launch4j/launch4j-3.12-linux.tgz rename to template/launch4j/launch4j-3.14-linux-x64.tgz index 516f678..8989973 100644 Binary files a/template/launch4j/launch4j-3.12-linux.tgz and b/template/launch4j/launch4j-3.14-linux-x64.tgz differ diff --git a/template/launch4j/launch4j-3.12-linux-x64.tgz b/template/launch4j/launch4j-3.14-linux.tgz similarity index 53% rename from template/launch4j/launch4j-3.12-linux-x64.tgz rename to template/launch4j/launch4j-3.14-linux.tgz index 074dd08..6306b77 100644 Binary files a/template/launch4j/launch4j-3.12-linux-x64.tgz and b/template/launch4j/launch4j-3.14-linux.tgz differ diff --git a/template/launch4j/launch4j-3.12-macosx-x86.tgz b/template/launch4j/launch4j-3.14-macosx-x86.tgz similarity index 51% rename from template/launch4j/launch4j-3.12-macosx-x86.tgz rename to template/launch4j/launch4j-3.14-macosx-x86.tgz index f525c0f..fec5dc5 100644 Binary files a/template/launch4j/launch4j-3.12-macosx-x86.tgz and b/template/launch4j/launch4j-3.14-macosx-x86.tgz differ diff --git a/tools/build.xml b/tools/build.xml new file mode 100644 index 0000000..cd309b8 --- /dev/null +++ b/tools/build.xml @@ -0,0 +1,81 @@ + + + + + + + DistMaker Library + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/buildRelease b/tools/buildRelease index 679d339..7828e03 100755 --- a/tools/buildRelease +++ b/tools/buildRelease @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 import argparse import glob @@ -7,40 +7,147 @@ import shutil import signal import subprocess import sys +import traceback -# Define the libraries the application depends on -libList = ['glum-1.3.7.jar', 'guava-18.0.jar', 'distMaker.jar'] +# Define the (baseline) version +baseVersion = "0.61" + +# Define relevant base names +appBaseName = 'DistMaker' +libBaseName = 'distMaker' + +# Define the libraries DistMaker depends on +libList = ['glum-2.0.0-RC3.jar', 'guava-18.0.jar'] +#libList += ['commons-compress-1.15.jar'] + +# Define the paths to various executables +antPath = '/spare/apache/apache-ant-1.10.8' +antExe = os.path.join(antPath, 'bin/ant') +jdkPath = '/spare/jdk-11' +jarExe = os.path.join(jdkPath, 'bin/jar') +javaExe = os.path.join(jdkPath, 'bin/java') -def buildRelease(aVersion, aDoNotClean=False): - """Method that builds a release of DistMaker. Upon sucessful execution, a - tar.gz archive will be generated named: 'DistMaker-.tar.gz'. Note - that releases of DistMaker aVersion 0.50 or later (2018May01+) will no longer - include static JREs.""" +def checkForInstalledApps(): + """Checks for installed applications needed to build a release of the + DistMaker library / package. + """ + # Ensure required applications are installed + errList = [] + for aPath in [antExe, jarExe, javaExe]: + if os.path.exists(aPath) == False: + errList.append('System executable is missing: ' + aPath) + if len(errList) > 0: + print('There are configuration errors with the environment or system.') +# print('System Path:' + str(sys.path)) + print('Please correct the following:') + for aError in errList: + print('\t' + aError) + sys.exit(0) + + +def buildLibraryJar(aVersion): + """Method that builds the library jars. Upon sucessful execution + jar files (binary + source) will be generated. + """ + # Note it is assumed that this is run from the path /proj/glum/ + + # Compile the java files + # Run the Ant script to build the class files + os.environ["JAVA_HOME"] = jdkPath + exeCmd = [antExe, '-f', 'tools/build.xml', 'compile'] + retCode = subprocess.call(exeCmd) + if retCode != 0: + print('Failed while trying to run ant script. Exiting...\n') + sys.exit(0) + print('Finished executing Ant script.\n') + + # Generate the manifest file + manifestFN = 'release/Manifest.txt' +# buildManifestFile(manifestFN) + + # Build the (bin) jar file + jarBinFN = 'release/' + libBaseName + '-' + aVersion + '.jar' +# exeCmd = [jarExe, 'cfm', jarBinFN, manifestFN, '-C', 'bin/classes', '.'] + exeCmd = [jarExe, 'cfM', jarBinFN, '-C', 'bin/classes', '.'] + retCode = subprocess.call(exeCmd) + if retCode != 0: + print('Failed to build jar file: ' + jarBinFN) + exit(-1) + + # Build the (src) jar file + jarSrcFN = 'release/' + libBaseName + '-' + aVersion + '-src.jar' + exeCmd = ['zip', '-D9q', '../' + jarSrcFN, '-r', '.'] + retCode = subprocess.call(exeCmd, cwd='./src') + if retCode != 0: + print('Failed to build jar file: ' + jarSrcFN) + exit(-1) + + # Remove the manifest file +# os.remove(manifestFN) + +def buildRelease(aExtraTag, aDoNotClean=False): + """Method that builds a release of DistMaker. Upon sucessful execution + the following will be created: + - distMaker-.jar + - distMaker--src.jar + - DistMaker-.tar.gz + """ + # Define the version to build + version = baseVersion + if aExtraTag != None: + if aExtraTag.startswith('.') or aExtraTag.startswith('-'): + version = baseVersion + aExtraTag + else: + version = baseVersion + '-' + aExtraTag + # Retrieve the install path installPath = getInstallRoot() installPath = os.path.dirname(installPath) - # Determine the workPath - workPath = os.path.join(installPath, 'release', 'DistMaker-' + aVersion) - destFileGZ = os.path.join(installPath, 'release', 'DistMaker-' + aVersion + '.tar.gz') + # Define the paths of interest + jarBinPathFN = os.path.join(installPath, 'release', libBaseName + '-' + version + '.jar') + jarSrcPathFN = os.path.join(installPath, 'release', libBaseName + '-' + version + '-src.jar') - # Bail if the work folder for which we compose the release already exists + workPath = os.path.join(installPath, 'release', appBaseName + '-' + version) + destFileGZ = os.path.join(installPath, 'release', appBaseName + '-' + version + '.tar.gz') + + # Let the user know of the version we are building + print('Building ' + appBaseName + ' release ' + version + '...\n') + + # Bail if there is a prior build + failMsgL = [] + if os.path.exists(jarBinPathFN) == True: + failMsgL += ['Library binary file already exists: ' + jarBinPathFN] + if os.path.exists(jarSrcPathFN) == True: + failMsgL += ['Library source file already exists: ' + jarSrcPathFN] if os.path.exists(workPath) == True: - errPrintln('\tAborting DistMaker release build. Release folder already exists: ' + workPath) + failMsgL += ['Release folder already exists: ' + workPath] + if os.path.exists(destFileGZ) == True: + failMsgL += ['Release package already exists: ' + destFileGZ] + + if len(failMsgL) > 0: + errPrintln('Aborting ' + appBaseName + ' release build. Reasons:') + for aFailMsg in failMsgL: + errPrintln(' - ' + aFailMsg) + errPrintln('') exit(-1) - # Bail if the release already exists - if os.path.exists(destFileGZ) == True: - errPrintln('\tAborting DistMaker release build. Release already exists. File: ' + destFileGZ) + # Build the library jars + buildLibraryJar(version) + + # Confirm that we have built the class files properly by retrieving the + # version from the built application jar and comparing it to our version. + tmpVersion = getLibraryBinVersion(jarBinPathFN) + if tmpVersion != version: + print('Failure: Embedded release: {} Expected: {}\n\tAborting...'.format(tmpVersion, version)) exit(-1) # Laydown the structure, and let the user know of the version we are building - print('Building DistMaker release ' + aVersion + '...') os.mkdir(workPath) - # Copy the regular docs + # Copy the regular documents dstPath = os.path.join(workPath, 'doc') os.mkdir(dstPath) for aFile in ['QuickStartGuide.pdf', 'ReadMe.txt']: @@ -61,6 +168,9 @@ def buildRelease(aVersion, aDoNotClean=False): srcPath = os.path.join(installPath, 'lib', aLib) shutil.copy2(srcPath, dstPath) + # Copy the (newly) built DistMaker (binary) library + shutil.copy2(jarBinPathFN, dstPath) + # Copy the scripts dstPath = os.path.join(workPath, 'script') os.mkdir(dstPath) @@ -73,7 +183,7 @@ def buildRelease(aVersion, aDoNotClean=False): os.makedirs(dstPath + '/apple') os.makedirs(dstPath + '/background') os.makedirs(dstPath + '/launch4j') - for aFile in ['appLauncher.jar', 'JreCatalog.txt', 'apple/.DS_Store.template', 'apple/JavaAppLauncher', 'background/background.png', 'launch4j/launch4j-3.12-linux-x64.tgz', 'launch4j/launch4j-3.12-linux.tgz', 'launch4j/launch4j-3.12-macosx-x86.tgz']: + for aFile in ['appLauncher.jar', 'JreCatalog.txt', 'apple/.DS_Store.template', 'apple/JavaAppLauncher', 'background/background.png', 'launch4j/launch4j-3.14-linux-x64.tgz', 'launch4j/launch4j-3.14-linux.tgz', 'launch4j/launch4j-3.14-macosx-x86.tgz']: srcPath = os.path.join(installPath, 'template', aFile) shutil.copy2(srcPath, dstPath + '/' + aFile) @@ -88,7 +198,10 @@ def buildRelease(aVersion, aDoNotClean=False): if aDoNotClean == False: shutil.rmtree(workPath) - print('DistMaker release ' + aVersion + ' built.') + print(appBaseName + ' release ' + version + ' built. Assets:') + for aFilePath in [jarBinPathFN, jarSrcPathFN, destFileGZ]: + print(' - ' + aFilePath) + print('') def errPrintln(aMessage=''): @@ -98,31 +211,20 @@ def errPrintln(aMessage=''): sys.stderr.write(aMessage + '\n') -def getDistMakerVersion(): - """Method that will return the version of the distMaker.jar file that resides - in the library path. The version of the DistMaker release is defined by the - value associated with the disMaker.jar file. Any failures will result in the - abrupt exit of this script.""" - # Retrieve the install path - installPath = getInstallRoot() - installPath = os.path.dirname(installPath) - - # Check for distMaker.jar library prerequisite - testPath = os.path.join(installPath, 'lib', 'distMaker.jar') - if os.path.exists(testPath) == False: - errPrintln('\tAborting DistMaker release build. The file ' + testPath + ' does not exist.') - errPrintln('\tPlease run the buildDistMakerBin.jardesc from your workspace.') - exit(-1) - +def getLibraryBinVersion(aJarBinPath): + """Method that will return the version of the specified binary jar file. + The binary jar file will be queried (package distmaker.DistApp) and the + output will be parsed. Any failures will result in the abrupt exit of this + script.""" try: - cpStr = ':lib/'.join(libList) - cpStr = 'lib/' + cpStr - exeCmd = ['java', '-cp', cpStr, 'distMaker.DistApp', '--version'] + cpStr = aJarBinPath + cpStr += ':lib/' + ':lib/'.join(libList) + exeCmd = [javaExe, '-cp', cpStr, 'distMaker.DistApp', '--version'] output = subprocess.check_output(exeCmd).decode('utf-8') - version = output.split()[1] + version = output.split()[1].strip() return version - except: - errPrintln('\tPlease run the buildDistMakerBin.jardesc from your workspace.') + except Exception as aExp: + traceback.print_exc() exit(-1) @@ -144,19 +246,20 @@ if __name__ == "__main__": # Logic to capture Ctrl-C and bail signal.signal(signal.SIGINT, handleSignal) - # Require python version 2.7 or later - targVer = (2, 7) + # Require python version 3.6 or later + targVer = (3, 6) if sys.version_info < targVer: print('The installed version of python is too old. Please upgrade.') print(' Current version: ' + '.'.join(str(i) for i in sys.version_info)) print(' Require version: ' + '.'.join(str(i) for i in targVer)) sys.exit(-1) - tmpDescr = 'Utility to build a DistMaker release\n' + tmpDescr = 'Utility to build a ' + appBaseName + ' release\n' parser = argparse.ArgumentParser(prefix_chars='-', description=tmpDescr, add_help=False, fromfile_prefix_chars='@') parser.add_argument('--help', '-h', help='Show this help message and exit.', action='help') parser.add_argument('--doNotClean', default=False, action='store_true', help='Do NOT remove temporary work folder created while generating release.') parser.add_argument('--doFullBuild', default=False, action='store_true', help='Force a full build of the main jar file. (Unsupported action)') + parser.add_argument('--extraTag', default=None, action='store', help='Specify an extra tag for to the version.') # Intercept any request for a help message and bail argv = sys.argv; @@ -168,12 +271,11 @@ if __name__ == "__main__": parser.formatter_class.max_help_position = 50 args = parser.parse_args() - # Get the version of DistMaker we are building - version = getDistMakerVersion() - print('DistMaker version: ' + version) - # TODO: Finish this functionality if args.doFullBuild == True: print("Unsupported action: [--doFullBuild]. Skipping...") - buildRelease(version, args.doNotClean) + # Ensure required applications are installed + checkForInstalledApps() + + buildRelease(args.extraTag, args.doNotClean)