mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-20 20:50:21 +02:00
get proper appDir in the AppImage linux release
This commit is contained in:
+18
-9
@@ -132,17 +132,26 @@ local function detectPortable()
|
|||||||
-- Recover the folder containing the .app so a packaged app finds its
|
-- Recover the folder containing the .app so a packaged app finds its
|
||||||
-- marker. On Windows/Linux the executable is not a bundle, so this is nil
|
-- marker. On Windows/Linux the executable is not a bundle, so this is nil
|
||||||
-- and the plain source-base directory (next to the .exe/AppImage) is used.
|
-- and the plain source-base directory (next to the .exe/AppImage) is used.
|
||||||
local function appContainer(path)
|
local function parentDir(path)
|
||||||
local appPath = path and path:match("^(.*%.app)/Contents/")
|
return path and path:match("^(.*)/[^/]+$") or nil
|
||||||
return appPath and appPath:match("^(.*)/[^/]+$") or nil
|
|
||||||
end
|
end
|
||||||
-- Order: the .app's containing folder (packaged macOS), then the
|
local function appContainer(path)
|
||||||
-- source-base directory (next to a packaged .exe/AppImage), then the
|
return parentDir(path and path:match("^(.*%.app)/Contents/"))
|
||||||
-- source itself (a `love <gamedir>` run drops portable.txt in the game
|
end
|
||||||
-- folder). First one holding the marker wins. Built by appending so a
|
-- The Linux AppImage build works similarly to macOs, but the runtime mounts
|
||||||
-- nil (e.g. no .app in the path) never truncates the ipairs scan.
|
-- the squashfs at a temp path, and that becomes the base directory.
|
||||||
|
-- The runtime exports the real .AppImage path in $APPIMAGE, so we get the
|
||||||
|
-- base dir from there.
|
||||||
|
local function appImageContainer()
|
||||||
|
return parentDir(os.getenv("APPIMAGE"))
|
||||||
|
end
|
||||||
|
-- Order: the packaged-app containing folder (macOS .app / Linux AppImage),
|
||||||
|
-- then the source-base directory (next to a packaged .exe), then the source
|
||||||
|
-- itself (a `love <gamedir>` run drops portable.txt in the game folder).
|
||||||
|
-- First one holding the marker wins. Built by appending so a nil (e.g. no
|
||||||
|
-- .app in the path) never truncates the ipairs scan.
|
||||||
local candidates = {}
|
local candidates = {}
|
||||||
local appDir = appContainer(src) or appContainer(sbd)
|
local appDir = appContainer(src) or appContainer(sbd) or appImageContainer()
|
||||||
if appDir then candidates[#candidates + 1] = appDir end
|
if appDir then candidates[#candidates + 1] = appDir end
|
||||||
if sbd then candidates[#candidates + 1] = sbd end
|
if sbd then candidates[#candidates + 1] = sbd end
|
||||||
if src then candidates[#candidates + 1] = src end
|
if src then candidates[#candidates + 1] = src end
|
||||||
|
|||||||
Reference in New Issue
Block a user