git: 598b9677b3e9 - stable/14 - Revert "loader/lua: Remove compat shim for loader.lua_path"

From: Warner Losh <imp_at_FreeBSD.org>
Date: Thu, 01 Aug 2024 14:50:28 UTC
The branch stable/14 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=598b9677b3e9ac01d81031d67426e49573b759d2

commit 598b9677b3e9ac01d81031d67426e49573b759d2
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-07-29 22:57:04 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-08-01 14:49:54 +0000

    Revert "loader/lua: Remove compat shim for loader.lua_path"
    
    This reverts commit ab97d42addae97a389c6f22d6bba62ed954bb8e7.
    
    There's too many people in the field with FreeBSD 12.0 loader.efi that
    stubbed their toe on upgrading to 14.1 since they'd not updated
    loader.efi. While we sort out that mess, add back this workaround.  Can
    revisit after 14.2 maybe.
    
    MFC After:              3 days
    Sponsored by:           Netflix
    Reviewed by:            kevans
    Differential Revision:  https://reviews.freebsd.org/D45882
    
    (cherry picked from commit 522a65a8d97a0d6b634266f1b4a89aa8f374279c)
---
 stand/lua/core.lua | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/stand/lua/core.lua b/stand/lua/core.lua
index eaabff6a7602..9226de564348 100644
--- a/stand/lua/core.lua
+++ b/stand/lua/core.lua
@@ -65,7 +65,13 @@ end
 -- message on failure.
 function try_include(module)
 	if module:sub(1, 1) ~= "/" then
-		module = loader.lua_path .. "/" .. module
+		local lua_path = loader.lua_path
+		-- XXX Temporary compat shim; this should be removed once the
+		-- loader.lua_path export has sufficiently spread.
+		if lua_path == nil then
+			lua_path = "/boot/lua"
+		end
+		module = lua_path .. "/" .. module
 		-- We only attempt to append an extension if an absolute path
 		-- wasn't specified.  This assumes that the caller either wants
 		-- to treat this like it would require() and specify just the