snapcrafters / sommelier-core

Package a Windows application for Linux using a Snap with Wine.
MIT License
30 stars 10 forks source link

[Enhancement]: Run pre-install hook before winetricks installs? #34

Closed n8marti closed 6 months ago

n8marti commented 2 years ago

What changes would you like?

I would like to use the pre-install hook to optionally copy previously-downloaded winetricks installers from $SNAP_REAL_HOME/.cache/winetricks into the snap's winetricks cache. However, the pre-install hook runs immediately after the winetricks installs: https://github.com/snapcrafters/sommelier-core/blob/master/scripts/sommelier#L111-L128

install_app() {
  echo "Installing application.."

  ORIGINAL_LINKS=( $(xdg-user-dir DESKTOP)/*.lnk )

  # Install additional requirements via winetricks
  if [[ -n "${TRICKS:-}" ]]; then
    for TRICK in ${TRICKS}; do
      "${WINETRICKS}" --unattended "${TRICK}" | \
      yad --progress --title="Installing ${TRICK}" --progress-text= --width=400 --center --no-buttons --auto-close --auto-kill --on-top --pulsate
    done
  fi

  # Run pre-install hook
  if [[ -f "$SNAP/sommelier/hooks/pre-install" ]]; then
    echo "Running hook '$SNAP/sommelier/hooks/pre-install'"
    . "$SNAP/sommelier/hooks/pre-install"
  fi

Can this hook be moved to run at the very beginning of the install_app function, just after echo "Installing application..", or maybe just after saving the original wine desktop links? (I'm not sure if certain winetricks additions could create additional links.)

Any extra information?

No response

mmtrt commented 2 years ago

See https://github.com/snapcrafters/sommelier-core/pull/21 it was changed due to installers requiring certain verbs in wineprefix to function.

n8marti commented 2 years ago

Ah, I missed that. I don't quite understand the reason, though. This is what I'm understanding (in my own words): Certain winetricks verbs need to have already been installed so that some Windows app installers can run correctly. But I must be misunderstanding something, because regardless of whether the pre-install hook is before or after the winetricks verbs installations, the Windows app installer runs after both of those have completed. Is it that some people are doing things in the pre-install hook that require winetricks verbs to have already been installed?

mmtrt commented 2 years ago

I use multi installers in pre-install with user selection dialog in yad which requires winetricks verb early in wineprefix to fix installer requirement.

So without installing tricks early will break tricks snapcraft envar defined verbs in snap snapcraft.yaml.

See pre-install

merlijn-sebrechts commented 2 years ago

@n8marti

We could add an additional hook "pre-winetricks". However, I want to have a better understanding of what you would use this hook for. Can you give more explanation for why this is needed?

n8marti commented 2 years ago

I live in a place with very poor internet, so while testing wine-based snap builds I'd like to be able to copy the "standard" winetricks folder at $HOME/.cache/winetricks into the snap's own winetricks cache before the winetricks verbs are installed. I've worked around it for now by adding this to sommelier-core's override-prime step:

      # Copy cached winetricks in $SNAP_REAL_HOME before installing winetricks.
      sed -r -i 's@(^install_app\(\).*)@\1\n  cp -r "${SNAP_REAL_HOME}/.cache/winetricks" "${SNAP_USER_COMMON}/.cache" || true@' bin/sommelier
mmtrt commented 2 years ago

@n8marti snaps don't have access to . files/dir by default unless its classic/devmode/store permission granted one.

n8marti commented 2 years ago

Oh, yes, good point. I haven't gotten that far yet to get beyond devmode for this snap.

Le 11/05/2022 à 17:57, Taqi Raza a écrit :

@n8marti https://github.com/n8marti snaps don't have access to |.| files/dir by default unless its |classic/devmode/store permission granted| one.

— Reply to this email directly, view it on GitHub https://github.com/snapcrafters/sommelier-core/issues/34#issuecomment-1124017858, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFSOCVJAQQTCS7CLVGSXVATVJPRF5ANCNFSM5VNPSK4A. You are receiving this because you were mentioned.Message ID: @.***>