Skip to content

Commit

Permalink
Fix #17. Add Alpine Support
Browse files Browse the repository at this point in the history
  • Loading branch information
thw26 committed Nov 30, 2024
1 parent 8926435 commit d407abb
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 37 deletions.
2 changes: 2 additions & 0 deletions ou_dedetai/logos.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def run_logos():
if not good_wine:
msg.logos_error(reason, app=self)
else:
if reason is not None:
logging.debug(f"Warning: Wine Check: {reason}")
wine.wineserver_kill()
app = self.app
if config.DIALOG == 'tk':
Expand Down
38 changes: 35 additions & 3 deletions ou_dedetai/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def get_package_manager():
)
config.L9PACKAGES = "" # FIXME: Missing Logos 9 Packages
config.BADPACKAGES = "" # appimagelauncher handled separately
elif shutil.which('zypper') is not None: # manjaro
elif shutil.which('zypper') is not None: # opensuse
config.PACKAGE_MANAGER_COMMAND_INSTALL = ["zypper", "--non-interactive", "install"] # noqa: E501
config.PACKAGE_MANAGER_COMMAND_DOWNLOAD = ["zypper", "download"] # noqa: E501
config.PACKAGE_MANAGER_COMMAND_REMOVE = ["zypper", "--non-interactive", "remove"] # noqa: E501
Expand All @@ -334,6 +334,22 @@ def get_package_manager():
)
config.L9PACKAGES = "" # FIXME: Missing Logos 9 Packages
config.BADPACKAGES = "" # appimagelauncher handled separately
elif shutil.which('apk') is not None: # alpine
config.PACKAGE_MANAGER_COMMAND_INSTALL = ["apk", "--no-interactive", "add"] # noqa: E501
config.PACKAGE_MANAGER_COMMAND_DOWNLOAD = ["apk", "--no-interactive", "fetch"] # noqa: E501
config.PACKAGE_MANAGER_COMMAND_REMOVE = ["apk", "--no-interactive", "del"] # noqa: E501
config.PACKAGE_MANAGER_COMMAND_QUERY = ["apk", "list", "-i"]
config.QUERY_PREFIX = ''
config.PACKAGES = (
"bash bash-completion" # bash support
"gcompat" # musl to glibc
"fuse-common fuse" # appimages
"wget curl" # network
"7zip" # winetricks
"samba sed grep gawk bash bash-completion" # other
)
config.L9PACKAGES = "" # FIXME: Missing Logos 9 Packages
config.BADPACKAGES = "" # appimagelauncher handled separately
elif shutil.which('pamac') is not None: # manjaro
config.PACKAGE_MANAGER_COMMAND_INSTALL = ["pamac", "install", "--no-upgrade", "--no-confirm"] # noqa: E501
config.PACKAGE_MANAGER_COMMAND_DOWNLOAD = ["pamac", "install", "--no-upgrade", "--download-only", "--no-confirm"] # noqa: E501
Expand Down Expand Up @@ -544,6 +560,19 @@ def postinstall_dependencies_steamos():
return command


def postinstall_dependencies_alpine():
user = os.getlogin()
command = [
config.SUPERUSER_COMMAND, "modprobe", "fuse", "&&",
config.SUPERUSER_COMMAND, "rc-update", "add", "fuse", "boot", "&&",
config.SUPERUSER_COMMAND, "sed", "-i", "'s/#user_allow_other/user_allow_other/g'", "/etc/fuse.conf", "&&",
config.SUPERUSER_COMMAND, "addgroup", "fuse", "&&",
config.SUPERUSER_COMMAND, "adduser", f"{user}", "fuse", "&&",
config.SUPERUSER_COMMAND, "rc-service", "fuse", "restart",
]
return command


def preinstall_dependencies(app=None):
command = []
logging.debug("Performing pre-install dependencies…")
Expand All @@ -559,6 +588,8 @@ def postinstall_dependencies(app=None):
logging.debug("Performing post-install dependencies…")
if config.OS_NAME == "Steam":
command = postinstall_dependencies_steamos()
if config.OS_NAME == "alpine":
command = postinstall_dependencies_alpine()
else:
logging.debug("No post-install dependencies required.")
return command
Expand All @@ -582,6 +613,7 @@ def install_dependencies(packages, bad_packages, logos9_packages=None, app=None)
conflicting_packages = {}
package_list = []
bad_package_list = []
bad_os = ['fedora', 'arch', 'alpine']

