mirror of
https://github.com/JHUAPL/DistMaker.git
synced 2026-01-09 22:47:56 -05:00
Changes to:
- Fix issue where legacy system JRE is required (Apple builds) - Provide a no-op UpdateCheckListener - Improve robustness of -dataCode argument in buildDist.py
This commit is contained in:
@@ -371,7 +371,6 @@ def buildPListInfoStatic(destFile, args, jreTarGzFile):
|
|||||||
|
|
||||||
f = open(destFile, 'wb')
|
f = open(destFile, 'wb')
|
||||||
writeln(f, 0, '<?xml version="1.0" ?>')
|
writeln(f, 0, '<?xml version="1.0" ?>')
|
||||||
# writeln(f, 0, '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">')
|
|
||||||
writeln(f, 0, '<plist version="1.0">')
|
writeln(f, 0, '<plist version="1.0">')
|
||||||
writeln(f, 1, '<dict>')
|
writeln(f, 1, '<dict>')
|
||||||
|
|
||||||
@@ -423,20 +422,20 @@ def buildPListInfoStatic(destFile, args, jreTarGzFile):
|
|||||||
writeln(f, 3, '<string>' + aStr + '</string>')
|
writeln(f, 3, '<string>' + aStr + '</string>')
|
||||||
writeln(f, 2, '</array>')
|
writeln(f, 2, '</array>')
|
||||||
|
|
||||||
# JVM configuration
|
# # ClassPath: AppLauncher
|
||||||
writeln(f, 2, '<key>Java</key>')
|
# writeln(f, 2, '<key>Java</key>')
|
||||||
writeln(f, 2, '<dict>')
|
# writeln(f, 2, '<dict>')
|
||||||
|
#
|
||||||
classPathStr = '$JAVAROOT/' + deployJreDist.getAppLauncherFileName()
|
# classPathStr = '$JAVAROOT/' + deployJreDist.getAppLauncherFileName()
|
||||||
|
#
|
||||||
tupList = []
|
# tupList = []
|
||||||
tupList.append(('ClassPath', classPathStr))
|
# tupList.append(('ClassPath', classPathStr))
|
||||||
|
#
|
||||||
for (key, val) in tupList:
|
# for (key, val) in tupList:
|
||||||
writeln(f, 3, '<key>' + key + '</key>')
|
# writeln(f, 3, '<key>' + key + '</key>')
|
||||||
writeln(f, 3, '<string>' + str(val) + '</string>')
|
# writeln(f, 3, '<string>' + str(val) + '</string>')
|
||||||
|
#
|
||||||
writeln(f, 2, '</dict>')
|
# writeln(f, 2, '</dict>')
|
||||||
writeln(f, 1, '</dict>')
|
writeln(f, 1, '</dict>')
|
||||||
writeln(f, 0, '</plist>')
|
writeln(f, 0, '</plist>')
|
||||||
|
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ if __name__ == "__main__":
|
|||||||
parser.add_argument('-version', default='0.0.1', help='The version of the application.')
|
parser.add_argument('-version', default='0.0.1', help='The version of the application.')
|
||||||
parser.add_argument('-mainClass', help='Application main entry point.')
|
parser.add_argument('-mainClass', help='Application main entry point.')
|
||||||
parser.add_argument('-appArgs', help='Application arguments. Note that this argument must ALWAYS be the last specified!', nargs=argparse.REMAINDER, default=[])
|
parser.add_argument('-appArgs', help='Application arguments. Note that this argument must ALWAYS be the last specified!', nargs=argparse.REMAINDER, default=[])
|
||||||
parser.add_argument('-dataCode', '-dc', help='A list of supporting folders for the application.', nargs='+', default=[])
|
parser.add_argument('-dataCode', '-dc', help='A list of supporting files or folders for the application. All items will be copied to the data folder. Symbolic links will not be presereved.', nargs='+', default=[])
|
||||||
parser.add_argument('-javaCode', '-jc', help='A folder which contains the Java build.')
|
parser.add_argument('-javaCode', '-jc', help='A folder which contains the Java build.')
|
||||||
parser.add_argument('-jreVersion', dest='jreVerSpec', help='JRE version to utilize. This should be either 1 or 2 values where each value should be something like 1.7 or 1.8 or 1.8.0_34. '
|
parser.add_argument('-jreVersion', dest='jreVerSpec', help='JRE version to utilize. This should be either 1 or 2 values where each value should be something like 1.7 or 1.8 or 1.8.0_34. '
|
||||||
+ 'If 2 values are specified than the second value must be later than the first value. Any static build will be built with the latest allowable JRE.'
|
+ 'If 2 values are specified than the second value must be later than the first value. Any static build will be built with the latest allowable JRE.'
|
||||||
@@ -301,16 +301,36 @@ if __name__ == "__main__":
|
|||||||
deltaCodePath = os.path.join(deltaPath, "code")
|
deltaCodePath = os.path.join(deltaPath, "code")
|
||||||
deltaDataPath = os.path.join(deltaPath, "data")
|
deltaDataPath = os.path.join(deltaPath, "data")
|
||||||
|
|
||||||
|
# Ensure the user does not specify the top level data folder so that a ~/data/data folder is not inadvertently created
|
||||||
|
if len(args.dataCode) == 1 and args.dataCode[0].rstrip('/').endswith('data'):
|
||||||
|
srcPath = args.dataCode[0].rstrip('/')
|
||||||
|
print(' [ERROR] The specified dataCode path will result in a data folder inside another data folder. Refusing action. Please specify the individual data files/folders.')
|
||||||
|
print(' Consider using:')
|
||||||
|
print(' -dataCode ' + srcPath + '/*')
|
||||||
|
print(' instead of:')
|
||||||
|
print(' -dataCode ' + args.dataCode[0] + '\n')
|
||||||
|
shutil.rmtree(buildPath)
|
||||||
|
exit(-1)
|
||||||
|
|
||||||
# Copy the dataCode to the delta location
|
# Copy the dataCode to the delta location
|
||||||
os.makedirs(deltaDataPath)
|
os.makedirs(deltaDataPath)
|
||||||
for aPath in args.dataCode:
|
for aSrcPath in args.dataCode:
|
||||||
srcPath = aPath
|
if os.path.exists(aSrcPath) == False:
|
||||||
if os.path.isdir(srcPath) == False:
|
print(' [ERROR] The dataCode path does not exist. Path: ' + aSrcPath + '\n')
|
||||||
print(' [ERROR] The dataCode path does not exist. Path: ' + srcPath + '\n')
|
shutil.rmtree(buildPath)
|
||||||
|
exit(-1)
|
||||||
|
elif os.path.isfile(aSrcPath):
|
||||||
|
dstPath = os.path.join(deltaDataPath, os.path.basename(aSrcPath))
|
||||||
|
shutil.copy(aSrcPath, dstPath)
|
||||||
|
continue
|
||||||
|
elif os.path.isdir(aSrcPath):
|
||||||
|
aSrcPath = aSrcPath.rstrip('/')
|
||||||
|
dstPath = os.path.join(deltaDataPath, os.path.basename(aSrcPath))
|
||||||
|
shutil.copytree(aSrcPath, dstPath, symlinks=False)
|
||||||
|
else:
|
||||||
|
print(' [ERROR] The dataCode path is not a valid file or folder. Path: ' + aSrcPath + '\n')
|
||||||
shutil.rmtree(buildPath)
|
shutil.rmtree(buildPath)
|
||||||
exit(-1)
|
exit(-1)
|
||||||
dstPath = os.path.join(deltaDataPath, os.path.basename(aPath))
|
|
||||||
shutil.copytree(srcPath, dstPath, symlinks=False)
|
|
||||||
|
|
||||||
# Build the java component of the distribution
|
# Build the java component of the distribution
|
||||||
if args.javaCode != None:
|
if args.javaCode != None:
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import distMaker.utils.Version;
|
|||||||
public class DistApp
|
public class DistApp
|
||||||
{
|
{
|
||||||
/** The DistMaker version is defined here. */
|
/** The DistMaker version is defined here. */
|
||||||
public static final Version version = new PlainVersion(0, 48, 0);
|
public static final Version version = new PlainVersion(0, 49, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main entry point that will print out the version of DistMaker to stdout.
|
* Main entry point that will print out the version of DistMaker to stdout.
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class DistMakerEngine
|
|||||||
/**
|
/**
|
||||||
* Method that will notify the user that updates are being checked for
|
* Method that will notify the user that updates are being checked for
|
||||||
*/
|
*/
|
||||||
public void checkForUpdates(UpdateCheckListener listener)
|
public void checkForUpdates(UpdateCheckListener aListener)
|
||||||
{
|
{
|
||||||
FullTaskPanel taskPanel;
|
FullTaskPanel taskPanel;
|
||||||
File installPath;
|
File installPath;
|
||||||
@@ -99,7 +99,7 @@ public class DistMakerEngine
|
|||||||
taskPanel.setVisible(true);
|
taskPanel.setVisible(true);
|
||||||
|
|
||||||
// Launch the actual checking of updates in a separate worker thread
|
// Launch the actual checking of updates in a separate worker thread
|
||||||
Runnable tmpRunnable = () -> checkForUpdatesWorker(taskPanel, listener);
|
Runnable tmpRunnable = () -> checkForUpdatesWorker(taskPanel, aListener);
|
||||||
ThreadUtil.launchRunnable(tmpRunnable, "thread-checkForUpdates");
|
ThreadUtil.launchRunnable(tmpRunnable, "thread-checkForUpdates");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,7 +255,7 @@ public class DistMakerEngine
|
|||||||
* <P>
|
* <P>
|
||||||
* This method will be called via reflection.
|
* This method will be called via reflection.
|
||||||
*/
|
*/
|
||||||
private void checkForUpdatesWorker(FullTaskPanel aTask, UpdateCheckListener listener)
|
private void checkForUpdatesWorker(FullTaskPanel aTask, UpdateCheckListener aListener)
|
||||||
{
|
{
|
||||||
List<AppRelease> fullList;
|
List<AppRelease> fullList;
|
||||||
AppRelease chosenItem;
|
AppRelease chosenItem;
|
||||||
@@ -281,7 +281,7 @@ public class DistMakerEngine
|
|||||||
}
|
}
|
||||||
|
|
||||||
// a successful test has been done, so notify the listener
|
// a successful test has been done, so notify the listener
|
||||||
listener.checkForNewVersionsPerformed();
|
aListener.checkForNewVersionsPerformed();
|
||||||
|
|
||||||
// In case there is only the current version, don't show the update selection panel.
|
// In case there is only the current version, don't show the update selection panel.
|
||||||
// Just show a short message that everything is up to date, and abort.
|
// Just show a short message that everything is up to date, and abort.
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package distMaker;
|
package distMaker;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* lets any interested party know that a check for for updates has been done
|
* lets any interested party know that a check for for updates has been done
|
||||||
*
|
*
|
||||||
@@ -8,5 +7,20 @@ package distMaker;
|
|||||||
*/
|
*/
|
||||||
public interface UpdateCheckListener
|
public interface UpdateCheckListener
|
||||||
{
|
{
|
||||||
void checkForNewVersionsPerformed();
|
/**
|
||||||
|
* UpdateCheckListener that does nothing. Use this (immutable) instance if you do not care about notifications.
|
||||||
|
*/
|
||||||
|
public final static UpdateCheckListener None = new UpdateCheckListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void checkForNewVersionsPerformed()
|
||||||
|
{
|
||||||
|
; // Nothing to do
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the listener that an update check has been performed.
|
||||||
|
*/
|
||||||
|
void checkForNewVersionsPerformed();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package distMaker.platform;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
@@ -111,62 +110,72 @@ public class AppleUtils
|
|||||||
*/
|
*/
|
||||||
public static void updateAppLauncher(AppLauncherRelease aRelease, File pFile)
|
public static void updateAppLauncher(AppLauncherRelease aRelease, File pFile)
|
||||||
{
|
{
|
||||||
List<String> inputList;
|
// Note the JavaAppLauncher executable appears to no longer support specifying the class path
|
||||||
String evalStr, tmpStr;
|
// Thus there is nothing to update as the AppLauncherRelease is implicitly loaded by it being in
|
||||||
String prevKeyValue;
|
// the path <AppName>/Contents/Java/ folder.
|
||||||
boolean isFound;
|
//
|
||||||
|
// Be aware of one big caveat - if there are multiple AppLauncher jars in the implicit location it
|
||||||
|
// is not clear which one will be selected!
|
||||||
|
//
|
||||||
|
// Change made as of 2018Apr11
|
||||||
|
return;
|
||||||
|
|
||||||
// Bail if the pFile is not writable
|
// List<String> inputList;
|
||||||
if (pFile.setWritable(true) == false)
|
// String evalStr, tmpStr;
|
||||||
throw new ErrorDM("The pFile is not writeable: " + pFile);
|
// String prevKeyValue;
|
||||||
|
// boolean isFound;
|
||||||
// Define the regex we will be searching for
|
//
|
||||||
String regex = "<string>(.*?)</string>";
|
// // Bail if the pFile is not writable
|
||||||
Pattern tmpPattern = Pattern.compile(regex);
|
// if (pFile.setWritable(true) == false)
|
||||||
|
// throw new ErrorDM("The pFile is not writeable: " + pFile);
|
||||||
// Process our input
|
//
|
||||||
inputList = new ArrayList<>();
|
// // Define the regex we will be searching for
|
||||||
try (BufferedReader br = MiscUtils.openFileAsBufferedReader(pFile))
|
// String regex = "<string>(.*?)</string>";
|
||||||
{
|
// Pattern tmpPattern = Pattern.compile(regex);
|
||||||
// Read the lines
|
//
|
||||||
isFound = false;
|
// // Process our input
|
||||||
prevKeyValue = "";
|
// inputList = new ArrayList<>();
|
||||||
while (true)
|
// try (BufferedReader br = MiscUtils.openFileAsBufferedReader(pFile))
|
||||||
{
|
// {
|
||||||
evalStr = br.readLine();
|
// // Read the lines
|
||||||
if (evalStr == null)
|
// isFound = false;
|
||||||
break;
|
// prevKeyValue = "";
|
||||||
|
// while (true)
|
||||||
// Keep track of the last key element
|
// {
|
||||||
tmpStr = evalStr.trim();
|
// evalStr = br.readLine();
|
||||||
if (tmpStr.startsWith("<key>") == true && tmpStr.endsWith("</key>") == true)
|
// if (evalStr == null)
|
||||||
prevKeyValue = tmpStr.substring(5, tmpStr.length() - 6).trim();
|
// break;
|
||||||
|
//
|
||||||
// The AppLauncher is specified just after the key element with the value: ClassPath
|
// // Keep track of the last key element
|
||||||
if (prevKeyValue.equals("ClassPath") == true && tmpPattern.matcher(evalStr).find() == true)
|
// tmpStr = evalStr.trim();
|
||||||
{
|
// if (tmpStr.startsWith("<key>") == true && tmpStr.endsWith("</key>") == true)
|
||||||
// Perform the replacement
|
// prevKeyValue = tmpStr.substring(5, tmpStr.length() - 6).trim();
|
||||||
String repStr = "<string>$JAVAROOT/" + PlatformUtils.getAppLauncherFileName(aRelease.getVersion()) + "</string>";
|
//
|
||||||
repStr = Matcher.quoteReplacement(repStr);
|
// // The AppLauncher is specified just after the key element with the value: ClassPath
|
||||||
evalStr = tmpPattern.matcher(evalStr).replaceFirst(repStr);
|
// if (prevKeyValue.equals("ClassPath") == true && tmpPattern.matcher(evalStr).find() == true)
|
||||||
|
// {
|
||||||
isFound = true;
|
// // Perform the replacement
|
||||||
}
|
// String repStr = "<string>$JAVAROOT/" + PlatformUtils.getAppLauncherFileName(aRelease.getVersion()) + "</string>";
|
||||||
|
// repStr = Matcher.quoteReplacement(repStr);
|
||||||
inputList.add(evalStr);
|
// evalStr = tmpPattern.matcher(evalStr).replaceFirst(repStr);
|
||||||
}
|
//
|
||||||
}
|
// isFound = true;
|
||||||
catch(IOException aExp)
|
// }
|
||||||
{
|
//
|
||||||
throw new ErrorDM(aExp, "Failed while processing the pFile: " + pFile);
|
// inputList.add(evalStr);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
// Fail if there was no update performed
|
// catch(IOException aExp)
|
||||||
if (isFound == false)
|
// {
|
||||||
throw new ErrorDM("[" + pFile + "] The pFile does not specify a 'ClassPath' section.");
|
// throw new ErrorDM(aExp, "Failed while processing the pFile: " + pFile);
|
||||||
|
// }
|
||||||
// Write the pFile
|
//
|
||||||
MiscUtils.writeDoc(pFile, inputList);
|
// // Fail if there was no update performed
|
||||||
|
// if (isFound == false)
|
||||||
|
// throw new ErrorDM("[" + pFile + "] The pFile does not specify a 'ClassPath' section.");
|
||||||
|
//
|
||||||
|
// // Write the pFile
|
||||||
|
// MiscUtils.writeDoc(pFile, inputList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -86,19 +86,12 @@ public final class DeployUtils {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e)
|
public void actionPerformed(ActionEvent e)
|
||||||
{
|
{
|
||||||
UpdateCheckListener listener = new UpdateCheckListener() {
|
|
||||||
@Override
|
|
||||||
public void checkForNewVersionsPerformed()
|
|
||||||
{
|
|
||||||
//autoUpdateCheckSettings.updateAutoCheckWithCurrentTime();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if(DistUtils.isDevelopersEnvironment()) {
|
if(DistUtils.isDevelopersEnvironment()) {
|
||||||
JOptionPane.showMessageDialog(parentFrame, "Cannot update tool in a developer environment.");
|
JOptionPane.showMessageDialog(parentFrame, "Cannot update tool in a developer environment.");
|
||||||
} else if (dme == null) {
|
} else if (dme == null) {
|
||||||
JOptionPane.showMessageDialog(parentFrame, "Unable to locate updates.");
|
JOptionPane.showMessageDialog(parentFrame, "Unable to locate updates.");
|
||||||
} else {
|
} else {
|
||||||
dme.checkForUpdates(listener);
|
dme.checkForUpdates(UpdateCheckListener.None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user