Updates for: added support to allow configuration of target platform to build, refactoring of glum.zio package, cleanup

This commit is contained in:
Norberto Lopez
2017-04-28 16:29:28 +00:00
parent f247ce9df4
commit cdaafece45
13 changed files with 135 additions and 98 deletions

View File

@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="script"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry exported="true" kind="lib" path="lib/glum.jar" sourcepath="lib/glum-src.jar"/>
<classpathentry kind="lib" path="lib/miglayout-3.7.2-swing.jar"/>
<classpathentry kind="lib" path="lib/miglayout-3.7.2.jar"/>
<classpathentry kind="lib" path="lib/guava-18.0.jar" sourcepath="lib/guava-18.0-sources.jar"/>
<classpathentry kind="lib" path="lib/commons-compress-1.10.jar" sourcepath="lib/commons-compress-1.10-sources.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="script"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="lib" path="lib/glum.jar" sourcepath="lib/glum-src.jar"/>
<classpathentry kind="lib" path="lib/miglayout-3.7.2-swing.jar"/>
<classpathentry kind="lib" path="lib/miglayout-3.7.2.jar"/>
<classpathentry kind="lib" path="lib/guava-18.0.jar" sourcepath="lib/guava-18.0-sources.jar"/>
<classpathentry kind="lib" path="lib/commons-compress-1.10.jar" sourcepath="lib/commons-compress-1.10-sources.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

Binary file not shown.

Binary file not shown.

View File

@@ -24,30 +24,39 @@ def buildRelease(args, buildPath):
jreVerSpec = args.jreVerSpec
platformStr = 'apple'
# Determine the types of builds we should do
platformType = miscUtils.getPlatformTypes(args.platform, platformStr)
if platformType.nonJre == False and platformType.withJre == False:
return;
# Warn if a request for a non-JRE build. We do not support that for the Apple platform.
if 'apple-' in args.platform:
print('Building an Apple release without a JRE is currently not supported. This release will not be made.')
# Check our system environment before proceeding
if checkSystemEnvironment() == False:
return
# Select the jreTarGzFile to utilize for static releases
jreTarGzFile = jreUtils.getJreTarGzFile(platformStr, jreVerSpec)
if jreTarGzFile == None:
# Let the user know that a compatible JRE was not found - thus no static release will be made.
print('[Warning] No compatible JRE ({0}) is available for the {1} platform. A static release will not be provided for the platform.'.format(jreVerSpec, platformStr.capitalize()))
# Let the user know that a compatible JRE was not found - and thus no Apple builds will be made
print('Only static Apple distributions are supported - thus there will be no Apple distribution of the application: ' + appName + '\n')
return
# Form the list of distributions to build (dynamic and static releases)
# Note as of 2016May01 there is no longer support for a dynamic Apple release
# distList = [(appName + '-' + version, None)]
# Form the list of distributions to build (dynamic and static JREs)
distList = []
if jreTarGzFile != None:
distList.append((appName + '-' + version + '-jre', jreTarGzFile))
# Note as of 2016May01 there is no longer support for a dynamic Apple release
# if platformType.nonJre == True:
# distList = [(appName + '-' + version, None)]
if platformType.withJre == True:
# Select the jreTarGzFile to utilize for static releases
jreTarGzFile = jreUtils.getJreTarGzFile(platformStr, jreVerSpec)
if jreTarGzFile == None:
# Let the user know that a compatible JRE was not found - thus no static release will be made.
print('[Warning] No compatible JRE ({0}) is available for the {1} platform. A static release will not be provided for the platform.'.format(jreVerSpec, platformStr.capitalize()))
# Let the user know that a compatible JRE was not found - and thus no Apple builds will be made
print('Only static Apple distributions are supported - thus there will be no Apple distribution of the application: ' + appName + '\n')
return
else:
distList.append((appName + '-' + version + '-jre', jreTarGzFile))
# Create the various distributions
for (aDistName, aJreTarGzFile) in distList:
print('Building {0} distribution: {1}'.format(platformStr.capitalize(), aDistName))
# Let the user know of the JRE tar.gz we are going to build with
# Let the user know of the JRE release we are going to build with
if aJreTarGzFile != None:
print('\tUtilizing JRE: ' + aJreTarGzFile)

View File

