Skip to content

Commit

Permalink
Fix installer
Browse files Browse the repository at this point in the history
  • Loading branch information
DerGoogler committed Oct 30, 2023
1 parent cea8d16 commit 6877b5a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 43 deletions.
47 changes: 9 additions & 38 deletions Website/src/activitys/TerminalActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,6 @@ const TerminalActivity = () => {
}, [lines]);
}

const installCli = (path: string) => {
if (Shell.isMagiskSU()) {
return modConf("MSUCLI", { ZIPFILE: path });
} else if (Shell.isKernelSU()) {
return modConf("KSUCLI", { ZIPFILE: path });
} else {
throw new Error("Unable to determine installation string");
}
};

const env = (i: { [key: string]: string }) => {
for (const k in i) {
Shell.setenv(k, i[k], 1);
}
};

const escapePath = React.useCallback(
(path: string) => {
return path.replace(/[\\^$*+?()[\]{}|\s]/g, "\\$&");
},
[extra.path]
);

const install = () => {
const { exploreInstall, path } = extra;

Expand All @@ -66,25 +43,20 @@ const TerminalActivity = () => {
const name = url[2];
const branch = url[4].split(".").slice(0, -1).join(".");

const installPath = window.__properties__.get("persist.mmrlini.install_folder", "/data/local/tmp/<NAME>-<BRANCH>-moduled.zip");

const envp_explore = {
MMRL: "true",
MMRL_VER: BuildConfig.VERSION_CODE.toString(),
NAME: name,
URL: path,
BRANCH: branch,
HAS_UPDATE_JSON: extra.hasUpdateJson,
INSTALLER_CLI: installCli(
formatString(installPath, {
NAME: name,
BRANCH: branch,
})
),
ROOTMANAGER: Shell.getRootManager(),
MSUCLI: modConf("MSUCLI"),
KSUCLI: modConf("KSUCLI"),
};

Terminal.exec({
command: `${modConf("MMRLINI")}/system/usr/share/mmrl/bin/mmrl_explore_install`,
command: `${modConf("MMRLINI")}/system/usr/share/mmrl/bin/mmrl_explore_install_v2`,
env: envp_explore,
onLine: (line) => {
addLine(line);
Expand All @@ -96,18 +68,17 @@ const TerminalActivity = () => {
},
});
} else {
console.log(escapePath(path));

const envp_local = {
MMRL: "true",
MMRL_VER: BuildConfig.VERSION_CODE.toString(),
EXCAPED_PATH: escapePath(path),
NORMAL_PATH: path,
INSTALLER_CLI: installCli(escapePath(path)),
ZIPFILE: path,
ROOTMANAGER: Shell.getRootManager(),
MSUCLI: modConf("MSUCLI"),
KSUCLI: modConf("KSUCLI"),
};

Terminal.exec({
command: `${modConf("MMRLINI")}/system/usr/share/mmrl/bin/mmrl_local_install`,
command: `${modConf("MMRLINI")}/system/usr/share/mmrl/bin/mmrl_local_install_v2`,
env: envp_local,
onLine: (line) => {
addLine(line);
Expand Down
10 changes: 5 additions & 5 deletions Website/src/hooks/useModConf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export interface ModConf {

export const INITIAL_MOD_CONF: ModConf = {
//cli
MSUCLI: "/system/bin/magisk --install-module <ZIPFILE>",
KSUCLI: "<ADB>/ksu/bin/ksud module install <ZIPFILE>",
MSUCLI: "/system/bin/magisk",
KSUCLI: "<ADB>/ksu/bin/ksud",

// default paths
ADB: "/data/adb",
Expand All @@ -66,7 +66,7 @@ export const INITIAL_MOD_CONF: ModConf = {
UPDATE: "<MODULECWD>/update",

// others
MMRLINI: "<MODULECWD>/mmrl_install_tools",
MMRLINI: "<MODULES>/mmrl_install_tools",
CONFCWD: "<MODULECWD>/system/usr/share/mmrl/config/<MODID>",
CONFINDEX: "<CONFCWD>/index.jsx",
};
Expand Down Expand Up @@ -105,7 +105,7 @@ export function formatString(template: string, object: object): string {
}

export const ModConfProvider = (props: React.PropsWithChildren) => {
const [modConf, setModConf] = useNativeStorage("modconf", INITIAL_MOD_CONF);
const [modConf, setModConf] = useNativeStorage("modconf_v2", INITIAL_MOD_CONF);

// Test purposes
// React.useEffect(() => {
Expand All @@ -131,7 +131,7 @@ export const ModConfProvider = (props: React.PropsWithChildren) => {
setModConf: (name, state, callback) => {
setModConf(
(prev) => {
const newValue = React.useMemo(() => (state instanceof Function ? state(prev[name]) : state), [name]);
const newValue = state instanceof Function ? state(prev[name]) : state;
return {
...prev,
[name]: newValue,
Expand Down

0 comments on commit 6877b5a

Please sign in to comment.