Various updates

This commit is contained in:
Norberto Lopez
2013-04-18 22:09:52 +00:00
parent 4d14a65a98
commit c6b5f43624
5 changed files with 132 additions and 118 deletions

View File

@@ -42,13 +42,12 @@ def buildRelease(args, buildPath):
# Create the DMG image via genisoimage
dmgFile = os.path.join(buildPath, distName + '.dmg')
# genisoimage -o Echo.6.dmg -V Echo -max-iso9660-filenames -hfs-unlock -uid 501 -guid 80 -r -apple ../test/tmp8eGdme/
# cmd = ['genisoimage', '-o', dmgFile, '-quiet', '-V', appName, '-max-iso9660-filenames', '-hfs-unlock', '-uid', '501', '-gid', '80', '-r', '-D', '-apple', tmpPath]
cmd = ['genisoimage', '-o', dmgFile, '-quiet', '-V', appName, '-max-iso9660-filenames', '-hfs-unlock', '-D', '-r', '-apple', tmpPath]
subprocess.call(cmd, stderr=subprocess.STDOUT)
# Perform cleanup: Remove the tmp folder
# shutil.rmtree(tmpPath)
shutil.rmtree(tmpPath)
@@ -272,7 +271,7 @@ def buildPListInfoShared(destFile, args):
f = open(destFile, 'wb')
writeln(f, 0, '<?xml version="1.0" encoding="UTF-8" standalone="no"?>')
writeln(f, 0, '<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">')
# writeln(f, 0, '<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">')
writeln(f, 0, '<plist version="1.0">')
writeln(f, 1, '<dict>')
@@ -333,7 +332,7 @@ def buildPListInfoStatic(destFile, args):
f = open(destFile, 'wb')
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, '<!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, 1, '<dict>')
@@ -365,9 +364,13 @@ def buildPListInfoStatic(destFile, args):
writeln(f, 3, '<array>')
for aStr in args.jvmArgs:
writeln(f, 4, '<string>' + aStr + '</string>')
# if icnsStr != None:
# writeln(f, 4, '<string>-Xdock:icon=Contents/Resources/' + icnsStr + '</string>')
writeln(f, 4, '<string>-Dapple.laf.useScreenMenuBar=true</string>')
writeln(f, 4, '<string>-Dcom.apple.macos.use-file-dialog-packages=true</string>')
writeln(f, 4, '<string>-Dcom.apple.macos.useScreenMenuBar=true</string>')
writeln(f, 4, '<string>-Dcom.apple.mrj.application.apple.menu.about.name=' + args.name + '</string>')
writeln(f, 4, '<string>-Dapple.awt.application.name=' + args.name + '</string>')
writeln(f, 4, '<string>-Djava.system.class.loader=appLauncher.RootClassLoader</string>')
writeln(f, 3, '</array>')

View File

