Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEXRootFSFetcher: Fallback to TTY if zenity isn't installed #4063

Merged
merged 2 commits into from
Sep 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion Source/Tools/FEXRootFSFetcher/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ namespace WorkingAppsTester {
static bool Has_Curl {false};
static bool Has_Squashfuse {false};
static bool Has_Unsquashfs {false};
static bool Has_Zenity {false};

// EroFS specific
static bool Has_EroFSFuse {false};
Expand Down Expand Up @@ -284,6 +285,17 @@ void CheckUnsquashfs() {
}
close(fd);
}
void CheckZenity() {
// Check if zenity exists on the host
std::vector<const char*> ExecveArgs = {
lioncash marked this conversation as resolved.
Show resolved Hide resolved
"zenity",
"-h",
nullptr,
};

int32_t Result = Exec::ExecAndWaitForResponseRedirect(ExecveArgs[0], const_cast<char* const*>(ExecveArgs.data()), -1, -1);
Has_Zenity = Result != -1;
}

// EroFS specific tests
void CheckEroFSFuse() {
Expand Down Expand Up @@ -312,6 +324,7 @@ void Init() {
CheckCurl();
CheckSquashfuse();
CheckUnsquashfs();
CheckZenity();
CheckEroFSFuse();
CheckEroFSFsck();
}
Expand Down Expand Up @@ -967,6 +980,14 @@ void CheckTTY() {
IsTTY = ArgOptions::UIOption == ArgOptions::UIOverrideOption::TTY;
}

if (!WorkingAppsTester::Has_Zenity) {
// Force TTY if zenity isn't installed.
if (ArgOptions::UIOption == ArgOptions::UIOverrideOption::Zenity) {
fmt::print("Zenity isn't executable. Falling back to TTY mode\n");
}
IsTTY = true;
}

if (IsTTY) {
_AskForConfirmation = TTY::AskForConfirmation;
_ExecWithInfo = TTY::ExecWithInfo;
Expand Down Expand Up @@ -1091,6 +1112,8 @@ int main(int argc, char** argv, char** const envp) {

ArgOptions::ParseArguments(argc, argv);

WorkingAppsTester::Init();

CheckTTY();

if (ArgOptions::RemainingArgs.size()) {
Expand All @@ -1103,7 +1126,6 @@ int main(int argc, char** argv, char** const envp) {
return 0;
}

WorkingAppsTester::Init();
// Check if curl exists on the host
if (!WorkingAppsTester::Has_Curl) {
ExecWithInfo("curl is required to use this tool. Please install curl before using.");
Expand Down
Loading