Skip to content

Commit

Permalink
add Hangover
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreRH committed Oct 29, 2024
1 parent 1c2387b commit aad2a28
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/Hangover/credits
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@AndreRH
10 changes: 10 additions & 0 deletions apps/Hangover/description
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Hangover runs simple Win64 and Win32 applications on arm64 Linux. Only the application is emulated instead of a whole Wine installation.

Examples on how to run:

$ wine your_x86_64_application.exe # Uses FEX for 64-bit apps
$ wine your_x86_application.exe # To use Box64 for 32-bit apps
$ HODLL=libwow64fex.dll wine your_x86_application.exe # To use FEX for 32-bit apps
$ HODLL=xtajit.dll taskset -c 1 wine your_x86_application.exe # To use QEMU for 32-bit apps

For more information see https://github.com/AndreRH/hangover/blob/master/README.md
Binary file added apps/Hangover/icon-24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/Hangover/icon-64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
145 changes: 145 additions & 0 deletions apps/Hangover/install-64
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
#!/bin/bash

version=9.20

# https://github.com/raspberrypi/bookworm-feedback/issues/107
PAGE_SIZE="$(getconf PAGE_SIZE)"
if [[ "$PAGE_SIZE" == "16384" ]]; then
#switch to 4K pagesize kernel
if [ -f /boot/config.txt ] || [ -f /boot/firmware/config.txt ]; then
if [ -f /boot/firmware/config.txt ]; then
boot_config="/boot/firmware/config.txt"
elif [ -f /boot/config.txt ]; then
boot_config="/boot/config.txt"
fi
text="Raspberry Pi 5 PiOS images ship by default with a 16K PageSize Linux Kernel.
This kernel causes incompatibilities with some software including Wine https://github.com/raspberrypi/bookworm-feedback/issues/107
Would you like to automatically switch to a 4K PageSize Linux Kernel?"
userinput_func "$text" "No, keep 16K PageSize Kernel and Exit" "Yes, switch to 4K PageSize Kernel"
if [ "$output" == "No, keep 16K PageSize Kernel and Exit" ]; then
error "User error: Your current running kernel is built with 16K PageSize and is incompatible with Wine (x64) with Box64. You must switch to a 4K PageSize kernel (and chose to not do so automatically) before installing Wine (x64)."
fi
echo "" | sudo tee --append $boot_config >/dev/null
echo "[pi5]" | sudo tee --append $boot_config >/dev/null
echo "kernel=kernel8.img" | sudo tee --append $boot_config >/dev/null
echo -e "The 4K PageSize Kernel has been enabled by adding 'kernel=kernel8.img' to $boot_config\nPlease reboot now and install the Wine (x64) app again."
sleep infinity
else
error "User error (reporting allowed): Your current running kernel is built with 16K PageSize and is incompatible with Wine (x64) with Box64. Changing kernels automatically cannot be done since no /boot/config.txt or /boot/firmware/config.txt file was found."
fi
fi

if [ "$__os_codename" == "bullseye" ]; then
ho_distro="debian11"
elif [ "$__os_codename" == "bookworm" ]; then
ho_distro="debian12"
elif [ "$__os_codename" == "focal" ]; then
ho_distro="ubuntu2004"
elif [ "$__os_codename" == "jammy" ]; then
ho_distro="ubuntu2204"
elif [ "$__os_codename" == "noble" ]; then
ho_distro="ubuntu2404"
else
error "User error: You are not using a supported Pi-Apps distribution."
fi

cd /tmp || error "Could not move to /tmp folder"
wget https://github.com/AndreRH/hangover/releases/download/hangover-${version}/hangover_${version}_${ho_distro}_${__os_codename}_arm64.tar || error "Failed to download Hangover!"
tar -xf hangover_${version}_${ho_distro}_${__os_codename}_arm64.tar || error "Failed to extract Hangover!"
rm -f hangover_${version}_${ho_distro}_${__os_codename}_arm64.tar
install_packages /tmp/hangover-libarm64ecfex_${version}_arm64.deb /tmp/hangover-libqemu_${version}~${__os_codename}_arm64.deb /tmp/hangover-libwow64fex_${version}_arm64.deb /tmp/hangover-wine_${version}~${__os_codename}_arm64.deb || exit 1
rm -f ./hangover-libarm64ecfex_${version}_arm64.deb ./hangover-libqemu_${version}~${__os_codename}_arm64.deb ./hangover-libwow64fex_${version}_arm64.deb ./hangover-wine_${version}~${__os_codename}_arm64.deb

