Группа :: Сети/Передача файлов
Пакет: azureus
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: azupdater-1.8.6-alt2.patch
Скачать
Скачать
org/gudy/azureus2/update/Updater.java | 518 +--------------------------------
plugin.properties | 4 +-
2 files changed, 3 insertions(+), 519 deletions(-)
diff --git a/org/gudy/azureus2/update/Updater.java b/org/gudy/azureus2/update/Updater.java
index dada757..2546400 100644
--- a/org/gudy/azureus2/update/Updater.java
+++ b/org/gudy/azureus2/update/Updater.java
@@ -30,20 +30,7 @@ import java.net.*;
public class
Updater
{
- private static String MAIN_CLASS = "org.gudy.azureus2.ui.swt.Main";
- private static final String UPDATER_JAR = "Updater.jar";
-
public static final String LOG_FILE_NAME = "update.log";
- public static final String UPDATE_PROPERTIES = "update.properties";
-
- private static String JAVA_EXEC_DIR = System.getProperty("java.home") +
- System.getProperty("file.separator") +
- "bin" +
- System.getProperty("file.separator");
-
-
- protected static String APPLICATION_NAME = "Azureus";
- protected static String APPLICATION_CMD = null;
// change these and you'll need to change the UpdateInstaller !!!!
@@ -184,110 +171,12 @@ Updater
return;
- }else{
-
- if ( isWindows ){
-
- // 2.2.0.0 shagged restart. unicode still not working. we end up with a user dir
- // of, say, C:\Documents and Settings\t?stt?st\Application Data\Azureus
- // with the unicode chars replaced with something unspeakable
-
- try{
- File up_file = new File( user_path );
-
- if ( !up_file.exists()){
-
- log.println( "user path not found, attempting to fix" );
-
- // see if we can patch things up
-
- String user_home = System.getProperty( "user.home" );
-
- File az_config = findConfig(new File( user_home ));
-
- if ( az_config != null ){
-
- log.println( " found config in " + az_config.toString() + ", using parent as user dir" );
-
- user_path = az_config.getParent();
- }
-
- }
- }catch( Throwable e ){
-
- e.printStackTrace( log );
- }
- }
}
waitForAzureusClose( log );
FileInputStream fis = null;
- try{
-
- File props_file = new File( user_path, UPDATE_PROPERTIES );
-
- if ( props_file.exists()){
-
- update_properties.load( new FileInputStream( props_file ));
-
- Iterator it = update_properties.keySet().iterator();
-
- log.println("Loaded 'update.properties'" );
-
- while( it.hasNext()){
-
- String key = (String)it.next();
-
- log.println( " " + key + " = " + update_properties.get(key));
- }
-
- String app_name = (String)update_properties.get( "app_name" );
-
- if ( app_name != null && app_name.trim().length() > 0 ){
-
- APPLICATION_NAME = app_name.trim();
- }
-
- String app_entry = (String)update_properties.get( "app_entry" );
-
- if ( app_entry != null && app_entry.trim().length() > 0 ){
-
- MAIN_CLASS = app_entry.trim();
- }
-
- String app_cmd = (String)update_properties.get( "app_cmd" );
-
- if ( app_cmd != null && app_cmd.trim().length() > 0 ){
-
- APPLICATION_CMD = app_cmd.trim();
- }
-
- }else{
-
- log.println( "No update.properties found" );
-
- }
- }catch( Throwable e ){
-
- log.println( "Failed to read update.properties" );
-
- e.printStackTrace( log );
-
- }finally{
- if ( fis != null ){
-
- try{
- fis.close();
-
- }catch( Throwable e ){
-
- e.printStackTrace( log );
- }
- }
- }
-
File update_dir = new File( user_path, UPDATE_DIR );
File[] inst_dirs = update_dir.listFiles();
@@ -317,79 +206,6 @@ Updater
}
}finally{
- if ( do_restart ){
-
- if ( log != null ){
-
- log.println( "Restarting " + APPLICATION_NAME );
- }
-
- String vendor = System.getProperty( "java.vm.vendor" );
-
- Vector vm_args = new Vector();
-
- // only for Sun JVM
-
- if ( vendor != null && vendor.toLowerCase().startsWith( "sun" )){
-
- String max_mem = (String)update_properties.get( "max_mem" );
-
- // for previous versions we default to 128m
-
- long max_mem_l = 0;
-
- if ( max_mem == null ){
-
- max_mem_l = 128*1024*1024;
-
- }else{
-
- try{
-
- max_mem_l = Long.parseLong( max_mem );
-
- }catch( Throwable e ){
-
- e.printStackTrace( log );
- }
-
- }
-
- // don't allow < 64m to be specified
-
- if ( max_mem_l < 64*1024*1024 ){
-
- max_mem_l = 64*1024*1024;
- }
-
- vm_args.add( "-Xmx" + (max_mem_l/(1024*1024)) + "m" );
- }
-
- vm_args.add( "-Duser.dir=\"" + app_path + "\"" );
-
- if ( config_override.length() > 0 ){
-
- vm_args.add( "-Dazureus.config.path=\"" + config_override + "\"" );
- }
-
- String[] props = new String[vm_args.size()];
-
- vm_args.toArray( props );
-
- restartAzureus( log, MAIN_CLASS, props, new String[0] );
-
- if ( log != null ){
-
- log.println( "Restart initiated" );
- }
- }else{
-
- if ( log != null ){
-
- log.println( "Not restarting " + APPLICATION_NAME );
- }
- }
-
if ( log != null ){
log.close();
@@ -397,39 +213,6 @@ Updater
}
}
- protected File
- findConfig(
- File dir )
- {
- File[] files = dir.listFiles();
-
- if ( files != null ){
-
- for (int i=0;i<files.length;i++){
-
- File f = files[i];
-
- if ( f.isDirectory()){
-
- File res = findConfig( f );
-
- if ( res != null ){
-
- return( res );
- }
- }else{
-
- if ( f.getName().equals( "azureus.config" )){
-
- return( f );
- }
- }
- }
- }
-
- return( null );
- }
-
protected void
processUpdate(
PrintWriter log,
@@ -789,269 +572,12 @@ Updater
}
- private String
- getClassPath()
- {
- String _classPath = System.getProperty("java.class.path");
- // we've got to remove Updater.jar from the classpath else if there's a
- // updater to Updater.jar we're stuffed
-
- StringTokenizer tok = new StringTokenizer( _classPath, System.getProperty("path.separator"));
-
- String classPath = "";
-
- while( tok.hasMoreTokens()){
-
- String bit = tok.nextToken();
-
- if ( !bit.endsWith( File.separator + UPDATER_JAR )){
-
- classPath += (classPath.length()==0?"":System.getProperty("path.separator")) + bit;
- }
- }
-
- return( "-classpath \"" + classPath + "\" " );
- }
-
- private boolean
- win32NativeRestart(
- PrintWriter log,
- String exec )
- {
- return( false );
- }
-
- public static final String OSName = System.getProperty("os.name");
-
- public static final boolean isOSX = OSName.toLowerCase().startsWith("mac os");
- public static final boolean isWindows = OSName.toLowerCase().startsWith("windows");
- // If it isn't windows or osx, it's most likely an unix flavor
- public static final boolean isUnix = !isWindows && !isOSX;
-
-
-
// ****************** This code is copied into Restarter / Updater so make changes there too !!!
//Beware that for OSX no SPECIAL Java will be used with
//This method.
- public void
- restartAzureus(
- PrintWriter log,
- String mainClass,
- String[] properties,
- String[] parameters )
- {
- if(isOSX){
-
- restartAzureus_OSX(log,mainClass,properties,parameters);
-
- }else if( isUnix ){
-
- restartAzureus_Linux(log,mainClass,properties,parameters);
-
- }else{
-
- restartAzureus_win32(log,mainClass,properties,parameters);
- }
- }
-
- private void
- restartAzureus_win32(
- PrintWriter log,
- String mainClass,
- String[] properties,
- String[] parameters)
- {
-
- String exec;
-
- if ( APPLICATION_CMD != null ){
-
- exec = APPLICATION_CMD;
-
- }else{
-
- //Classic restart way using Runtime.exec directly on java(w)
- exec = "\"" + JAVA_EXEC_DIR + "javaw\" "+ getClassPath() + getLibraryPath();
-
- for (int i=0;i<properties.length;i++){
- exec += properties[i] + " ";
- }
-
- exec += mainClass;
-
- for(int i = 0 ; i < parameters.length ; i++) {
- exec += " \"" + parameters[i] + "\"";
- }
- }
-
- if ( log != null ){
- log.println( " " + exec );
- }
-
- if ( !win32NativeRestart( log, exec )){
-
- javaSpawn(log, exec);
- }
- }
-
-
- private boolean
- javaSpawn(
- PrintWriter log,
- String execString)
- {
- try {
- // hmm, try java method - this WILL inherit handles but might work :)
-
- log.println("Using java spawn");
-
- //NOTE: no logging done here, as we need the method to return right away, before the external process completes
- Process p = Runtime.getRuntime().exec(execString);
-
- return true;
- } catch (Throwable t) {
-
- t.printStackTrace();
- return false;
- }
- }
-
- private void
- restartAzureus_OSX(
- PrintWriter log,
- String mainClass,
- String[] properties,
- String[] parameters)
- {
-
- String bundle_path = System.getProperty("user.dir") + "/" + APPLICATION_NAME + ".app";
- bundle_path = new File( bundle_path ).getAbsolutePath();
-
- String exec;
-
- if( APPLICATION_CMD != null ) {
-
- log.println( "Updater: app_cmd key found: " + APPLICATION_CMD );
-
- exec = APPLICATION_CMD;
- }
- else {
- //THIS SHOULD NEVER GET CALLED 2306 ONWARDS
-
- exec = "\"" +bundle_path+ "/Contents/MacOS/java_swt\" " + getClassPath() +getLibraryPath();
-
- for (int i=0;i<properties.length;i++){
- exec += properties[i] + " ";
- }
-
- exec += mainClass;
-
- for(int i = 0 ; i < parameters.length ; i++) {
- exec += " \"" + parameters[i] + "\"";
- }
- }
-
- runExternalCommandViaUnixShell( log, exec );
- }
-
-
-
- private int getUnixScriptVersion(PrintWriter log) {
- String sVersion = System.getProperty("azureus.script.version", "0");
- int version = 0;
- try {
- version = Integer.parseInt(sVersion);
- } catch (Throwable t) {
-
- log.println( "getScriptVersion failed for '" + sVersion + "'" );
- t.printStackTrace( log );
- }
-
- log.println( "getScriptVersion -> " + version );
- return version;
- }
-
- private void
- restartAzureus_Linux(
- PrintWriter log,
- String mainClass,
- String[] properties,
- String[] parameters)
- {
- if (getUnixScriptVersion( log ) >= 1) {
- // Already setup for restart by core and script
-
- log.println( "restartLinux: script performing restart");
-
- return;
- }
-
- String exec = "\"" + JAVA_EXEC_DIR + "java\" " + getClassPath() + getLibraryPath();
-
- for (int i=0;i<properties.length;i++){
- exec += properties[i] + " ";
- }
-
- exec += mainClass ;
-
- for(int i = 0 ; i < parameters.length ; i++) {
- exec += " \"" + parameters[i] + "\"";
- }
-
- runExternalCommandViaUnixShell( log, exec );
- }
-
-
-
- private String
- getLibraryPath()
- {
- String libraryPath = System.getProperty("java.library.path");
-
- if ( libraryPath == null ){
-
- libraryPath = "";
-
- }else{
-
- // remove any quotes from the damn thing
-
- String temp = "";
-
- for (int i=0;i<libraryPath.length();i++){
-
- char c = libraryPath.charAt(i);
-
- if ( c != '"' ){
-
- temp += c;
- }
- }
-
- libraryPath = temp;
-
- // remove trailing separator chars if they exist as they stuff up
- // the following "
-
- while( libraryPath.endsWith(File.separator)){
-
- libraryPath = libraryPath.substring( 0, libraryPath.length()-1 );
- }
-
- if ( libraryPath.length() > 0 ){
-
- libraryPath = "-Djava.library.path=\"" + libraryPath + "\" ";
- }
- }
-
- return( libraryPath );
- }
-
-
-
private void logStream(String message,InputStream stream,PrintWriter log) {
BufferedReader br = new BufferedReader (new InputStreamReader(stream));
String line = null;
@@ -1083,24 +609,6 @@ Updater
}
- private Process runExternalCommandLogged( PrintWriter log, String command ) { //NOTE: will not return until external command process has completed
- log.println("About to execute: U:[" +command+ "]" );
-
- try {
- Process runner = Runtime.getRuntime().exec( command );
- runner.waitFor();
- logStream( "runtime.exec() output:", runner.getInputStream(), log);
- logStream( "runtime.exec() error:", runner.getErrorStream(), log);
- return runner;
- }
- catch( Throwable t ) {
- log.println( t.getMessage() != null ? t.getMessage() : "<null>" );
- log.println( t );
- t.printStackTrace( log );
- return null;
- }
- }
-
private Process runExternalCommandsLogged( PrintWriter log, String[] commands ) { //NOTE: will not return until external command process has completed
String cmd = "About to execute: U:[";
for( int i=0; i < commands.length; i++ ) {
@@ -1127,28 +635,4 @@ Updater
}
- private void runExternalCommandViaUnixShell( PrintWriter log, String command ) {
- String[] to_run = new String[3];
- to_run[0] = "/bin/sh";
- to_run[1] = "-c";
- to_run[2] = command;
-
- if( log != null ) log.println("Executing: U:[" +to_run[0]+ " " +to_run[1]+ " " +to_run[2]+ "]" );
-
- try {
- //NOTE: no logging done here, as we need the method to return right away, before the external process completes
- Runtime.getRuntime().exec( to_run );
- }
- catch(Throwable t) {
- if( log != null ) {
- log.println( t.getMessage() != null ? t.getMessage() : "<null>" );
- log.println( t );
- t.printStackTrace( log );
- }
- else {
- t.printStackTrace();
- }
- }
- }
-
- }
\ No newline at end of file
+ }
diff --git a/plugin.properties b/plugin.properties
index e485c9e..ae6718f 100644
--- a/plugin.properties
+++ b/plugin.properties
@@ -1,3 +1,3 @@
-plugin.class=org.gudy.azureus2.update.UpdaterUpdateChecker;org.gudy.azureus2.update.UpdaterPatcher
-plugin.name=Azureus Update Support;Azureus Updater Support Patcher
+plugin.class=org.gudy.azureus2.update.UpdaterUpdateChecker
+plugin.name=Azureus Update Support
plugin.version=1.8.6