Various updates:

[1] Updates Java source to support DistMaker 0.55 features
- Preliminary architecture support (initially just: x64)
- Arbitrary JRE file naming convention
[2] Update to use launch4j (3.12)
[3] Updated glum library.
[4] Various code cleanups.
This commit is contained in:
Norberto Lopez
2019-12-04 21:09:54 +00:00
parent e3dba5f9a0
commit 13f7eb0b0b
11 changed files with 126 additions and 92 deletions

View File

@@ -7,7 +7,7 @@
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/glum.jar">
<classpathentry kind="lib" path="lib/glum.jar" sourcepath="lib/glum-src.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>

Binary file not shown.

Binary file not shown.

View File

@@ -53,9 +53,9 @@ def buildRelease(args, buildPath):
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']
exeCmd = ['tar', '-C', tmpPath, '-xf', l4jPath + '/launch4j-3.12-macosx-x86.tgz']
else:
exeCmd = ['tar', '-C', tmpPath, '-xf', l4jPath + '/launch4j-3.8-linux.tgz']
exeCmd = ['tar', '-C', tmpPath, '-xf', l4jPath + '/launch4j-3.12-linux-x64.tgz']
retCode = subprocess.call(exeCmd)
if retCode != 0:
print('Failed to extract launch4j package...')

View File