@@ -46,7 +46,7 @@ public class DistMakerEngine
msgPanel = new MessagePanel(parentFrame);
msgPanel.setSize(450, 250);
promptPanel = new PromptPanel(parentFrame);
promptPanel.setSize(350, 150);
promptPanel.setSize(400, 200);
initialize();
}
@@ -208,11 +208,11 @@ public class DistMakerEngine
* This method will be called via reflection.
*/
@SuppressWarnings("unused")
private void checkForUpdatesWorker(final Task aTask)
private void checkForUpdatesWorker(Task aTask)
{
final List<Release> fullList;
List<Release> fullList;
Release chosenItem;
final File installPath, deltaPath;
File installPath, deltaPath;
String appName;
boolean isPass;
@@ -237,44 +237,24 @@ public class DistMakerEngine
aTask.infoAppendln("Please select the release to install...");
try
{
SwingUtilities.invokeAndWait(new Runnable()
{
@Override
public void run()
{
// Query the user, if the wish to destroy the old update
if (deltaPath.isDirectory() == true)
{
promptPanel.setTitle("Overwrite recent update?");
promptPanel.setInfo("An update has already been downloaded... If you proceed this update will be removed. Proceed?");
promptPanel.setVisibleAsModal();
if (promptPanel.isAccepted() == false)
{
aTask.abort();
return;
}
FunctionRunnable aFuncRunnable;
IoUtil.deleteDirectory(deltaPath);
}
// Query the user of the version to update to
pickVersionPanel.setConfiguration(fullList);
pickVersionPanel.setVisibleAsModal();
}
});
aFuncRunnable = new FunctionRunnable(this, "queryUserForInput", aTask, deltaPath, fullList);
SwingUtilities.invokeAndWait(aFuncRunnable);
}
catch (Exception aExp)
{
aExp.printStackTrace();
}
// pickVersionPanel.setVisibleAsModal();
// Bail if the task has been aborted
if (aTask.isActive() == false)
return;
// Retrieve the chosen item
chosenItem = pickVersionPanel.getChosenItem();
if (chosenItem == null)
{
aTask.infoAppendln("No release specified. Update has been aborted.");
aTask.abort();
return;
}
// Log the user chosen action
aTask.infoAppendln("\tRelease chosen: " + chosenItem.getVersion());
@@ -309,6 +289,24 @@ public class DistMakerEngine
aTask.setProgress(1.0);
}
/**
* Helper method to display a DistMaker information notice
*/
private void displayNotice(String aMsg)
{
// Default message
if (aMsg == null)
{
aMsg = "This application does not appear to be a properly configured DistMaker application.\n\n";
aMsg += "Please check installation configuration.";
}
// Display the message
msgPanel.setTitle("Application Updater");
msgPanel.setInfo(aMsg);
msgPanel.setVisible(true);
}
/**
* Helper method to download the specified release.
* <P>
@@ -333,13 +331,13 @@ public class DistMakerEngine
aExp.printStackTrace();
return false;
}
// Download the update catalog to the (local) delta location
catUrl = IoUtil.createURL(updateUrl.toString() + "/catalog.txt");
catalogFile = new File(destPath, "catalog.txt");
if (DistUtils.downloadFile(aTask, catUrl, catalogFile, refCredential) == false)
return false;
// Load the map of stale nodes
catalogFile = new File(DistUtils.getAppPath(), "catalog.txt");
staleMap = DistUtils.readCatalog(aTask, catalogFile, staleUrl);
@@ -373,7 +371,7 @@ public class DistMakerEngine
}
// Use the remote update copy, if we were not able to use a local stale copy
if (isPass == false)
if (isPass == false && aTask.isActive() == true)
{
isPass = updateNode.transferContentTo(aTask, refCredential, destPath);
if (isPass == true)
@@ -381,7 +379,7 @@ public class DistMakerEngine
}
// Log the failure and bail
if (isPass == false)
if (isPass == false && aTask.isActive() == true)
{
aTask.infoAppendln("Failed to download from update site.");
aTask.infoAppendln("\tSite: " + updateUrl);
@@ -390,59 +388,11 @@ public class DistMakerEngine
return false;
}
}
// Update the Info.plist file (Apple specific)
File pFile;
String errMsg;
pFile = new File(destPath.getParentFile(), "Info.plist");
if (pFile.isFile() == true)
{
errMsg = null;
if (pFile.setWritable(true) == false)
errMsg = "Failure. No writable permmisions for file: " + pFile;
else if (PropFileUtil.updateVersion(pFile, aRelease.getVersion()) == false)
errMsg = "Failure. Failed to update file: " + pFile;
if (errMsg != null)
{
aTask.infoAppendln(errMsg);
return false;
}
}
return true;
}
// Update the platform configuration files
isPass = updatePlatformConfigFiles(aTask, aRelease);
/**
* Helper method to display a DistMaker information notice
*/
private void displayNotice(String aMsg)
{
// Default message
if (aMsg == null)
{
aMsg = "This application does not appear to be a properly configured DistMaker application.\n\n";
aMsg += "Please check installation configuration.";
}
// Display the message
msgPanel.setTitle("Application Updater");
msgPanel.setInfo(aMsg);
msgPanel.setVisible(true);
return isPass;
}
/**
@@ -481,4 +431,80 @@ public class DistMakerEngine
displayNotice(msg);
}
/**
* Helper method that prompts the user for forms of input depending on the state of the App
* <P>
* This method will be called via reflection.
*/
@SuppressWarnings("unused")
private void queryUserForInput(Task aTask, File deltaPath, List<Release> fullList)
{
Release chosenItem;
// Query the user, if the wish to destroy the old update
if (deltaPath.isDirectory() == true)
{
promptPanel.setTitle("Overwrite recent update?");
promptPanel.setInfo("An update has already been downloaded... If you proceed this update will be removed. Proceed?");
promptPanel.setVisibleAsModal();
if (promptPanel.isAccepted() == false)
{
aTask.infoAppendln("Previous update will not be overwritten.");
aTask.abort();
return;
}
// Remove the retrieved update, and restore the platform configuration files to this (running) release
// It is necessary to do this, since the user may later cancel the update request and it is important to
// leave the program and configuration files in a stable state.
IoUtil.deleteDirectory(deltaPath);
updatePlatformConfigFiles(aTask, currRelease);
}
// Query the user of the version to update to
pickVersionPanel.setConfiguration(fullList);
pickVersionPanel.setVisibleAsModal();
chosenItem = pickVersionPanel.getChosenItem();
if (chosenItem == null)
{
aTask.infoAppendln("No release specified. Update has been aborted.");
aTask.abort();
return;
}
}
/**
* Helper method to update platform specific configuration files
*/
private boolean updatePlatformConfigFiles(Task aTask, Release aRelease)
{
File installPath, pFile;
String errMsg;
// Get the top level install path
installPath = DistUtils.getAppPath().getParentFile();
// Apple specific platform files
pFile = new File(installPath, "Info.plist");
if (pFile.isFile() == false)
pFile = new File(installPath.getParentFile(), "Info.plist");
if (pFile.isFile() == true)
{
errMsg = null;
if (pFile.setWritable(true) == false)
errMsg = "Failure. No writable permmisions for file: " + pFile;
else if (PropFileUtil.updateVersion(pFile, aRelease.getVersion()) == false)
errMsg = "Failure. Failed to update file: " + pFile;
if (errMsg != null)
{
aTask.infoAppendln(errMsg);
return false;
}
}
return true;
}
}

