Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for newer Lua versions #253

Open
mimi89999 opened this issue Aug 28, 2024 · 4 comments
Open

Add support for newer Lua versions #253

mimi89999 opened this issue Aug 28, 2024 · 4 comments

Comments

@mimi89999
Copy link

Hello,
Currently raspi-config depends on lua5.1 (https://github.com/RPi-Distro/raspi-config/blob/bookworm/debian/control#L12). Would it be possible to add support for newer versions of Lua and not depend on that very old Lua?

@XECDesign
Copy link
Member

I haven't used lua in many many years, so I don't know if we can just switch over to 5.4 without any changes to the snippets of lua in raspi-config itself. It doesn't look like there's anything tricky going on and 5.4 should just work, but I don't have time to check that right now.

local key=assert(arg[1])
local fn=assert(arg[2])
local file=assert(io.open(fn))
for line in file:lines() do
  if line:match("^%s*"..key.."=.*$") then
    line="#"..line
  end
  print(line)
end
local key=assert(arg[1])
local fn=assert(arg[2])
local file=assert(io.open(fn))
local found=false
for line in file:lines() do
  local val = line:match("^%s*"..key.."=(.*)$")
  if (val ~= nil) then
    print(val)
    found=true
    break
  end
end
if not found then
   print(0)
end

It looks like these could just be rewritten to use sed and the lua dependency could be dropped entirely.

@mimi89999
Copy link
Author

I tested the code with Lua3.4 and it seems to be working fine. I fear that switching to sed might potentially introduce new bugs and make the code less readable.

@mimi89999
Copy link
Author

Anyway, the lua command is called and it's handled by the Debian alternatives system:

michel@kokomi:~ $ which lua
/usr/bin/lua
michel@kokomi:~ $ ls -l /usr/bin/lua
lrwxrwxrwx 1 root root 33 Feb 21  2023 /usr/bin/lua -> /etc/alternatives/lua-interpreter
michel@kokomi:~ $ ls -l /etc/alternatives/lua-interpreter
lrwxrwxrwx 1 root root 15 Aug 28 21:09 /etc/alternatives/lua-interpreter -> /usr/bin/lua5.4
michel@kokomi:~ $ sudo update-alternatives --list lua-interpreter
/usr/bin/lua5.1
/usr/bin/lua5.4

So even though the package depends on lua5.1, the lua command could be any version of lua 🤷‍♂️

@XECDesign
Copy link
Member

Thanks for checking and that's a good point about the lua symlink. But I still think the lua snippets are a bit out of place in a shell script. I don't think it will be any less readable. It would be using the same regular expressions, which is usually the least readable part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants