From: <fwi...@us...> - 2008-09-06 20:07:27
|
Revision: 5296 http://jython.svn.sourceforge.net/jython/?rev=5296&view=rev Author: fwierzbicki Date: 2008-09-06 20:07:25 +0000 (Sat, 06 Sep 2008) Log Message: ----------- Update installer as installer25 did. In part: uses jython-complete.jar, removes jythonc. Modified Paths: -------------- trunk/installer/src/java/org/python/util/install/DirectorySelectionPage.java trunk/installer/src/java/org/python/util/install/JarInstaller.java trunk/installer/src/java/org/python/util/install/StartScriptGenerator.java Modified: trunk/installer/src/java/org/python/util/install/DirectorySelectionPage.java =================================================================== --- trunk/installer/src/java/org/python/util/install/DirectorySelectionPage.java 2008-09-06 19:34:07 UTC (rev 5295) +++ trunk/installer/src/java/org/python/util/install/DirectorySelectionPage.java 2008-09-06 20:07:25 UTC (rev 5296) @@ -142,7 +142,7 @@ File defaultDirectory = null; File parentDirectory = new File(directory); if (parentDirectory.exists() && parentDirectory.isDirectory()) { - String jythonSubDirectoryName = "jython" + _jarInfo.getVersion(); + String jythonSubDirectoryName = "jython" + (_jarInfo.getVersion()).replaceAll("\\+", ""); defaultDirectory = new File(parentDirectory, jythonSubDirectoryName); } return defaultDirectory; @@ -189,4 +189,4 @@ } } -} \ No newline at end of file +} Modified: trunk/installer/src/java/org/python/util/install/JarInstaller.java =================================================================== --- trunk/installer/src/java/org/python/util/install/JarInstaller.java 2008-09-06 19:34:07 UTC (rev 5295) +++ trunk/installer/src/java/org/python/util/install/JarInstaller.java 2008-09-06 20:07:25 UTC (rev 5296) @@ -17,7 +17,7 @@ * moment). */ public class JarInstaller { - public static final String JYTHON_JAR = "jython.jar"; + public static final String JYTHON_JAR = "jython-complete.jar"; private static final String PATH_SEPARATOR = "/"; private static final String LIB_NAME_SEP = "Lib" + PATH_SEPARATOR; @@ -52,6 +52,8 @@ List coreLibFiles = new ArrayList(); if (!installationType.installSources()) { excludeDirs.add("src"); + excludeDirs.add("grammar"); + excludeDirs.add("extlibs"); } if (!installationType.installDocumentation()) { excludeDirs.add("Doc"); @@ -93,6 +95,10 @@ exclude = true; } } + // exclude build.xml when not installing source + if (!installationType.installSources() && zipEntryName.equals("build.xml")) + exclude = true; + // handle exclusion of core Lib files if (!exclude) { exclude = shouldExcludeFile(installationType, coreLibFiles, zipEntry, zipEntryName); @@ -133,6 +139,7 @@ _progressListener.progressStartScripts(); StartScriptGenerator generator = new StartScriptGenerator(targetDirectory, javaHome); generator.generateStartScripts(); + StandalonePackager.emptyDirectory(new File(targetDirectory, "bin"), null); } else { _progressListener.progressStandalone(); File jythonJar = new File(targetDirectory, JYTHON_JAR); @@ -220,6 +227,8 @@ coreLibFiles.add("javapath.py"); coreLibFiles.add("jreload.py"); coreLibFiles.add("marshal.py"); + coreLibFiles.add("os.py"); + coreLibFiles.add("posixpath.py"); coreLibFiles.add("random.py"); coreLibFiles.add("re.py"); coreLibFiles.add("site.py"); @@ -228,6 +237,7 @@ coreLibFiles.add("sre_compile.py"); coreLibFiles.add("sre_constants.py"); coreLibFiles.add("sre_parse.py"); + coreLibFiles.add("stat.py"); coreLibFiles.add("string.py"); coreLibFiles.add("zipfile.py"); coreLibFiles.add("zlib.py"); @@ -258,4 +268,4 @@ return exclude; } -} \ No newline at end of file +} Modified: trunk/installer/src/java/org/python/util/install/StartScriptGenerator.java =================================================================== --- trunk/installer/src/java/org/python/util/install/StartScriptGenerator.java 2008-09-06 19:34:07 UTC (rev 5295) +++ trunk/installer/src/java/org/python/util/install/StartScriptGenerator.java 2008-09-06 20:07:25 UTC (rev 5296) @@ -1,6 +1,7 @@ package org.python.util.install; import java.io.File; +import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.text.MessageFormat; @@ -17,8 +18,6 @@ private final static String JYTHON = "jython"; private final static String JYTHON_BAT = "jython.bat"; - private final static String JYTHONC = "jythonc"; - private final static String JYTHONC_BAT = "jythonc.bat"; private final static String JYTHON_JAR = JarInstaller.JYTHON_JAR; static { @@ -73,7 +72,6 @@ protected final void generateStartScripts() throws IOException { generateJythonScript(); - generateJythoncScript(); } private final void generateJythonScript() throws IOException { @@ -90,43 +88,18 @@ } } - private final void generateJythoncScript() throws IOException { - switch (getFlavour()) { - case BOTH_FLAVOUR: - writeToFile(JYTHONC_BAT, getJythoncScript(WINDOWS_FLAVOUR)); - makeExecutable(writeToFile(JYTHONC, getJythoncScript(BOTH_FLAVOUR))); - break; - case WINDOWS_FLAVOUR: - writeToFile(JYTHONC_BAT, getJythoncScript(WINDOWS_FLAVOUR)); - break; - default: - makeExecutable(writeToFile(JYTHONC, getJythoncScript(UNIX_FLAVOUR))); - } - } - /** * only <code>protected</code> for unit test use */ protected final String getJythonScript(int flavour) throws IOException { if (flavour == WINDOWS_FLAVOUR) { - return getStartScript(getWindowsJythonTemplate()); + return getStartScript(getWindowsJythonTemplate()) + readFromFile(JYTHON_BAT); } else { - return getStartScript(getUnixJythonTemplate(flavour)); + return getStartScript(getUnixJythonTemplate()) + readFromFile(JYTHON); } } /** - * only <code>protected</code> for unit test use - */ - protected final String getJythoncScript(int flavour) throws IOException { - if (flavour == WINDOWS_FLAVOUR) { - return getStartScript(getWindowsJythoncTemplate()); - } else { - return getStartScript(getUnixJythoncTemplate()); - } - } - - /** * These placeholders are valid for all private methods: * * {0} : current date <br> @@ -150,8 +123,9 @@ */ private String getWindowsJythonTemplate() { StringBuffer buffer = getWindowsHeaderTemplate(); - buffer.append("\"{2}\\bin\\java.exe\" -Dpython.home=\"{3}\" -Dpython.executable=\"%0\" -classpath \"{3}\\" + JYTHON_JAR - + ";%CLASSPATH%\" org.python.util.jython %ARGS%" + WIN_CR_LF); + buffer.append("set JAVA_HOME=\"{2}\"" + WIN_CR_LF); + buffer.append("set JYTHON_HOME=\"{3}\"" + WIN_CR_LF); + buffer.append(WIN_CR_LF); return buffer.toString(); } @@ -160,32 +134,12 @@ * * @see getStartScript */ - private String getWindowsJythoncTemplate() { - StringBuffer buffer = getWindowsHeaderTemplate(); - buffer.append("\"{3}\\jython.bat\" \"{3}\\Tools\\jythonc\\jythonc.py\" %ARGS%" + WIN_CR_LF); - return buffer.toString(); - } - - /** - * placeholders: - * - * @see getStartScript - */ private StringBuffer getWindowsHeaderTemplate() { StringBuffer buffer = new StringBuffer(1000); buffer.append("@echo off" + WIN_CR_LF); buffer.append("rem This file was generated by the Jython installer" + WIN_CR_LF); buffer.append("rem Created on {0} by {1}" + WIN_CR_LF); buffer.append(WIN_CR_LF); - buffer.append("set ARGS=" + WIN_CR_LF); - buffer.append(WIN_CR_LF); - buffer.append(":loop" + WIN_CR_LF); - buffer.append("if [%1] == [] goto end" + WIN_CR_LF); - buffer.append(" set ARGS=%ARGS% %1" + WIN_CR_LF); - buffer.append(" shift" + WIN_CR_LF); - buffer.append(" goto loop" + WIN_CR_LF); - buffer.append(":end" + WIN_CR_LF); - buffer.append(WIN_CR_LF); return buffer; } @@ -194,11 +148,11 @@ * * @see getStartScript */ - private String getUnixJythonTemplate(int flavour) { + private String getUnixJythonTemplate() { StringBuffer buffer = getUnixHeaderTemplate(); - buffer.append("CP=\"{3}/" + JYTHON_JAR + "\"\n"); - buffer.append("if [ ! -z \"$CLASSPATH\" ]\nthen\n CP=$CP:$CLASSPATH\nfi\n"); - buffer.append("\"{2}/bin/java\" -Dpython.home=\"{3}\" -Dpython.executable=\"$0\" -classpath \"$CP\" org.python.util.jython \"$@\"\n"); + buffer.append("JAVA_HOME=\"{2}\"\n"); + buffer.append("JYTHON_HOME=\"{3}\"\n"); + buffer.append("\n"); return buffer.toString(); } @@ -207,20 +161,9 @@ * * @see getStartScript */ - private String getUnixJythoncTemplate() { - StringBuffer buffer = getUnixHeaderTemplate(); - buffer.append("\"{3}/jython\" \"{3}/Tools/jythonc/jythonc.py\" \"$@\"\n"); - return buffer.toString(); - } - - /** - * placeholders: - * - * @see getStartScript - */ private StringBuffer getUnixHeaderTemplate() { StringBuffer buffer = new StringBuffer(1000); - buffer.append("#!/bin/sh\n"); + buffer.append("#!/usr/bin/env bash\n"); buffer.append("\n"); buffer.append("# This file was generated by the Jython installer\n"); buffer.append("# Created on {0} by {1}\n"); @@ -230,6 +173,24 @@ /** * @param fileName The short file name, e.g. JYTHON_BAT + * + * @throws IOException + */ + private String readFromFile(String fileName) throws IOException { + File file = new File(new File(_targetDirectory, "bin"), fileName); + FileReader fileReader = new FileReader(file); + StringBuffer sb = new StringBuffer(); + char[] b = new char[8192]; + int n; + + while ( (n = fileReader.read(b)) > 0) { + sb.append(b, 0, n); + } + return sb.toString(); + } + + /** + * @param fileName The short file name, e.g. JYTHON_BAT * @param contents * * @throws IOException This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |