Skip to content

Commit

Permalink
Version 1.5.1
Browse files Browse the repository at this point in the history
Updated status command and ShellEnv class
  • Loading branch information
meefik committed May 20, 2015
1 parent e8d401e commit 2237b57
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 60 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ru.meefik.linuxdeploy"
android:versionCode="134"
android:versionName="1.5.0" >
android:versionCode="135"
android:versionName="1.5.1" >

<uses-sdk
android:minSdkVersion="7"
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Changelog (English)
===================

1.5.1
Updated command "status"

1.5.0
Added support for devices with an Intel architecture
Added support for cross-architecture installation x86 <-> ARM based on QEMU (binfmt_misc require support in the kernel)
Expand Down Expand Up @@ -278,6 +281,9 @@ Updated list packages of base system installation
История изменений (Русский)
===========================

1.5.1
Обновлена команда "состояние"

1.5.0
Добавлена поддержка устройств с Intel архитектурой
Добавлена поддержка кросс-архитектурной инсталляции x86 <-> ARM на основе QEMU (требуется поддержка binfmt_misc на уровне ядра)
Expand Down
9 changes: 2 additions & 7 deletions assets/root/bin/linuxdeploy
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ status_system()
[ -z "$is_mounted" ] && msg " ...not mounted anything"

msg "Available mount points: "
for p in $(cat /proc/mounts | grep ^/dev/ | grep -v $MNT_TARGET | grep -v ' /mnt/asec/' | grep -v ' /mnt/secure/' | awk '{print $2":"$3}')
for p in $(grep -v $MNT_TARGET /proc/mounts | grep ^/ | awk '{print $2":"$3}')
do
PART=$(echo $p | awk -F: '{print $1}')
FSTYPE=$(echo $p | awk -F: '{print $2}')
Expand All @@ -1605,12 +1605,7 @@ status_system()
for PART in $PARTS
do
SIZE=$(fdisk -l $PART | grep 'Disk.*bytes' | awk '{ sub(/,/,""); print $3" "$4}')
BOOT=$(fdisk -l $DEVPATH | grep ^$PART | awk '{print $2}')
if [ "$BOOT" = "*" ]; then
TYPE=$(fdisk -l $DEVPATH | grep ^$PART | awk '{str=$7; for (i=8;i<=11;i++) if ($i!="") str=str" "$i; printf("%s",str)}')
else
TYPE=$(fdisk -l $DEVPATH | grep ^$PART | awk '{str=$6; for (i=7;i<=10;i++) if ($i!="") str=str" "$i; printf("%s",str)}')
fi
TYPE=$(fdisk -l $DEVPATH | grep ^$PART | tr -d '*' | awk '{str=$6; for (i=7;i<=10;i++) if ($i!="") str=str" "$i; printf("%s",str)}')
msg "* $PART: $SIZE ($TYPE)"
is_partitions=1
done
Expand Down
Binary file modified libs/android-support-v4.jar
Binary file not shown.
83 changes: 32 additions & 51 deletions src/ru/meefik/linuxdeploy/ShellEnv.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,29 @@ public ShellEnv(Context c) {
private boolean execCmd(List<String> params) {
boolean result = true;
try {
Process process = Runtime.getRuntime().exec(params.get(0));
params.remove(0);
Process process = Runtime.getRuntime().exec("su");

final OutputStream stdin = process.getOutputStream();
final InputStream stdout = process.getInputStream();
final InputStream stderr = process.getErrorStream();

params.add("exit $?");
params.add(0, "PATH=" + PrefStore.ENV_DIR
+ "/bin:$PATH; export PATH");
if (!PrefStore.DEBUG_MODE.equals("y")) {
params.add(0, "exec 2>/dev/null");
params.add(0, "exec 1>/dev/null");
}
if (PrefStore.TRACE_MODE.equals("y"))
params.add(0, "set -x");

OutputStream stdin = process.getOutputStream();
DataOutputStream os = new DataOutputStream(stdin);
for (String tmpCmd : params) {
os.writeBytes(tmpCmd + "\n");
for (String cmd : params) {
os.writeBytes(cmd + "\n");
}
os.flush();
os.close();

final InputStream stdout = process.getInputStream();
final InputStream stderr = process.getErrorStream();

(new Thread() {
@Override
public void run() {
Expand All @@ -60,6 +69,7 @@ public void run() {
}

process.waitFor();

if (process.exitValue() != 0)
result = false;

Expand Down Expand Up @@ -110,7 +120,6 @@ public void run() {
private boolean isRooted() {
// exec linuxdeploy command
List<String> params = new ArrayList<String>();
params.add("su");
params.add("ls /data/local 1>/dev/null");
if (!execCmd(params)) {
sendLogs("Require superuser privileges (root)!\n");
Expand Down Expand Up @@ -170,7 +179,7 @@ private boolean extractDir(String rootAsset, String path) {
if (!extractFile(rootAsset, path))
return false;
} else {
String fullPath = PrefStore.ENV_DIR + path;
String fullPath = PrefStore.ENV_DIR + path;
File dir = new File(fullPath);
if (!dir.exists()) {
dir.mkdir();
Expand Down Expand Up @@ -200,19 +209,11 @@ public void updateEnv() {
}

List<String> params = new ArrayList<String>();
params.add("su");
if (PrefStore.TRACE_MODE.equals("y"))
params.add("set -x");
if (!PrefStore.DEBUG_MODE.equals("y")) {
params.add("exec 1>/dev/null");
params.add("exec 2>/dev/null");
}
params.add("mkdir " + PrefStore.ENV_DIR);
params.add("rm -R " + PrefStore.ENV_DIR + "/bin");
params.add("rm -R " + PrefStore.ENV_DIR + "/etc");
params.add("rm -R " + PrefStore.ENV_DIR + "/deploy");
params.add("chmod 777 " + PrefStore.ENV_DIR);
params.add("exit");
if (!execCmd(params)) {
sendLogs("fail\n");
return;
Expand All @@ -222,37 +223,30 @@ public void updateEnv() {
sendLogs("fail\n");
return;
}
if (!extractDir(PrefStore.MARCH+"/all", "")) {
if (!extractDir(PrefStore.MARCH + "/all", "")) {
sendLogs("fail\n");
return;
}
// PIE for Android L
if (android.os.Build.VERSION.SDK_INT >= 21) {
if (!extractDir(PrefStore.MARCH+"/pie", "")) {
if (!extractDir(PrefStore.MARCH + "/pie", "")) {
sendLogs("fail\n");
return;
}
} else {
if (!extractDir(PrefStore.MARCH+"/nopie", "")) {
if (!extractDir(PrefStore.MARCH + "/nopie", "")) {
sendLogs("fail\n");
return;
}
}

params.clear();
params.add("su");
if (PrefStore.TRACE_MODE.equals("y"))
params.add("set -x");
if (!PrefStore.DEBUG_MODE.equals("y")) {
params.add("exec 1>/dev/null");
params.add("exec 2>/dev/null");
}

if (PrefStore.BUILTIN_SHELL) {
params.add("chmod 755 " + PrefStore.ENV_DIR + "/bin/busybox");
params.add(PrefStore.ENV_DIR + "/bin/busybox --install -s "
+ PrefStore.ENV_DIR + "/bin");
+ PrefStore.ENV_DIR + "/bin");
}
params.add("PATH=" + PrefStore.ENV_DIR + "/bin:$PATH; export PATH");
if (PrefStore.SYMLINK) {
params.add("rm -f /system/bin/linuxdeploy");
params.add("ln -s "
Expand All @@ -265,12 +259,13 @@ public void updateEnv() {
params.add("echo '" + PrefStore.VERSION + "' > " + PrefStore.ENV_DIR
+ "/etc/version");
params.add("chmod 755 " + PrefStore.ENV_DIR);
String[] files = {PrefStore.ENV_DIR + "/bin", PrefStore.ENV_DIR + "/etc", PrefStore.ENV_DIR + "/deploy"};
for (int i = 0; i < files.length; i++) {
params.add("chmod -R 755 " + files[i]);
params.add("find " + files[i] + " | while read f; do chmod 755 $f; done");
String[] dirs = { PrefStore.ENV_DIR + "/bin",
PrefStore.ENV_DIR + "/etc", PrefStore.ENV_DIR + "/deploy" };
for (int i = 0; i < dirs.length; i++) {
params.add("chmod -R 755 " + dirs[i]);
params.add("find " + dirs[i]
+ " | while read f; do chmod 755 $f; done");
}
params.add("exit");
if (!execCmd(params)) {
sendLogs("fail\n");
return;
Expand All @@ -289,14 +284,6 @@ public void updateConfig() {
sendLogs("Updating configuration file ... ");

List<String> params = new ArrayList<String>();
params.add("su");
if (PrefStore.TRACE_MODE.equals("y"))
params.add("set -x");
if (!PrefStore.DEBUG_MODE.equals("y")) {
params.add("exec 1>/dev/null");
params.add("exec 2>/dev/null");
}
params.add("PATH=" + PrefStore.ENV_DIR + "/bin:$PATH; export PATH");
params.add("cd " + PrefStore.ENV_DIR);
params.add("sed -i 's|^ENV_DIR=.*|ENV_DIR=\"" + PrefStore.ENV_DIR
+ "\"|g' " + PrefStore.ENV_DIR + "/bin/linuxdeploy");
Expand Down Expand Up @@ -361,9 +348,8 @@ public void updateConfig() {
params.add("sed -i 's|^VNC_GEOMETRY=.*|VNC_GEOMETRY=\""
+ PrefStore.VNC_GEOMETRY + "\"|g' " + PrefStore.ENV_DIR
+ "/etc/deploy.conf");
params.add("sed -i 's|^VNC_ARGS=.*|VNC_ARGS=\""
+ PrefStore.VNC_ARGS + "\"|g' " + PrefStore.ENV_DIR
+ "/etc/deploy.conf");
params.add("sed -i 's|^VNC_ARGS=.*|VNC_ARGS=\"" + PrefStore.VNC_ARGS
+ "\"|g' " + PrefStore.ENV_DIR + "/etc/deploy.conf");
params.add("sed -i 's|^XSERVER_DISPLAY=.*|XSERVER_DISPLAY=\""
+ PrefStore.XSERVER_DISPLAY + "\"|g' " + PrefStore.ENV_DIR
+ "/etc/deploy.conf");
Expand All @@ -383,7 +369,6 @@ public void updateConfig() {
+ "\"|g' " + PrefStore.ENV_DIR + "/etc/deploy.conf");
params.add("sed -i 's|^FB_FREEZE=.*|FB_FREEZE=\"" + PrefStore.FB_FREEZE
+ "\"|g' " + PrefStore.ENV_DIR + "/etc/deploy.conf");
params.add("[ $? -eq 0 ] && exit 0 || exit 1");

if (!execCmd(params)) {
sendLogs("fail\n");
Expand Down Expand Up @@ -421,11 +406,7 @@ public void deployCmd(String cmd) {
}
// exec linuxdeploy command
List<String> params = new ArrayList<String>();
params.add("su");
if (PrefStore.TRACE_MODE.equals("y"))
params.add("set -x");
params.add(PrefStore.ENV_DIR + "/bin/linuxdeploy " + cmd);
params.add("exit");
execCmd(params);
}

Expand Down

0 comments on commit 2237b57

Please sign in to comment.