@@ -98,7 +98,7 @@ 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)')
genisoimagePath = distutils.spawn.find_executable('genisoimage')
hdiutilPath = distutils.spawn.find_executable('hdiutil')
if genisoimagePath == None and hdiutilPath == None:
@@ -142,7 +142,7 @@ def getClassPath(javaCodePath):
retList = []
# Ensure the javaCodePath has a trailing slash
# to allow for proper computation of clipLen
# to allow for proper computation of clipLen
if javaCodePath.endswith('/') == False:
javaCodePath += '/'
clipLen = len(javaCodePath)
@@ -167,7 +167,7 @@ if __name__ == "__main__":
# Logic to capture Ctrl-C and bail
signal.signal(signal.SIGINT, miscUtils.handleSignal)
# Set up the argument parser
# Set up the argument parser
parser = FancyArgumentParser(prefix_chars='-', add_help=False, fromfile_prefix_chars='@')
parser.add_argument('-help', '-h', help='Show this help message and exit.', action='help')
parser.add_argument('-name', help='The name of the application.')
@@ -189,6 +189,9 @@ if __name__ == "__main__":
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('-platform', help='Target platforms to build. Choices are: [apple, linux, windows]. Note the following (append) modifiers.'
+ ' Modifier \'-\' results in only the non-JRE build. Modifier \'+\' results in only the JRE build. Default: apple+, linux, windows', nargs='+', default=['apple+', 'linux', 'windows'],
choices=['apple', 'apple-', 'apple+', 'linux', 'linux-', 'linux+', 'windows', 'windows-', 'windows+'], metavar='PLATFORM')
# parser.add_argument('-bundleId', help='Apple specific id descriptor.')
# Intercept any request for a help message and bail
@@ -200,11 +203,16 @@ if __name__ == "__main__":
# Check to ensure all of the required applications are installed before proceeding
checkForRequiredApplicationsAndExit()
# Parse the args
# Parse the args
parser.formatter_class.max_help_position = 50
args = parser.parse_args()
# print args
# Warn if there are not any valid targets
if args.platform == ['apple-']:
print('The only release specified is Apple without JRE. This is currently unsupported.\nExiting...')
exit()
# Ensure we are getting the bare minimum options
errList = [];
if args.name == None:
@@ -217,7 +225,7 @@ if __name__ == "__main__":
print('At a minimum the following must be specified: ' + str(errList) + '.\nExiting...')
exit()
# Ensure the reserved 'jre' name is not utilized
# Ensure the reserved 'jre' name is not utilized
if args.name.lower() == 'jre':
print('The application can not be named: {}. That name is reserved for the JRE.'.format(args.name))
exit()
@@ -252,7 +260,7 @@ 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
@@ -305,7 +313,7 @@ if __name__ == "__main__":
dstPath = deltaCodePath;
shutil.copytree(srcPath, dstPath, symlinks=False)
# Form the app.cfg file
# Form the app.cfg file
dstPath = os.path.join(buildPath, "delta/app.cfg")
miscUtils.buildAppLauncherConfig(dstPath, args)

View File

@@ -21,20 +21,27 @@ def buildRelease(args, buildPath):
jreVerSpec = args.jreVerSpec
platformStr = 'linux'
# Determine the types of builds we should do
platformType = miscUtils.getPlatformTypes(args.platform, platformStr)
if platformType.nonJre == False and platformType.withJre == False:
return;
# Check our system environment before proceeding
if checkSystemEnvironment() == False:
return
# Select the jreTarGzFile to utilize for static releases
jreTarGzFile = jreUtils.getJreTarGzFile(platformStr, jreVerSpec)
if jreTarGzFile == None:
# Let the user know that a compatible JRE was not found - thus no static release will be made.
print('[Warning] No compatible JRE ({0}) is available for the {1} platform. A static release will not be provided for the platform.'.format(jreVerSpec, platformStr.capitalize()))
# Form the list of distributions to build (dynamic and static JREs)
distList = [(appName + '-' + version, None)]
if jreTarGzFile != None:
distList.append((appName + '-' + version + '-jre', jreTarGzFile))
distList = []
if platformType.nonJre == True:
distList = [(appName + '-' + version, None)]
if platformType.withJre == True:
# Select the jreTarGzFile to utilize for static releases
jreTarGzFile = jreUtils.getJreTarGzFile(platformStr, jreVerSpec)
if jreTarGzFile == None:
# Let the user know that a compatible JRE was not found - thus no static release will be made.
print('[Warning] No compatible JRE ({0}) is available for the {1} platform. A static release will not be provided for the platform.'.format(jreVerSpec, platformStr.capitalize()))
else:
distList.append((appName + '-' + version + '-jre', jreTarGzFile))
# Create a tmp (working) folder
tmpPath = tempfile.mkdtemp(prefix=platformStr, dir=buildPath)

View File

