diff options
| author | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2025-01-31 13:46:42 -0500 |
|---|---|---|
| committer | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2025-01-31 13:46:42 -0500 |
| commit | d552946c28256cb2e7d087dced15576e32d08b21 (patch) | |
| tree | 01db3f105ff1d972b2ecd1b1beac1bda1ba1d6f4 | |
| parent | b1ddda49a5f625b22f682813748155d1faaa0290 (diff) | |
| download | Decky-Framegen-d552946c28256cb2e7d087dced15576e32d08b21.tar.gz Decky-Framegen-d552946c28256cb2e7d087dced15576e32d08b21.zip | |
feat: rework prepare.sh to extract from /bin remote binaries
| -rwxr-xr-x | defaults/assets/prepare.sh | 112 | ||||
| -rw-r--r-- | main.py | 33 | ||||
| -rw-r--r-- | plugin.json | 2 |
3 files changed, 50 insertions, 97 deletions
diff --git a/defaults/assets/prepare.sh b/defaults/assets/prepare.sh index a48ffcb..888c4f3 100755 --- a/defaults/assets/prepare.sh +++ b/defaults/assets/prepare.sh @@ -3,93 +3,61 @@ set -x # Enable debugging exec > >(tee -i /tmp/prepare.log) 2>&1 # Log output and errors -# Function to test if curl works with a given LD_LIBRARY_PATH -test_curl() { - local lib_path=$1 - export LD_LIBRARY_PATH=$lib_path:$LD_LIBRARY_PATH - echo "Testing curl with LD_LIBRARY_PATH=$LD_LIBRARY_PATH" - curl --version >/dev/null 2>&1 - return $? -} - -# Try library paths and choose the one that works -if test_curl "/usr/lib"; then - echo "Using OpenSSL library path: /usr/lib" - export LD_LIBRARY_PATH="/usr/lib:$LD_LIBRARY_PATH" -elif test_curl "/usr/lib64"; then - echo "Using OpenSSL library path: /usr/lib64" - export LD_LIBRARY_PATH="/usr/lib64:$LD_LIBRARY_PATH" -elif test_curl "/lib"; then - echo "Using OpenSSL library path: /lib" - export LD_LIBRARY_PATH="/usr/lib:$LD_LIBRARY_PATH" -elif test_curl "/lib64"; then - echo "Using OpenSSL library path: /lib64" - export LD_LIBRARY_PATH="/usr/lib64:$LD_LIBRARY_PATH" -elif test_curl "/usr/local/lib"; then - echo "Using OpenSSL library path: /usr/local/lib" - export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" -elif test_curl "/usr/local/ssl/lib"; then - echo "Using OpenSSL library path: /usr/local/ssl/lib" - export LD_LIBRARY_PATH="/usr/local/ssl/lib:$LD_LIBRARY_PATH" -else - echo "Failed to configure OpenSSL for curl. Exiting." - exit 1 -fi - mod_path="$HOME/fgmod" -nvidiaver=555.52.04 -enablerver=3.02.000.0 -fakenvapiver=v1.2.0 +bin_path="$(dirname "$(realpath "$0")")/../bin" +assets_path="$(dirname "$(realpath "$0")")" + +nvidiaver="NVIDIA-Linux-x86_64-555.52.04.run" +enablerver="dlss-enabler-setup-3.02.000.0.exe" +fakenvapiver="fakenvapi.7z" standalone=1 if [[ -d "$mod_path" ]] && [[ ! $mod_path == . ]]; then rm -r "$mod_path" fi -# In case script gets ran from a different directory -cd "$(dirname "$0")" - mkdir -p "$mod_path" -if [[ ! $standalone -eq 0 ]]; then - [[ -f fgmod.sh ]] && cp fgmod.sh "$mod_path/fgmod" || exit 1 - [[ -f fgmod-uninstaller.sh ]] && cp fgmod-uninstaller.sh "$mod_path" || exit 1 -fi cd "$mod_path" || exit 1 -curl -OLf https://github.com/artur-graniszewski/DLSS-Enabler/releases/download/$enablerver/dlss-enabler-setup-$enablerver.exe || exit 1 -curl -OLf https://download.nvidia.com/XFree86/Linux-x86_64/$nvidiaver/NVIDIA-Linux-x86_64-$nvidiaver.run || exit 1 -curl -OLf https://raw.githubusercontent.com/mozilla/fxc2/master/dll/d3dcompiler_47.dll || exit 1 -curl -OLf https://github.com/FakeMichau/innoextract/releases/download/6.3.0/innoextract || exit 1 -curl -OLf https://github.com/FakeMichau/fakenvapi/releases/download/$fakenvapiver/fakenvapi.7z || exit 1 -[[ $standalone -eq 0 ]] && curl -o fgmod -Lf https://raw.githubusercontent.com/FakeMichau/fgmod/main/fgmod.sh -[[ $standalone -eq 0 ]] && curl -OL https://raw.githubusercontent.com/FakeMichau/fgmod/main/fgmod-uninstaller.sh - -[[ ! -f dlss-enabler-setup-$enablerver.exe ]] || -[[ ! -f NVIDIA-Linux-x86_64-$nvidiaver.run ]] || -[[ ! -f d3dcompiler_47.dll ]] || -[[ ! -f innoextract ]] || -[[ ! -f fakenvapi.7z ]] || -[[ ! -f fgmod ]] || -[[ ! -f fgmod-uninstaller.sh ]] && exit 1 +# Copy required files from bin directory +cp "$bin_path/$enablerver" . +cp "$bin_path/$nvidiaver" . +cp "$bin_path/d3dcompiler_47.dll" . +cp "$bin_path/innoextract" . +cp "$bin_path/$fakenvapiver" . + +# Copy fgmod.sh and fgmod-uninstaller.sh from defaults/assets +cp "$assets_path/fgmod.sh" "$mod_path/fgmod" || exit 1 +cp "$assets_path/fgmod-uninstaller.sh" "$mod_path" || exit 1 + +if [[ ! -f "$enablerver" || ! -f "$nvidiaver" || ! -f "d3dcompiler_47.dll" || ! -f "innoextract" || ! -f "$fakenvapiver" || ! -f "fgmod" || ! -f "fgmod-uninstaller.sh" ]]; then + echo "Missing one or more required files. Exiting." + exit 1 +fi # Extract files -chmod +x NVIDIA-Linux-x86_64-$nvidiaver.run -./NVIDIA-Linux-x86_64-$nvidiaver.run -x +chmod +x "$nvidiaver" +./"$nvidiaver" -x chmod +x innoextract -./innoextract dlss-enabler-setup-$enablerver.exe +./innoextract "$enablerver" # Prepare mod files mv app/* . rm -r app -[[ -f "$(which 7z 2>/dev/null)" ]] && 7z -y x fakenvapi.7z -cp -f NVIDIA-Linux-x86_64-$nvidiaver/nvngx.dll _nvngx.dll -cp -f NVIDIA-Linux-x86_64-$nvidiaver/LICENSE "licenses/LICENSE (NVIDIA driver)" +[[ -f "$(which 7z 2>/dev/null)" ]] && 7z -y x "$fakenvapiver" +cp -f NVIDIA-Linux-x86_64-555.52.04/nvngx.dll _nvngx.dll +cp -f NVIDIA-Linux-x86_64-555.52.04/LICENSE "licenses/LICENSE (NVIDIA driver)" chmod +r _nvngx.dll -rm -rf innoextract NVIDIA-Linux-x86_64-$nvidiaver dlss-enabler-setup-$enablerver.exe NVIDIA-Linux-x86_64-$nvidiaver.run fakenvapi.7z -rm -rf plugins nvapi64-proxy.dll dlss-enabler-fsr.dll dlss-enabler-xess.dll dbghelp.dll version.dll winmm.dll nvngx.dll dlss-finder.exe dlss-enabler.log dlssg_to_fsr3.log fakenvapi.log "LICENSE (DLSSG to FSR3 mod).txt" "Readme (DLSS enabler).txt" "READ ME (DLSSG to FSR3 mod).txt" "XESS LICENSE.pdf" + +# Cleanup +rm -rf innoextract NVIDIA-Linux-x86_64-555.52.04 dlss-enabler-setup-3.02.000.0.exe NVIDIA-Linux-x86_64-555.52.04.run fakenvapi.7z +rm -rf plugins nvapi64-proxy.dll dlss-enabler-fsr.dll dlss-enabler-xess.dll dbghelp.dll version.dll winmm.dll nvngx.dll \ + dlss-finder.exe dlss-enabler.log dlssg_to_fsr3.log fakenvapi.log "LICENSE (DLSSG to FSR3 mod).txt" \ + "Readme (DLSS enabler).txt" "READ ME (DLSSG to FSR3 mod).txt" "XESS LICENSE.pdf" [[ -f "$(which nvidia-smi 2>/dev/null)" ]] && rm -rf nvapi64.dll fakenvapi.ini +# Update paths in scripts sed -i 's|mod_path="/usr/share/fgmod"|mod_path="'"$mod_path"'"|g' fgmod chmod +x fgmod @@ -98,13 +66,13 @@ chmod +x fgmod-uninstaller.sh echo "" -# Flatpak doesn't have access to home by default +# Flatpak compatibility if flatpak list | grep "com.valvesoftware.Steam" 1>/dev/null; then - echo Flatpak version of Steam detected, adding access to fgmod\'s folder - echo Please restart Steam! + echo "Flatpak version of Steam detected, adding access to fgmod's folder" + echo "Please restart Steam!" flatpak override --user --filesystem="$mod_path" com.valvesoftware.Steam fi -echo For Steam, add this to the launch options: "$mod_path/fgmod" %COMMAND% -echo For Heroic, add this as a new wrapper: "$mod_path/fgmod" -echo All done!
\ No newline at end of file +echo "For Steam, add this to the launch options: \"$mod_path/fgmod\" %COMMAND%" +echo "For Heroic, add this as a new wrapper: \"$mod_path/fgmod\"" +echo "All done!"
\ No newline at end of file @@ -26,42 +26,27 @@ class Plugin: async def run_install_fgmod(self) -> dict: try: assets_dir = Path(decky.DECKY_PLUGIN_DIR) / "assets" - downloads_dir = Path(decky.HOME) / "Downloads" + prepare_script = assets_dir / "prepare.sh" - if not assets_dir.exists(): - decky.logger.error(f"Assets directory not found: {assets_dir}") + if not prepare_script.exists(): + decky.logger.error(f"prepare.sh not found: {prepare_script}") return { "status": "error", - "message": f"Assets directory not found: {assets_dir}" + "message": f"prepare.sh not found in plugin assets." } - downloads_dir.mkdir(parents=True, exist_ok=True) + # Ensure prepare.sh has execution permissions + prepare_script.chmod(0o755) - files_to_copy = ["prepare.sh", "fgmod.sh", "fgmod-uninstaller.sh"] - for file_name in files_to_copy: - src = assets_dir / file_name - if not src.exists(): - decky.logger.error(f"Required file missing: {src}") - return { - "status": "error", - "message": f"Required file missing: {file_name}" - } - - dest = downloads_dir / file_name - dest.write_bytes(src.read_bytes()) - dest.chmod(0o755) - - prepare_script = downloads_dir / "prepare.sh" + # Run prepare.sh directly from the plugin's assets folder process = subprocess.run( ["/bin/bash", str(prepare_script)], + cwd=str(assets_dir), # Run in assets directory to use correct paths capture_output=True, text=True, timeout=300 ) - fgmod_path = Path(decky.HOME) / "fgmod" - fgmod_path.mkdir(parents=True, exist_ok=True) - decky.logger.info(f"Script output:\n{process.stdout}") decky.logger.error(f"Script errors:\n{process.stderr}") @@ -90,7 +75,7 @@ class Plugin: "message": e.stderr } except Exception as e: - decky.logger.error(f"Unexpected error: {str(e)}") + decky.logger.error(f"Unexpected error: {str(e)}") return { "status": "error", "message": str(e) diff --git a/plugin.json b/plugin.json index 1d18b92..54c4597 100644 --- a/plugin.json +++ b/plugin.json @@ -1,5 +1,5 @@ { - "name": "Decky Framegen", + "name": "decky-framegen", "author": "JSON Derulo", "flags": [], "api_version": 1, |