if packages:
package_list = packages.split()
Expand All @@ -605,7 +637,7 @@ def install_dependencies(packages, bad_packages, logos9_packages=None, app=None)
)

if config.PACKAGE_MANAGER_COMMAND_INSTALL:
if config.OS_NAME in ['fedora', 'arch']:
if config.OS_NAME in bad_os:
message = False
no_message = False
secondary = False
Expand Down Expand Up @@ -682,7 +714,7 @@ def install_dependencies(packages, bad_packages, logos9_packages=None, app=None)
app.root.event_generate('<<StartIndeterminateProgress>>')
msg.status("Installing dependencies…", app)
final_command = [
f"{config.SUPERUSER_COMMAND}", 'sh', '-c', "'", *command, "'"
f"{config.SUPERUSER_COMMAND}", 'sh', '-c', '"', *command, '"'
]
command_str = ' '.join(final_command)
# TODO: Fix fedora/arch handling.
Expand Down
73 changes: 39 additions & 34 deletions ou_dedetai/wine.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,54 +159,57 @@ def check_wine_rules(wine_release, release_version):
]

major_min, minor_min = required_wine_minimum
major, minor, release_type = wine_release
result = True, "None" # Whether the release is allowed; error message
for rule in rules:
if major == rule["major"]:
# Verify release is allowed
if release_type not in rule["allowed_releases"]:
if minor >= rule.get("devel_allowed", float('inf')):
if release_type not in ["staging", "devel"]:
if wine_release:
major, minor, release_type = wine_release
result = True, "None" # Whether the release is allowed; error message
for rule in rules:
if major == rule["major"]:
# Verify release is allowed
if release_type not in rule["allowed_releases"]:
if minor >= rule.get("devel_allowed", float('inf')):
if release_type not in ["staging", "devel"]:
result = (
False,
(
f"Wine release needs to be devel or staging. "
f"Current release: {release_type}."
)
)
break
else:
result = (
False,
(
f"Wine release needs to be devel or staging. "
f"Wine release needs to be {rule['allowed_releases']}. " # noqa: E501
f"Current release: {release_type}."
)
)
break
else:
result = (
False,
(
f"Wine release needs to be {rule['allowed_releases']}. " # noqa: E501
f"Current release: {release_type}."
)
)
# Verify version is allowed
if minor in rule.get("minor_bad", []):
result = False, f"Wine version {major}.{minor} will not work."
break
# Verify version is allowed
if minor in rule.get("minor_bad", []):
result = False, f"Wine version {major}.{minor} will not work."
break
if major < major_min:
result = (
False,
(
f"Wine version {major}.{minor} is "
f"below minimum required ({major_min}.{minor_min}).")
)
break
elif major == major_min and minor < minor_min:
if not rule["proton"]:
if major < major_min:
result = (
False,
(
f"Wine version {major}.{minor} is "
f"below minimum required ({major_min}.{minor_min}).") # noqa: E501
f"below minimum required ({major_min}.{minor_min}).")
)
break
logging.debug(f"Result: {result}")
return result
elif major == major_min and minor < minor_min:
if not rule["proton"]:
result = (
False,
(
f"Wine version {major}.{minor} is "
f"below minimum required ({major_min}.{minor_min}).") # noqa: E501
)
break
logging.debug(f"Result: {result}")
return result
else:
return True, "Default to trusting user override"


def check_wine_version_and_branch(release_version, test_binary):
Expand Down Expand Up @@ -552,6 +555,8 @@ def get_wine_branch(binary):
logging.debug("Binary object is not an AppImage.")
logging.info(f"'{binary}' resolved to '{binary_obj}'")
mscoree64 = binary_obj.parents[1] / 'lib64' / 'wine' / 'x86_64-windows' / 'mscoree.dll' # noqa: E501
if not mscoree64.exists(): #alpine
mscoree64 = binary_obj.parents[1] / 'lib' / 'wine' / 'x86_64-windows' / 'mscoree.dll' # noqa: E501
return get_mscoree_winebranch(mscoree64)


Expand Down

0 comments on commit d407abb

Please sign in to comment.