This commit is contained in:
crschnick
2026-03-22 13:15:17 +00:00
parent 31a8f0c104
commit 48e2691ba8
4 changed files with 24 additions and 8 deletions
@@ -21,6 +21,7 @@ public class ShellView {
protected Boolean administrator;
protected PasswdFile passwdFile;
protected GroupFile groupFile;
protected String recognized;
protected final Map<String, Boolean> installedApplications = new HashMap<>();
protected final Map<String, Boolean> genericCache = new HashMap<>();
@@ -137,6 +138,17 @@ public class ShellView {
.executeAndCheck();
}
public String getRecognizedArch() throws Exception {
if (shellControl.getOsType() == OsType.WINDOWS) {
var env = getEnvironmentVariable("PROCESSOR_ARCHITECTURE").orElse(null);
var effective = "ARM64".equals(env) ? "arm64" : "x86_64";
return recognized = effective;
} else {
var uname = shellControl.command(CommandBuilder.of().add("uname", "-m")).readStdoutIfPossible();
return recognized = "arm64".equals(uname.orElse("x86_64")) ? "arm64" : "x86_64";
}
}
public void deleteDirectory(FilePath path) throws Exception {
getDialect().deleteFileOrDirectory(shellControl, path.toString()).execute();
}
@@ -20,7 +20,8 @@ public class ClinkHelper {
}
var targetDir = getTargetDir(sc);
return sc.view().fileExists(targetDir.join("clink_x64.exe"));
var arch = sc.view().getRecognizedArch().equals("x86_64") ? "x64" : "arm64";
return sc.view().fileExists(targetDir.join("clink_" + arch + ".exe"));
}
public static void install(ShellControl sc) throws Exception {
@@ -28,15 +29,16 @@ public class ClinkHelper {
sc.view().mkdir(targetDir);
var temp = GithubReleaseDownloader.getDownloadTempFile(
"chrisant996/clink", "clink.zip", name -> name.endsWith(".zip") && !name.endsWith("symbols.zip"));
var arch = sc.view().getRecognizedArch().equals("x86_64") ? "x64" : "arm64";
try (var fs = FileSystems.newFileSystem(temp)) {
var exeFile = fs.getPath("clink_x64.exe");
sc.view().transferLocalFile(exeFile, targetDir.join("clink_x64.exe"));
var exeFile = fs.getPath("clink_" + arch + ".exe");
sc.view().transferLocalFile(exeFile, targetDir.join("clink_" + arch + ".exe"));
var batFile = fs.getPath("clink.bat");
sc.view().transferLocalFile(batFile, targetDir.join("clink.bat"));
var dllFile = fs.getPath("clink_dll_x64.dll");
sc.view().transferLocalFile(dllFile, targetDir.join("clink_dll_x64.dll"));
var dllFile = fs.getPath("clink_dll_" + arch + ".dll");
sc.view().transferLocalFile(dllFile, targetDir.join("clink_dll_" + arch + ".dll"));
}
}
}
@@ -162,8 +162,9 @@ public class OhMyPoshTerminalPrompt extends ConfigFileTerminalPrompt {
var dir = getBinaryDirectory(sc);
sc.view().mkdir(dir);
if (sc.getOsType() == OsType.WINDOWS) {
var arch = sc.view().getRecognizedArch().equals("x86_64") ? "amd64" : "arm64";
var file = GithubReleaseDownloader.getDownloadTempFile(
"JanDeDobbeleer/oh-my-posh", "posh-windows-amd64.exe", s -> s.equals("posh-windows-amd64.exe"));
"JanDeDobbeleer/oh-my-posh", "posh-windows-" + arch + ".exe", s -> s.equals("posh-windows-" + arch + ".exe"));
sc.view().transferLocalFile(file, dir.join("oh-my-posh.exe"));
} else {
var configDir = getConfigurationDirectory(sc);
@@ -125,10 +125,11 @@ public class StarshipTerminalPrompt extends ConfigFileTerminalPrompt {
var dir = getBinaryDirectory(sc);
sc.view().mkdir(dir);
if (sc.getOsType() == OsType.WINDOWS) {
var arch = sc.view().getRecognizedArch().equals("x86_64") ? "x86_64" : "aarch64";
var file = GithubReleaseDownloader.getDownloadTempFile(
"starship/starship",
"starship-x86_64-pc-windows-msvc.zip",
s -> s.equals("starship-x86_64-pc-windows-msvc.zip"));
"starship-" + arch + "-pc-windows-msvc.zip",
s -> s.equals("starship-" + arch + "-pc-windows-msvc.zip"));
try (var fs = FileSystems.newFileSystem(file)) {
var exeFile = fs.getPath("starship.exe");
sc.view().transferLocalFile(exeFile, dir.join("starship.exe"));