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

Install package dependencies when installing BizHawk on Linux #30

Open
fenhl opened this issue Jul 29, 2023 · 4 comments
Open

Install package dependencies when installing BizHawk on Linux #30

fenhl opened this issue Jul 29, 2023 · 4 comments
Labels
component: installer Related to the multiworld installer frontend: BizHawk Related to the BizHawk emulator os: Linux Related to running on Linux type: bug Something isn't working

Comments

@fenhl
Copy link
Member

fenhl commented Jul 29, 2023

The Linux version of BizHawk requires the mono-complete APT package. We should install it as part of the multiworld installer. The question is: what's the best way to do this from a GUI? Does Ubuntu's software-center have a CLI for specifying packages to install? Is there a graphical version of sudo that can be used?

@fenhl fenhl added type: bug Something isn't working status: help wanted Extra attention is needed frontend: BizHawk Related to the BizHawk emulator os: Linux Related to running on Linux labels Jul 29, 2023
@Louis-Simon22
Copy link

I'm guessing it's on this line?

//TODO check if apt-get exists and install prerequisite packages if it does? (mono-complete & libcanberra-gtk-module)

If you don't mind only supporting the Gnome desktop, this behavior can be achieved using two bash scripts that would be run by a std::process::Command.

use std::process::Command;

fn main() {
    let output = Command::new("bash")
        .arg("./install.sh")
        .output()
        .expect("failed to execute bash installation script");
    print!("stdout: {}", String::from_utf8_lossy(&output.stdout));
    print!("stderr: {}", String::from_utf8_lossy(&output.stderr));
}

install.sh

#!/bin/bash
set -e # Exit the script if a command fails

# Returns the path to the script's directory, no matter from where it was run
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
# Sets the script to execute when asking for sudo
export SUDO_ASKPASS="$SCRIPT_DIR/password_prompt.sh"

# The -A makes sudo use the script in SUDO_ASKPASS to prompt the user for the password
sudo -A apt update -y

password_prompt.sh

#!/bin/bash
set -e # Exit the script if a command fails

# We can customize the title and message
zenity --password --title="Installing dependencies"

If you want I can implement this in the installation script.
Sorry for taking this long I didn't get a notif for this issue. If you ever get another linux specific question like this feel free to @ me.

@fenhl
Copy link
Member Author

fenhl commented Aug 26, 2023

This looks promising, thank you! I'm going to go ahead and implement this. Some quick notes from testing:

  • sudo's -A flag is short for --askpass. I'm going to use the long name to make the code a bit more readable.
  • password_prompt.sh really does need to be a separate file, since the SUDO_ASKPASS envar does not allow arguments (it interprets spaces as part of the program name).

@Louis-Simon22
Copy link

I think you should also check for the existence of zenity and print instructions if it doesn't. It exists on gnome versions of ubuntu, but could be missing in other distros and flavors. For example with something like this maybe:

if command -v zenity &> /dev/null
then
    echo "Zenity exists"
else
    echo "Zenity does not exist"
fi

@fenhl fenhl removed the status: help wanted Extra attention is needed label Aug 28, 2023
@fenhl
Copy link
Member Author

fenhl commented Sep 15, 2023

Automatic installation of mono-complete when both apt and zenity exist is now implemented. Still need to add the manual instructions in case one or both commands don't exist.

@fenhl fenhl added the component: installer Related to the multiworld installer label Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: installer Related to the multiworld installer frontend: BizHawk Related to the BizHawk emulator os: Linux Related to running on Linux type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants