[tor-commits] [orbot/master] more updates to install clean-up process
n8fr8 at torproject.org
n8fr8 at torproject.org
Tue Apr 8 20:10:39 UTC 2014
commit 60a79a2ae09703e534faa425a81b2144cdfc9d4d
Author: Nathan Freitas <nathan at freitas.net>
Date: Tue Apr 8 16:09:04 2014 -0400
more updates to install clean-up process
---
external/.tx/config | 6 ++++
.../android/service/TorResourceInstaller.java | 38 +++++++++++++++-----
src/org/torproject/android/service/TorService.java | 7 ++++
.../android/service/TorServiceConstants.java | 8 ++---
4 files changed, 46 insertions(+), 13 deletions(-)
diff --git a/external/.tx/config b/external/.tx/config
index 7cec373..efc0cc8 100644
--- a/external/.tx/config
+++ b/external/.tx/config
@@ -8,3 +8,9 @@ host = https://www.transifex.com
source_file = ../res/values/strings.xml
source_lang = en
+[orbot.DESCRIPTION]
+file_filter=../docs/play/description-<lang>.txt
+host = https://www.transifex.com
+source_file = ../docs/play/description.txt
+source_lang = en
+
diff --git a/src/org/torproject/android/service/TorResourceInstaller.java b/src/org/torproject/android/service/TorResourceInstaller.java
index ff1f2b0..d17cd70 100644
--- a/src/org/torproject/android/service/TorResourceInstaller.java
+++ b/src/org/torproject/android/service/TorResourceInstaller.java
@@ -37,6 +37,25 @@ public class TorResourceInstaller implements TorServiceConstants {
this.context = context;
}
+ public void deleteDirectory(File file) {
+ if( file.exists() ) {
+ if (file.isDirectory()) {
+ File[] files = file.listFiles();
+ for(int i=0; i<files.length; i++) {
+ if(files[i].isDirectory()) {
+ deleteDirectory(files[i]);
+ }
+ else {
+ files[i].delete();
+ }
+ }
+ }
+ file.delete();
+ }
+ }
+
+ private final static String COMMAND_RM_FORCE = "rm -f ";
+
//
/*
* Extract the Tor resources from the APK file using ZIP
@@ -47,43 +66,45 @@ public class TorResourceInstaller implements TorServiceConstants {
InputStream is;
File outFile;
+ deleteDirectory(installFolder);
+
installFolder.mkdirs();
Shell shell = Shell.startShell(new ArrayList<String>(),installFolder.getAbsolutePath());
is = context.getResources().openRawResource(R.raw.torrc);
outFile = new File(installFolder, TORRC_ASSET_KEY);
- shell.add(new SimpleCommand("rm " + outFile.getAbsolutePath())).waitForFinish();
+ shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, false);
is = context.getResources().openRawResource(R.raw.torrctether);
outFile = new File(installFolder, TORRC_TETHER_KEY);
- shell.add(new SimpleCommand("rm " + outFile.getAbsolutePath())).waitForFinish();
+ shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is, outFile, false, false);
is = context.getResources().openRawResource(R.raw.privoxy_config);
outFile = new File(installFolder, PRIVOXYCONFIG_ASSET_KEY);
- shell.add(new SimpleCommand("rm " + outFile.getAbsolutePath())).waitForFinish();
+ shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, false);
is = context.getResources().openRawResource(R.raw.tor);
outFile = new File(installFolder, TOR_ASSET_KEY);
- shell.add(new SimpleCommand("rm " + outFile.getAbsolutePath())).waitForFinish();
+ shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, true);
is = context.getResources().openRawResource(R.raw.privoxy);
outFile = new File(installFolder, PRIVOXY_ASSET_KEY);
- shell.add(new SimpleCommand("rm " + outFile.getAbsolutePath())).waitForFinish();
+ shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, true);
is = context.getResources().openRawResource(R.raw.obfsproxy);
outFile = new File(installFolder, OBFSPROXY_ASSET_KEY);
- shell.add(new SimpleCommand("rm " + outFile.getAbsolutePath())).waitForFinish();
+ shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, true);
is = context.getResources().openRawResource(R.raw.xtables);
outFile = new File(installFolder, IPTABLES_ASSET_KEY);
- shell.add(new SimpleCommand("rm " + outFile.getAbsolutePath())).waitForFinish();
+ shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, true);
return true;
@@ -136,8 +157,7 @@ public class TorResourceInstaller implements TorServiceConstants {
int bytecount;
-
- OutputStream stmOut = new FileOutputStream(outFile, append);
+ OutputStream stmOut = new FileOutputStream(outFile.getAbsolutePath(), append);
ZipInputStream zis = null;
if (zip)
diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java
index ae54593..9382fe2 100644
--- a/src/org/torproject/android/service/TorService.java
+++ b/src/org/torproject/android/service/TorService.java
@@ -270,6 +270,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
*/
public int onStartCommand(Intent intent, int flags, int startId) {
+
appBinHome = getDir(DIRECTORY_TOR_BINARY,Application.MODE_PRIVATE);
appCacheHome = getDir(DIRECTORY_TOR_DATA,Application.MODE_PRIVATE);
@@ -517,11 +518,15 @@ public class TorService extends Service implements TorServiceConstants, TorConst
SharedPreferences prefs = getSharedPrefs(getApplicationContext());
String version = prefs.getString(PREF_BINARY_TOR_VERSION_INSTALLED,null);
+
+ logNotice("checking binary version: " + version);
if (version == null || (!version.equals(BINARY_TOR_VERSION)))
{
stopTor();
+ logNotice("upgrading binaries to latest version: " + BINARY_TOR_VERSION);
+
TorResourceInstaller installer = new TorResourceInstaller(this, appBinHome);
boolean success = installer.installResources();
@@ -531,6 +536,8 @@ public class TorService extends Service implements TorServiceConstants, TorConst
else if (!fileTorRc.exists())
{
stopTor();
+
+ logNotice("upgrading binaries to latest version: " + BINARY_TOR_VERSION);
TorResourceInstaller installer = new TorResourceInstaller(this, appBinHome);
boolean success = installer.installResources();
diff --git a/src/org/torproject/android/service/TorServiceConstants.java b/src/org/torproject/android/service/TorServiceConstants.java
index 321207b..f11315d 100644
--- a/src/org/torproject/android/service/TorServiceConstants.java
+++ b/src/org/torproject/android/service/TorServiceConstants.java
@@ -7,7 +7,7 @@ public interface TorServiceConstants {
public final static String TOR_APP_USERNAME = "org.torproject.android";
public final static String ORWEB_APP_USERNAME = "info.guardianproject.browser";
- public final static String DIRECTORY_TOR_BINARY = "bins";
+ public final static String DIRECTORY_TOR_BINARY = "bin";
public final static String DIRECTORY_TOR_DATA = "data";
//name of the tor C binary
@@ -79,10 +79,10 @@ public interface TorServiceConstants {
public static final int DISABLE_TOR_MSG = 3;
public static final int LOG_MSG = 4;
- public static final String BINARY_TOR_VERSION = "0.2.4.21-openssl1.0.1g-installfix";
+ public static final String BINARY_TOR_VERSION = "0.2.4.21-openssl1.0.1g-if6";
public static final String BINARY_PRIVOXY_VERSION = "3.0.12";
- public static final String PREF_BINARY_TOR_VERSION_INSTALLED = "BINARY_TOR_VERSION_INTALLED";
- public static final String PREF_BINARY_PRIVOXY_VERSION_INSTALLED = "BINARY_PRIVOXY_VERSION_INTALLED";
+ public static final String PREF_BINARY_TOR_VERSION_INSTALLED = "BINARY_TOR_VERSION_INSTALLED";
+ public static final String PREF_BINARY_PRIVOXY_VERSION_INSTALLED = "BINARY_PRIVOXY_VERSION_INSTALLED";
//obfsproxy
public static final String OBFSPROXY_ASSET_KEY = "obfsproxy";
More information about the tor-commits
mailing list