@@ -66,6 +66,31 @@ def computeDigestForFile(evalFile, digestType, block_size=2**20):
return hash.hexdigest()
def getPlatformTypes(platformArr, platformStr):
"""Returns an object that defines the release types that should be built for the given platform. The object will
have 2 field members: [nonJre, withJre]. If the field is set to True then the corresonding platform should be
built. This is determined by examaning the platformStr and determine it's occurance in the platformArr. For
example to determine the build platforms for Linux one might call getPlatformArr(someArr, 'linux'). Following are
the results of contents in someArr:
[''] ---> nonJre = False, withJre = False
['linux'] ---> nonJre = True, withJre = True
['linux+'] ---> nonJre = False, withJre = True
['linux-'] ---> nonJre = True, withJre = False"""
class PlatformType(object):
nonJre = False
withJre = False
retObj = PlatformType()
if platformStr in platformArr:
retObj.nonJre = True
retObj.withJre = True
if platformStr + '-' in platformArr:
retObj.nonJre = True
if platformStr + '+' in platformArr:
retObj.withJre = True
return retObj
def getInstallRoot():
"""Returns the root path where the running script is installed."""
argv = sys.argv;
@@ -89,16 +114,16 @@ def executeAndLog(command, indentStr=""):
print(indentStr + 'Stack Trace:')
outStr = logUtils.appendLogOutputWithText(aExp.child_traceback, indentStr + '\t')
print(outStr)
class Proc:
returncode = None
proc = Proc
return proc
# if proc.returncode != 0:
# print('\tError: Failed to build executable. Return code: ' + proc.returncode)
def getPathSize(aRoot):
"""Computes the total disk space used by the specified path.
Note if aRoot does not exist or is None then this will return 0"""

View File