View File

@@ -124,7 +124,8 @@ public class DistUtils
// Bail if aTask is aborted
if (aTask.isActive() == false)
{
aTask.infoAppendln("Download of file: " + aFile + " has been aborted!");
aTask.infoAppendln("File transfer request has been aborted...");
aTask.infoAppendln("\tFile: " + aFile);
return false;
}
}

View File

@@ -2,15 +2,16 @@ package distMaker.apple;
import glum.io.IoUtil;
import java.io.*;
import java.io.File;
import java.io.FileOutputStream;
import javax.xml.parsers.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.*;
import org.xml.sax.SAXException;
/**
* Utility class which contains a set of methods to interact with an Apple Info.plist file.
@@ -64,20 +65,9 @@ public class PropFileUtil
return true;
}
catch (ParserConfigurationException aExp)
catch (Exception aExp)
{
aExp.printStackTrace();
// System.out.println(aExp);
}
catch (SAXException aExp)
{
aExp.printStackTrace();
// System.out.println(aExp);
}
catch (IOException aExp)
{
aExp.printStackTrace();
// System.err.println(aExp);
}
return false;
@@ -103,25 +93,19 @@ public class PropFileUtil
// Serialize the Document
oStream = new FileOutputStream(aFile);
tr.transform(new DOMSource(aDoc), new StreamResult(oStream));
return true;
}
catch (TransformerException aExp)
catch (Exception aExp)
{
aExp.printStackTrace();
// System.out.println(aExp);
return false;
}
catch (IOException aExp)
{
aExp.printStackTrace();
// System.out.println(aExp);
return false;
}
finally
{
IoUtil.forceClose(oStream);
}
return true;
return false;
}
}

Binary file not shown.