Merge pull request #485 from moelbanna-bot/main

fix-linux-appimage
This commit is contained in:
Pin Studios 2025-04-04 06:12:59 +08:00 committed by GitHub
commit d8799cdf2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 55 additions and 4 deletions

0
build.sh Normal file → Executable file
View File

View File

@ -8,6 +8,7 @@ import sqlite3
import platform import platform
import re import re
import tempfile import tempfile
import glob
from colorama import Fore, Style, init from colorama import Fore, Style, init
from typing import Tuple from typing import Tuple
import configparser import configparser
@ -49,6 +50,25 @@ def get_cursor_paths(translator=None) -> Tuple[str, str]:
"Linux": ["/opt/Cursor/resources/app", "/usr/share/cursor/resources/app", os.path.expanduser("~/.local/share/cursor/resources/app"), "/usr/lib/cursor/app/"] "Linux": ["/opt/Cursor/resources/app", "/usr/share/cursor/resources/app", os.path.expanduser("~/.local/share/cursor/resources/app"), "/usr/lib/cursor/app/"]
} }
if system == "Linux":
# Look for extracted AppImage with correct usr structure
extracted_usr_paths = glob.glob(os.path.expanduser("~/squashfs-root/usr/share/cursor/resources/app"))
# Also check current directory for extraction without home path prefix
current_dir_paths = glob.glob("squashfs-root/usr/share/cursor/resources/app")
# Add any found paths to the Linux paths list
default_paths["Linux"].extend(extracted_usr_paths)
default_paths["Linux"].extend(current_dir_paths)
# Print debug information
print(f"{Fore.CYAN}{EMOJI['INFO']} Available paths found:{Style.RESET_ALL}")
for path in default_paths["Linux"]:
if os.path.exists(path):
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {path} (exists){Style.RESET_ALL}")
else:
print(f"{Fore.RED}{EMOJI['ERROR']} {path} (not found){Style.RESET_ALL}")
# If config doesn't exist, create it with default paths # If config doesn't exist, create it with default paths
if not os.path.exists(config_file): if not os.path.exists(config_file):
for section in ['MacPaths', 'WindowsPaths', 'LinuxPaths']: for section in ['MacPaths', 'WindowsPaths', 'LinuxPaths']:
@ -181,6 +201,12 @@ def get_workbench_cursor_path(translator=None) -> str:
"main": "out/vs/workbench/workbench.desktop.main.js" "main": "out/vs/workbench/workbench.desktop.main.js"
} }
} }
if system == "Linux":
# Add extracted AppImage with correct usr structure
extracted_usr_paths = glob.glob(os.path.expanduser("~/squashfs-root/usr/share/cursor/resources/app"))
paths_map["Linux"]["bases"].extend(extracted_usr_paths)
if system not in paths_map: if system not in paths_map:
raise OSError(translator.get('reset.unsupported_os', system=system) if translator else f"不支持的操作系统: {system}") raise OSError(translator.get('reset.unsupported_os', system=system) if translator else f"不支持的操作系统: {system}")
@ -188,9 +214,9 @@ def get_workbench_cursor_path(translator=None) -> str:
if system == "Linux": if system == "Linux":
for base in paths_map["Linux"]["bases"]: for base in paths_map["Linux"]["bases"]:
main_path = os.path.join(base, paths_map["Linux"]["main"]) main_path = os.path.join(base, paths_map["Linux"]["main"])
print(f"{Fore.CYAN}{EMOJI['INFO']} Checking path: {main_path}{Style.RESET_ALL}")
if os.path.exists(main_path): if os.path.exists(main_path):
return main_path return main_path
raise OSError(translator.get('reset.linux_path_not_found') if translator else "在 Linux 系统上未找到 Cursor 安装路径")
if system == "Windows": if system == "Windows":
base_path = config.get('WindowsPaths', 'cursor_path') base_path = config.get('WindowsPaths', 'cursor_path')

View File

@ -14,6 +14,7 @@ import configparser
from new_signup import get_user_documents_path from new_signup import get_user_documents_path
import traceback import traceback
from config import get_config from config import get_config
import glob
# Initialize colorama # Initialize colorama
init() init()
@ -49,6 +50,24 @@ def get_cursor_paths(translator=None) -> Tuple[str, str]:
"Linux": ["/opt/Cursor/resources/app", "/usr/share/cursor/resources/app", os.path.expanduser("~/.local/share/cursor/resources/app")] "Linux": ["/opt/Cursor/resources/app", "/usr/share/cursor/resources/app", os.path.expanduser("~/.local/share/cursor/resources/app")]
} }
if system == "Linux":
# Look for extracted AppImage directories - with usr structure
extracted_usr_paths = glob.glob(os.path.expanduser("~/squashfs-root/usr/share/cursor/resources/app"))
# Check current directory for extraction without home path prefix
current_dir_paths = glob.glob("squashfs-root/usr/share/cursor/resources/app")
# Add all paths to the Linux paths list
default_paths["Linux"].extend(extracted_usr_paths)
default_paths["Linux"].extend(current_dir_paths)
# Print debug info for troubleshooting
print(f"{Fore.CYAN}{EMOJI['INFO']} Available paths found:{Style.RESET_ALL}")
for path in default_paths["Linux"]:
if os.path.exists(path):
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {path} (exists){Style.RESET_ALL}")
else:
print(f"{Fore.RED}{EMOJI['ERROR']} {path} (not found){Style.RESET_ALL}")
# If config doesn't exist, create it with default paths # If config doesn't exist, create it with default paths
if not os.path.exists(config_file): if not os.path.exists(config_file):
for section in ['MacPaths', 'WindowsPaths', 'LinuxPaths']: for section in ['MacPaths', 'WindowsPaths', 'LinuxPaths']:
@ -175,10 +194,16 @@ def get_workbench_cursor_path(translator=None) -> str:
} }
} }
if system not in paths_map:
raise OSError(translator.get('reset.unsupported_os', system=system) if translator else f"不支持的操作系统: {system}")
if system == "Linux": if system == "Linux":
# Look for extracted AppImage with correct usr structure
extracted_usr_paths = glob.glob(os.path.expanduser("~/squashfs-root/usr/share/cursor/resources/app"))
# Check current directory for extraction
current_dir_paths = glob.glob("squashfs-root/usr/share/cursor/resources/app")
paths_map["Linux"]["bases"].extend(extracted_usr_paths)
paths_map["Linux"]["bases"].extend(current_dir_paths)
for base in paths_map["Linux"]["bases"]: for base in paths_map["Linux"]["bases"]:
main_path = os.path.join(base, paths_map["Linux"]["main"]) main_path = os.path.join(base, paths_map["Linux"]["main"])
if os.path.exists(main_path): if os.path.exists(main_path):