Added support for conditionally including or excluding parameters based on
the client operating system.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: Application.java,v 1.23 2004/07/30 00:27:39 mdb Exp $
|
// $Id: Application.java,v 1.24 2004/07/30 02:23:52 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.getdown.data;
|
package com.threerings.getdown.data;
|
||||||
|
|
||||||
@@ -166,20 +166,20 @@ public class Application
|
|||||||
* @exception IOException thrown if there is an error reading the file
|
* @exception IOException thrown if there is an error reading the file
|
||||||
* or an error encountered during its parsing.
|
* or an error encountered during its parsing.
|
||||||
*/
|
*/
|
||||||
public UpdateInterface init ()
|
public UpdateInterface init (boolean checkPlatform)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
// parse our configuration file
|
// parse our configuration file
|
||||||
HashMap cdata = null;
|
HashMap cdata = null;
|
||||||
try {
|
try {
|
||||||
cdata = ConfigUtil.parseConfig(_config);
|
cdata = ConfigUtil.parseConfig(_config, checkPlatform);
|
||||||
} catch (FileNotFoundException fnfe) {
|
} catch (FileNotFoundException fnfe) {
|
||||||
// thanks to funny windows bullshit, we have to do this backup
|
// thanks to funny windows bullshit, we have to do this backup
|
||||||
// file fiddling in case we got screwed while updating our
|
// file fiddling in case we got screwed while updating our
|
||||||
// very critical getdown config file
|
// very critical getdown config file
|
||||||
File cbackup = getLocalPath(CONFIG_FILE + "_old");
|
File cbackup = getLocalPath(CONFIG_FILE + "_old");
|
||||||
if (cbackup.exists()) {
|
if (cbackup.exists()) {
|
||||||
cdata = ConfigUtil.parseConfig(cbackup);
|
cdata = ConfigUtil.parseConfig(cbackup, checkPlatform);
|
||||||
} else {
|
} else {
|
||||||
throw fnfe;
|
throw fnfe;
|
||||||
}
|
}
|
||||||
@@ -516,7 +516,7 @@ public class Application
|
|||||||
// if the new copy validates, reinitialize ourselves;
|
// if the new copy validates, reinitialize ourselves;
|
||||||
// otherwise report baffling hoseage
|
// otherwise report baffling hoseage
|
||||||
if (_digest.validateResource(crsrc, null)) {
|
if (_digest.validateResource(crsrc, null)) {
|
||||||
init();
|
init(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: Digest.java,v 1.5 2004/07/28 01:28:55 mdb Exp $
|
// $Id: Digest.java,v 1.6 2004/07/30 02:23:52 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.getdown.data;
|
package com.threerings.getdown.data;
|
||||||
|
|
||||||
@@ -41,7 +41,8 @@ public class Digest
|
|||||||
{
|
{
|
||||||
// parse and validate our digest file contents
|
// parse and validate our digest file contents
|
||||||
StringBuffer data = new StringBuffer();
|
StringBuffer data = new StringBuffer();
|
||||||
List pairs = ConfigUtil.parsePairs(new File(appdir, DIGEST_FILE));
|
File dfile = new File(appdir, DIGEST_FILE);
|
||||||
|
List pairs = ConfigUtil.parsePairs(dfile, false);
|
||||||
for (Iterator iter = pairs.iterator(); iter.hasNext(); ) {
|
for (Iterator iter = pairs.iterator(); iter.hasNext(); ) {
|
||||||
String[] pair = (String[])iter.next();
|
String[] pair = (String[])iter.next();
|
||||||
if (pair[0].equals(DIGEST_FILE)) {
|
if (pair[0].equals(DIGEST_FILE)) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: Getdown.java,v 1.23 2004/07/30 00:27:19 mdb Exp $
|
// $Id: Getdown.java,v 1.24 2004/07/30 02:23:52 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.getdown.launcher;
|
package com.threerings.getdown.launcher;
|
||||||
|
|
||||||
@@ -78,12 +78,12 @@ public class Getdown extends Thread
|
|||||||
try {
|
try {
|
||||||
// first parses our application deployment file
|
// first parses our application deployment file
|
||||||
try {
|
try {
|
||||||
_ifc = _app.init();
|
_ifc = _app.init(true);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
Log.warning("Failed to parse 'getdown.txt': " + ioe);
|
Log.warning("Failed to parse 'getdown.txt': " + ioe);
|
||||||
_app.attemptRecovery(this);
|
_app.attemptRecovery(this);
|
||||||
// and re-initalize
|
// and re-initalize
|
||||||
_ifc = _app.init();
|
_ifc = _app.init(true);
|
||||||
// now force our UI to be recreated with the updated info
|
// now force our UI to be recreated with the updated info
|
||||||
createInterface(true);
|
createInterface(true);
|
||||||
}
|
}
|
||||||
@@ -177,7 +177,7 @@ public class Getdown extends Thread
|
|||||||
// finally update our metadata files...
|
// finally update our metadata files...
|
||||||
_app.updateMetadata();
|
_app.updateMetadata();
|
||||||
// ...and reinitialize the application
|
// ...and reinitialize the application
|
||||||
_ifc = _app.init();
|
_ifc = _app.init(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: Differ.java,v 1.5 2004/07/28 02:25:49 mdb Exp $
|
// $Id: Differ.java,v 1.6 2004/07/30 02:23:52 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.getdown.tools;
|
package com.threerings.getdown.tools;
|
||||||
|
|
||||||
@@ -74,13 +74,13 @@ public class Differ
|
|||||||
}
|
}
|
||||||
|
|
||||||
Application oapp = new Application(ovdir);
|
Application oapp = new Application(ovdir);
|
||||||
oapp.init();
|
oapp.init(false);
|
||||||
ArrayList orsrcs = new ArrayList();
|
ArrayList orsrcs = new ArrayList();
|
||||||
orsrcs.addAll(oapp.getCodeResources());
|
orsrcs.addAll(oapp.getCodeResources());
|
||||||
orsrcs.addAll(oapp.getResources());
|
orsrcs.addAll(oapp.getResources());
|
||||||
|
|
||||||
Application napp = new Application(nvdir);
|
Application napp = new Application(nvdir);
|
||||||
napp.init();
|
napp.init(false);
|
||||||
ArrayList nrsrcs = new ArrayList();
|
ArrayList nrsrcs = new ArrayList();
|
||||||
nrsrcs.addAll(napp.getCodeResources());
|
nrsrcs.addAll(napp.getCodeResources());
|
||||||
nrsrcs.addAll(napp.getResources());
|
nrsrcs.addAll(napp.getResources());
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: DigesterTask.java,v 1.2 2004/07/13 17:43:52 mdb Exp $
|
// $Id: DigesterTask.java,v 1.3 2004/07/30 02:23:52 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.getdown.tools;
|
package com.threerings.getdown.tools;
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ public class DigesterTask extends Task
|
|||||||
// create our application and instruct it to parse its business
|
// create our application and instruct it to parse its business
|
||||||
Application app = new Application(_appdir);
|
Application app = new Application(_appdir);
|
||||||
try {
|
try {
|
||||||
app.init();
|
app.init(false);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
throw new BuildException("Error parsing getdown.txt: " +
|
throw new BuildException("Error parsing getdown.txt: " +
|
||||||
ioe.getMessage(), ioe);
|
ioe.getMessage(), ioe);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ConfigUtil.java,v 1.2 2004/07/02 15:22:49 mdb Exp $
|
// $Id: ConfigUtil.java,v 1.3 2004/07/30 02:23:52 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.getdown.util;
|
package com.threerings.getdown.util;
|
||||||
|
|
||||||
@@ -17,6 +17,8 @@ import java.util.List;
|
|||||||
import com.samskivert.io.StreamUtil;
|
import com.samskivert.io.StreamUtil;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
|
import com.threerings.getdown.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a file containing key/value pairs and returns a {@link HashMap}
|
* Parses a file containing key/value pairs and returns a {@link HashMap}
|
||||||
* with the values. Keys may be repeated, in which case they will be made
|
* with the values. Keys may be repeated, in which case they will be made
|
||||||
@@ -31,10 +33,12 @@ public class ConfigUtil
|
|||||||
* @return a list of <code>String[]</code> instances containing the
|
* @return a list of <code>String[]</code> instances containing the
|
||||||
* key/value pairs in the order they were parsed from the file.
|
* key/value pairs in the order they were parsed from the file.
|
||||||
*/
|
*/
|
||||||
public static List parsePairs (File config)
|
public static List parsePairs (File config, boolean checkPlatform)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
ArrayList pairs = new ArrayList();
|
ArrayList pairs = new ArrayList();
|
||||||
|
String osname = System.getProperty("os.name");
|
||||||
|
osname = (osname == null) ? "" : osname.toLowerCase();
|
||||||
|
|
||||||
// parse our configuration file
|
// parse our configuration file
|
||||||
FileInputStream fin = null;
|
FileInputStream fin = null;
|
||||||
@@ -67,6 +71,35 @@ public class ConfigUtil
|
|||||||
pair[1] = "";
|
pair[1] = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// allow a value to have a [Linux]
|
||||||
|
if (pair[1].startsWith("[")) {
|
||||||
|
cidx = pair[1].indexOf("]");
|
||||||
|
if (cidx == -1) {
|
||||||
|
Log.warning("Bogus platform specifier [key=" + pair[0] +
|
||||||
|
", value=" + pair[1] + "].");
|
||||||
|
} else {
|
||||||
|
String platform = pair[1].substring(1, cidx);
|
||||||
|
platform = platform.trim().toLowerCase();
|
||||||
|
pair[1] = pair[1].substring(cidx+1).trim();
|
||||||
|
if (checkPlatform) {
|
||||||
|
if (platform.startsWith("!")) {
|
||||||
|
platform = platform.substring(1);
|
||||||
|
if (osname.indexOf(platform) != -1) {
|
||||||
|
Log.info("Skipping [platform=!" + platform +
|
||||||
|
", key=" + pair[0] +
|
||||||
|
", value=" + pair[1] + "].");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else if (osname.indexOf(platform) == -1) {
|
||||||
|
Log.info("Skipping [platform=" + platform +
|
||||||
|
", key=" + pair[0] +
|
||||||
|
", value=" + pair[1] + "].");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pairs.add(pair);
|
pairs.add(pair);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,10 +118,10 @@ public class ConfigUtil
|
|||||||
* of strings if more than one key/value pair in the config file was
|
* of strings if more than one key/value pair in the config file was
|
||||||
* associated with the same key.
|
* associated with the same key.
|
||||||
*/
|
*/
|
||||||
public static HashMap parseConfig (File config)
|
public static HashMap parseConfig (File config, boolean checkPlatform)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
List pairs = parsePairs(config);
|
List pairs = parsePairs(config, checkPlatform);
|
||||||
HashMap data = new HashMap();
|
HashMap data = new HashMap();
|
||||||
|
|
||||||
for (Iterator iter = pairs.iterator(); iter.hasNext(); ) {
|
for (Iterator iter = pairs.iterator(); iter.hasNext(); ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user