@@ -22,25 +22,32 @@ def buildRelease(args, buildPath):
jreVerSpec = args.jreVerSpec
platformStr = 'windows'
# Determine the types of builds we should do
platformType = miscUtils.getPlatformTypes(args.platform, platformStr)
if platformType.nonJre == False and platformType.withJre == False:
return;
# Check our system environment before proceeding
if checkSystemEnvironment() == False:
return
# Select the jreTarGzFile to utilize for static releases
jreTarGzFile = jreUtils.getJreTarGzFile(platformStr, jreVerSpec)
if jreTarGzFile == None:
# Let the user know that a compatible JRE was not found - thus no static release will be made.
print('[Warning] No compatible JRE ({0}) is available for the {1} platform. A static release will not be provided for the platform.'.format(jreVerSpec, platformStr.capitalize()))
# Form the list of distributions to build (dynamic and static JREs)
distList = [(appName + '-' + version, None)]
if jreTarGzFile != None:
distList.append((appName + '-' + version + '-jre', jreTarGzFile))
distList = []
if platformType.nonJre == True:
distList = [(appName + '-' + version, None)]
if platformType.withJre == True:
# Select the jreTarGzFile to utilize for static releases
jreTarGzFile = jreUtils.getJreTarGzFile(platformStr, jreVerSpec)
if jreTarGzFile == None:
# Let the user know that a compatible JRE was not found - thus no static release will be made.
print('[Warning] No compatible JRE ({0}) is available for the {1} platform. A static release will not be provided for the platform.'.format(jreVerSpec, platformStr.capitalize()))
else:
distList.append((appName + '-' + version + '-jre', jreTarGzFile))
# Create a tmp (working) folder
tmpPath = tempfile.mkdtemp(prefix=platformStr, dir=buildPath)
# Unpack the proper launch4j release (for the platform we are
# 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)
@@ -58,7 +65,7 @@ def buildRelease(args, buildPath):
# Create the various distributions
for (aDistName, aJreTarGzFile) in distList:
print('Building {0} distribution: {1}'.format(platformStr.capitalize(), aDistName))
# Let the user know of the JRE tar.gz we are going to build with
# Let the user know of the JRE release we are going to build with
if aJreTarGzFile != None:
print('\tUtilizing JRE: ' + aJreTarGzFile)
@@ -223,8 +230,8 @@ def checkSystemEnvironment():
def getJreMajorVersion(aJreVerSpec):
"""Returns the minimum version of the JRE to utilize based on the passed in JreVerSpec. If aJreVerSpec is None then
the value specified in jreUtils.getDefaultJreVerStr() will be utilized. If that value is None then the value of
1.8.0 will be utilized."""
the value specified in jreUtils.getDefaultJreVerStr() will be utilized. If that value is None then the value of
1.8.0 will be utilized."""
if aJreVerSpec == None:
aJreVerSpec = [jreUtils.getDefaultJreVerStr()]
minJreVerStr = aJreVerSpec[0]

View File

@@ -9,7 +9,6 @@ import glum.gui.panel.GlassPanel;
import glum.gui.panel.generic.MessagePanel;
import glum.unit.ByteUnit;
import glum.util.ThreadUtil;
import glum.zio.raw.ZioRaw;
import java.awt.*;
import java.awt.event.ActionEvent;
@@ -30,7 +29,7 @@ import static distMaker.platform.MemUtils.KB_SIZE;
import static distMaker.platform.MemUtils.MB_SIZE;
import static distMaker.platform.MemUtils.GB_SIZE;
public class MemoryConfigPanel extends GlassPanel implements ActionListener, ZioRaw, ListSelectionListener
public class MemoryConfigPanel extends GlassPanel implements ActionListener, ListSelectionListener
{
/** Unused - but added to eliminate warning due to poorly designed java.io.Serializable interface. */
private static final long serialVersionUID = 1L;

View File

@@ -9,7 +9,6 @@ import glum.gui.panel.itemList.StaticItemProcessor;
import glum.gui.panel.itemList.query.*;
import glum.unit.ConstUnitProvider;
import glum.unit.DateUnit;
import glum.zio.raw.ZioRaw;
import java.awt.*;
import java.awt.event.ActionEvent;
@@ -27,7 +26,7 @@ import net.miginfocom.swing.MigLayout;
import distMaker.LookUp;
import distMaker.node.AppRelease;
public class PickReleasePanel extends GlassPanel implements ActionListener, ZioRaw, ListSelectionListener
public class PickReleasePanel extends GlassPanel implements ActionListener, ListSelectionListener
{
private static final long serialVersionUID = 1L;

View File

@@ -1,14 +1,13 @@
package dsstore;
import glum.io.IoUtil;
import glum.task.*;
import glum.zio.*;
import glum.zio.stream.FileZinStream;
import glum.zio.stream.FileZoutStream;
import java.io.*;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.*;
import dsstore.record.*;
@@ -46,20 +45,14 @@ public class MainApp
public void writeStore(File aFile)
{
FileZoutStream aStream;
int fileMagicKey;
// Ensure we have a valid dataBuf
if (dataBuf == null)
return;
aStream = null;
try
try (FileZoutStream aStream = new FileZoutStream(aFile);)
{
aStream = new FileZoutStream(aFile);
// Write the file's MagicKey
fileMagicKey = 0x0001;
int fileMagicKey = 0x0001;
aStream.writeInt(fileMagicKey);
// Dump the contents of aBytBuff
@@ -69,11 +62,8 @@ public class MainApp
}
catch(IOException aExp)
{
IoUtil.forceClose(aStream);
aExp.printStackTrace();
}
}
/**
@@ -83,9 +73,6 @@ public class MainApp
*/
public boolean readStore(File aFile)
{
ZinStream aStream;
int fileSize;
// Bail if the file is not valid
if (aFile.isFile() == false)
{
@@ -94,8 +81,7 @@ public class MainApp
}
dataBuf = null;
aStream = null;
try
try (FileZinStream iStream = new FileZinStream(aFile))
{
byte[] byteArr;
List<BlockDir> blockDirList;
@@ -105,17 +91,16 @@ int allocBlockOffset1, allocBlockOffset2, allocBlockSize;
int blockCnt, tmpSize, seekDiff, dirCnt;
int blockAddrArr[];
fileSize = (int)aFile.length();
aStream = new FileZinStream(aFile);
int fileSize = (int)aFile.length();
// DS_Store magic key: 0x0001
fileMagicKey = aStream.readInt();
fileMagicKey = iStream.readInt();
if (fileMagicKey != 0x0001)
throw new IOException("Bad magic key value: " + fileMagicKey + " Expected: " + 0x0001);
// Read the rest of the contents into a bytebuffer
byteArr = new byte[fileSize - 4];
aStream.readFully(byteArr);
iStream.readFully(byteArr);
dataBuf = ByteBuffer.wrap(byteArr);
// Header block (not stored in the allocators list)
@@ -209,12 +194,10 @@ refTask.infoAppendln("Reading freelists...");
catch (IOException aExp)
{
aExp.printStackTrace();
IoUtil.forceClose(aStream);
return false;
}
return true;
}

View File

@@ -1,9 +1,9 @@
This template area contains images and application stubs and other resources that will be used by the distMaker release buildiong script when building the distMaker app for allthe platforms.
This template area contains images, application stubs, and other resources that will be packed with the DistMaker software during the build step.
launch4j - (Windows only) Needed a modified version to launch from any dir
apple - Binary launchers for the Apple platform
background - Images that go behind the apple installer (only one currently being used now)
.DS_Store.template - File used as a template Apple (Finder?) file which is modified durring the packaging process.
background - Images that go behind the Apple installer (only one currently being used now)
launch4j - Utility to build executable for the Windows platform.
.DS_Store.template - File used as a template Apple (Finder?) file which is modified during the packaging process.
applauncher.jar - This comes from the app launcher project - it gets built there and copied here manually
appLauncher.jar - This comes from the AppLauncher project - it gets built there and copied here manually

View File

@@ -11,7 +11,7 @@ import time
# Globals
# The default version of DistMaker
version = '0.44'
version = '0.45'
def logAndPrint(message="", indent=0, showTime=False):