@@ -12,7 +12,7 @@ import distMaker.utils.Version;
public class DistApp
{
/** The DistMaker version is defined here. */
public static final Version version = new PlainVersion(0, 50, 0);
public static final Version version = new PlainVersion(0, 55, 0);
/**
* Main entry point that will print out the version of DistMaker to stdout.

View File

@@ -744,7 +744,7 @@ public class DistMakerEngine
aTask.infoAppendln("\tMaximum JRE: " + tmpJreVer.getLabel());
aTask.infoAppendln("");
// Bail if we are running a bundled JRE
// Bail if we are running a non-bundled JRE
if (DistUtils.isJreBundled() == false)
{
aTask.infoAppend("This is the non bundled JRE version of the application. You are running the system JRE. ");
@@ -768,11 +768,12 @@ public class DistMakerEngine
}
// Retrieve the latest appropriate JreRelease
String platform = PlatformUtils.getPlatform();
jreList = JreUtils.getMatchingPlatforms(jreList, platform);
String archStr = PlatformUtils.getArchitecture();
String platStr = PlatformUtils.getPlatform();
jreList = JreUtils.getMatchingPlatforms(jreList, archStr, platStr);
if (jreList.size() == 0)
{
aTask.infoAppendln("There are no JRE releases available for the platform: " + platform + "!");
aTask.infoAppendln("There are no JRE releases available for platform: (" + archStr + ") " + platStr + "!");
return null;
}

View File

@@ -230,12 +230,12 @@ public class PickReleasePanel extends GlassPanel implements ActionListener, List
private JPanel buildItemListTablePanel()
{
QueryComposer<LookUp> tmpComposer;
QueryItemHandler<AppRelease> tmpIH;
QueryItemHandler<AppRelease, LookUp> tmpIH;
DateUnit dateUnit;
dateUnit = new DateUnit("", "yyyyMMMdd HH:mm");
tmpComposer = new QueryComposer<LookUp>();
tmpComposer = new QueryComposer<>();
tmpComposer.addAttribute(LookUp.Version, String.class, "Version", null);
tmpComposer.addAttribute(LookUp.BuildTime, new ConstUnitProvider(dateUnit), "Build Date", null);
@@ -245,10 +245,10 @@ public class PickReleasePanel extends GlassPanel implements ActionListener, List
tmpComposer.setRenderer(LookUp.Version, col0Renderer);
tmpComposer.setRenderer(LookUp.BuildTime, col1Renderer);
tmpIH = new QueryItemHandler<AppRelease>(tmpComposer);
tmpIH = new QueryItemHandler<>(tmpComposer);
myItemProcessor = new StaticItemProcessor<>();
listPanel = new ItemListPanel<>(tmpIH, myItemProcessor, false, false);
listPanel = new ItemListPanel<>(tmpIH, myItemProcessor, false);
listPanel.setSortingEnabled(false);
listPanel.addListSelectionListener(this);
return listPanel;

View File

@@ -10,23 +10,29 @@ import distMaker.utils.Version;
*/
public class JreRelease implements Comparable<JreRelease>
{
private final JreVersion version;
private final Version alMinVer;
private final Version alMaxVer;
private final String platform;
private final JreVersion version;
private final Digest digest;
private final String archStr;
private final String platStr;
private final String fileName;
private final Digest digest;
private final long fileLen;
public JreRelease(String aPlatform, String aVersion, String aFileName, Digest aDigest, long aFileLen, Version aAlMinVer, Version aAlMaxVer)
public JreRelease(String aArchStr, String aPlatStr, JreVersion aVersion, String aFileName, Digest aDigest, long aFileLen, Version aAlMinVer, Version aAlMaxVer)
{
platform = aPlatform;
version = new JreVersion(aVersion);
version = aVersion;
alMinVer = aAlMinVer;
alMaxVer = aAlMaxVer;
archStr = aArchStr.toLowerCase();
platStr = aPlatStr.toLowerCase();
fileName = aFileName;
digest = aDigest;
fileLen = aFileLen;
alMinVer = aAlMinVer;
alMaxVer = aAlMaxVer;
}
/**
@@ -62,22 +68,28 @@ public class JreRelease implements Comparable<JreRelease>
}
/**
* Returns true if the specified platform matches our platform.
* Returns true if the specified system matches the JRE's system.
*
* @param aArchStr
* Architecture of the relevant system. (Ex: x64)
* @param aPlatStr
* Platform of the relevant system. (Ex: linux)
* @return
*/
public boolean isPlatformMatch(String aPlatform)
public boolean isSystemMatch(String aArchStr, String aPlatStr)
{
String platformStr;
aArchStr = aArchStr.toLowerCase();
aPlatStr = aPlatStr.toLowerCase();
// Ensure the architecture matches
if (archStr.equals(aArchStr) == false)
return false;
// Ensure the platform matches
if (platStr.equals(aPlatStr) == false)
return false;
// Consider this JreRelease a match if our platform is contained within aPlatform
platformStr = platform.toUpperCase();
if (aPlatform.toUpperCase().contains(platformStr) == true)
return true;
// If our platform == APPLE - then check to see if aPlatform mathes against 'MACOSX'
if (platformStr.equals("APPLE") == true && aPlatform.toUpperCase().contains("MACOSX") == true)
return true;
return false;
return true;
}
/**
@@ -101,7 +113,11 @@ public class JreRelease implements Comparable<JreRelease>
{
int cmpVal;
cmpVal = platform.compareTo(aItem.platform);
cmpVal = archStr.compareTo(aItem.archStr);
if (cmpVal != 0)
return cmpVal;
cmpVal = platStr.compareTo(aItem.platStr);
if (cmpVal != 0)
return cmpVal;

View File

@@ -65,7 +65,7 @@ public class JreUtils
PlainVersion alMinVer = PlainVersion.Zero;
PlainVersion alMaxVer = PlainVersion.AbsMax;
DigestType digestType = DigestType.MD5;
String version = null;
JreVersion version = null;
inStream = null;
bufReader = null;
@@ -89,12 +89,11 @@ public class JreUtils
if (strLine.isEmpty() == true || strLine.startsWith("#") == true)
continue;
String[] tokens;
tokens = strLine.split(",", 5);
if (tokens.length == 2 && tokens[0].equals("name") == true && tokens[1].equals("JRE") == true)
String[] tokens = strLine.split(",", 5);
if (tokens[0].equals("name") == true && tokens.length == 2 && tokens[1].equals("JRE") == true)
; // Nothing to do - we just entered the "JRE" section
// Logic to handle the 'exit' command
else if (tokens.length >= 1 && tokens[0].equals("exit") == true)
else if (tokens[0].equals("exit") == true && tokens.length >= 1)
{
// We support exit commands with 3 tokens. All others
// we will just exit.
@@ -107,27 +106,25 @@ public class JreUtils
break;
}
// Logic to handle the 'digest' command
else if (tokens.length == 2 && tokens[0].equals("digest") == true)
else if (tokens[0].equals("digest") == true && tokens.length == 2)
{
DigestType tmpDigestType;
tmpDigestType = DigestType.parse(tokens[1]);
DigestType tmpDigestType = DigestType.parse(tokens[1]);
if (tmpDigestType == null)
aTask.infoAppendln("Failed to locate DigestType for: " + tokens[1]);
else
digestType = tmpDigestType;
}
// Logic to handle the 'jre' command
else if (tokens.length == 2 && tokens[0].equals("jre") == true)
else if (tokens[0].equals("jre") == true && tokens.length == 2)
{
version = tokens[1];
version = new JreVersion(tokens[1]);
// On any new JRE version reset the default required AppLauncher versions
alMinVer = PlainVersion.Zero;
alMaxVer = new PlainVersion(0, 99, 0);
}
// Logic to handle the 'require' command: JRE File
else if (tokens.length >= 3 && tokens[0].equals("require") == true)
else if (tokens[0].equals("require") == true && tokens.length >= 3)
{
String target;
@@ -146,11 +143,8 @@ public class JreUtils
aTask.infoAppendln("Unreconized line: " + strLine);
}
// Logic to handle the 'F' command: JRE File
else if (tokens.length == 5 && tokens[0].equals("F") == true)
else if (tokens[0].equals("F") == true && tokens.length >= 4 && tokens.length <= 6)
{
String platform, filename, digestStr;
long fileLen;
if (version == null)
{
aTask.infoAppendln("Skipping input: " + strLine);
@@ -158,42 +152,47 @@ public class JreUtils
continue;
}
// Form the JreRelease
digestStr = tokens[1];
fileLen = GuiUtil.readLong(tokens[2], -1);
platform = tokens[3];
filename = tokens[4];
// Parse the JRE release
String archStr, platStr, filename, digestStr;
long fileLen;
if (tokens.length == 6)
{
archStr = tokens[1];
platStr = tokens[2];
filename = tokens[3];
digestStr = tokens[4];
fileLen = GuiUtil.readLong(tokens[5], -1);
}
else if (tokens.length == 5)
{
archStr = "x64";
digestStr = tokens[1];
fileLen = GuiUtil.readLong(tokens[2], -1);
platStr = tokens[3];
if (platStr.equalsIgnoreCase("apple") == true)
platStr = "macosx";
filename = tokens[4];
}
else // tokens.length == 4
{
archStr = "x64";
digestStr = tokens[1];
fileLen = GuiUtil.readLong(tokens[2], -1);
filename = tokens[3];
platStr = JreUtils.getPlatformOfJreTarGz(filename);
if (platStr == null)
{
aTask.infoAppendln("Skipping input: " + strLine);
aTask.infoAppendln("\tFailed to determine the target platform of the JRE.");
continue;
}
}
// Form the JreRelease
Digest tmpDigest = new Digest(digestType, digestStr);
retList.add(new JreRelease(platform, version, filename, tmpDigest, fileLen, alMinVer, alMaxVer));
}
// Legacy Logic to handle the 'F' command: JRE File (pre DistMaker 0.50)
else if (tokens.length == 4 && tokens[0].equals("F") == true)
{
String platform, filename, digestStr;
long fileLen;
if (version == null)
{
aTask.infoAppendln("Skipping input: " + strLine);
aTask.infoAppendln("\tJRE version has not been specifed. Missing input line: jre,<jreVersion>");
continue;
}
// Form the JreRelease
digestStr = tokens[1];
fileLen = GuiUtil.readLong(tokens[2], -1);
filename = tokens[3];
platform = JreUtils.getPlatformOfJreTarGz(filename);
if (platform == null)
{
aTask.infoAppendln("Skipping input: " + strLine);
aTask.infoAppendln("\tFailed to determine the target platform of the JRE.");
continue;
}
retList.add(new JreRelease(platform, version, filename, new Digest(digestType, digestStr), fileLen, alMinVer, alMaxVer));
retList.add(new JreRelease(archStr, platStr, version, filename, tmpDigest, fileLen, alMinVer, alMaxVer));
}
else
{
@@ -235,7 +234,7 @@ public class JreUtils
* Utility method that returns a list of matching JREs. The list will be sorted in order from newest to oldest. All
* returned JREs will have a platform that matches aPlatform.
*/
public static List<JreRelease> getMatchingPlatforms(List<JreRelease> aJreList, String aPlatform)
public static List<JreRelease> getMatchingPlatforms(List<JreRelease> aJreList, String aArchStr, String aPlatStr)
{
List<JreRelease> retList;
@@ -243,7 +242,7 @@ public class JreUtils
retList = new ArrayList<>();
for (JreRelease aRelease : aJreList)
{
if (aRelease.isPlatformMatch(aPlatform) == false)
if (aRelease.isSystemMatch(aArchStr, aPlatStr) == false)
continue;
retList.add(aRelease);
@@ -270,7 +269,7 @@ public class JreUtils
if (aFileName.contains("LINUX") == true)
return "Linux";
if (aFileName.contains("MACOSX") == true)
return "Apple";
return "Macosx";
if (aFileName.contains("WINDOWS") == true)
return "Windows";

View File

@@ -21,6 +21,9 @@ public class JreVersion implements Comparable<JreVersion>, Version
/** Flag for legacy JRE versions. JRE versions prior to 9.0 are considered legacy. */
private final boolean isLegacy;
/**
* Standard Constructor
*/
public JreVersion(String aLabel)
{
label = aLabel;

View File

@@ -99,7 +99,22 @@ public class PlatformUtils
}
/**
* Returns the platform (Apple, Linux, or Windows) on which the current JRE is running on.
* Returns the architecture the current JRE is running on.
* <P>
* This always returns x64.
* <P>
* TODO: In the future update the code to return the architecture rather than assume x64!
*/
public static String getArchitecture()
{
// TODO: In the future update the code to return the architecture rather than assume x64!
return "x64";
}
/**
* Returns the platform (Linux, Macosx, or Windows) on which the current JRE is running on.
* <P>
* If the platform is not recognized the a {@link ErrorDM} will be thrown.
*/
public static String getPlatform()
{
@@ -108,12 +123,12 @@ public class PlatformUtils
osName = System.getProperty("os.name").toUpperCase();
if (osName.startsWith("LINUX") == true)
return "Linux";
if (osName.startsWith("MAC OS X") == true)
return "Apple";
if (osName.startsWith("WINDOWS") == true)
else if (osName.startsWith("MAC OS X") == true)
return "Macosx";
else if (osName.startsWith("WINDOWS") == true)
return "Windows";
return System.getProperty("os.name");
throw new ErrorDM("Unrecognized os.name: " + osName);
}
/**