cat << EOF | sudo tee /usr/local/bin/generate-hangover-prefix >/dev/null
#!/bin/bash
echo
#set up functions
$(declare -f error)
$(declare -f status)
$(declare -f status_green)
$(declare -f warning)
$(declare -f userinput_func)
if [ "\$(id -u)" == 0 ];then
error "Please don't run this script with sudo."
fi
if [ -z "\$WINEPREFIX" ];then
WINEPREFIX="\$HOME/.wine"
fi
export WINEPREFIX
if [ -f "\$WINEPREFIX/system.reg" ];then
registry_exists=true
else
registry_exists=false
fi
export WINEDEBUG=-virtual #hide harmless memory errors
if [ -e "\$WINEPREFIX" ];then
status "Checking Wine prefix at \$WINEPREFIX..."
echo "To choose another prefix, set the WINEPREFIX variable."
echo -n "Waiting 5 seconds... "
sleep 5
echo
# check for existance of incompatible prefix (see server_init_process https://github.com/wine-mirror/wine/blob/884cff821481b4819f9bdba455217bd5a3f97744/dlls/ntdll/unix/server.c#L1544-L1670)
# Boot wine and check for errors (make fresh wineprefix)
output="\$(set -o pipefail; wine wineboot 2>&1 | tee /dev/stderr; )" #this won't display any dialog boxes that require a button to be clicked
if [ "\$?" != 0 ]; then
text="Your previously existing Wine prefix failed with an error (see terminal log).
Would you like to remove and regenerate your Wine prefix? Doing so will delete anything you may have installed into your Wine prefix."
userinput_func "\$text" "No, keep broken Wine prefix and Exit" "Yes, delete and regenerate Wine prefix"
if [ "\$output" == "No, keep broken Wine prefix and Exit" ]; then
error "User error: Your current Wine prefix caused Wine to error on launch and you chose to keep it. Manually correct your Wine prefix before installing or updating Wine (x64)."
fi
warning "Your previously existing Wine prefix failed with an error (see above). You chose to remove it and so it will be re-generated."
rm -rf "\$WINEPREFIX"
registry_exists=false
wine wineboot #this won't display any dialog boxes that require a button to be clicked
fi
#wait until above process exits
sleep 2
while [ ! -z "\$(pgrep -i 'wine C:')" ];do
sleep 1
done
else
status "Generating Wine prefix at \$WINEPREFIX..."
echo "To choose another prefix, set the WINEPREFIX variable."
echo "Waiting 5 seconds..."
sleep 5
# Boot wine (make fresh wineprefix)
wine wineboot #this won't display any dialog boxes that require a button to be clicked
#wait until above process exits
sleep 2
while [ ! -z "\$(pgrep -i 'wine C:')" ];do
sleep 1
done
fi
if [ "\$registry_exists" == false ];then
status "Making registry changes..."
TMPFILE="\$(mktemp)" || exit 1
echo 'REGEDIT4' > \$TMPFILE
echo " - Disabling Wine mime associations" #see https://askubuntu.com/a/400430
echo '
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunServices]
"winemenubuilder"="C:\\\\windows\\\\system32\\\\winemenubuilder.exe -r"
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices]
"winemenubuilder"="C:\\\\windows\\\\system32\\\\winemenubuilder.exe -r"' >> \$TMPFILE
wine regedit \$TMPFILE
rm -f \$TMPFILE
fi #end of if statement that only runs if this script was started when there was no wine registry
true
EOF

sudo chmod +x /usr/local/bin/generate-hangover-prefix
/usr/local/bin/generate-hangover-prefix || exit 1
24 changes: 24 additions & 0 deletions apps/Hangover/uninstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

pkill -9 wine
command -v wineserver >/dev/null && wineserver -k

status -n "Removing terminal commands... "
sudo rm -rf /usr/local/bin/generate-hangover-prefix
status_green "Done"

status -n "Removing mimetypes... "
#See: https://askubuntu.com/a/400430
rm -f ~/.local/share/mime/packages/x-wine*
rm -f ~/.local/share/applications/wine-extension*
rm -f ~/.local/share/icons/hicolor/*/*/application-x-wine-extension*
rm -f ~/.local/share/mime/application/x-wine-extension*
status_green "Done"

purge_packages || exit 1

if [ -e "$HOME/.wine" ];then
echo -e "\n\n\e[93mYou just uninstalled the Hangover app, but it's not completely gone yet.
To prevent data loss, your Wine configuration is still\nlocated in the $HOME/.wine folder. Feel free to delete it to save space or to rename the folder for troubleshooting.\e[39m\n"
fi
true
1 change: 1 addition & 0 deletions apps/Hangover/website
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/AndreRH/hangover
1 change: 1 addition & 0 deletions etc/categories
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Gnumeric|Office
Godot|Games
GParted|System Management
Guake Terminal|Terminals
Hangover|Tools/Emulation
Heroes 2|Games
Https File Server|Tools
HTTrack Website Copier|Internet
Expand Down

0 comments on commit aad2a28

Please sign in to comment.