Skip to content

Commit fa371aa

Browse files
fixed stuff
1 parent 6ea9be6 commit fa371aa

File tree

4 files changed

+40
-14
lines changed

4 files changed

+40
-14
lines changed

src/plugins/terminal/scripts/init-alpine.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@ fi
3030
[ ! -L /bin/login ] && mv /bin/login /bin/real_login
3131
ln -sf /bin/bash /bin/login
3232

33+
if [ "$1" = "--installing" ]; then
34+
echo "Installation completed."
35+
exit 0
36+
fi
37+
38+
3339
if [ "$#" -eq 0 ]; then
40+
chmod +x $PREFIX/axs
3441
$PREFIX/axs
3542
else
3643
exec "$@"

src/plugins/terminal/scripts/init-sandbox.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ fi
1212
ln -s "$NATIVE_DIR/libtalloc.so" "$PREFIX/libtalloc.so.2"
1313

1414

15-
$NATIVE_DIR/libproot-xed.so -b $PREFIX:$PREFIX -b /data:/data -b /system:/system -b /vendor:/vendor -R $PREFIX/alpine sh $PREFIX/init-alpine.sh "$@"
15+
$NATIVE_DIR/libproot-xed.so -b $PREFIX:$PREFIX -b /data:/data -b /system:/system -b /vendor:/vendor -S $PREFIX/alpine /bin/sh $PREFIX/init-alpine.sh "$@"

src/plugins/terminal/src/android/Executor.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import java.util.concurrent.*;
99
import android.content.Context;
1010
import android.app.Activity;
11+
import android.content.pm.PackageInfo;
12+
import android.content.pm.PackageManager;
1113

1214
public class Executor extends CordovaPlugin {
1315

@@ -68,6 +70,16 @@ private void exec(String cmd, CallbackContext callbackContext) {
6870
env.put("PREFIX", context.getFilesDir().getAbsolutePath());
6971
env.put("NATIVE_DIR", context.getApplicationInfo().nativeLibraryDir);
7072

73+
try {
74+
int target = context.getPackageManager()
75+
.getPackageInfo(context.getPackageName(), 0)
76+
.applicationInfo.targetSdkVersion;
77+
env.put("FDROID", String.valueOf(target <= 28));
78+
} catch (PackageManager.NameNotFoundException e) {
79+
e.printStackTrace();
80+
}
81+
82+
7183
Process process = builder.start();
7284

7385
// Capture stdout
@@ -116,6 +128,16 @@ private void startProcess(String pid, String cmd, CallbackContext callbackContex
116128
env.put("PREFIX", context.getFilesDir().getAbsolutePath());
117129
env.put("NATIVE_DIR", context.getApplicationInfo().nativeLibraryDir);
118130

131+
try {
132+
int target = context.getPackageManager()
133+
.getPackageInfo(context.getPackageName(), 0)
134+
.applicationInfo.targetSdkVersion;
135+
env.put("FDROID", String.valueOf(target <= 28));
136+
} catch (PackageManager.NameNotFoundException e) {
137+
e.printStackTrace();
138+
}
139+
140+
119141
Process process = builder.start();
120142

121143
processes.put(pid, process);

src/plugins/terminal/www/Terminal.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const Executor = require("./Executor");
44
const AXS_VERSION_TAG="v0.2.5"
55

66
const Terminal = {
7-
async startAxs(logger = console.log,err_logger = console.error){
7+
async startAxs(installing = false,logger = console.log,err_logger = console.error){
88
const filesDir = await new Promise((resolve, reject) => {
99
system.getFilesDir(resolve, reject);
1010
});
@@ -21,16 +21,13 @@ const Terminal = {
2121
logger(data);
2222
}).then(async (pid) => {
2323
system.writeText(`${filesDir}/pid`,pid,logger,err_logger)
24-
await Executor.write(pid,`source ${filesDir}/init-sandbox.sh; exit`);
24+
await Executor.write(pid, `source ${filesDir}/init-sandbox.sh ${installing ? "--installing" : ""}; exit`);
2525
});
2626
})
2727

2828
},
2929

3030
async stopAxs(){
31-
if (await this.isInstalled()) return;
32-
if (!(await this.isSupported())) return;
33-
3431
const pidExists = await new Promise((resolve, reject) => {
3532
system.fileExists(`${filesDir}/pid`, false, (result) => {
3633
resolve(result == 1);
@@ -45,9 +42,6 @@ const Terminal = {
4542
},
4643

4744
async isAxsRunning(){
48-
if (await this.isInstalled()) return false;
49-
if (!(await this.isSupported())) return false;
50-
5145
const pidExists = await new Promise((resolve, reject) => {
5246
system.fileExists(`${filesDir}/pid`, false, (result) => {
5347
resolve(result == 1);
@@ -78,13 +72,13 @@ const Terminal = {
7872
let alpineUrl;
7973
let axsUrl;
8074
if (arch === "arm64-v8a") {
81-
axsUrl = `https://github.com/bajrangCoder/acodex_server/releases/download/${AXS_VERSION_TAG}/axs-aarch64-unknown-linux-musl`
75+
axsUrl = `https://github.com/bajrangCoder/acodex_server/releases/download/${AXS_VERSION_TAG}/axs-musl-android-arm64`
8276
alpineUrl = "https://dl-cdn.alpinelinux.org/alpine/v3.21/releases/aarch64/alpine-minirootfs-3.21.0-aarch64.tar.gz";
8377
} else if (arch === "armeabi-v7a") {
84-
axsUrl = `https://github.com/bajrangCoder/acodex_server/releases/download/${AXS_VERSION_TAG}/axs-android-armv7`
78+
axsUrl = `https://github.com/bajrangCoder/acodex_server/releases/download/${AXS_VERSION_TAG}/axs-musl-android-armv7`
8579
alpineUrl = "https://dl-cdn.alpinelinux.org/alpine/v3.21/releases/armhf/alpine-minirootfs-3.21.0-armhf.tar.gz";
8680
} else if (arch === "x86_64") {
87-
axsUrl = `https://github.com/bajrangCoder/acodex_server/releases/download/${AXS_VERSION_TAG}/axs-android-x86_64`
81+
axsUrl = `https://github.com/bajrangCoder/acodex_server/releases/download/${AXS_VERSION_TAG}/axs-musl-android-x86_64`
8882
alpineUrl = "https://dl-cdn.alpinelinux.org/alpine/v3.21/releases/x86_64/alpine-minirootfs-3.21.0-x86_64.tar.gz";
8983
} else {
9084
throw new Error(`Unsupported architecture: ${arch}`);
@@ -135,6 +129,9 @@ const Terminal = {
135129
await new Promise((resolve, reject) => {
136130
system.mkdirs(`${filesDir}/.extracted`, resolve, reject);
137131
});
132+
133+
//update system and install required packages
134+
this.startAxs(true,logger,err_logger)
138135

139136
} catch (e) {
140137
err_logger("Installation failed:", e);
@@ -196,8 +193,8 @@ function readAsset(assetPath, callback) {
196193

197194
reader.onloadend = () => callback(reader.result);
198195
reader.readAsText(file);
199-
}, err_logger);
200-
}, err_logger);
196+
},console.error);
197+
}, console.error);
201198
}
202199

203200

0 commit comments

Comments
 (0)