winepak / applications

A collection of flatpak manifest for building Microsoft Windows applications with Wine via flatpak
https://www.winepak.org
416 stars 39 forks source link

Unified installer script #1

Open julianrichen opened 6 years ago

julianrichen commented 6 years ago

Currently applications each have their own installer script, like so:

{
    "type": "script",
    "only-arches": ["x86_64"],
    "dest-filename": "@APPLICATION_BIN@-installer",
    "commands": [
        "if [ -z \"$WINEPREFIX\" ] ; then",
        "    \"No wine prefix set or is empty, abort.\"",
        "    exit 1",
        "fi",
        "",
        "if [ -e \"${WINEPREFIX}/dosdevices/c:/PATH/TO/GAME/DIRECTORY\" ] ; then",
        "    echo \"This prefix already has an exisiting '@APPLICATION_NAME@' install at ${WINEPREFIX}\"",
        "    echo \"In order to install '@APPLICATION_NAME@' you must move or delete the current prefix. \"",
        "    exit 1",
        "fi",
        "",
        "echo \"Downloading installer...\"",
        "curl --progress-bar --output \"${XDG_DATA_HOME}/cache/@APPLICATION_BIN@-installer.exe\" \"protocol://domain.tld/installer.exe\"",
        "",
        "echo \"Setting-up wine prefix...\"",
        "wineboot",
        "",
        "echo \"Installing Extension(s)...\"",
        "",
        "echo \"Performing tweak(s)...\"",
        "",
        "echo \"Installing application...\"",
        "wine64 \"${XDG_DATA_HOME}/cache/@APPLICATION_BIN@-installer.exe\"",
        "",
        "echo \"Installer finished\""
    ]
}

This is less then ideal because:

Regarding the GUI. Each installer normally has to download a third-party executable/installer which can't be checksum-ed since the link is for the latest installer, many windows games do this. Using apply_extra and extra-data is out of the question as updating the checksum daily would be impossible. Since the installer downloads the script in the background if users don't launch the flatpak via the terminal for the first time they won't see the download progress via curl and might assume the flatpak is not working. Adding a GUI option would launch an "Installing " window with progress and a terminal output. The GUI would be optional.

The unified installer will probably be written in Python so Tkinter could be used, so no need for an extra toolkit.

Example commands:

# Pick-up app-id, name, prefix, arch from enviroment

winepak installer init
    +- shortcut for -> winepak installer run wineboot
winepak installer download "protocol://domain.tld/installer.exe"
winepak installer extensions d3dx9,example2
winepak installer tweaks win7,example2
winepak installer run installer.exe

One line...

winepak installer --download "protocol://domain.tld/installer.exe"
                  --extensions d3dx9,example2
                  --tweaks win7,example2
                  --run installer.exe

Maybe add the ability to write the installer in a json manifest:

winepak installer manifest.json
# or...
winepak installer manifest.json

GUI option:

winepak installer --gui manifest.json
# or...
winepak installer -g manifest.json
Roboe commented 6 years ago

I've stumbled upon an article of a Wine Snap package and saw quickly that it has a GUI. A quick peek at it's source reveals they are using yad, which is a "tool for creating graphical dialogs from shell scripts", specifically. Just trying to help, :hugs:.

I've been trying to figure out how to package some legal GOG games downloading them with lgogdownloader and this seems like a quite good solution to enter login and password to the user GOG account. Yad can create forms too, so furthermore, the flatpak post-install could announce users they can sideload themselves the game to a directory of their choose, if they distrust to give passwords to third-party tools (like I'd do).

julianrichen commented 6 years ago

I actually never look before but the freedesktop Sdk & Platform package glib2 & gtk3: https://github.com/flatpak/freedesktop-sdk-images/blob/1.6/org.freedesktop.Sdk.json.in#L1073 https://github.com/flatpak/freedesktop-sdk-images/blob/1.6/org.freedesktop.Sdk.json.in#L2103

So we could actually make fairly decent looking windows using Python or yad without having to package a toolkit or use the sub-par tkinter toolkit for Python. For Python pygobject would still need to be packaged.

TLATER commented 5 years ago

I'd like to have a closer look at this because I'm finding it too cumbersome to create new applications in any reasonable amount of time - I'd love to add more, but clearly we don't have a great workflow yet.

Before we can go about designing an installer, we'll probably need to have a look at how exactly we're modelling the installation process, and how we want to abstract things. I think drafting a manifest first is a good way to go about that.

Here's my first draft for a .yml format, applied to a few existing applications (we seem to be using yml almost everywhere, let's stick with it):

hearthstone:
  installation-directory: "C:/Program Files (x86)/Hearthstone"
  # We'd need to support vendor-specific launcher protocols, but I
  # think that's ok
  installer-url: "battlenet://WTCG"
  command: ["wine64", "C:/Program Files (x86)/Battle.net/Battle.net Launcher.exe", "battlenet://WTCG"]
  tweaks:
    - win10
    - d3dx9

fortninte:
  installation-directory: "C:/Program Files (x86)/Epic Games/"
  installer-url: "https://launcher-public-service-prod06.ol.epicgames.com/launcher/api/installer/download/EpicGamesLauncherInstaller.msi"
  command: ["wine64", "C:/Program Files (x86)/Epic Games/Launcher/Portal/Binaries/Win32/EpicGamesLauncher.exe", "{@:--SkipBuildPatchPrereq -opengl}"]
  tweaks:
    - disable-winemenubuilder
    - win10
    - disable-shcore

wot:
  installation-directory: "C:/Games/World_of_Tanks"
  installer-url: "http://redirect.wargaming.net/WoT/latest_web_install_na"
  command: ["wine", "C:/Games/World_of_Tanks/WoTLauncher.exe", "$@"]
  extensions:
    - d3dx9/bin/d3dx9-install64
    - d3dx9/bin/d3dx9-install64-wow64
  tweaks:
    - disable-winemenubuilder

ie8:
  installation-directory: "c:/Program Files/Internet Explorer"
  installer-url: "file:///app/extra/ie8-installer.exe"
  command: ["wine", "C:/Program Files (x86)/Internet Explorer/iexplore.exe"]
  tweaks:
    - disable-winemenubuilder
    - winvista
    # Perhaps we could add an API that lets you call python modules or
    # bash scripts here to add application-specific things like
    # removing iexplorer.exe?

This is pretty far from perfect yet, of course. It doesn't let you easily do the "Battle.net Helper.exe" check required for hearthstone, modify battle.net config, or tweak the installation/download commands much - but I think these are kinks that can be sorted out when we need that functionality.

I think we should also draft a script that can perform this without worrying about a GUI for now - it's a neat idea, but we don't have a GUI yet, so it doesn't regress anything and it would already simplify the process. As long as applications use the installer we'd get a GUI for installers for free whenever we implement that.

What do you think?