Menci / arcaea-builder

Build your own Arcaea game client to play self-made or modified official charts!
2 stars 0 forks source link

[F-R] Windows Compatibility #2

Open TechnoHT opened 3 years ago

TechnoHT commented 3 years ago

It seem like Linux fs path is not compatible with WinNT

yarn run v1.22.10
$ ts-node -r tsconfig-paths/register src/main unpack
info:    Project directory: C:\Users\hieut\arcaea-builder\project
info:    Removing old Android unpacked files
info:    Unpacking Android original package
info:    Execuating ["apktool", "d", "C:\\Users\\hieut\\arcaea-builder\\project\\original\\arcaea_3.5.3c.apk", "-o", "C:\\Users\\hieut\\arcaea-builder\\project\\original\\package"]
info:    Removing extra 64 bit binaries from Android unpacked files
Error: spawnSync apktool ENOENT
    at Object.spawnSync (node:internal/child_process:1086:20)
    at spawnSync (node:child_process:693:24)
    at Object.execFileSync (node:child_process:720:15)
    at Object.exec (C:\Users\hieut\arcaea-builder\src\lib\exec.ts:8:17)
    at Object.action (C:\Users\hieut\arcaea-builder\src\actions\unpack.ts:24:7)
    at Object.runAction (C:\Users\hieut\arcaea-builder\src\action.ts:35:10)
error Command failed with exit code 1.
Menci commented 3 years ago

On Windows you must enter the tools' full path in the project.yaml.

Menci commented 3 years ago

https://github.com/Menci/arcaea-builder/blob/9d19e1ef1f2800d2f8e989ba09b52b7987488848/example/project.yaml#L1-L5

TechnoHT commented 3 years ago

On Windows you must enter the tools' full path in the project.yaml.

I pointed directly to the wrapper script, or execute directly from PATH, it seem to Work until apktool found the file path but failed to decompile it

Menci commented 3 years ago

How was it "failed to decompile it"?

TechnoHT commented 3 years ago

take a quick look at

info:    Removing old Android unpacked files
info:    Unpacking Android original package
info:    Execuating ["apktool", "d", "C:\\Users\\hieut\\arcaea-builder\\project\\original\\arcaea_3.5.3c.apk", "-o", "C:\\Users\\hieut\\arcaea-builder\\project\\original\\package"]
info:    Removing extra 64 bit binaries from Android unpacked files
Error: spawnSync apktool ENOENT

It found and executed apktook.bat ( which is the wrapper script ) but nothing showed up afterwards, no matter I point the project.yaml to the apktool.jar or apktool.bat, $PATH either.

Menci commented 3 years ago

Oh no sorry I didn't use the path provided by project.yaml. I'll fix it right now.

Menci commented 3 years ago

Check out https://github.com/Menci/arcaea-builder/commit/8d5520332b8f5b056fd36fff6fb9704f6f99008d

TechnoHT commented 3 years ago
yarn run v1.22.10
$ ts-node -r tsconfig-paths/register src/main unpack
info:    Project directory: C:\Users\hieut\arcaea-builder\project
info:    Removing old Android unpacked files
info:    Unpacking Android original package
info:    Execuating ["C:/Windows", "d", "C:\\Users\\hieut\\arcaea-builder\\project\\original\\arcaea_3.5.3c.apk", "-o", "C:\\Users\\hieut\\arcaea-builder\\project\\original\\package"]
info:    Removing extra 64 bit binaries from Android unpacked files
Error: spawnSync C:/Windows ENOENT
    at Object.spawnSync (node:internal/child_process:1086:20)
    at spawnSync (node:child_process:693:24)
    at Object.execFileSync (node:child_process:720:15)
    at Object.exec (C:\Users\hieut\arcaea-builder\src\lib\exec.ts:8:17)
    at Object.action (C:\Users\hieut\arcaea-builder\src\actions\unpack.ts:24:7)
    at Object.runAction (C:\Users\hieut\arcaea-builder\src\action.ts:35:10)
error Command failed with exit code 1.
I: Using Apktool 2.5.0 on arcaea_3.5.3c.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\hieut\AppData\Local\apktool\framework\1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
Press any key to continue . . .
info:    Removing extra 64 bit binaries from Android unpacked files
info:    Removing ALL songs (except for tutorial) from Android unpack files
Done in 30.06s.

Worked Not really what I expected 😂 exec apktool after the error I will try to rewrite exec.ts to execute the wrapper script instead

Menci commented 3 years ago

What did you write in your project.yaml

TechnoHT commented 3 years ago

both produced the same thing

tools:
  apktool: C:\Windows\apktool.bat
  jarsigner: jarsigner

targets:
  android: arcaea_3.5.3c.apk
tools:
  apktool: C:\Windows
  jarsigner: jarsigner

targets:
  android: arcaea_3.5.3c.apk

C:\Windows is where I put the apktool.jar and apktool.bat if I point the .jar file it need to be executed under java -jar apktool.jar instead

Menci commented 3 years ago

C:\Windows\apktool.bat is correct

TechnoHT commented 3 years ago

told ya both give the

Error: spawnSync C:/Windows ENOENT

because the command apktool can be executed from the wrapper script without .bat/.cmd unless exec.ts require .bat/.cmd

Menci commented 3 years ago

I don't know why your C:\Windows\apktool.bat leads to spawnSync C:/Windows ... The filename is eaten ...

TechnoHT commented 3 years ago

will try to make a specific snippet for Windows for now it seem to work except the press any key to continue ..... because the .bat/.cmd can't be called from exec.ts with the command only 😂

Menci commented 3 years ago

Why it can't be called? I'm not familiar with Windows but I think .bat is just like .sh

TechnoHT commented 3 years ago

In Windows certain command or $PATH have to be suffixed with .bat/.cmd because PATH/APPEND/PROMPT/SET/ASSOC in .cmd files will set ERRORLEVEL regardless of error while .bat sets ERRORLEVEL only on errors. have to be called with something similar to

require('child_process').spawnSync('apktool.bat')

or include cross-spawn module for spawnSync

Menci commented 3 years ago

So why I can't execFileSync("C:\\Windows\\apktool.bat")?

TechnoHT commented 3 years ago

I don't really know if it's related to the Windows compatibility layer for .bat .bat is for 16-bit env, while .cmd is for 32-bit env ( similar to .sh ) so far the only solution I'm trying is cross spawn